Crazy Eddie's GUI System 0.8.7
Controls.h
1/***********************************************************************
2 created: 20th February 2010
3 author: Lukas E Meindl
4
5 purpose: Interface to base class for ColourPickerControls Widget
6*************************************************************************/
7/***************************************************************************
8* Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
9*
10* Permission is hereby granted, free of charge, to any person obtaining
11* a copy of this software and associated documentation files (the
12* "Software"), to deal in the Software without restriction, including
13* without limitation the rights to use, copy, modify, merge, publish,
14* distribute, sublicense, and/or sell copies of the Software, and to
15* permit persons to whom the Software is furnished to do so, subject to
16* the following conditions:
17*
18* The above copyright notice and this permission notice shall be
19* included in all copies or substantial portions of the Software.
20*
21* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27* OTHER DEALINGS IN THE SOFTWARE.
28***************************************************************************/
29#ifndef _CEGUIColourPickerControls_h_
30#define _CEGUIColourPickerControls_h_
31
32#include "CEGUI/CommonDialogs/Module.h"
33#include "CEGUI/Window.h"
34#include "CEGUI/CommonDialogs/ColourPicker/Types.h"
35
36#if defined(_MSC_VER)
37# pragma warning(push)
38# pragma warning(disable : 4251)
39#endif
40
41// Start of CEGUI namespace section
42namespace CEGUI
43{
44class ColourPicker;
45
47class CEGUI_COMMONDIALOGS_API ColourPickerControls : public Window
48{
49public:
50 enum SliderMode
51 {
52 SliderMode_Lab_L = 1,
53 SliderMode_Lab_A = 1 << 1,
54 SliderMode_Lab_B = 1 << 2,
55 SliderMode_HSV_H = 1 << 3,
56 SliderMode_HSV_S = 1 << 4,
57 SliderMode_HSV_V = 1 << 5
58 };
59
61 ColourPickerControls(const String& type, const String& name);
62
65
67 static const String EventNamespace;
69 static const String WidgetTypeName;
70
76 static const String EventClosed;
77
78 RGB_Colour getSelectedColourRGB();
79
88 void setColours(const Colour& newColour);
89
90 void setPreviousColour(const Colour& previousColour);
91
92 void refreshAllElements();
93
102
103 // overridden from window
105 void destroy(void);
106
107protected:
116 static const String TitleBarName;
117 static const String ColourPickerStaticImageName;
118 static const String ColourPickerImageSliderName;
119 static const String ColourPickerAlphaSliderName;
120 static const String NewColourDescriptionName;
121 static const String OldColourDescriptionName;
122 static const String NewColourRectName;
123 static const String OldColourRectName;
124 static const String ColourEditBoxRDescriptionName;
125 static const String ColourEditBoxGDescriptionName;
126 static const String ColourEditBoxBDescriptionName;
127 static const String ColourEditBoxRName;
128 static const String ColourEditBoxGName;
129 static const String ColourEditBoxBName;
130 static const String HSVRadioButtonHName;
131 static const String HSVRadioButtonSName;
132 static const String HSVRadioButtonVName;
133 static const String HSVEditBoxHName;
134 static const String HSVEditBoxSName;
135 static const String HSVEditBoxVName;
136 static const String LabRadioButtonLName;
137 static const String LabRadioButtonAName;
138 static const String LabRadioButtonBName;
139 static const String LabEditBoxLName;
140 static const String LabEditBoxAName;
141 static const String LabEditBoxBName;
142 static const String AlphaEditBoxName;
143 static const String ColourPickerCursorName;
152
153 static const float LAB_L_MIN;
154 static const float LAB_L_MAX;
155 static const float LAB_L_DIFF;
156 static const float LAB_A_MIN;
157 static const float LAB_A_MAX;
158 static const float LAB_A_DIFF;
159 static const float LAB_B_MIN;
160 static const float LAB_B_MAX;
161 static const float LAB_B_DIFF;
162
163 void initColourPickerControlsImageSet();
164 void deinitColourPickerControlsTexture();
165 void refreshColourPickerControlsTextures();
166
167 void refreshColourSliderImage();
168 void refreshColourPickingImage();
169 void refreshAlphaSliderImage();
170
171 void reloadColourPickerControlsTexture();
172
173 Lab_Colour getColourSliderPositionColourLAB(float value);
174 Lab_Colour getColourPickingPositionColourLAB(float xAbs, float yAbs);
175
176 HSV_Colour getColourSliderPositionColourHSV(float value);
177 HSV_Colour getColourPickingPositionColourHSV(float xAbs, float yAbs);
178
179 RGB_Colour getAlphaSliderPositionColour(int x, int y);
180
181 Vector2f getColourPickingColourPosition();
182 void getColourPickingColourPositionHSV(float& x, float& y);
183
184 // Handlers to relay child widget events so they appear to come from us
185 bool handleCancelButtonClicked(const EventArgs& e);
186 bool handleAcceptButtonClicked(const EventArgs& e);
187 bool handleEditboxDeactivated(const EventArgs& args);
188 bool handleRadioButtonModeSelection(const EventArgs& args);
189
190 bool handleHexadecimalEditboxTextChanged(const EventArgs& args);
191 bool handleRGBEditboxTextChanged(const EventArgs& args);
192 bool handleLABEditboxTextChanged(const EventArgs& args);
193 bool handleHSVEditboxTextChanged(const EventArgs& args);
194
195 bool handleAlphaEditboxTextChanged(const EventArgs& args);
196
197 bool handleColourPickerStaticImageMouseLeaves(const EventArgs& args);
198 bool handleColourPickerStaticImageMouseButtonUp(const EventArgs& args);
199 bool handleColourPickerStaticImageMouseButtonDown(const EventArgs& args);
200 bool handleColourPickerStaticImageMouseMove(const EventArgs& args);
201
202 virtual void onCancelButtonClicked(WindowEventArgs& e);
203 virtual void onAcceptButtonClicked(WindowEventArgs& e);
204
205 void onColourCursorPositionChanged();
206 void onColourSliderChanged();
207
208 void refreshColourPickerCursorPosition(const MouseEventArgs& mouseEventArgs);
209 void refreshAlpha();
210
211 void refreshOnlyColourSliderImage();
212 bool handleColourPickerSliderValueChanged(const EventArgs& args);
213 bool handleAlphaSliderValueChanged(const EventArgs& args);
214
215 void refreshEditboxesAndColourRects();
216
217 void refreshColourRects();
218 void positionColourPickerCursorAbsolute(float x, float y);
219 void positionColourPickerCursorRelative(float x, float y);
220 void setColours(const Lab_Colour& newColourLAB);
221 void setColours(const RGB_Colour& newColourRGB);
222 void setColours(const HSV_Colour& newColourHSV);
223
224 void setColourAlpha(float alphaValue);
225
226 void refreshColourPickerCursorPosition();
227 void refreshColourSliderPosition();
228
229 void initColourPicker();
230 PushButton* getCancelButton();
231 PushButton* getAcceptButton();
232 Window* getHexadecimalDescription();
233 Editbox* getHexadecimalEditbox();
234 Titlebar* getTitleBar();
235 Slider* getColourPickerImageSlider();
236 Slider* getColourPickerAlphaSlider();
237 Window* getColourPickerStaticImage();
238 Window* getNewColourDescription();
239 Window* getOldColourDescription();
240 Window* getNewColourRect();
241 Window* getOldColourRect();
242 Window* getColourEditBoxRDescription();
243 Window* getColourEditBoxGDescription();
244 Window* getColourEditBoxBDescription();
245 Editbox* getColourEditBoxR();
246 Editbox* getColourEditBoxG();
247 Editbox* getColourEditBoxB();
248 RadioButton* getHSVRadioButtonH();
249 RadioButton* getHSVRadioButtonS();
250 RadioButton* getHSVRadioButtonV();
251 Editbox* getHSVEditBoxH();
252 Editbox* getHSVEditBoxS();
253 Editbox* getHSVEditBoxV();
254 RadioButton* getLabRadioButtonL();
255 RadioButton* getLabRadioButtonA();
256 RadioButton* getLabRadioButtonB();
257 Editbox* getLabEditBoxL();
258 Editbox* getLabEditBoxA();
259 Editbox* getLabEditBoxB();
260 Editbox* getAlphaEditBox();
261 Window* getColourPickerCursorStaticImage();
262
263 ColourPicker* d_callingColourPicker;
264 Window* d_colourPickerCursor;
265
266 SliderMode d_sliderMode;
267
282
285
286 TextureTarget* d_colourPickerControlsTextureTarget;
287
288 int d_colourPickerImageOffset;
289 int d_colourPickerPickingImageHeight;
290 int d_colourPickerPickingImageWidth;
291 int d_colourPickerColourSliderImageWidth;
292 int d_colourPickerColourSliderImageHeight;
293 int d_colourPickerAlphaSliderImageWidth;
294 int d_colourPickerAlphaSliderImageHeight;
295
296 int d_colourPickerControlsTextureSize;
297
298 bool d_draggingColourPickerCursor;
299
300 RGB_Colour* d_colourPickingTexture;
301
302 bool d_ignoreEvents;
303 RegexMatcher& d_regexMatcher;
304};
305
306}
307
308#if defined(_MSC_VER)
309# pragma warning(pop)
310#endif
311
312
313#endif
314
Base class for the ColourPickerControls widget.
Definition: Controls.h:48
~ColourPickerControls()
Destructor for ColourPickerControls class.
static const String HexaDecimalDescriptionName
Widget name for the static text label of the hexadecimal colour value EditBox.
Definition: Controls.h:113
static const String HexaDecimalEditBoxName
Widget name for the colour value EditBox.
Definition: Controls.h:115
static const String AcceptButtonName
Widget name for the accept button component.
Definition: Controls.h:111
Colour d_selectedColour
selected colour of the ColourPickerControls as CEGUI colour
Definition: Controls.h:269
static const String ColourRectPropertyName
Name of the colour defining ColourRectProperty of ColourRect windows.
Definition: Controls.h:151
void setColours(const Colour &newColour)
Set the current colour of the colour picker manually and refresh the ColourPickerControls elements ac...
HSV_Colour d_selectedColourHSV
Definition: Controls.h:281
Colour d_previouslySelectedColour
Previously selected colour of the ColourPickerControls.
Definition: Controls.h:284
static const String CancelButtonName
Widget name for the cancel button component.
Definition: Controls.h:109
void initialiseComponents()
Initialises the Window based object ready for use.
void destroy(void)
Internal destroy method which actually just adds the window and any parent destructed child windows t...
void setCallingColourPicker(ColourPicker *colourPicker)
Set the local d_callingColourPicker pointer to the colour picker window.
static const String ColourPickerControlsAlphaSliderTextureImageName
Name of the Slider Texture Image in the ImageSet.
Definition: Controls.h:149
static const String WidgetTypeName
Window type name.
Definition: Controls.h:69
RGB_Colour d_selectedColourRGB
Definition: Controls.h:273
Lab_Colour d_selectedColourLAB
Definition: Controls.h:277
static const String ColourPickerControlsColourSliderTextureImageName
Name of the Slider Texture Image in the ImageSet.
Definition: Controls.h:147
ColourPickerControls(const String &type, const String &name)
Constructor for ColourPickerControls class.
static const String ColourPickerControlsPickingTextureImageName
Name of the Picking Texture Image in the ImageSet.
Definition: Controls.h:145
static const String EventColourAccepted
Definition: Controls.h:75
Base class for the ColourPicker widget.
Definition: ColourPicker.h:47
Class representing colour values within the system.
Definition: Colour.h:46
Base class for an Editbox widget.
Definition: widgets/Editbox.h:70
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:51
Class representing an HSV (hue, saturation and value) colour using floats.
Definition: Types.h:113
Class representing a Colour according to the L*a*b* standard.
Definition: Types.h:90
EventArgs based class that is used for objects passed to input event handlers concerning mouse input.
Definition: InputEvent.h:281
Base class to provide logic for push button type widgets.
Definition: PushButton.h:48
Class representing an RGB colour using unsigned chars.
Definition: Types.h:65
Base class to provide the logic for Radio Button widgets.
Definition: RadioButton.h:41
Interface for Regex matching support classes.
Definition: RegexMatcher.h:41
Base class for Slider widgets.
Definition: widgets/Slider.h:99
String class used within the GUI system.
Definition: String.h:64
Specialisation of RenderTarget interface that should be used as the base class for RenderTargets that...
Definition: TextureTarget.h:41
Class representing the title bar for Frame Windows.
Definition: widgets/Titlebar.h:51
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:252
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1