nux-0.9.46

Nux/PropertyItem/RGBAProperty.h

Go to the documentation of this file.
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 RGBAPROPERTY_H
00024 #define RGBAPROPERTY_H
00025 
00026 namespace nux
00027 {
00028 
00029   class PushButton;
00030   class ColorGradientPropertyItem;
00031 
00032   class RGBAPropertyItem: public SectionProperty
00033   {
00034     NODE_XML_CLASS_MEMBER (RGBAPropertyItem);
00035     NODE_SKIP_CHILD (true);
00036     NODE_SIG_RECEIVER (RecvPropertyChange, ColorGradient *);
00037 
00038   public:
00039     RGBAPropertyItem (const TCHAR *name, float red = 0.0f, float green = 0.0f, float blue = 0.0f, float alpha = 1.0f);
00040     virtual ~RGBAPropertyItem();
00041 
00042     virtual long ProcessPropertyEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00043     virtual void DrawProperty (GraphicsEngine &GfxContext, TableCtrl *table, bool force_draw, Geometry geo, const BasePainter &Painter, RowHeader *row, const std::vector<ColumnHeader>& column_vector, Color ItemBackgroundColor = Color (0x0) );
00044     virtual void ComputePropertyLayout (int x, int y, RowHeader *row, const std::vector<ColumnHeader>& column_vector);
00045     virtual int GetItemBestHeight();
00046 
00047     void SetRed (double red)
00048     {
00049       m_red->SetValue (red);
00050       UpdateStartToEndColors();
00051     }
00052     void SetGreen (double green)
00053     {
00054       m_green->SetValue (green);
00055       UpdateStartToEndColors();
00056     }
00057     void SetBlue (double blue)
00058     {
00059       m_blue->SetValue (blue);
00060       UpdateStartToEndColors();
00061     }
00062     void SetAlpha (double alpha)
00063     {
00064       m_alpha->SetValue (alpha);
00065       UpdateStartToEndColors();
00066     }
00067 
00068     double GetRed()     const
00069     {
00070       return m_Red;
00071     }
00072     double GetGreen()   const
00073     {
00074       return m_Green;
00075     }
00076     double GetBlue()    const
00077     {
00078       return m_Blue;
00079     }
00080     double GetAlpha()   const
00081     {
00082       return m_Alpha;
00083     }
00084     void SetColor (double red, double green, double blue, double alpha)
00085     {
00086       m_red->SetValue (red);
00087       m_green->SetValue (green);
00088       m_blue->SetValue (blue);
00089       m_alpha->SetValue (alpha);
00090       UpdateStartToEndColors();
00091     }
00092 
00093     void OnChangeColorModel();
00094     void OnChangeColorFormat();
00095 
00096     void SetColorModel (eColorModel cm);
00097     void SetColorFormat (Color::Format cf);
00098 
00099   private:
00100     void UpdateStartToEndColors();
00101 
00102     void RedChange (ColorGradient *slider);
00103     void GreenChange (ColorGradient *slider);
00104     void BlueChange (ColorGradient *slider);
00105     void AlphaChange (ColorGradient *slider);
00106 
00107     ColorGradientPropertyItem *m_red;
00108     ColorGradientPropertyItem *m_green;
00109     ColorGradientPropertyItem *m_blue;
00110     ColorGradientPropertyItem *m_alpha;
00111 
00112     float m_Red, m_Green, m_Blue, m_Alpha;
00113     PushButton *m_ColorModel;
00114     PushButton *m_ColorFormat;
00115     enum eColorModel m_color_model;
00116     Color::Format m_color_format;
00117   };
00118 
00119 }
00120 
00121 #endif // RGBAPROPERTY_H
00122 
00123