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

FXColorSelector.h

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

Copyright © 1997-2004 Jeroen van der Zijp