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/string.h"
30 class WXDLLEXPORT wxTreeLayout
: public wxObject
34 virtual ~wxTreeLayout() { }
37 virtual void GetChildren(long id
, wxList
& list
) = 0;
38 virtual long GetNextNode(long id
) = 0;
39 virtual long GetNodeParent(long id
) = 0;
40 virtual long GetNodeX(long id
) = 0;
41 virtual long GetNodeY(long id
) = 0;
42 virtual void SetNodeX(long id
, long x
) = 0;
43 virtual void SetNodeY(long id
, long y
) = 0;
44 virtual void ActivateNode(long id
, bool active
) = 0;
45 virtual bool NodeActive(long id
) = 0;
47 // Optional redefinition
48 void Initialize(void);
49 inline virtual void SetNodeName(long WXUNUSED(id
), const wxString
& WXUNUSED(name
)) {}
50 inline virtual wxString
GetNodeName(long WXUNUSED(id
)) { return wxString(wxT("")); }
51 virtual void GetNodeSize(long id
, long *x
, long *y
, wxDC
& dc
);
52 virtual void Draw(wxDC
& dc
);
53 virtual void DrawNodes(wxDC
& dc
);
54 virtual void DrawBranches(wxDC
& dc
);
55 virtual void DrawNode(long id
, wxDC
& dc
);
56 virtual void DrawBranch(long from
, long to
, wxDC
& dc
);
59 virtual void DoLayout(wxDC
& dc
, long topNode
= -1);
61 // Accessors -- don't redefine
62 inline void SetTopNode(long id
) { m_parentNode
= id
; }
63 inline long GetTopNode(void) const { return m_parentNode
; }
64 inline void SetSpacing(long x
, long y
) { m_xSpacing
= x
; m_ySpacing
= y
; }
65 inline long GetXSpacing(void) const { return m_xSpacing
; }
66 inline long GetYSpacing(void) const { return m_ySpacing
; }
67 inline void SetMargins(long x
, long y
) { m_leftMargin
= x
; m_topMargin
= y
; }
68 inline long GetTopMargin(void) const { return m_topMargin
; }
69 inline long GetLeftMargin(void) const { return m_leftMargin
; }
71 inline bool GetOrientation(void) const { return m_orientation
; }
72 inline void SetOrientation(bool orient
) { m_orientation
= orient
; }
75 void CalcLayout(long node_id
, int level
, wxDC
& dc
);
85 bool m_orientation
; // TRUE for top-to-bottom, FALSE for left-to-right
88 DECLARE_ABSTRACT_CLASS(wxTreeLayout
)
91 class WXDLLEXPORT wxStoredNode
102 * A version of wxTreeLayout with storage for nodes
105 class WXDLLEXPORT wxTreeLayoutStored
: public wxTreeLayout
108 wxTreeLayoutStored(int noNodes
= 200);
109 virtual ~wxTreeLayoutStored(void);
110 void Initialize(int n
);
112 wxString
HitTest(wxMouseEvent
& event
, wxDC
& dc
);
113 wxStoredNode
* GetNode(long id
) const;
114 inline int GetNumNodes() const { return m_maxNodes
; };
115 inline int GetNodeCount() const { return m_num
; };
117 virtual void GetChildren(long id
, wxList
& list
);
118 virtual long GetNextNode(long id
);
119 virtual long GetNodeParent(long id
);
120 virtual long GetNodeX(long id
);
121 virtual long GetNodeY(long id
);
122 virtual void SetNodeX(long id
, long x
);
123 virtual void SetNodeY(long id
, long y
);
124 virtual void SetNodeName(long id
, const wxString
& name
);
125 virtual wxString
GetNodeName(long id
);
126 virtual void ActivateNode(long id
, bool active
);
127 virtual bool NodeActive(long id
);
128 virtual void SetClientData(long id
, long clientData
);
129 virtual long GetClientData(long id
) const;
131 virtual long AddChild(const wxString
& name
, const wxString
& parent
= wxT(""));
132 virtual long AddChild(const wxString
& name
, long parent
);
133 virtual long NameToId(const wxString
& name
);
137 wxStoredNode
* m_nodes
;
142 DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored
)
145 // For backward compatibility
146 #define wxStoredTree wxTreeLayoutStored