00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, *** 00017 *** MERIGNAC, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 00024 00025 #ifndef _SO_WIN_COLOR_SLIDER_ 00026 #define _SO_WIN_COLOR_SLIDER_ 00027 00028 #include <Inventor/Win/SoWinBeginStrict.h> 00029 00030 #include <Inventor/Win/SoWinSlider.h> 00031 00032 class SbColor; 00033 class SbVec2f; 00034 00035 00037 // 00038 // Class: SoWinColorSlider 00039 // 00040 // This class defines the color slider which is a set of predefined 00041 // sliders (R, G, B, H, S, V,..) with special behaviors. 00042 // 00044 00045 00046 { 00047 00048 public: 00049 00050 // 00051 // list of color sliders types 00052 // 00053 enum Type { 00054 RED_SLIDER, 00055 GREEN_SLIDER, 00056 BLUE_SLIDER, 00057 HUE_SLIDER, 00058 SATURATION_SLIDER, 00059 VALUE_SLIDER, 00060 INTENSITY_SLIDER // independent of the slider value 00061 }; 00062 00063 // Constructor/Destructor 00064 SoWinColorSlider(SoWidget parent = NULL, 00065 const char *name = NULL, 00066 SbBool buildInsideParent = TRUE, 00067 Type type = INTENSITY_SLIDER); 00068 00069 ~SoWinColorSlider(); 00070 00071 // 00072 // Routine used to specify the slider value and also the top region 00073 // color (WYSIWYGmode in most cases). Users should call this routine 00074 // instead of the base class setValue() routine if they want the color 00075 // slider top region to correctly reflect the current color. 00076 // (code is optimized for WYSIWYGmode off) 00077 // 00078 // NOTE: routine expects 00079 // an rgb color for R, G or B slider type 00080 // an hsv color for H, S, or V slider type 00081 // an rgb color for Intensity slider type 00082 // 00083 // NOTE: if calling setBaseColor() changes the thumb position the 00084 // valueChanged callbacks will be called with the new value. 00085 // 00086 void setBaseColor(const float rgbOrHsv[3], SbBool updateText = TRUE); 00087 const float *getBaseColor() { return color; } 00088 00089 // 00090 // This routine sets the WYSIWYG (What You See Is What You Get) mode 00091 // to be true or false (default FALSE). Immediate mode. 00092 // This has no effect on monochrome sliders. 00093 // 00094 void setWYSIWYG(SbBool trueOrFalse); // default FALSE 00095 SbBool isWYSIWYG() { return WYSIWYGmode; } 00096 00097 // returns the type of the slider 00098 SoWinColorSlider::Type getType() { return type; } 00099 00100 private: 00101 00102 // This constructor takes a boolean whether to build the widget now. 00103 // Subclasses can pass FALSE, then call SoWinSlider::buildWidget() 00104 // when they are ready for it to be built. 00105 SoEXTENDER 00106 SoWinColorSlider(SoWidget parent, 00107 const char *name, 00108 SbBool buildInsideParent, 00109 Type type, 00110 SbBool buildNow); 00111 00112 // redefine this routine to cache slider top geometry 00113 virtual void sizeChanged(const SbVec2s &newSize); 00114 00115 // redefine this routine to do the actual slider top region drawing. 00116 // This routine is automatically called by the SoWinSlider::redraw() routine. 00117 virtual void drawSliderTopRegion(); 00118 00119 private: 00120 00121 // local vars 00122 Boolean WYSIWYGmode; 00123 Type type; 00124 float color[3]; 00125 SbColor *defaultColors, *colors; 00126 SbVec2f *geometry; 00127 00128 // routine that make the default and WYSIWYG colors 00129 void makeDefaultColors(); 00130 void makeWYSIWYGcolors(); 00131 00132 static void sliderChangedCB(void *, float val); 00133 00134 // this is called by both constructors 00135 void constructorCommon(SoWinColorSlider::Type type, SbBool buildNow); 00136 }; 00137 00138 #include <Inventor/Win/SoWinEndStrict.h> 00139 00140 00141 #endif /* _SO_WIN_COLOR_SLIDER_ */ 00142 00143 00144