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

FXColorSelector.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                          C o l o r   S e l e c t o r                          *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1998,2006 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: FXColorSelector.h,v 1.30 2006/01/22 17:57:59 fox Exp $                   *
00023 ********************************************************************************/
00024 #ifndef FXCOLORSELECTOR_H
00025 #define FXCOLORSELECTOR_H
00026 
00027 #ifndef FXPACKER_H
00028 #include "FXPacker.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 class FXTabBook;
00035 class FXColorBar;
00036 class FXColorWell;
00037 class FXColorWheel;
00038 class FXColorRing;
00039 class FXColorList;
00040 class FXList;
00041 class FXSlider;
00042 class FXTextField;
00043 class FXButton;
00044 class FXIcon;
00045 class FXLabel;
00046 
00047 
00048 /// Color selection widget
00049 class FXAPI FXColorSelector : public FXPacker {
00050   FXDECLARE(FXColorSelector)
00051 protected:
00052   FXTabBook    *panels;               // Color panes
00053   FXColorWell  *well;                 // Main well
00054   FXColorList  *list;                 // List of color names
00055   FXColorRing  *wheel;                // Color ring
00056   FXSlider     *rgbaslider[4];        // RGBA sliders
00057   FXTextField  *rgbatext[4];          // RGBA text fields
00058   FXSlider     *hsvaslider[4];        // HSVA sliders
00059   FXTextField  *hsvatext[4];          // HSVA text fields
00060   FXSlider     *cmyslider[4];         // CMY sliders
00061   FXTextField  *cmytext[4];           // CMY text fields
00062   FXColorWell  *colorwells[24];       // Custom color wells
00063   FXIcon       *eyedropicon;          // Icon for eye dropper
00064   FXIcon       *dialmodeicon;         // Icon for dial mode
00065   FXIcon       *rgbmodeicon;          // Icon for RGB mode
00066   FXIcon       *hsvmodeicon;          // Icon for HSV mode
00067   FXIcon       *cmymodeicon;          // Icon for CMY mode
00068   FXIcon       *txtmodeicon;          // Icon for TEXT mode
00069   FXButton     *accept;               // Accept button
00070   FXButton     *cancel;               // Cancel button
00071   FXfloat       rgba[4];              // Accurate RGBA color
00072   FXfloat       hsva[4];              // Accurate HSVA color
00073 protected:
00074   static const FXchar* wellname[24];  // Well names
00075 protected:
00076   FXColorSelector(){}
00077   void updateWell();
00078 private:
00079   FXColorSelector(const FXColorSelector&);
00080   FXColorSelector &operator=(const FXColorSelector&);
00081 public:
00082   long onCmdWell(FXObject*,FXSelector,void*);
00083   long onChgWell(FXObject*,FXSelector,void*);
00084   long onCmdRGBSlider(FXObject*,FXSelector,void*);
00085   long onUpdRGBSlider(FXObject*,FXSelector,void*);
00086   long onCmdRGBText(FXObject*,FXSelector,void*);
00087   long onUpdRGBText(FXObject*,FXSelector,void*);
00088   long onCmdHSVSlider(FXObject*,FXSelector,void*);
00089   long onUpdHSVSlider(FXObject*,FXSelector,void*);
00090   long onCmdHSVText(FXObject*,FXSelector,void*);
00091   long onUpdHSVText(FXObject*,FXSelector,void*);
00092   long onCmdCMYSlider(FXObject*,FXSelector,void*);
00093   long onUpdCMYSlider(FXObject*,FXSelector,void*);
00094   long onCmdCMYText(FXObject*,FXSelector,void*);
00095   long onUpdCMYText(FXObject*,FXSelector,void*);
00096   long onCmdList(FXObject*,FXSelector,void*);
00097   long onCmdCustomWell(FXObject*,FXSelector,void*);
00098   long onChgCustomWell(FXObject*,FXSelector,void*);
00099   long onCmdSetValue(FXObject*,FXSelector,void*);
00100   long onCmdActivePane(FXObject*,FXSelector,void*);
00101   long onCmdAlphaSlider(FXObject*,FXSelector,void*);
00102   long onUpdAlphaSlider(FXObject*,FXSelector,void*);
00103   long onCmdAlphaText(FXObject*,FXSelector,void*);
00104   long onUpdAlphaText(FXObject*,FXSelector,void*);
00105   long onUpdAlphaLabel(FXObject*,FXSelector,void*);
00106   long onCmdWheel(FXObject*,FXSelector,void*);
00107   long onUpdWheel(FXObject*,FXSelector,void*);
00108   long onCmdColorPick(FXObject*,FXSelector,void*);
00109 public:
00110   enum {
00111     ID_CUSTOM_FIRST=FXPacker::ID_LAST,
00112     ID_CUSTOM_LAST=ID_CUSTOM_FIRST+24,
00113     ID_RGB_RED_SLIDER,
00114     ID_RGB_GREEN_SLIDER,
00115     ID_RGB_BLUE_SLIDER,
00116     ID_RGB_RED_TEXT,
00117     ID_RGB_GREEN_TEXT,
00118     ID_RGB_BLUE_TEXT,
00119     ID_HSV_HUE_SLIDER,
00120     ID_HSV_SATURATION_SLIDER,
00121     ID_HSV_VALUE_SLIDER,
00122     ID_HSV_HUE_TEXT,
00123     ID_HSV_SATURATION_TEXT,
00124     ID_HSV_VALUE_TEXT,
00125     ID_CMY_CYAN_SLIDER,
00126     ID_CMY_MAGENTA_SLIDER,
00127     ID_CMY_YELLOW_SLIDER,
00128     ID_CMY_CYAN_TEXT,
00129     ID_CMY_MAGENTA_TEXT,
00130     ID_CMY_YELLOW_TEXT,
00131     ID_DIAL_WHEEL,
00132     ID_COLOR_LIST,
00133     ID_WELL_CHANGED,
00134     ID_ACTIVEPANE,
00135     ID_ALPHA_SLIDER,
00136     ID_ALPHA_TEXT,
00137     ID_ALPHA_LABEL,
00138     ID_COLORPICK,
00139     ID_LAST
00140     };
00141 public:
00142 
00143   /// Construct a new ColorSelector
00144   FXColorSelector(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00145 
00146   /// Create the ColorSelector
00147   virtual void create();
00148 
00149   /// Return a pointer to the "Accept" button
00150   FXButton *acceptButton() const { return accept; }
00151 
00152   /// Return a pointer to the "Cancel" button
00153   FXButton *cancelButton() const { return cancel; }
00154 
00155   /// Set the selected color
00156   void setRGBA(FXColor clr);
00157 
00158   /// Get the selected color
00159   FXColor getRGBA() const;
00160 
00161   /// Return true if only opaque colors allowed
00162   FXbool isOpaqueOnly() const;
00163 
00164   /// Change opaque only mode
00165   void setOpaqueOnly(FXbool opaque);
00166 
00167   /// Save to a stream
00168   virtual void save(FXStream& store) const;
00169 
00170   /// Load from a stream
00171   virtual void load(FXStream& store);
00172 
00173   /// Destructor
00174   virtual ~FXColorSelector();
00175   };
00176 
00177 }
00178 
00179 #endif

Copyright © 1997-2005 Jeroen van der Zijp