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

/home/jeroen/FOX/fox/fox-1.7.33/include/FXColorRing.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                         C o l o r R i n g   W i d g e t                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2005,2012 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 #ifndef FXCOLORRING_H
00022 #define FXCOLORRING_H
00023 
00024 #ifndef FXFRAME_H
00025 #include "FXFrame.h"
00026 #endif
00027 
00028 namespace FX {
00029 
00030 
00031 class FXImage;
00032 
00033 
00042 class FXAPI FXColorRing : public FXFrame {
00043   FXDECLARE(FXColorRing)
00044 protected:
00045   FXImage  *dial;         // HSV dial image
00046   FXfloat   hsv[3];       // Hue, saturation, value
00047   FXint     ringwidth;    // Width of hue ring
00048   FXint     ringouter;    // Outer radius
00049   FXint     ringinner;    // Inner radius
00050   FXint     dialx;        // Dial x location
00051   FXint     dialy;        // Dial y location
00052   FXint     satvalx;      // Saturation value x
00053   FXint     satvaly;      // Saturation value y
00054   FXint     huex;         // Hue x
00055   FXint     huey;         // Hue y
00056   FXint     clrx;         // Color corner of triangle
00057   FXint     clry;
00058   FXint     blkx;         // Black corner of triangle
00059   FXint     blky;
00060   FXint     whtx;         // White corner of triangle
00061   FXint     whty;
00062   FXString  tip;          // Tooltip value
00063   FXString  help;         // Help value
00064   FXuchar   mode;         // Mode widget is in
00065 protected:
00066   FXColorRing();
00067   void updatering();
00068   FXfloat hueFromXY(FXint x,FXint y) const;
00069   void hueToXY(FXint& x,FXint& y,FXfloat hue) const;
00070   void satValToXY(FXint& x,FXint& y,FXfloat s,FXfloat v) const;
00071   void satValFromXY(FXfloat& s,FXfloat& v,FXint x,FXint y) const;
00072   FXbool inCorner(FXint x,FXint y) const;
00073   FXbool inHueRing(FXint x,FXint y) const;
00074   FXbool inTriangle(FXint x,FXint y) const;
00075 protected:
00076   enum {
00077     MOUSE_NONE,         // No mouse operation
00078     MOUSE_HUE,          // Moving in hue-ring
00079     MOUSE_SATVAL        // Moving in saturation/value triangle
00080     };
00081 private:
00082   FXColorRing(const FXColorRing&);
00083   FXColorRing &operator=(const FXColorRing&);
00084 public:
00085   long onPaint(FXObject*,FXSelector,void*);
00086   long onLeftBtnPress(FXObject*,FXSelector,void*);
00087   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00088   long onMotion(FXObject*,FXSelector,void*);
00089   long onMouseWheel(FXObject*,FXSelector,void*);
00090   long onCmdSetHelp(FXObject*,FXSelector,void*);
00091   long onCmdGetHelp(FXObject*,FXSelector,void*);
00092   long onCmdSetTip(FXObject*,FXSelector,void*);
00093   long onCmdGetTip(FXObject*,FXSelector,void*);
00094   long onQueryHelp(FXObject*,FXSelector,void*);
00095   long onQueryTip(FXObject*,FXSelector,void*);
00096 public:
00097 
00099   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);
00100 
00102   virtual void create();
00103 
00105   virtual void detach();
00106 
00108   virtual void layout();
00109 
00111   virtual FXint getDefaultWidth();
00112 
00114   virtual FXint getDefaultHeight();
00115 
00117   void setHue(FXfloat h);
00118 
00120   FXfloat getHue() const { return hsv[0]; }
00121 
00123   void setSat(FXfloat s);
00124 
00126   FXfloat getSat() const { return hsv[1]; }
00127 
00129   void setVal(FXfloat v);
00130 
00132   FXfloat getVal() const { return hsv[2]; }
00133 
00135   void setHueSatVal(FXfloat h,FXfloat s,FXfloat v);
00136 
00138   void setRingWidth(FXint rw);
00139 
00141   FXint getRingWidth() const { return ringwidth; }
00142 
00144   void setHelpText(const FXString& text){ help=text; }
00145 
00147   const FXString& getHelpText() const { return help; }
00148 
00150   void setTipText(const FXString& text){ tip=text; }
00151 
00153   const FXString& getTipText() const { return tip; }
00154 
00156   virtual void save(FXStream& store) const;
00157 
00159   virtual void load(FXStream& store);
00160 
00162   virtual ~FXColorRing();
00163   };
00164 
00165 }
00166 
00167 #endif

Copyright © 1997-2011 Jeroen van der Zijp