![]() |
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,2002 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (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 GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXColorWheel.h,v 1.18 2002/09/30 13:06:55 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXCOLORWHEEL_H 00025 #define FXCOLORWHEEL_H 00026 00027 #ifndef FXFRAME_H 00028 #include "FXFrame.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 class FXImage; 00035 00036 00037 /** 00038 * A color wheel is a widget which controls a color by means 00039 * of the hue, saturation, value color specification system. 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 spotx; // Spot x location 00047 FXint spoty; // Spot Y location 00048 FXint dialx; // Dial x location 00049 FXint dialy; // Dial 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 virtual void layout(); 00059 private: 00060 FXColorWheel(const FXColorWheel&); 00061 FXColorWheel &operator=(const FXColorWheel&); 00062 public: 00063 long onPaint(FXObject*,FXSelector,void*); 00064 long onLeftBtnPress(FXObject*,FXSelector,void*); 00065 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00066 long onMotion(FXObject*,FXSelector,void*); 00067 long onQueryHelp(FXObject*,FXSelector,void*); 00068 long onQueryTip(FXObject*,FXSelector,void*); 00069 public: 00070 00071 /// Construct color well with initial color clr 00072 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); 00073 00074 /// Create server-side resources 00075 virtual void create(); 00076 00077 /// Detach server-side resources 00078 virtual void detach(); 00079 00080 /// Return default width 00081 virtual FXint getDefaultWidth(); 00082 00083 /// Return default height 00084 virtual FXint getDefaultHeight(); 00085 00086 /// Change hue 00087 void setHue(FXfloat h); 00088 00089 /// Return hue 00090 FXfloat getHue() const { return hsv[0]; } 00091 00092 /// Change saturation 00093 void setSat(FXfloat s); 00094 00095 /// Return saturation 00096 FXfloat getSat() const { return hsv[1]; } 00097 00098 /// Change value 00099 void setVal(FXfloat v); 00100 00101 /// Return value 00102 FXfloat getVal() const { return hsv[2]; } 00103 00104 /// Set status line help text for this color well 00105 void setHelpText(const FXString& text); 00106 00107 /// Get status line help text for this color well 00108 const FXString& getHelpText() const { return help; } 00109 00110 /// Set tool tip message for this color well 00111 void setTipText(const FXString& text); 00112 00113 /// Get tool tip message for this color well 00114 const FXString& getTipText() const { return tip; } 00115 00116 /// Save color well to a stream 00117 virtual void save(FXStream& store) const; 00118 00119 /// Load color well from a stream 00120 virtual void load(FXStream& store); 00121 00122 /// Destructor 00123 virtual ~FXColorWheel(); 00124 }; 00125 00126 } 00127 00128 #endif