![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * C o l o r R i n g W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2005,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: FXColorRing.h,v 1.17 2009/01/06 13:07:22 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXCOLORRING_H 00024 #define FXCOLORRING_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 Color Ring widget provides an intuitive way to specify a color. 00038 * The outer ring of the widget is rotated to control the hue of the color 00039 * being specified, while the inner triangle varies the color saturation 00040 * and the brightness of the color. The color saturation axis of the 00041 * triangle goes from a fully saturated "pure" color to "pastel" color; 00042 * the brightness goes from black to a bright color. 00043 */ 00044 class FXAPI FXColorRing : public FXFrame { 00045 FXDECLARE(FXColorRing) 00046 protected: 00047 FXImage *dial; // HSV dial image 00048 FXfloat hsv[3]; // Hue, saturation, value 00049 FXint ringwidth; // Width of hue ring 00050 FXint ringouter; // Outer radius 00051 FXint ringinner; // Inner radius 00052 FXint dialx; // Dial x location 00053 FXint dialy; // Dial y location 00054 FXint satvalx; // Saturation value x 00055 FXint satvaly; // Saturation value y 00056 FXint huex; // Hue x 00057 FXint huey; // Hue y 00058 FXint clrx; // Color corner of triangle 00059 FXint clry; 00060 FXint blkx; // Black corner of triangle 00061 FXint blky; 00062 FXint whtx; // White corner of triangle 00063 FXint whty; 00064 FXString tip; // Tooltip value 00065 FXString help; // Help value 00066 FXuchar mode; // Mode widget is in 00067 protected: 00068 FXColorRing(); 00069 void updatering(); 00070 FXfloat hueFromXY(FXint x,FXint y) const; 00071 void hueToXY(FXint& x,FXint& y,FXfloat hue) const; 00072 void satValToXY(FXint& x,FXint& y,FXfloat s,FXfloat v) const; 00073 void satValFromXY(FXfloat& s,FXfloat& v,FXint x,FXint y) const; 00074 FXbool inCorner(FXint x,FXint y) const; 00075 FXbool inHueRing(FXint x,FXint y) const; 00076 FXbool inTriangle(FXint x,FXint y) const; 00077 protected: 00078 enum { 00079 MOUSE_NONE, // No mouse operation 00080 MOUSE_HUE, // Moving in hue-ring 00081 MOUSE_SATVAL // Moving in saturation/value triangle 00082 }; 00083 private: 00084 FXColorRing(const FXColorRing&); 00085 FXColorRing &operator=(const FXColorRing&); 00086 public: 00087 long onPaint(FXObject*,FXSelector,void*); 00088 long onLeftBtnPress(FXObject*,FXSelector,void*); 00089 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00090 long onMotion(FXObject*,FXSelector,void*); 00091 long onMouseWheel(FXObject*,FXSelector,void*); 00092 long onCmdSetHelp(FXObject*,FXSelector,void*); 00093 long onCmdGetHelp(FXObject*,FXSelector,void*); 00094 long onCmdSetTip(FXObject*,FXSelector,void*); 00095 long onCmdGetTip(FXObject*,FXSelector,void*); 00096 long onQueryHelp(FXObject*,FXSelector,void*); 00097 long onQueryTip(FXObject*,FXSelector,void*); 00098 public: 00099 00100 /// Construct color ring with initial color clr 00101 FXColorRing(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); 00102 00103 /// Create server-side resources 00104 virtual void create(); 00105 00106 /// Detach server-side resources 00107 virtual void detach(); 00108 00109 /// Perform layout 00110 virtual void layout(); 00111 00112 /// Return default width 00113 virtual FXint getDefaultWidth(); 00114 00115 /// Return default height 00116 virtual FXint getDefaultHeight(); 00117 00118 /// Change hue 00119 void setHue(FXfloat h); 00120 00121 /// Return hue 00122 FXfloat getHue() const { return hsv[0]; } 00123 00124 /// Change saturation 00125 void setSat(FXfloat s); 00126 00127 /// Return saturation 00128 FXfloat getSat() const { return hsv[1]; } 00129 00130 /// Change value 00131 void setVal(FXfloat v); 00132 00133 /// Return value 00134 FXfloat getVal() const { return hsv[2]; } 00135 00136 /// Set hue, saturation, value 00137 void setHueSatVal(FXfloat h,FXfloat s,FXfloat v); 00138 00139 /// Change width of hue ring 00140 void setRingWidth(FXint rw); 00141 00142 /// Return width of hue ring 00143 FXint getRingWidth() const { return ringwidth; } 00144 00145 /// Set status line help text for this color well 00146 void setHelpText(const FXString& text){ help=text; } 00147 00148 /// Get status line help text for this color well 00149 const FXString& getHelpText() const { return help; } 00150 00151 /// Set tool tip message for this color well 00152 void setTipText(const FXString& text){ tip=text; } 00153 00154 /// Get tool tip message for this color well 00155 const FXString& getTipText() const { return tip; } 00156 00157 /// Save color well to a stream 00158 virtual void save(FXStream& store) const; 00159 00160 /// Load color well from a stream 00161 virtual void load(FXStream& store); 00162 00163 /// Destructor 00164 virtual ~FXColorRing(); 00165 }; 00166 00167 } 00168 00169 #endif
![]() |