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_XT_COLOR_SLIDER_ 00026 #define _SO_XT_COLOR_SLIDER_ 00027 00028 #include "SoXtSlider.h" 00029 00030 class SbColor; 00031 class SbVec2f; 00032 00033 00035 // 00036 // Class: SoXtColorSlider 00037 // 00038 // This class defines the color slider which is a set of predefined 00039 // sliders (R, G, B, H, S, V,..) with special behaviors. 00040 // 00042 00043 { 00044 00045 public: 00046 00047 // 00048 // list of color sliders types 00049 // 00050 enum Type { 00051 RED_SLIDER, 00052 GREEN_SLIDER, 00053 BLUE_SLIDER, 00054 HUE_SLIDER, 00055 SATURATION_SLIDER, 00056 VALUE_SLIDER, 00057 INTENSITY_SLIDER // independent of the slider value 00058 }; 00059 00060 // Constructor/Destructor 00061 SoXtColorSlider( 00062 SoWidget parent = NULL, 00063 const char *name = NULL, 00064 SbBool buildInsideParent = TRUE, 00065 Type type = INTENSITY_SLIDER); 00066 ~SoXtColorSlider(); 00067 00068 // 00069 // Routine used to specify the slider value and also the top region 00070 // color (WYSIWYGmode in most cases). Users should call this routine 00071 // instead of the base class setValue() routine if they want the color 00072 // slider top region to correctly reflect the current color. 00073 // (code is optimized for WYSIWYGmode off) 00074 // 00075 // NOTE: routine expects 00076 // an rgb color for R, G or B slider type 00077 // an hsv color for H, S, or V slider type 00078 // an rgb color for Intensity slider type 00079 // 00080 // NOTE: if calling setBaseColor() changes the thumb position the 00081 // valueChanged callbacks will be called with the new value. 00082 // 00083 void setBaseColor(const float rgbOrHsv[3]); 00084 const float *getBaseColor() { return color; } 00085 00086 // 00087 // This routine sets the WYSIWYG (What You See Is What You Get) mode 00088 // to be true or false (default FALSE). Immediate mode. 00089 // This has no effect on monochrome sliders. 00090 // 00091 void setWYSIWYG(SbBool trueOrFalse); // default FALSE 00092 SbBool isWYSIWYG() { return WYSIWYGmode; } 00093 00094 // returns the type of the slider 00095 SoXtColorSlider::Type getType() { return type; } 00096 00097 private: 00098 00099 // This constructor takes a boolean whether to build the widget now. 00100 // Subclasses can pass FALSE, then call SoXtSlider::buildWidget() 00101 // when they are ready for it to be built. 00102 SoEXTENDER 00103 SoXtColorSlider( 00104 SoWidget parent, 00105 const char *name, 00106 SbBool buildInsideParent, 00107 Type type, 00108 SbBool buildNow); 00109 00110 // redefine this routine to cache slider top geometry 00111 virtual void sizeChanged(const SbVec2s &newSize); 00112 00113 // redefine this routine to do the actual slider top region drawing. 00114 // This routine is automatically called by the SoXtSlider::redraw() routine. 00115 virtual void drawSliderTopRegion(); 00116 00117 private: 00118 00119 // local vars 00120 Boolean WYSIWYGmode; 00121 Type type; 00122 float color[3]; 00123 SbColor *defaultColors, *colors; 00124 SbVec2f *geometry; 00125 00126 // routine that make the default and WYSIWYG colors 00127 void makeDefaultColors(); 00128 void makeWYSIWYGcolors(); 00129 00130 static void sliderChangedCB(void *, float val); 00131 00132 // this is called by both constructors 00133 void constructorCommon(SoXtColorSlider::Type type, SbBool buildNow); 00134 }; 00135 00136 00137 #endif /* _SO_XT_COLOR_SLIDER_ */ 00138 00139 00140