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

FXColorSelector.h
1 /********************************************************************************
2 * *
3 * C o l o r S e l e c t o r *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2024 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (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 *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXCOLORSELECTOR_H
22 #define FXCOLORSELECTOR_H
23 
24 #ifndef FXPACKER_H
25 #include "FXPacker.h"
26 #endif
27 
28 namespace FX {
29 
30 
31 class FXTabBook;
32 class FXColorBar;
33 class FXColorWell;
34 class FXColorWheel;
35 class FXColorRing;
36 class FXColorList;
37 class FXList;
38 class FXSlider;
39 class FXTextField;
40 class FXButton;
41 class FXIcon;
42 class FXLabel;
43 
44 
45 // Color panel tabs
46 enum {
47  COLORTAB_COLOR_RING,
48  COLORTAB_RED_GREEN_BLUE,
49  COLORTAB_HUE_SATURATION_VALUE,
50  COLORTAB_CYAN_MAGENTA_YELLOW,
51  COLORTAB_COLOR_LIST
52  };
53 
54 
56 class FXAPI FXColorSelector : public FXPacker {
57  FXDECLARE(FXColorSelector)
58 protected:
59  FXTabBook *panels; // Color panes
60  FXColorWell *well; // Main well
61  FXColorList *list; // List of color names
62  FXColorRing *wheel; // Color ring
63  FXSlider *rgbaslider[4]; // RGBA sliders
64  FXTextField *rgbatext[4]; // RGBA text fields
65  FXSlider *hsvaslider[4]; // HSVA sliders
66  FXTextField *hsvatext[4]; // HSVA text fields
67  FXSlider *cmyslider[4]; // CMY sliders
68  FXTextField *cmytext[4]; // CMY text fields
69  FXColorWell *colorwells[24]; // Custom color wells
70  FXIcon *eyedropicon; // Icon for eye dropper
71  FXIcon *dialmodeicon; // Icon for dial mode
72  FXIcon *rgbmodeicon; // Icon for RGB mode
73  FXIcon *hsvmodeicon; // Icon for HSV mode
74  FXIcon *cmymodeicon; // Icon for CMY mode
75  FXIcon *txtmodeicon; // Icon for TEXT mode
76  FXButton *accept; // Accept button
77  FXButton *cancel; // Cancel button
78  FXfloat rgba[4]; // Accurate RGBA color
79  FXfloat hsva[4]; // Accurate HSVA color
80 protected:
81  FXColorSelector(){}
82  void updateWell();
83 private:
85  FXColorSelector &operator=(const FXColorSelector&);
86 public:
87  long onCmdWell(FXObject*,FXSelector,void*);
88  long onChgWell(FXObject*,FXSelector,void*);
89  long onCmdRGBSlider(FXObject*,FXSelector,void*);
90  long onUpdRGBSlider(FXObject*,FXSelector,void*);
91  long onCmdRGBText(FXObject*,FXSelector,void*);
92  long onUpdRGBText(FXObject*,FXSelector,void*);
93  long onCmdHSVSlider(FXObject*,FXSelector,void*);
94  long onUpdHSVSlider(FXObject*,FXSelector,void*);
95  long onCmdHSVText(FXObject*,FXSelector,void*);
96  long onUpdHSVText(FXObject*,FXSelector,void*);
97  long onCmdCMYSlider(FXObject*,FXSelector,void*);
98  long onUpdCMYSlider(FXObject*,FXSelector,void*);
99  long onCmdCMYText(FXObject*,FXSelector,void*);
100  long onUpdCMYText(FXObject*,FXSelector,void*);
101  long onCmdList(FXObject*,FXSelector,void*);
102  long onCmdCustomWell(FXObject*,FXSelector,void*);
103  long onCmdSetValue(FXObject*,FXSelector,void*);
104  long onCmdAlphaSlider(FXObject*,FXSelector,void*);
105  long onUpdAlphaSlider(FXObject*,FXSelector,void*);
106  long onCmdAlphaText(FXObject*,FXSelector,void*);
107  long onUpdAlphaText(FXObject*,FXSelector,void*);
108  long onUpdAlphaLabel(FXObject*,FXSelector,void*);
109  long onCmdWheel(FXObject*,FXSelector,void*);
110  long onUpdWheel(FXObject*,FXSelector,void*);
111  long onCmdColorPick(FXObject*,FXSelector,void*);
112  long onCmdSetIntValue(FXObject*,FXSelector,void*);
113  long onCmdGetIntValue(FXObject*,FXSelector,void*);
114 public:
115  enum {
116  ID_CUSTOM_FIRST=FXPacker::ID_LAST,
117  ID_CUSTOM_LAST=ID_CUSTOM_FIRST+24,
118  ID_RGB_RED_SLIDER,
119  ID_RGB_GREEN_SLIDER,
120  ID_RGB_BLUE_SLIDER,
121  ID_RGB_RED_TEXT,
122  ID_RGB_GREEN_TEXT,
123  ID_RGB_BLUE_TEXT,
124  ID_HSV_HUE_SLIDER,
125  ID_HSV_SATURATION_SLIDER,
126  ID_HSV_VALUE_SLIDER,
127  ID_HSV_HUE_TEXT,
128  ID_HSV_SATURATION_TEXT,
129  ID_HSV_VALUE_TEXT,
130  ID_CMY_CYAN_SLIDER,
131  ID_CMY_MAGENTA_SLIDER,
132  ID_CMY_YELLOW_SLIDER,
133  ID_CMY_CYAN_TEXT,
134  ID_CMY_MAGENTA_TEXT,
135  ID_CMY_YELLOW_TEXT,
136  ID_DIAL_WHEEL,
137  ID_COLOR_LIST,
138  ID_WELL_CHANGED,
139  ID_ALPHA_SLIDER,
140  ID_ALPHA_TEXT,
141  ID_ALPHA_LABEL,
142  ID_COLORPICK,
143  ID_LAST
144  };
145 public:
146 
148  FXColorSelector(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
149 
151  FXButton *acceptButton() const { return accept; }
152 
154  FXButton *cancelButton() const { return cancel; }
155 
157  void setRGBA(FXColor color,FXbool notify=false);
158 
160  FXColor getRGBA() const;
161 
163  void setActivePanel(FXint pnl=COLORTAB_COLOR_RING);
164 
166  FXint getActivePanel() const;
167 
169  void setWellColor(FXint w,FXColor clr);
170 
172  FXColor getWellColor(FXint w) const;
173 
175  void setOpaqueOnly(FXbool opaque);
176 
178  FXbool isOpaqueOnly() const;
179 
181  virtual void save(FXStream& store) const;
182 
184  virtual void load(FXStream& store);
185 
187  virtual ~FXColorSelector();
188  };
189 
190 }
191 
192 #endif
A button provides a push button, with optional icon and/or text label.
Definition: FXButton.h:70
The slider widget is a valuator widget which provides simple linear value range.
Definition: FXSlider.h:57
Base composite.
Definition: FXComposite.h:32
FXButton * acceptButton() const
Return a pointer to the "Accept" button.
Definition: FXColorSelector.h:151
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
FXButton * cancelButton() const
Return a pointer to the "Cancel" button.
Definition: FXColorSelector.h:154
A color well is a widget which controls color settings.
Definition: FXColorWell.h:51
Definition: FX4Splitter.h:28
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:42
A ColorList Widget displays a list of colors.
Definition: FXColorList.h:64
Packer is a layout manager which automatically places child windows inside its area against the left...
Definition: FXPacker.h:48
Color selection widget.
Definition: FXColorSelector.h:56
A text field is a single-line text entry widget.
Definition: FXTextField.h:63
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
The tab book layout manager arranges pairs of children; the even numbered children (0...
Definition: FXTabBook.h:48
A ColorRing widget provides an intuitive way to specify a color.
Definition: FXColorRing.h:44

Copyright © 1997-2022 Jeroen van der Zijp