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_
16 #pragma interface "wxtree.h"
20 #include <wx/object.h>
26 #include <wx/string.h>
28 class WXDLLEXPORT wxTreeLayout
: public wxObject
30 DECLARE_ABSTRACT_CLASS(wxTreeLayout
)
36 virtual void GetChildren(long id
, wxList
& list
) = 0;
37 virtual long GetNextNode(long id
) = 0;
38 virtual long GetNodeParent(long id
) = 0;
39 virtual long GetNodeX(long id
) = 0;
40 virtual long GetNodeY(long id
) = 0;
41 virtual void SetNodeX(long id
, long x
) = 0;
42 virtual void SetNodeY(long id
, long y
) = 0;
43 virtual void ActivateNode(long id
, bool active
) = 0;
44 virtual bool NodeActive(long id
) = 0;
46 // Optional redefinition
47 void Initialize(void);
48 inline virtual void SetNodeName(long WXUNUSED(id
), const wxString
& WXUNUSED(name
)) {}
49 inline virtual wxString
GetNodeName(long WXUNUSED(id
)) { return wxString(""); }
50 virtual void GetNodeSize(long id
, long *x
, long *y
, wxDC
& dc
);
51 virtual void Draw(wxDC
& dc
);
52 virtual void DrawNodes(wxDC
& dc
);
53 virtual void DrawBranches(wxDC
& dc
);
54 virtual void DrawNode(long id
, wxDC
& dc
);
55 virtual void DrawBranch(long from
, long to
, wxDC
& dc
);
58 virtual void DoLayout(wxDC
& dc
, long topNode
= -1);
60 // Accessors -- don't redefine
61 inline void SetTopNode(long id
) { m_parentNode
= id
; }
62 inline long GetTopNode(void) const { return m_parentNode
; }
63 inline void SetSpacing(long x
, long y
) { m_xSpacing
= x
; m_ySpacing
= y
; }
64 inline long GetXSpacing(void) const { return m_xSpacing
; }
65 inline long GetYSpacing(void) const { return m_ySpacing
; }
66 inline void SetMargins(long x
, long y
) { m_leftMargin
= x
; m_topMargin
= y
; }
67 inline long GetTopMargin(void) const { return m_topMargin
; }
68 inline long GetLeftMargin(void) const { return m_leftMargin
; }
70 inline bool GetOrientation(void) const { return m_orientation
; }
71 inline void SetOrientation(bool orient
) { m_orientation
= orient
; }
74 void CalcLayout(long node_id
, int level
, wxDC
& dc
);
86 bool m_orientation
; // TRUE for top-to-bottom, FALSE for left-to-right
89 class WXDLLEXPORT wxStoredNode
100 * A version of wxTreeLayout with storage for nodes
103 class WXDLLEXPORT wxTreeLayoutStored
: public wxTreeLayout
105 DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored
)
107 wxTreeLayoutStored(int noNodes
= 200);
108 ~wxTreeLayoutStored(void);
109 void Initialize(int n
);
111 wxString
HitTest(wxMouseEvent
& event
, wxDC
& dc
);
112 wxStoredNode
* GetNode(long id
) const;
113 inline int GetNumNodes() const { return m_maxNodes
; };
114 inline int GetNodeCount() const { return m_num
; };
116 virtual void GetChildren(long id
, wxList
& list
);
117 virtual long GetNextNode(long id
);
118 virtual long GetNodeParent(long id
);
119 virtual long GetNodeX(long id
);
120 virtual long GetNodeY(long id
);
121 virtual void SetNodeX(long id
, long x
);
122 virtual void SetNodeY(long id
, long y
);
123 virtual void SetNodeName(long id
, const wxString
& name
);
124 virtual wxString
GetNodeName(long id
);
125 virtual void ActivateNode(long id
, bool active
);
126 virtual bool NodeActive(long id
);
127 virtual void SetClientData(long id
, long clientData
);
128 virtual long GetClientData(long id
) const;
130 virtual long AddChild(const wxString
& name
, const wxString
& parent
= "");
131 virtual long NameToId(const wxString
& name
);
135 wxStoredNode
* m_nodes
;
140 // For backward compatibility
141 #define wxStoredTree wxTreeLayoutStored