1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTreeLayout class
4 // Author: Julian Smart
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TREELAY_H_
13 #define _WX_TREELAY_H_
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "wxtree.h"
20 #include "wx/object.h"
26 #include "wx/deprecated/setup.h"
27 #include "wx/string.h"
31 class WXDLLEXPORT wxTreeLayout
: public wxObject
35 virtual ~wxTreeLayout() { }
38 virtual void GetChildren(long id
, wxList
& list
) = 0;
39 virtual long GetNextNode(long id
) = 0;
40 virtual long GetNodeParent(long id
) = 0;
41 virtual long GetNodeX(long id
) = 0;
42 virtual long GetNodeY(long id
) = 0;
43 virtual void SetNodeX(long id
, long x
) = 0;
44 virtual void SetNodeY(long id
, long y
) = 0;
45 virtual void ActivateNode(long id
, bool active
) = 0;
46 virtual bool NodeActive(long id
) = 0;
48 // Optional redefinition
49 void Initialize(void);
50 inline virtual void SetNodeName(long WXUNUSED(id
), const wxString
& WXUNUSED(name
)) {}
51 inline virtual wxString
GetNodeName(long WXUNUSED(id
)) { return wxString(wxT("")); }
52 virtual void GetNodeSize(long id
, long *x
, long *y
, wxDC
& dc
);
53 virtual void Draw(wxDC
& dc
);
54 virtual void DrawNodes(wxDC
& dc
);
55 virtual void DrawBranches(wxDC
& dc
);
56 virtual void DrawNode(long id
, wxDC
& dc
);
57 virtual void DrawBranch(long from
, long to
, wxDC
& dc
);
60 virtual void DoLayout(wxDC
& dc
, long topNode
= -1);
62 // Accessors -- don't redefine
63 inline void SetTopNode(long id
) { m_parentNode
= id
; }
64 inline long GetTopNode(void) const { return m_parentNode
; }
65 inline void SetSpacing(long x
, long y
) { m_xSpacing
= x
; m_ySpacing
= y
; }
66 inline long GetXSpacing(void) const { return m_xSpacing
; }
67 inline long GetYSpacing(void) const { return m_ySpacing
; }
68 inline void SetMargins(long x
, long y
) { m_leftMargin
= x
; m_topMargin
= y
; }
69 inline long GetTopMargin(void) const { return m_topMargin
; }
70 inline long GetLeftMargin(void) const { return m_leftMargin
; }
72 inline bool GetOrientation(void) const { return m_orientation
; }
73 inline void SetOrientation(bool orient
) { m_orientation
= orient
; }
76 void CalcLayout(long node_id
, int level
, wxDC
& dc
);
86 bool m_orientation
; // TRUE for top-to-bottom, FALSE for left-to-right
89 DECLARE_ABSTRACT_CLASS(wxTreeLayout
)
92 class WXDLLEXPORT wxStoredNode
103 * A version of wxTreeLayout with storage for nodes
106 class WXDLLEXPORT wxTreeLayoutStored
: public wxTreeLayout
109 wxTreeLayoutStored(int noNodes
= 200);
110 virtual ~wxTreeLayoutStored(void);
111 void Initialize(int n
);
113 wxString
HitTest(wxMouseEvent
& event
, wxDC
& dc
);
114 wxStoredNode
* GetNode(long id
) const;
115 inline int GetNumNodes() const { return m_maxNodes
; };
116 inline int GetNodeCount() const { return m_num
; };
118 virtual void GetChildren(long id
, wxList
& list
);
119 virtual long GetNextNode(long id
);
120 virtual long GetNodeParent(long id
);
121 virtual long GetNodeX(long id
);
122 virtual long GetNodeY(long id
);
123 virtual void SetNodeX(long id
, long x
);
124 virtual void SetNodeY(long id
, long y
);
125 virtual void SetNodeName(long id
, const wxString
& name
);
126 virtual wxString
GetNodeName(long id
);
127 virtual void ActivateNode(long id
, bool active
);
128 virtual bool NodeActive(long id
);
129 virtual void SetClientData(long id
, long clientData
);
130 virtual long GetClientData(long id
) const;
132 virtual long AddChild(const wxString
& name
, const wxString
& parent
= wxT(""));
133 virtual long AddChild(const wxString
& name
, long parent
);
134 virtual long NameToId(const wxString
& name
);
138 wxStoredNode
* m_nodes
;
143 DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored
)
144 DECLARE_NO_COPY_CLASS(wxTreeLayoutStored
)
147 // For backward compatibility
148 #define wxStoredTree wxTreeLayoutStored