![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * C o l o r W h e e l W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2001,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXColorWheel.h,v 1.37 2009/01/06 13:07:22 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXCOLORWHEEL_H 00024 #define FXCOLORWHEEL_H 00025 00026 #ifndef FXFRAME_H 00027 #include "FXFrame.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 class FXImage; 00034 00035 00036 /** 00037 * A ColorWheel is a widget which controls the hue and saturation values of a 00038 * color. It is most often used together with a Color Bar which controls the 00039 * brighness. 00040 */ 00041 class FXAPI FXColorWheel : public FXFrame { 00042 FXDECLARE(FXColorWheel) 00043 protected: 00044 FXImage *dial; // HSV dial image 00045 FXfloat hsv[3]; // Hue, saturation, value 00046 FXint dialx; // Dial x location 00047 FXint dialy; // Dial Y location 00048 FXint spotx; // Spot x location 00049 FXint spoty; // Spot Y location 00050 FXString tip; // Tooltip value 00051 FXString help; // Help value 00052 protected: 00053 FXColorWheel(); 00054 void updatedial(); 00055 void movespot(FXint x,FXint y); 00056 FXbool hstoxy(FXint& x,FXint& y,FXfloat h,FXfloat s) const; 00057 FXbool xytohs(FXfloat& h,FXfloat& s,FXint x,FXint y) const; 00058 private: 00059 FXColorWheel(const FXColorWheel&); 00060 FXColorWheel &operator=(const FXColorWheel&); 00061 public: 00062 long onPaint(FXObject*,FXSelector,void*); 00063 long onLeftBtnPress(FXObject*,FXSelector,void*); 00064 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00065 long onMotion(FXObject*,FXSelector,void*); 00066 long onMouseWheel(FXObject*,FXSelector,void*); 00067 long onCmdSetHelp(FXObject*,FXSelector,void*); 00068 long onCmdGetHelp(FXObject*,FXSelector,void*); 00069 long onCmdSetTip(FXObject*,FXSelector,void*); 00070 long onCmdGetTip(FXObject*,FXSelector,void*); 00071 long onQueryHelp(FXObject*,FXSelector,void*); 00072 long onQueryTip(FXObject*,FXSelector,void*); 00073 public: 00074 00075 /// Construct color wheel with initial color clr 00076 FXColorWheel(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); 00077 00078 /// Create server-side resources 00079 virtual void create(); 00080 00081 /// Detach server-side resources 00082 virtual void detach(); 00083 00084 /// Perform layout 00085 virtual void layout(); 00086 00087 /// Return default width 00088 virtual FXint getDefaultWidth(); 00089 00090 /// Return default height 00091 virtual FXint getDefaultHeight(); 00092 00093 /// Change hue 00094 void setHue(FXfloat h); 00095 00096 /// Return hue 00097 FXfloat getHue() const { return hsv[0]; } 00098 00099 /// Change saturation 00100 void setSat(FXfloat s); 00101 00102 /// Return saturation 00103 FXfloat getSat() const { return hsv[1]; } 00104 00105 /// Change value 00106 void setVal(FXfloat v); 00107 00108 /// Return value 00109 FXfloat getVal() const { return hsv[2]; } 00110 00111 /// Set hue, saturation, value 00112 void setHueSatVal(FXfloat h,FXfloat s,FXfloat v); 00113 00114 /// Set status line help text for this color well 00115 void setHelpText(const FXString& text){ help=text; } 00116 00117 /// Get status line help text for this color well 00118 const FXString& getHelpText() const { return help; } 00119 00120 /// Set tool tip message for this color well 00121 void setTipText(const FXString& text){ tip=text; } 00122 00123 /// Get tool tip message for this color well 00124 const FXString& getTipText() const { return tip; } 00125 00126 /// Save color well to a stream 00127 virtual void save(FXStream& store) const; 00128 00129 /// Load color well from a stream 00130 virtual void load(FXStream& store); 00131 00132 /// Destructor 00133 virtual ~FXColorWheel(); 00134 }; 00135 00136 } 00137 00138 #endif
![]() |