nux-0.9.46

Nux/PropertyItem/RGBProperty.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 RGBPROPERTY_H
00024 #define RGBPROPERTY_H
00025 
00026 namespace nux
00027 {
00028 
00029   class PushButton;
00030   class ColorGradientPropertyItem;
00031 
00032   class RGBPropertyItem: public SectionProperty
00033   {
00034     NODE_XML_CLASS_MEMBER (RGBPropertyItem);
00035     NODE_SKIP_CHILD (true);
00036     NODE_SIG_RECEIVER (RecvPropertyChange, ColorGradient *);
00037 
00038   public:
00039     RGBPropertyItem (const TCHAR *name, float red = 0.0f, float green = 0.0f, float blue = 0.0f);
00040     virtual ~RGBPropertyItem();
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 
00063     double GetRed()     const
00064     {
00065       return m_Red;
00066     }
00067     double GetGreen()   const
00068     {
00069       return m_Green;
00070     }
00071     double GetBlue()    const
00072     {
00073       return m_Blue;
00074     }
00075 
00076     void SetColor (double red, double green, double blue)
00077     {
00078       m_red->SetValue (red);
00079       m_green->SetValue (green);
00080       m_blue->SetValue (blue);
00081       UpdateStartToEndColors();
00082     }
00083 
00084     void OnChangeColorModel();
00085     void OnChangeColorFormat();
00086 
00087     void SetColorModel (eColorModel cm);
00088     void SetColorFormat (Color::Format cf);
00089 
00090   private:
00091     void UpdateStartToEndColors();
00092 
00093     void RedChange (ColorGradient *slider);
00094     void GreenChange (ColorGradient *slider);
00095     void BlueChange (ColorGradient *slider);
00096     void AlphaChange (ColorGradient *slider);
00097 
00098     ColorGradientPropertyItem *m_red;
00099     ColorGradientPropertyItem *m_green;
00100     ColorGradientPropertyItem *m_blue;
00101 
00102     float m_Red, m_Green, m_Blue;
00103     PushButton *m_ColorModel;
00104     PushButton *m_ColorFormat;
00105     enum eColorModel m_color_model;
00106     Color::Format m_color_format;
00107   };
00108 
00109 }
00110 
00111 #endif // RGBPROPERTY_H
00112 
00113