nux-0.9.48
|
00001 /* 00002 * Copyright 2010 Inalogic® Inc. 00003 * 00004 * This program is free software: you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License, as 00006 * published by the Free Software Foundation; either version 2.1 or 3.0 00007 * of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranties of 00011 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 00012 * PURPOSE. See the applicable version of the GNU Lesser General Public 00013 * License for more details. 00014 * 00015 * You should have received a copy of both the GNU Lesser General Public 00016 * License along with this program. If not, see <http://www.gnu.org/licenses/> 00017 * 00018 * Authored by: Jay Taoko <jaytaoko@inalogic.com> 00019 * 00020 */ 00021 00022 00023 #ifndef RGBGEVALUATOR_H 00024 #define RGBGEVALUATOR_H 00025 00026 #include "HexRegExpValidator.h" 00027 #include "IntegerValidator.h" 00028 #include "DoubleValidator.h" 00029 00030 namespace nux 00031 { 00032 00033 class PushButton; 00034 class VLayout; 00035 class HLayout; 00036 class EditTextBox; 00037 00038 class RGBValuator : public View //public ValuatorAbstraction 00039 { 00040 public: 00041 00042 enum ColorFormat 00043 { 00044 COLORFORMAT_FLOAT = 0, 00045 COLORFORMAT_HEX, 00046 COLORFORMAT_INT, 00047 }; 00048 00049 RGBValuator (NUX_FILE_LINE_PROTO); 00050 RGBValuator (Color color, NUX_FILE_LINE_PROTO); 00059 RGBValuator (float red, float green, float blue, float alpha, NUX_FILE_LINE_PROTO); 00069 RGBValuator (eColorModel colorModel, float x, float y, float z, float alpha, NUX_FILE_LINE_PROTO); 00070 00071 ~RGBValuator(); 00072 00073 // API 00074 void SetColorModel (eColorModel cm); 00075 void SetColorFormat (ColorFormat cf); 00076 Color GetColor(); 00077 float GetRed(); 00078 float GetGreen(); 00079 float GetBlue(); 00080 float GetAlpha(); 00081 virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo); 00082 00083 virtual void Draw (GraphicsEngine &GfxContext, bool force_draw); 00084 virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw); 00085 virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw); 00086 00087 void SetRGB (Color color); 00088 void SetRGB (float r, float g, float b); 00089 void SetAlpha (float alpha); 00090 void SetRGBA (Color color); 00091 void SetRGBA (float r, float g, float b, float a); 00092 00093 void SetHSV (float h, float s, float v); 00094 void SetHLS (float h, float l, float s); 00095 00096 // emitters 00097 void OnReceiveMouseDown_Red (int x, int y, unsigned long button_flags, unsigned long key_flags); 00098 void OnReceiveMouseDown_Green (int x, int y, unsigned long button_flags, unsigned long key_flags); 00099 void OnReceiveMouseDown_Blue (int x, int y, unsigned long button_flags, unsigned long key_flags); 00100 void OnReceiveMouseDown_Alpha (int x, int y, unsigned long button_flags, unsigned long key_flags); 00101 void OnReceiveMouseDrag_Red (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); 00102 void OnReceiveMouseDrag_Green (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); 00103 void OnReceiveMouseDrag_Blue (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); 00104 void OnReceiveMouseDrag_Alpha (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); 00105 void OnChangeColorModel(); 00106 void OnChangeColorFormat(); 00107 void RecvMouseDownColorModel (int x, int y, unsigned long button_flags, unsigned long key_flags); 00108 00109 void OnReceiveMouseUp_Red (int x, int y, unsigned long button_flags, unsigned long key_flags); 00110 void OnReceiveMouseUp_Green (int x, int y, unsigned long button_flags, unsigned long key_flags); 00111 void OnReceiveMouseUp_Blue (int x, int y, unsigned long button_flags, unsigned long key_flags); 00112 00113 void OnComponentInput (EditTextBox *textbox, const NString &s, int componentIndex); 00114 void OnChannelKeyboardFocus(); 00115 void OnChannelLostKeyboardFocus(); 00116 void OnChannelValidateKeyboardEntry(); 00117 void OnChannelCharacter (unsigned int character, int componentIndex); 00118 00120 00124 void EmitColorChangedSignal(); 00125 00126 // signals 00127 //sigc::signal<void, float, float, float> sigSetRGB; 00128 sigc::signal<void, float, float, float, float> sigColorChanged; 00129 00130 protected: 00131 void InitializeWidgets(); 00132 void InitializeLayout(); 00133 void DestroyLayout(); 00134 00135 private: 00136 void DrawRedMarker (GraphicsEngine &GfxContext); 00137 void DrawGreenMarker (GraphicsEngine &GfxContext); 00138 void DrawBlueMarker (GraphicsEngine &GfxContext); 00139 void DrawAlphaMarker (GraphicsEngine &GfxContext); 00140 00141 void DrawRGB (GraphicsEngine &GfxContext); 00142 void DrawHSV (GraphicsEngine &GfxContext); 00143 void DrawHLS (GraphicsEngine &GfxContext); 00144 00145 HLayout *hlayout; 00146 HLayout *redlayout; 00147 HLayout *greenlayout; 00148 HLayout *bluelayout; 00149 HLayout *alphalayout; 00150 VLayout *vlayout; 00151 VLayout *colormodel_layout; 00152 00153 EditTextBox *m_RedCaption; 00154 EditTextBox *m_GreenCaption; 00155 EditTextBox *m_BlueCaption; 00156 EditTextBox *m_AlphaCaption; 00157 InputArea *m_RedValuator; 00158 InputArea *m_GreenValuator; 00159 InputArea *m_BlueValuator; 00160 InputArea *m_AlphaValuator; 00161 InputArea *m_ColorSquare; 00162 00163 InputArea *m_ComponentLabel0; 00164 InputArea *m_ComponentLabel1; 00165 InputArea *m_ComponentLabel2; 00166 InputArea *m_ComponentAlpha; 00167 00168 TextureLayer *m_CheckboardLayer; 00169 float m_Red; 00170 float m_Green; 00171 float m_Blue; 00172 float m_Alpha; 00173 00174 float m_HSVHue; 00175 float m_HSVSaturation; 00176 float m_HSVValue; 00177 00178 float m_HLSHue; 00179 float m_HLSLight; 00180 float m_HLSSaturation; 00181 00182 PushButton *m_ColorModel; 00183 PushButton *m_ColorFormat; 00184 00185 enum eColorModel m_color_model; 00186 enum ColorFormat m_color_format; 00187 00188 HexRegExpValidator m_HexRegExp; 00189 IntegerValidator m_IntRegExp; 00190 DoubleValidator m_DoubleRegExp; 00191 virtual long ComputeChildLayout(); 00192 }; 00193 00194 } 00195 00196 #endif // RGBGEVALUATOR_H 00197 00198