Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Controls.h
1 /***********************************************************************
2  filename: Controls.h
3  created: 20th February 2010
4  author: Lukas E Meindl
5 
6  purpose: Interface to base class for ColourPickerControls Widget
7 *************************************************************************/
8 /***************************************************************************
9 * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining
12 * a copy of this software and associated documentation files (the
13 * "Software"), to deal in the Software without restriction, including
14 * without limitation the rights to use, copy, modify, merge, publish,
15 * distribute, sublicense, and/or sell copies of the Software, and to
16 * permit persons to whom the Software is furnished to do so, subject to
17 * the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be
20 * included in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 ***************************************************************************/
30 #ifndef _CEGUIColourPickerControls_h_
31 #define _CEGUIColourPickerControls_h_
32 
33 #include "CEGUI/CommonDialogs/Module.h"
34 #include "CEGUI/Window.h"
35 #include "CEGUI/CommonDialogs/ColourPicker/Types.h"
36 
37 #if defined(_MSC_VER)
38 # pragma warning(push)
39 # pragma warning(disable : 4251)
40 #endif
41 
42 // Start of CEGUI namespace section
43 namespace CEGUI
44 {
45 class ColourPicker;
46 
48 class CEGUI_COMMONDIALOGS_API ColourPickerControls : public Window
49 {
50 public:
51  enum SliderMode
52  {
53  SliderMode_Lab_L = 1,
54  SliderMode_Lab_A = 1 << 1,
55  SliderMode_Lab_B = 1 << 2,
56  SliderMode_HSV_H = 1 << 3,
57  SliderMode_HSV_S = 1 << 4,
58  SliderMode_HSV_V = 1 << 5
59  };
60 
62  ColourPickerControls(const String& type, const String& name);
63 
66 
68  static const String EventNamespace;
70  static const String WidgetTypeName;
71 
77  static const String EventClosed;
78 
79  RGB_Colour getSelectedColourRGB();
80 
89  void setColours(const Colour& newColour);
90 
91  void setPreviousColour(const Colour& previousColour);
92 
93  void refreshAllElements();
94 
102  void setCallingColourPicker(ColourPicker* colourPicker);
103 
104  // overridden from window
105  void initialiseComponents();
106 
107 protected:
109  static const String CancelButtonName;
111  static const String AcceptButtonName;
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