Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

GTree.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 #ifndef __GTREE2_H
00006 #define __GTREE2_H
00007 
00008 #include "GList.h"
00009 
00010 enum GTreeItemRect
00011 {
00012     TreeItemPos,
00013     TreeItemThumb,
00014     TreeItemText,
00015     TreeItemIcon
00016 };
00017 
00019 class LgiClass GTreeItem :
00020     public GItem
00021 {
00022     friend class GTree;
00023 
00024 protected:
00025     class GTreeItemPrivate *d;
00026 
00027     // Private methods
00028     void _RePour();
00029     void _Pour(GdcPt2 *Limit, int Depth, bool Visible);
00030     void _Remove();
00031     void _MouseClick(GMouse &m);
00032     void _SetTreePtr(GTree *t);
00033     GTreeItem *_HitTest(int x, int y);
00034     GRect *_GetRect(GTreeItemRect Which);
00035     GdcPt2 _ScrollPos();
00036 
00037     virtual void _PourText(GdcPt2 &Size);
00038     virtual void _PaintText(GSurface *pDC, COLOUR Fore, COLOUR Back);
00039 
00040 protected:
00041     char *Str;
00042     int Sys_Image;
00043     GTree *Tree;
00044     GTreeItem *Parent;
00045     List<GTreeItem> Items;
00046 
00047 public:
00048     GTreeItem();
00049     virtual ~GTreeItem();
00050 
00057     char *GetText(int i=0);
00061     bool SetText(char *s, int i=0);
00063     int GetImage(int Flags = 0);
00065     void SetImage(int i);
00068     void Update();
00070     bool Select();
00072     void Select(bool b);
00074     bool Expanded();
00076     void Expanded(bool b);
00077 
00079     GTreeItem *Insert(GTreeItem *Obj = NULL, int Pos = -1);
00081     void Remove();
00083     void Detach();
00085     GTreeItem *GetNext();
00087     GTreeItem *GetPrev();
00089     GTreeItem *GetChild();
00091     GTreeItem *GetParent() { return Parent; }
00093     GTree *GetTree() { return Tree; }
00095     bool IsRoot();
00097     int IndexOf();
00099     void ScrollTo();
00100 
00102     virtual void OnExpand(bool b) {}
00103 
00105     virtual void OnPaint(GSurface *pDC, GRect &r, COLOUR Back);
00106 };
00107 
00109 class LgiClass GTree :
00110     public ResObject,
00111     public GLayout,
00112     public GItemContainer,
00113     public GTreeItem
00114 {
00115     friend class GTreeItem;
00116     class GTreePrivate *d;
00117 
00118     // Private methods
00119     void _Pour();
00120     void _OnSelect(GTreeItem *Item);
00121     GdcPt2 _ScrollPos();
00122     void _Update(GRect *r = 0, bool Now = false);
00123     void _UpdateBelow(int y, bool Now = false);
00124     void _UpdateScrollBars();
00125 
00126 protected:
00127     // Options
00128     bool Lines;
00129     bool Buttons;
00130     bool LinesAtRoot;
00131     bool EditLabels;
00132     bool MultipleSelect;
00133     
00134     GTreeItem *GetAdjacent(GTreeItem *From, bool Down);
00135     
00136 public:
00137     GTree(int id, int x, int y, int cx, int cy, char *name = 0);
00138     ~GTree();
00139 
00141     virtual void OnItemClick(GTreeItem *Item, GMouse &m);
00143     virtual void OnItemBeginDrag(GTreeItem *Item, int Flags);
00145     virtual void OnItemExpand(GTreeItem *Item, bool Expand);
00147     virtual void OnItemSelect(GTreeItem *Item);
00148     
00149     // Implementation
00150     void OnMouseClick(GMouse &m);
00151     void OnMouseMove(GMouse &m);
00152     void OnMouseWheel(double Lines);
00153     void OnPaint(GSurface *pDC);
00154     void OnFocus(bool b);
00155     void OnPosChange();
00156     bool OnKey(GKey &k);
00157     int OnNotify(GView *Ctrl, int Flags);
00158     int OnEvent(GMessage *Msg);
00159 
00161     GTreeItem *Insert(GTreeItem *Obj = 0, int Pos = -1);
00163     bool Delete(GTreeItem *Obj);
00165     bool Remove(GTreeItem *Obj);
00167     GTreeItem *ItemAt(int Pos) { return Items.ItemAt(Pos); }
00168 
00170     bool Select(GTreeItem *Obj);
00172     GTreeItem *Selection();
00174     GTreeItem *ItemAtPoint(int x, int y);
00177     void SelectDropTarget(GTreeItem *Item);
00178 
00180     void Empty();
00182     void RemoveAll();
00183 };
00184 
00185 #endif
00186 

Generated on Wed Oct 26 14:46:50 2005 for Lgi by  doxygen 1.4.1