Crazy Eddie's GUI System  0.8.4
Controls.h
00001 /***********************************************************************
00002     created:    20th February 2010
00003     author:     Lukas E Meindl
00004 
00005     purpose:    Interface to base class for ColourPickerControls Widget
00006 *************************************************************************/
00007 /***************************************************************************
00008 *   Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
00009 *
00010 *   Permission is hereby granted, free of charge, to any person obtaining
00011 *   a copy of this software and associated documentation files (the
00012 *   "Software"), to deal in the Software without restriction, including
00013 *   without limitation the rights to use, copy, modify, merge, publish,
00014 *   distribute, sublicense, and/or sell copies of the Software, and to
00015 *   permit persons to whom the Software is furnished to do so, subject to
00016 *   the following conditions:
00017 *
00018 *   The above copyright notice and this permission notice shall be
00019 *   included in all copies or substantial portions of the Software.
00020 *
00021 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00022 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00023 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00024 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00025 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00026 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00027 *   OTHER DEALINGS IN THE SOFTWARE.
00028 ***************************************************************************/
00029 #ifndef _CEGUIColourPickerControls_h_
00030 #define _CEGUIColourPickerControls_h_
00031 
00032 #include "CEGUI/CommonDialogs/Module.h"
00033 #include "CEGUI/Window.h"
00034 #include "CEGUI/CommonDialogs/ColourPicker/Types.h"
00035 
00036 #if defined(_MSC_VER)
00037 #   pragma warning(push)
00038 #   pragma warning(disable : 4251)
00039 #endif
00040 
00041 // Start of CEGUI namespace section
00042 namespace CEGUI
00043 {
00044 class ColourPicker;
00045 
00047 class CEGUI_COMMONDIALOGS_API ColourPickerControls : public Window
00048 {
00049 public:
00050     enum SliderMode
00051     {
00052         SliderMode_Lab_L = 1,
00053         SliderMode_Lab_A = 1 << 1,
00054         SliderMode_Lab_B = 1 << 2,
00055         SliderMode_HSV_H = 1 << 3,
00056         SliderMode_HSV_S = 1 << 4,
00057         SliderMode_HSV_V = 1 << 5
00058     };
00059 
00061     ColourPickerControls(const String& type, const String& name);
00062 
00064     ~ColourPickerControls();
00065 
00067     static const String EventNamespace;
00069     static const String WidgetTypeName;
00070 
00075     static const String EventColourAccepted;
00076     static const String EventClosed;
00077 
00078     RGB_Colour getSelectedColourRGB();
00079 
00088     void setColours(const Colour& newColour);
00089 
00090     void setPreviousColour(const Colour& previousColour);
00091 
00092     void refreshAllElements();
00093 
00101     void setCallingColourPicker(ColourPicker* colourPicker);
00102 
00103     // overridden from window
00104     void initialiseComponents();
00105 
00106 protected:
00108     static const String CancelButtonName;
00110     static const String AcceptButtonName;
00112     static const String HexaDecimalDescriptionName;
00114     static const String HexaDecimalEditBoxName;
00115     static const String TitleBarName;
00116     static const String ColourPickerStaticImageName;
00117     static const String ColourPickerImageSliderName;
00118     static const String ColourPickerAlphaSliderName;
00119     static const String NewColourDescriptionName;
00120     static const String OldColourDescriptionName;
00121     static const String NewColourRectName;
00122     static const String OldColourRectName;
00123     static const String ColourEditBoxRDescriptionName;
00124     static const String ColourEditBoxGDescriptionName;
00125     static const String ColourEditBoxBDescriptionName;
00126     static const String ColourEditBoxRName;
00127     static const String ColourEditBoxGName;
00128     static const String ColourEditBoxBName;
00129     static const String HSVRadioButtonHName;
00130     static const String HSVRadioButtonSName;
00131     static const String HSVRadioButtonVName;
00132     static const String HSVEditBoxHName;
00133     static const String HSVEditBoxSName;
00134     static const String HSVEditBoxVName;
00135     static const String LabRadioButtonLName;
00136     static const String LabRadioButtonAName;
00137     static const String LabRadioButtonBName;
00138     static const String LabEditBoxLName;
00139     static const String LabEditBoxAName;
00140     static const String LabEditBoxBName;
00141     static const String AlphaEditBoxName;
00142     static const String ColourPickerCursorName;
00144     static const String ColourPickerControlsPickingTextureImageName;
00146     static const String ColourPickerControlsColourSliderTextureImageName;
00148     static const String ColourPickerControlsAlphaSliderTextureImageName;
00150     static const String ColourRectPropertyName;
00151 
00152     static const float LAB_L_MIN;
00153     static const float LAB_L_MAX;
00154     static const float LAB_L_DIFF;
00155     static const float LAB_A_MIN;
00156     static const float LAB_A_MAX;
00157     static const float LAB_A_DIFF;
00158     static const float LAB_B_MIN;
00159     static const float LAB_B_MAX;
00160     static const float LAB_B_DIFF;
00161 
00162     void initColourPickerControlsImageSet();
00163     void deinitColourPickerControlsTexture();
00164     void refreshColourPickerControlsTextures();
00165 
00166     void refreshColourSliderImage();
00167     void refreshColourPickingImage();
00168     void refreshAlphaSliderImage();
00169 
00170     void reloadColourPickerControlsTexture();
00171 
00172     Lab_Colour getColourSliderPositionColourLAB(float value);
00173     Lab_Colour getColourPickingPositionColourLAB(float xAbs, float yAbs);
00174 
00175     HSV_Colour getColourSliderPositionColourHSV(float value);
00176     HSV_Colour getColourPickingPositionColourHSV(float xAbs, float yAbs);
00177 
00178     RGB_Colour getAlphaSliderPositionColour(int x, int y);
00179 
00180     Vector2f getColourPickingColourPosition();
00181     void getColourPickingColourPositionHSV(float& x, float& y);
00182 
00183     // Handlers to relay child widget events so they appear to come from us
00184     bool handleCancelButtonClicked(const EventArgs& e);
00185     bool handleAcceptButtonClicked(const EventArgs& e);
00186     bool handleEditboxDeactivated(const EventArgs& args);
00187     bool handleRadioButtonModeSelection(const EventArgs& args);
00188 
00189     bool handleHexadecimalEditboxTextChanged(const EventArgs& args);
00190     bool handleRGBEditboxTextChanged(const EventArgs& args);
00191     bool handleLABEditboxTextChanged(const EventArgs& args);
00192     bool handleHSVEditboxTextChanged(const EventArgs& args);
00193 
00194     bool handleAlphaEditboxTextChanged(const EventArgs& args);
00195 
00196     bool handleColourPickerStaticImageMouseLeaves(const EventArgs& args);
00197     bool handleColourPickerStaticImageMouseButtonUp(const EventArgs& args);
00198     bool handleColourPickerStaticImageMouseButtonDown(const EventArgs& args);
00199     bool handleColourPickerStaticImageMouseMove(const EventArgs& args);
00200 
00201     virtual void onCancelButtonClicked(WindowEventArgs& e);
00202     virtual void onAcceptButtonClicked(WindowEventArgs& e);
00203 
00204     void onColourCursorPositionChanged();
00205     void onColourSliderChanged();
00206 
00207     void refreshColourPickerCursorPosition(const MouseEventArgs& mouseEventArgs);
00208     void refreshAlpha();
00209 
00210     void refreshOnlyColourSliderImage();
00211     bool handleColourPickerSliderValueChanged(const EventArgs& args);
00212     bool handleAlphaSliderValueChanged(const EventArgs& args);
00213 
00214     void refreshEditboxesAndColourRects();
00215 
00216     void refreshColourRects();
00217     void positionColourPickerCursorAbsolute(float x, float y);
00218     void positionColourPickerCursorRelative(float x, float y);
00219     void setColours(const Lab_Colour& newColourLAB);
00220     void setColours(const RGB_Colour& newColourRGB);
00221     void setColours(const HSV_Colour& newColourHSV);
00222 
00223     void setColourAlpha(float alphaValue);
00224 
00225     void refreshColourPickerCursorPosition();
00226     void refreshColourSliderPosition();
00227 
00228     void initColourPicker();
00229     PushButton* getCancelButton();
00230     PushButton* getAcceptButton();
00231     Window* getHexadecimalDescription();
00232     Editbox* getHexadecimalEditbox();
00233     Titlebar* getTitleBar();
00234     Slider* getColourPickerImageSlider();
00235     Slider* getColourPickerAlphaSlider();
00236     Window* getColourPickerStaticImage();
00237     Window* getNewColourDescription();
00238     Window* getOldColourDescription();
00239     Window* getNewColourRect();
00240     Window* getOldColourRect();
00241     Window* getColourEditBoxRDescription();
00242     Window* getColourEditBoxGDescription();
00243     Window* getColourEditBoxBDescription();
00244     Editbox* getColourEditBoxR();
00245     Editbox* getColourEditBoxG();
00246     Editbox* getColourEditBoxB();
00247     RadioButton* getHSVRadioButtonH();
00248     RadioButton* getHSVRadioButtonS();
00249     RadioButton* getHSVRadioButtonV();
00250     Editbox* getHSVEditBoxH();
00251     Editbox* getHSVEditBoxS();
00252     Editbox* getHSVEditBoxV();
00253     RadioButton* getLabRadioButtonL();
00254     RadioButton* getLabRadioButtonA();
00255     RadioButton* getLabRadioButtonB();
00256     Editbox* getLabEditBoxL();
00257     Editbox* getLabEditBoxA();
00258     Editbox* getLabEditBoxB();
00259     Editbox* getAlphaEditBox();
00260     Window* getColourPickerCursorStaticImage();
00261 
00262     ColourPicker* d_callingColourPicker;
00263     Window* d_colourPickerCursor;
00264 
00265     SliderMode d_sliderMode;
00266 
00268     Colour d_selectedColour;
00272     RGB_Colour d_selectedColourRGB;
00276     Lab_Colour d_selectedColourLAB;
00280     HSV_Colour d_selectedColourHSV;
00281 
00283     Colour d_previouslySelectedColour;
00284 
00285     TextureTarget* d_colourPickerControlsTextureTarget;
00286 
00287     int d_colourPickerImageOffset;
00288     int d_colourPickerPickingImageHeight;
00289     int d_colourPickerPickingImageWidth;
00290     int d_colourPickerColourSliderImageWidth;
00291     int d_colourPickerColourSliderImageHeight;
00292     int d_colourPickerAlphaSliderImageWidth;
00293     int d_colourPickerAlphaSliderImageHeight;
00294 
00295     int d_colourPickerControlsTextureSize;
00296 
00297     bool d_draggingColourPickerCursor;
00298 
00299     RGB_Colour* d_colourPickingTexture;
00300 
00301     bool d_ignoreEvents;
00302     RegexMatcher& d_regexMatcher;
00303 };
00304 
00305 }
00306 
00307 #if defined(_MSC_VER)
00308 #   pragma warning(pop)
00309 #endif
00310 
00311 
00312 #endif
00313 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends