nux-1.16.0
RGBAProperty.h
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 ToggleButton;
00030   class ColorGradientPropertyItem;
00031 
00032   // TODO: Tim Penhey 2011-05-12
00033   // Both this class and RGBPropertyItem should share a base class
00034   // as many of the color calculations are common to the two.
00035   class RGBAPropertyItem: public SectionProperty
00036   {
00037     NODE_XML_CLASS_MEMBER (RGBAPropertyItem);
00038     NODE_SKIP_CHILD (true);
00039     NODE_SIG_RECEIVER (RecvPropertyChange, ColorGradient *);
00040 
00041   public:
00042     RGBAPropertyItem (const TCHAR *name, float red = 0.0f, float green = 0.0f, float blue = 0.0f, float alpha = 1.0f);
00043     virtual ~RGBAPropertyItem();
00044 
00045     virtual long ProcessPropertyEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00046     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) );
00047     virtual void ComputePropertyLayout (int x, int y, RowHeader *row, const std::vector<ColumnHeader>& column_vector);
00048     virtual int GetItemBestHeight();
00049 
00050     void SetRed (double red)
00051     {
00052       m_red->SetValue (red);
00053       UpdateStartToEndColors();
00054     }
00055     void SetGreen (double green)
00056     {
00057       m_green->SetValue (green);
00058       UpdateStartToEndColors();
00059     }
00060     void SetBlue (double blue)
00061     {
00062       m_blue->SetValue (blue);
00063       UpdateStartToEndColors();
00064     }
00065     void SetAlpha (double alpha)
00066     {
00067       m_alpha->SetValue (alpha);
00068       UpdateStartToEndColors();
00069     }
00070 
00071     double GetRed()     const
00072     {
00073       return color_.red;
00074     }
00075     double GetGreen()   const
00076     {
00077       return color_.green;
00078     }
00079     double GetBlue()    const
00080     {
00081       return color_.blue;
00082     }
00083     double GetAlpha()   const
00084     {
00085       return color_.alpha;
00086     }
00087     void SetColor (double red, double green, double blue, double alpha)
00088     {
00089       m_red->SetValue (red);
00090       m_green->SetValue (green);
00091       m_blue->SetValue (blue);
00092       m_alpha->SetValue (alpha);
00093       UpdateStartToEndColors();
00094     }
00095 
00096     void OnChangeColorModel();
00097     void OnChangeColorFormat();
00098 
00099     void SetColorModel (color::Model cm);
00100     void SetColorFormat (color::Format cf);
00101 
00102   private:
00103     void UpdateStartToEndColors();
00104 
00105     void RedChange (ColorGradient *slider);
00106     void GreenChange (ColorGradient *slider);
00107     void BlueChange (ColorGradient *slider);
00108     void AlphaChange (ColorGradient *slider);
00109 
00110     ColorGradientPropertyItem *m_red;
00111     ColorGradientPropertyItem *m_green;
00112     ColorGradientPropertyItem *m_blue;
00113     ColorGradientPropertyItem *m_alpha;
00114 
00115     Color color_;
00116     ToggleButton *m_ColorModel;
00117     ToggleButton *m_ColorFormat;
00118     color::Model color_model_;
00119     color::Format color_format_;
00120   };
00121 
00122 }
00123 
00124 #endif // RGBAPROPERTY_H
00125 
00126 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends