Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXColorWheel.h

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.15 2002/01/18 22:42:51 jeroen Exp $                   *
00023 ********************************************************************************/
00024 #ifndef FXCOLORWHEEL_H
00025 #define FXCOLORWHEEL_H
00026 
00027 #ifndef FXFRAME_H
00028 #include "FXFrame.h"
00029 #endif
00030 
00031 
00032 
00033 class FXImage;
00034 
00035 
00036 /**
00037 * A color wheel is a widget which controls a color by means
00038 * of the hue, saturation, value color specification system.
00039 */
00040 class FXAPI FXColorWheel : public FXFrame {
00041   FXDECLARE(FXColorWheel)
00042 protected:
00043   FXImage  *dial;         // HSV dial image
00044   FXfloat   hsv[3];       // Hue, saturation, value
00045   FXint     spotx;        // Spot x location
00046   FXint     spoty;        // Spot Y location
00047   FXint     dialx;        // Dial x location
00048   FXint     dialy;        // Dial Y location
00049   FXString  tip;          // Tooltip value
00050   FXString  help;         // Help value
00051 protected:
00052   FXColorWheel();
00053   void updatedial();
00054   void movespot(FXint x,FXint y);
00055   FXbool hstoxy(FXint& x,FXint& y,FXfloat h,FXfloat s) const;
00056   FXbool xytohs(FXfloat& h,FXfloat& s,FXint x,FXint y) const;
00057   virtual void layout();
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 onQueryHelp(FXObject*,FXSelector,void*);
00067   long onQueryTip(FXObject*,FXSelector,void*);
00068 public:
00069 
00070   /// Construct color well with initial color clr
00071   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);
00072 
00073   /// Create server-side resources
00074   virtual void create();
00075 
00076   /// Detach server-side resources
00077   virtual void detach();
00078 
00079   /// Return default width
00080   virtual FXint getDefaultWidth();
00081 
00082   /// Return default height
00083   virtual FXint getDefaultHeight();
00084 
00085   /// Change hue
00086   void setHue(FXfloat h);
00087 
00088   /// Return hue
00089   FXfloat getHue() const { return hsv[0]; }
00090 
00091   /// Change saturation
00092   void setSat(FXfloat s);
00093 
00094   /// Return saturation
00095   FXfloat getSat() const { return hsv[1]; }
00096 
00097   /// Change value
00098   void setVal(FXfloat v);
00099 
00100   /// Return value
00101   FXfloat getVal() const { return hsv[2]; }
00102 
00103   /// Set status line help text for this color well
00104   void setHelpText(const FXString& text);
00105 
00106   /// Get status line help text for this color well
00107   FXString getHelpText() const { return help; }
00108 
00109   /// Set tool tip message for this color well
00110   void setTipText(const FXString& text);
00111 
00112   /// Get tool tip message for this color well
00113   FXString getTipText() const { return tip; }
00114 
00115   /// Save color well to a stream
00116   virtual void save(FXStream& store) const;
00117 
00118   /// Load color well from a stream
00119   virtual void load(FXStream& store);
00120 
00121   /// Destructor
00122   virtual ~FXColorWheel();
00123   };
00124 
00125 
00126 #endif