1 /******************************************************************************** 2 * * 3 * C o l o r B a r W i d g e t * 4 * * 5 ********************************************************************************* 6 * Copyright (C) 2001,2005 by Jeroen van der Zijp. All Rights Reserved. * 7 ********************************************************************************* 8 * This library is free software; you can redistribute it and/or * 9 * modify it under the terms of the GNU Lesser General Public * 10 * License as published by the Free Software Foundation; either * 11 * version 2.1 of the License, or (at your option) any later version. * 12 * * 13 * This library is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 16 * Lesser General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU Lesser General Public * 19 * License along with this library; if not, write to the Free Software * 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 21 ********************************************************************************* 22 * $Id: FXColorBar.h,v 1.19 2005/01/16 16:06:06 fox Exp $ * 23 ********************************************************************************/ 24 #ifndef FXCOLORBAR_H 25 #define FXCOLORBAR_H 26 27 #ifndef FXFRAME_H 28 #include "FXFrame.h" 29 #endif 30 31 namespace FX { 32 33 34 /// Color bar orientation 35 enum { 36 COLORBAR_HORIZONTAL = 0, /// Color bar shown horizontally 37 COLORBAR_VERTICAL = 0x00008000 /// Color bar shown vertically 38 }; 39 40 41 class FXImage; 42 43 44 /** 45 * A Color Bar is a widget which controls the brightness (value) of a 46 * color by means of the hue, saturation, value specification system. 47 * It is most useful when used together with the Color Wheel which controls 48 * the hue and saturation. 49 * The options COLORBAR_HORIZONTAL and COLORBAR_VERTICAL control the orientation 50 * of the bar. 51 */ 52 class FXAPI FXColorBar : public FXFrame { 53 FXDECLARE(FXColorBar) 54 protected: 55 FXImage *bar; // Intensity bar 56 FXfloat hsv[3]; // Hue, saturation, value 57 FXString tip; // Tooltip value 58 FXString help; // Help value 59 protected: 60 FXColorBar(); 61 void updatebar(); 62 private: 63 FXColorBar(const FXColorBar&); 64 FXColorBar &operator=(const FXColorBar&); 65 public: 66 long onPaint(FXObject*,FXSelector,void*); 67 long onLeftBtnPress(FXObject*,FXSelector,void*); 68 long onLeftBtnRelease(FXObject*,FXSelector,void*); 69 long onMotion(FXObject*,FXSelector,void*); 70 long onCmdSetHelp(FXObject*,FXSelector,void*); 71 long onCmdGetHelp(FXObject*,FXSelector,void*); 72 long onCmdSetTip(FXObject*,FXSelector,void*); 73 long onCmdGetTip(FXObject*,FXSelector,void*); 74 long onQueryHelp(FXObject*,FXSelector,void*); 75 long onQueryTip(FXObject*,FXSelector,void*); 76 public: 77 78 /// Construct color bar 79 FXColorBar(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=FRAME_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD); 80 81 /// Create server-side resources 82 virtual void create(); 83 84 /// Detach server-side resources 85 virtual void detach(); 86 87 /// Return default width 88 virtual FXint getDefaultWidth(); 89 90 /// Return default height 91 virtual FXint getDefaultHeight(); 92 93 /// Perform layout 94 virtual void layout(); 95 96 /// Change hue 97 void setHue(FXfloat h); 98 99 /// Return hue getHue()100 FXfloat getHue() const { return hsv[0]; } 101 102 /// Change saturation 103 void setSat(FXfloat s); 104 105 /// Return saturation getSat()106 FXfloat getSat() const { return hsv[1]; } 107 108 /// Change value 109 void setVal(FXfloat v); 110 111 /// Return value getVal()112 FXfloat getVal() const { return hsv[2]; } 113 114 /// Change the color bar style 115 FXuint getBarStyle() const; 116 117 /// Get the color bar style 118 void setBarStyle(FXuint style); 119 120 /// Set status line help text for this color bar setHelpText(const FXString & text)121 void setHelpText(const FXString& text){ help=text; } 122 123 /// Get status line help text for this color bar getHelpText()124 const FXString& getHelpText() const { return help; } 125 126 /// Set tool tip message for this color bar setTipText(const FXString & text)127 void setTipText(const FXString& text){ tip=text; } 128 129 /// Get tool tip message for this color bar getTipText()130 const FXString& getTipText() const { return tip; } 131 132 /// Save color bar to a stream 133 virtual void save(FXStream& store) const; 134 135 /// Load color bar from a stream 136 virtual void load(FXStream& store); 137 138 /// Destructor 139 virtual ~FXColorBar(); 140 }; 141 142 } 143 144 #endif 145