nux-1.14.0
TableItem.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 TABLEITEM_H
00024 #define TABLEITEM_H
00025 
00026 #include "NodeItem.h"
00027 #include "NodeNetProtocol.h"
00028 
00029 namespace nux
00030 {
00031 
00032   class TableItem;
00033   class TableCtrl;
00034   class TreeView;
00035 
00036   extern const int ITEMDEFAULTWIDTH;
00037   extern const int ITEMDEFAULTHEIGHT;
00038   extern Color GPropertyItemTextColor0;
00039   extern Color GPropertyItemTextColor1;
00040 
00041   class ColumnHeader
00042   {
00043   public:
00044     ColumnHeader();
00045     ColumnHeader(const ColumnHeader& Other);
00046     ~ColumnHeader();
00047 
00048     ColumnHeader& operator = (const ColumnHeader& Other);
00049 
00050     InputArea *m_header_area;
00051     bool _fix_width;
00052     int _fix_width_value;
00053   };
00054 
00055   class RowHeader
00056   {
00057   public:
00058     RowHeader();
00059     RowHeader(const RowHeader& Other);
00060     ~RowHeader();
00061 
00062     RowHeader& operator = (const RowHeader& Other);
00063 
00064     //void SetItem(TableItem* item);
00065     //TableItem* GetItem();
00066 
00067     TableItem *_table_item;
00068   };
00069 
00070   class TableItem: public NodeNetCom
00071   {
00072   public:
00073     TableItem (const TCHAR *name, NodeParameterType type = NODE_TYPE_STATICTEXT);
00074     virtual ~TableItem();
00075 
00076     virtual long ProcessPropertyEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00077     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) );
00078     virtual void ComputePropertyLayout (int x, int y, RowHeader *row, const std::vector<ColumnHeader>& column_vector) {};
00079     virtual int GetItemBestHeight();
00080     virtual void SetPropertyItemWidth();
00081 
00082     void SetItemTextColor (Color const& color)
00083     {
00084       m_PropertyTextColor = color;
00085     }
00086 
00087     Color const& GetItemTextColor() const
00088     {
00089       return m_PropertyTextColor;
00090     }
00091 
00092     virtual void SetBackgroundColor(Color const& c)
00093     {
00094       m_ItemBackgroundColor = c;
00095     }
00096     Color const& GetBackgroundColor() const
00097     {
00098       return m_ItemBackgroundColor;
00099     }
00100 
00104     void SetAlwaysShowOpeningButton (bool b)
00105     {
00106       m_AlwaysShowOpeningButton = b;
00107     }
00111     bool AlwaysShowOpeningButton()
00112     {
00113       return m_AlwaysShowOpeningButton;
00114     }
00119     void Open()
00120     {
00121       m_isOpen = true;
00122     }
00126     void Close()
00127     {
00128       m_isOpen = false;
00129     }
00133     bool isOpen() const
00134     {
00135       return m_isOpen;
00136     }
00140     void Hide()
00141     {
00142       m_bParentOpen = false;
00143     }
00147     void Show()
00148     {
00149       m_bParentOpen = true;
00150     }
00154     bool IsParentOpen() const
00155     {
00156       return m_bParentOpen;
00157     };
00158     void setDirtyItem (bool b)
00159     {
00160       m_bDirty = b;
00161     }
00162     bool isDirtyItem() const
00163     {
00164       return m_bDirty;
00165     }
00166 
00167     void RequestPropertyRedraw()
00168     {
00169       m_PropertyRedraw = true;
00170     }
00171 
00172     virtual void      PushChildFront ( NodeItem *child );
00173     virtual void      PushChildBack ( NodeItem *child );
00174     virtual void      AddNextSibling ( NodeItem *sibling );
00175     virtual void      AddPrevSibling ( NodeItem *sibling );
00176     virtual void      Unlink ( void );
00177 
00178     sigc::signal<void> sigCellFocus;
00179     sigc::signal<void> sigRowFocus;
00180 
00181     TableCtrl *GetTable()
00182     {
00183       return m_Table;
00184     }
00185   protected:
00186     //  Only the Root node of the table has this value defined. Every other item should have it set to NULL;
00187     TableCtrl *m_Table;
00188     bool m_isOpen;
00190     bool m_bParentOpen;
00191 
00192     int m_x;
00193     int m_y;
00194     int m_height;
00195     int m_width;
00196     int m_depth;
00197 
00198     bool m_bDirty;
00199 
00200     bool m_PropertyRedraw;
00201     Color m_ItemBackgroundColor;
00202     Color m_PropertyTextColor;
00203 
00204     bool  m_AlwaysShowOpeningButton;
00205 
00207     InputArea *_row_header_area;
00209     std::vector<Geometry> m_ItemGeometryVector;
00210     //Geometry m_FirstColumnInRowGeometry;
00211     Geometry m_RowHeaderGeometry;
00212     Geometry m_FirstColumnUsableGeometry;
00213     Geometry m_TotalGeometry;
00214 
00215     bool m_bIsMouseInside;
00216     bool m_bIsFirstVisibleItem;
00217     bool m_bIsLastVisibleItem;
00218 
00219     friend class TableCtrl;
00220     friend class TreeControl;
00221     friend class ListControl;
00222   };
00223 
00224 }
00225 
00226 #endif // TABLEITEM_H
00227 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends