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

FXColorSelector.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * C o l o r S e l e c t o r *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXColorSelector.h,v 1.30 2006/01/22 17:57:59 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXCOLORSELECTOR_H
25 #define FXCOLORSELECTOR_H
26 
27 #ifndef FXPACKER_H
28 #include "FXPacker.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 class FXTabBook;
35 class FXColorBar;
36 class FXColorWell;
37 class FXColorWheel;
38 class FXColorRing;
39 class FXColorList;
40 class FXList;
41 class FXSlider;
42 class FXTextField;
43 class FXButton;
44 class FXIcon;
45 class FXLabel;
46 
47 
48 /// Color selection widget
49 class FXAPI FXColorSelector : public FXPacker {
51 protected:
52  FXTabBook *panels; // Color panes
53  FXColorWell *well; // Main well
54  FXColorList *list; // List of color names
55  FXColorRing *wheel; // Color ring
56  FXSlider *rgbaslider[4]; // RGBA sliders
57  FXTextField *rgbatext[4]; // RGBA text fields
58  FXSlider *hsvaslider[4]; // HSVA sliders
59  FXTextField *hsvatext[4]; // HSVA text fields
60  FXSlider *cmyslider[4]; // CMY sliders
61  FXTextField *cmytext[4]; // CMY text fields
62  FXColorWell *colorwells[24]; // Custom color wells
63  FXIcon *eyedropicon; // Icon for eye dropper
64  FXIcon *dialmodeicon; // Icon for dial mode
65  FXIcon *rgbmodeicon; // Icon for RGB mode
66  FXIcon *hsvmodeicon; // Icon for HSV mode
67  FXIcon *cmymodeicon; // Icon for CMY mode
68  FXIcon *txtmodeicon; // Icon for TEXT mode
69  FXButton *accept; // Accept button
70  FXButton *cancel; // Cancel button
71  FXfloat rgba[4]; // Accurate RGBA color
72  FXfloat hsva[4]; // Accurate HSVA color
73 protected:
74  static const FXchar* wellname[24]; // Well names
75 protected:
76  FXColorSelector(){}
77  void updateWell();
78 private:
80  FXColorSelector &operator=(const FXColorSelector&);
81 public:
82  long onCmdWell(FXObject*,FXSelector,void*);
83  long onChgWell(FXObject*,FXSelector,void*);
84  long onCmdRGBSlider(FXObject*,FXSelector,void*);
85  long onUpdRGBSlider(FXObject*,FXSelector,void*);
86  long onCmdRGBText(FXObject*,FXSelector,void*);
87  long onUpdRGBText(FXObject*,FXSelector,void*);
88  long onCmdHSVSlider(FXObject*,FXSelector,void*);
89  long onUpdHSVSlider(FXObject*,FXSelector,void*);
90  long onCmdHSVText(FXObject*,FXSelector,void*);
91  long onUpdHSVText(FXObject*,FXSelector,void*);
92  long onCmdCMYSlider(FXObject*,FXSelector,void*);
93  long onUpdCMYSlider(FXObject*,FXSelector,void*);
94  long onCmdCMYText(FXObject*,FXSelector,void*);
95  long onUpdCMYText(FXObject*,FXSelector,void*);
96  long onCmdList(FXObject*,FXSelector,void*);
97  long onCmdCustomWell(FXObject*,FXSelector,void*);
98  long onChgCustomWell(FXObject*,FXSelector,void*);
99  long onCmdSetValue(FXObject*,FXSelector,void*);
100  long onCmdActivePane(FXObject*,FXSelector,void*);
101  long onCmdAlphaSlider(FXObject*,FXSelector,void*);
102  long onUpdAlphaSlider(FXObject*,FXSelector,void*);
103  long onCmdAlphaText(FXObject*,FXSelector,void*);
104  long onUpdAlphaText(FXObject*,FXSelector,void*);
105  long onUpdAlphaLabel(FXObject*,FXSelector,void*);
106  long onCmdWheel(FXObject*,FXSelector,void*);
107  long onUpdWheel(FXObject*,FXSelector,void*);
108  long onCmdColorPick(FXObject*,FXSelector,void*);
109 public:
110  enum {
111  ID_CUSTOM_FIRST=FXPacker::ID_LAST,
112  ID_CUSTOM_LAST=ID_CUSTOM_FIRST+24,
113  ID_RGB_RED_SLIDER,
114  ID_RGB_GREEN_SLIDER,
115  ID_RGB_BLUE_SLIDER,
116  ID_RGB_RED_TEXT,
117  ID_RGB_GREEN_TEXT,
118  ID_RGB_BLUE_TEXT,
119  ID_HSV_HUE_SLIDER,
120  ID_HSV_SATURATION_SLIDER,
121  ID_HSV_VALUE_SLIDER,
122  ID_HSV_HUE_TEXT,
123  ID_HSV_SATURATION_TEXT,
124  ID_HSV_VALUE_TEXT,
125  ID_CMY_CYAN_SLIDER,
126  ID_CMY_MAGENTA_SLIDER,
127  ID_CMY_YELLOW_SLIDER,
128  ID_CMY_CYAN_TEXT,
129  ID_CMY_MAGENTA_TEXT,
130  ID_CMY_YELLOW_TEXT,
131  ID_DIAL_WHEEL,
132  ID_COLOR_LIST,
133  ID_WELL_CHANGED,
134  ID_ACTIVEPANE,
135  ID_ALPHA_SLIDER,
136  ID_ALPHA_TEXT,
137  ID_ALPHA_LABEL,
138  ID_COLORPICK,
139  ID_LAST
140  };
141 public:
142 
143  /// Construct a new ColorSelector
144  FXColorSelector(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
145 
146  /// Create the ColorSelector
147  virtual void create();
148 
149  /// Return a pointer to the "Accept" button
150  FXButton *acceptButton() const { return accept; }
151 
152  /// Return a pointer to the "Cancel" button
153  FXButton *cancelButton() const { return cancel; }
154 
155  /// Set the selected color
156  void setRGBA(FXColor clr);
157 
158  /// Get the selected color
159  FXColor getRGBA() const;
160 
161  /// Return true if only opaque colors allowed
162  FXbool isOpaqueOnly() const;
163 
164  /// Change opaque only mode
165  void setOpaqueOnly(FXbool opaque);
166 
167  /// Save to a stream
168  virtual void save(FXStream& store) const;
169 
170  /// Load from a stream
171  virtual void load(FXStream& store);
172 
173  /// Destructor
174  virtual ~FXColorSelector();
175  };
176 
177 }
178 
179 #endif
char FXchar
Definition: fxdefs.h:387
Definition: FXWindow.h:241
unsigned int FXuint
Definition: fxdefs.h:396
FXuint FXSelector
Association key.
Definition: FXObject.h:53
A button provides a push button, with optional icon and/or text label.
Definition: FXButton.h:85
#define FXAPI
Definition: fxdefs.h:122
The slider widget is a valuator widget which provides simple linear value range.
Definition: FXSlider.h:67
FXuchar FXbool
Definition: fxdefs.h:393
Base composite.
Definition: FXComposite.h:35
#define NULL
Definition: fxdefs.h:41
FXuint FXColor
Definition: fxdefs.h:454
A color well is a widget which controls color settings.
Definition: FXColorWell.h:62
int FXint
Definition: fxdefs.h:397
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:45
A ColorList Widget displays a list of colors.
Definition: FXColorList.h:58
Packer is a layout manager which automatically places child windows inside its area against the left...
Definition: FXPacker.h:58
Color selection widget.
Definition: FXColorSelector.h:49
A text field is a single-line text entry widget.
Definition: FXTextField.h:73
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
float FXfloat
Definition: fxdefs.h:398
The tab book layout manager arranges pairs of children; the even numbered children (0...
Definition: FXTabBook.h:50
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
A Color Ring widget provides an intuitive way to specify a color.
Definition: FXColorRing.h:45

Copyright © 1997-2005 Jeroen van der Zijp