Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
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