nux-1.14.0
PropertyList.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 PROPERTYLIST_H
00024 #define PROPERTYLIST_H
00025 
00026 #include "View.h"
00027 #include "ActionItem.h"
00028 #include "RangeValue.h"
00029 #include "Button.h"
00030 #include "ComboBoxComplex.h"
00031 #include "SpinBox.h"
00032 #include "DoubleValidator.h"
00033 #include "SpinBoxDouble.h"
00034 #include "CheckBox.h"
00035 #include "TableItem.h"
00036 #include "NodeItem.h"
00037 #include "TableCtrl.h"
00038 #include "EditTextBox.h"
00039 #include "SplineCurveEditor.h"
00040 #include "SplineCurvePreview.h"
00041 #include "ComboBoxSimple.h"
00042 #include "ValuatorDouble.h"
00043 #include "ValuatorInt.h"
00044 #include "Vector3ValuatorDouble.h"
00045 #include "ColorPreview.h"
00046 #include "Matrix4Preview.h"
00047 #include "Matrix3Preview.h"
00048 #include "RangeValueInteger.h"
00049 #include "ColorGradient.h"
00050 
00051 namespace nux
00052 {
00053 
00054   extern Color GPropertyItemTextColor0;
00055   extern Color GPropertyItemTextColor1;
00056 
00057   extern const int PROPERTY_BORDER_X;
00058   extern const int PROPERTY_BORDER_Y;
00059 
00060 #if NODE_XML_NET_PROTOCOL
00061 #define NODE_XML_CLASS_MEMBER(cls)   public:                                                                    \
00062         static cls* CreateFromXML(const TiXmlElement* elementxml, NodeNetCom* parent, const TCHAR* Name, int id); \
00063         virtual TiXmlElement* ToXML() const;                                                                        \
00064         virtual bool FromXML(const TiXmlElement* elementxml);
00065 
00066 #define NODE_SKIP_CHILD(b)  public:         \
00067         virtual bool SkipChild() const {return b;}
00068 #else
00069 #define NODE_XML_CLASS_MEMBER(cls)
00070 
00071 #define NODE_SKIP_CHILD(b)
00072 #endif
00073 
00074 #define NODE_SIG_RECEIVER(MemFunc, Cls)                     \
00075     void MemFunc(Cls)                                       \
00076     {                                                       \
00077         TableItem* parent = (TableItem*)Parent();           \
00078         bool ParentCanHandleChild = false;                  \
00079         while(parent)                                       \
00080         {                                                   \
00081             if(parent->SkipChild() == true)                 \
00082             {                                               \
00083                 ParentCanHandleChild = true;                \
00084                 break;                                      \
00085             }                                               \
00086             parent = (TableItem*)parent->Parent();          \
00087         }                                                   \
00088         if(ParentCanHandleChild)                            \
00089         {                                                   \
00090             TableItem* root = (TableItem*) RootNode();      \
00091             root->GetTable()->sigItemChange.emit(*parent);  \
00092         }                                                   \
00093         else                                                \
00094         {                                                   \
00095             TableItem* root = (TableItem*) RootNode();      \
00096             root->GetTable()->sigItemChange.emit(*this);    \
00097         }                                                   \
00098     }
00099 
00100 #define NODE_SIG_RECEIVER2(MemFunc, Cls)                    \
00101     void MemFunc(Cls)                                       \
00102     {                                                       \
00103         TableItem* parent = (TableItem*)Parent();           \
00104         bool ParentCanHandleChild = false;                  \
00105         while(parent)                                       \
00106         {                                                   \
00107             if(parent->SkipChild() == true)                 \
00108             {                                               \
00109                 ParentCanHandleChild = true;                \
00110                 break;                                      \
00111             }                                               \
00112             parent = (TableItem*)parent->Parent();          \
00113         }                                                   \
00114         if(ParentCanHandleChild)                            \
00115         {                                                   \
00116             TableItem* root = (TableItem*) RootNode();      \
00117             root->GetTable()->sigItemChange.emit(*parent);  \
00118         }                                                   \
00119         else                                                \
00120         {                                                   \
00121             TableItem* root = (TableItem*) RootNode();      \
00122             root->GetTable()->sigItemChange.emit(*this);    \
00123         }                                                   \
00124     }
00125 
00126 #define NODE_SIG_CONNECT(signal, Cls, MemFun) signal.connect(sigc::mem_fun(this, &Cls::MemFun));
00127 
00128   class SectionProperty : public TableItem//, public View
00129   {
00130     NODE_XML_CLASS_MEMBER (SectionProperty);
00131   public:
00132     SectionProperty (const char *name, NodeParameterType type = NODE_TYPE_STATICTEXT);
00133     virtual ~SectionProperty();
00134 
00135 //    virtual long ProcessPropertyEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00136     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) );
00137     virtual void ComputePropertyLayout (int x, int y, RowHeader *row, const std::vector<ColumnHeader>& column_vector);
00138     virtual int GetItemBestHeight();
00139 
00140     void SetString (NString str)
00141     {
00142       m_String = str;
00143     }
00144     NString GetString (NString str) const
00145     {
00146       return m_String;
00147     }
00148 
00149   private:
00150     NString m_String;
00151   };
00152 
00153 // class ComboBoxPropertyItem: public SectionProperty, public ComboBoxComplex
00154 // {
00155 //     //NODE_XML_CLASS_MEMBER(ComboBoxPropertyItem);
00156 //     NODE_SKIP_CHILD(true);
00157 // public:
00158 //     ComboBoxPropertyItem(const TCHAR* name);
00159 //     virtual ~ComboBoxPropertyItem();
00160 //
00161 //     virtual long ProcessPropertyEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00162 //     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));
00163 //     virtual void ComputePropertyLayout(int x, int y, RowHeader* row, const std::vector<ColumnHeader>& column_vector);
00164 //     virtual int GetItemBestHeight();
00165 // private:
00166 //     //RangeValue m_range_value;
00167 // };
00168 
00169 // class ComboBoxSimplePropertyItem: public SectionProperty, public ComboBoxSimple
00170 // {
00171 //     NODE_XML_CLASS_MEMBER(ComboBoxSimplePropertyItem);
00172 //     NODE_SKIP_CHILD(true);
00173 //     NODE_SIG_RECEIVER(RecvPropertyChange, ComboBoxSimple*);
00174 // public:
00175 //     ComboBoxSimplePropertyItem(const TCHAR* name);
00176 //     virtual ~ComboBoxSimplePropertyItem();
00177 //
00178 //     virtual long ProcessPropertyEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00179 //     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));
00180 //     virtual void ComputePropertyLayout(int x, int y, RowHeader* row, const std::vector<ColumnHeader>& column_vector);
00181 //     virtual int GetItemBestHeight();
00182 // private:
00183 //     //RangeValue m_range_value;
00184 // };
00185 
00186 // class SpinBoxPropertyItem: public SectionProperty, public SpinBox
00187 // {
00188 //     NODE_XML_CLASS_MEMBER(SpinBoxPropertyItem);
00189 //     NODE_SIG_RECEIVER(RecvPropertyChange, SpinBox*);
00190 // public:
00191 //     SpinBoxPropertyItem(const TCHAR* name, int Value = 0, int Step = 1, int MinValue = 0, int MaxValue = 100);
00192 //     virtual ~SpinBoxPropertyItem();
00193 //
00194 //     virtual long ProcessPropertyEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00195 //     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));
00196 //     virtual void ComputePropertyLayout(int x, int y, RowHeader* row, const std::vector<ColumnHeader>& column_vector);
00197 //     virtual int GetItemBestHeight();
00198 //
00199 // private:
00200 //     //RangeValue m_range_value;
00201 // };
00202 
00203 // class SpinBoxDoublePropertyItem: public SectionProperty, public SpinBoxDouble
00204 // {
00205 //     NODE_XML_CLASS_MEMBER(DoubleSpinBoxPropertyItem);
00206 //     NODE_SIG_RECEIVER(RecvPropertyChange, SpinBoxDouble*);
00207 // public:
00208 //     DoubleSpinBoxPropertyItem(const TCHAR* name, double Value = 0.0, double Step = 1.0, double MinValue = 0.0, double MaxValue = 100.0);
00209 //     virtual ~DoubleSpinBoxPropertyItem();
00210 //
00211 //     virtual long ProcessPropertyEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00212 //     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));
00213 //     virtual void ComputePropertyLayout(int x, int y, RowHeader* row, const std::vector<ColumnHeader>& column_vector);
00214 //     virtual int GetItemBestHeight();
00215 //
00216 // private:
00217 //     //RangeValue m_range_value;
00218 // };
00219 
00220 // class Vector3ValuatorPropertyItem: public SectionProperty, public Vector3DoubleValuator
00221 // {
00222 //     NODE_XML_CLASS_MEMBER(Vector3ValuatorPropertyItem);
00223 //     NODE_SIG_RECEIVER(RecvPropertyChange, Vector3DoubleValuator*);
00224 // public:
00225 //     Vector3ValuatorPropertyItem(const TCHAR* name, double X = 0, double Y = 0, double Z = 0,
00226 //         double Step = 1.0, double MinValue = -1.7E308, double MaxValue = 1.7E308);
00227 //     virtual ~Vector3ValuatorPropertyItem();
00228 //
00229 //     virtual long ProcessPropertyEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00230 //     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));
00231 //     virtual void ComputePropertyLayout(int x, int y, RowHeader* row, const std::vector<ColumnHeader>& column_vector);
00232 //     virtual int GetItemBestHeight();
00233 //
00234 // private:
00235 //     //RangeValue m_range_value;
00236 // };
00237 
00238 
00239 
00240 
00241 
00242 
00243 
00244 }
00245 
00246 #endif //PROPERTYLIST_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends