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
42 namespace CEGUI
43 {
44 class ColourPicker;
45 
47 class CEGUI_COMMONDIALOGS_API ColourPickerControls : public Window
48 {
49 public:
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 
101  void setCallingColourPicker(ColourPicker* colourPicker);
102 
103  // overridden from window
104  void initialiseComponents();
105 
106 protected:
108  static const String CancelButtonName;
110  static const String AcceptButtonName;
115  static const String TitleBarName;
116  static const String ColourPickerStaticImageName;
117  static const String ColourPickerImageSliderName;
118  static const String ColourPickerAlphaSliderName;
119  static const String NewColourDescriptionName;
120  static const String OldColourDescriptionName;
121  static const String NewColourRectName;
122  static const String OldColourRectName;
123  static const String ColourEditBoxRDescriptionName;
124  static const String ColourEditBoxGDescriptionName;
125  static const String ColourEditBoxBDescriptionName;
126  static const String ColourEditBoxRName;
127  static const String ColourEditBoxGName;
128  static const String ColourEditBoxBName;
129  static const String HSVRadioButtonHName;
130  static const String HSVRadioButtonSName;
131  static const String HSVRadioButtonVName;
132  static const String HSVEditBoxHName;
133  static const String HSVEditBoxSName;
134  static const String HSVEditBoxVName;
135  static const String LabRadioButtonLName;
136  static const String LabRadioButtonAName;
137  static const String LabRadioButtonBName;
138  static const String LabEditBoxLName;
139  static const String LabEditBoxAName;
140  static const String LabEditBoxBName;
141  static const String AlphaEditBoxName;
142  static const String ColourPickerCursorName;
151 
152  static const float LAB_L_MIN;
153  static const float LAB_L_MAX;
154  static const float LAB_L_DIFF;
155  static const float LAB_A_MIN;
156  static const float LAB_A_MAX;
157  static const float LAB_A_DIFF;
158  static const float LAB_B_MIN;
159  static const float LAB_B_MAX;
160  static const float LAB_B_DIFF;
161 
162  void initColourPickerControlsImageSet();
163  void deinitColourPickerControlsTexture();
164  void refreshColourPickerControlsTextures();
165 
166  void refreshColourSliderImage();
167  void refreshColourPickingImage();
168  void refreshAlphaSliderImage();
169 
170  void reloadColourPickerControlsTexture();
171 
172  Lab_Colour getColourSliderPositionColourLAB(float value);
173  Lab_Colour getColourPickingPositionColourLAB(float xAbs, float yAbs);
174 
175  HSV_Colour getColourSliderPositionColourHSV(float value);
176  HSV_Colour getColourPickingPositionColourHSV(float xAbs, float yAbs);
177 
178  RGB_Colour getAlphaSliderPositionColour(int x, int y);
179 
180  Vector2f getColourPickingColourPosition();
181  void getColourPickingColourPositionHSV(float& x, float& y);
182 
183  // Handlers to relay child widget events so they appear to come from us
184  bool handleCancelButtonClicked(const EventArgs& e);
185  bool handleAcceptButtonClicked(const EventArgs& e);
186  bool handleEditboxDeactivated(const EventArgs& args);
187  bool handleRadioButtonModeSelection(const EventArgs& args);
188 
189  bool handleHexadecimalEditboxTextChanged(const EventArgs& args);
190  bool handleRGBEditboxTextChanged(const EventArgs& args);
191  bool handleLABEditboxTextChanged(const EventArgs& args);
192  bool handleHSVEditboxTextChanged(const EventArgs& args);
193 
194  bool handleAlphaEditboxTextChanged(const EventArgs& args);
195 
196  bool handleColourPickerStaticImageMouseLeaves(const EventArgs& args);
197  bool handleColourPickerStaticImageMouseButtonUp(const EventArgs& args);
198  bool handleColourPickerStaticImageMouseButtonDown(const EventArgs& args);
199  bool handleColourPickerStaticImageMouseMove(const EventArgs& args);
200 
201  virtual void onCancelButtonClicked(WindowEventArgs& e);
202  virtual void onAcceptButtonClicked(WindowEventArgs& e);
203 
204  void onColourCursorPositionChanged();
205  void onColourSliderChanged();
206 
207  void refreshColourPickerCursorPosition(const MouseEventArgs& mouseEventArgs);
208  void refreshAlpha();
209 
210  void refreshOnlyColourSliderImage();
211  bool handleColourPickerSliderValueChanged(const EventArgs& args);
212  bool handleAlphaSliderValueChanged(const EventArgs& args);
213 
214  void refreshEditboxesAndColourRects();
215 
216  void refreshColourRects();
217  void positionColourPickerCursorAbsolute(float x, float y);
218  void positionColourPickerCursorRelative(float x, float y);
219  void setColours(const Lab_Colour& newColourLAB);
220  void setColours(const RGB_Colour& newColourRGB);
221  void setColours(const HSV_Colour& newColourHSV);
222 
223  void setColourAlpha(float alphaValue);
224 
225  void refreshColourPickerCursorPosition();
226  void refreshColourSliderPosition();
227 
228  void initColourPicker();
229  PushButton* getCancelButton();
230  PushButton* getAcceptButton();
231  Window* getHexadecimalDescription();
232  Editbox* getHexadecimalEditbox();
233  Titlebar* getTitleBar();
234  Slider* getColourPickerImageSlider();
235  Slider* getColourPickerAlphaSlider();
236  Window* getColourPickerStaticImage();
237  Window* getNewColourDescription();
238  Window* getOldColourDescription();
239  Window* getNewColourRect();
240  Window* getOldColourRect();
241  Window* getColourEditBoxRDescription();
242  Window* getColourEditBoxGDescription();
243  Window* getColourEditBoxBDescription();
244  Editbox* getColourEditBoxR();
245  Editbox* getColourEditBoxG();
246  Editbox* getColourEditBoxB();
247  RadioButton* getHSVRadioButtonH();
248  RadioButton* getHSVRadioButtonS();
249  RadioButton* getHSVRadioButtonV();
250  Editbox* getHSVEditBoxH();
251  Editbox* getHSVEditBoxS();
252  Editbox* getHSVEditBoxV();
253  RadioButton* getLabRadioButtonL();
254  RadioButton* getLabRadioButtonA();
255  RadioButton* getLabRadioButtonB();
256  Editbox* getLabEditBoxL();
257  Editbox* getLabEditBoxA();
258  Editbox* getLabEditBoxB();
259  Editbox* getAlphaEditBox();
260  Window* getColourPickerCursorStaticImage();
261 
262  ColourPicker* d_callingColourPicker;
263  Window* d_colourPickerCursor;
264 
265  SliderMode d_sliderMode;
266 
281 
284 
285  TextureTarget* d_colourPickerControlsTextureTarget;
286 
287  int d_colourPickerImageOffset;
288  int d_colourPickerPickingImageHeight;
289  int d_colourPickerPickingImageWidth;
290  int d_colourPickerColourSliderImageWidth;
291  int d_colourPickerColourSliderImageHeight;
292  int d_colourPickerAlphaSliderImageWidth;
293  int d_colourPickerAlphaSliderImageHeight;
294 
295  int d_colourPickerControlsTextureSize;
296 
297  bool d_draggingColourPickerCursor;
298 
299  RGB_Colour* d_colourPickingTexture;
300 
301  bool d_ignoreEvents;
302  RegexMatcher& d_regexMatcher;
303 };
304 
305 }
306 
307 #if defined(_MSC_VER)
308 # pragma warning(pop)
309 #endif
310 
311 
312 #endif
313 
Base class for the ColourPicker widget.
Definition: ColourPicker.h:46
static const String AcceptButtonName
Widget name for the accept button component.
Definition: Controls.h:110
static const String EventColourAccepted
Definition: Controls.h:75
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
Class representing an RGB colour using unsigned chars.
Definition: Types.h:63
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:49
static const String CancelButtonName
Widget name for the cancel button component.
Definition: Controls.h:108
Specialisation of RenderTarget interface that should be used as the base class for RenderTargets that...
Definition: TextureTarget.h:40
Interface for Regex matching support classes.
Definition: RegexMatcher.h:39
RGB_Colour d_selectedColourRGB
Definition: Controls.h:272
static const String ColourPickerControlsPickingTextureImageName
Name of the Picking Texture Image in the ImageSet.
Definition: Controls.h:144
Class representing an HSV (hue, saturation and value) colour using floats.
Definition: Types.h:111
Class representing a Colour according to the L*a*b* standard.
Definition: Types.h:88
static const String ColourPickerControlsColourSliderTextureImageName
Name of the Slider Texture Image in the ImageSet.
Definition: Controls.h:146
static const String ColourRectPropertyName
Name of the colour defining ColourRectProperty of ColourRect windows.
Definition: Controls.h:150
Base class for Slider widgets.
Definition: widgets/Slider.h:98
Class representing the title bar for Frame Windows.
Definition: widgets/Titlebar.h:50
Base class to provide logic for push button type widgets.
Definition: PushButton.h:47
Colour d_selectedColour
selected colour of the ColourPickerControls as CEGUI colour
Definition: Controls.h:268
Base class to provide the logic for Radio Button widgets.
Definition: RadioButton.h:40
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:149
HSV_Colour d_selectedColourHSV
Definition: Controls.h:280
Base class for an Editbox widget.
Definition: widgets/Editbox.h:69
Lab_Colour d_selectedColourLAB
Definition: Controls.h:276
static const String WidgetTypeName
Window type name.
Definition: Controls.h:69
Class representing colour values within the system.
Definition: Colour.h:44
Base class for the ColourPickerControls widget.
Definition: Controls.h:47
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:251
EventArgs based class that is used for objects passed to input event handlers concerning mouse input...
Definition: InputEvent.h:280
static const String ColourPickerControlsAlphaSliderTextureImageName
Name of the Slider Texture Image in the ImageSet.
Definition: Controls.h:148
static const String HexaDecimalEditBoxName
Widget name for the colour value EditBox.
Definition: Controls.h:114
static const String HexaDecimalDescriptionName
Widget name for the static text label of the hexadecimal colour value EditBox.
Definition: Controls.h:112
Colour d_previouslySelectedColour
Previously selected colour of the ColourPickerControls.
Definition: Controls.h:283
String class used within the GUI system.
Definition: String.h:62