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
32 DECLARE_ABSTRACT_CLASS(wxTreeLayout
)
36 virtual ~wxTreeLayout() { }
39 virtual void GetChildren(long id
, wxList
& list
) = 0;
40 virtual long GetNextNode(long id
) = 0;
41 virtual long GetNodeParent(long id
) = 0;
42 virtual long GetNodeX(long id
) = 0;
43 virtual long GetNodeY(long id
) = 0;
44 virtual void SetNodeX(long id
, long x
) = 0;
45 virtual void SetNodeY(long id
, long y
) = 0;
46 virtual void ActivateNode(long id
, bool active
) = 0;
47 virtual bool NodeActive(long id
) = 0;
49 // Optional redefinition
50 void Initialize(void);
51 inline virtual void SetNodeName(long WXUNUSED(id
), const wxString
& WXUNUSED(name
)) {}
52 inline virtual wxString
GetNodeName(long WXUNUSED(id
)) { return wxString(""); }
53 virtual void GetNodeSize(long id
, long *x
, long *y
, wxDC
& dc
);
54 virtual void Draw(wxDC
& dc
);
55 virtual void DrawNodes(wxDC
& dc
);
56 virtual void DrawBranches(wxDC
& dc
);
57 virtual void DrawNode(long id
, wxDC
& dc
);
58 virtual void DrawBranch(long from
, long to
, wxDC
& dc
);
61 virtual void DoLayout(wxDC
& dc
, long topNode
= -1);
63 // Accessors -- don't redefine
64 inline void SetTopNode(long id
) { m_parentNode
= id
; }
65 inline long GetTopNode(void) const { return m_parentNode
; }
66 inline void SetSpacing(long x
, long y
) { m_xSpacing
= x
; m_ySpacing
= y
; }
67 inline long GetXSpacing(void) const { return m_xSpacing
; }
68 inline long GetYSpacing(void) const { return m_ySpacing
; }
69 inline void SetMargins(long x
, long y
) { m_leftMargin
= x
; m_topMargin
= y
; }
70 inline long GetTopMargin(void) const { return m_topMargin
; }
71 inline long GetLeftMargin(void) const { return m_leftMargin
; }
73 inline bool GetOrientation(void) const { return m_orientation
; }
74 inline void SetOrientation(bool orient
) { m_orientation
= orient
; }
77 void CalcLayout(long node_id
, int level
, wxDC
& dc
);
89 bool m_orientation
; // TRUE for top-to-bottom, FALSE for left-to-right
92 class WXDLLEXPORT wxStoredNode
103 * A version of wxTreeLayout with storage for nodes
106 class WXDLLEXPORT wxTreeLayoutStored
: public wxTreeLayout
108 DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored
)
110 wxTreeLayoutStored(int noNodes
= 200);
111 virtual ~wxTreeLayoutStored(void);
112 void Initialize(int n
);
114 wxString
HitTest(wxMouseEvent
& event
, wxDC
& dc
);
115 wxStoredNode
* GetNode(long id
) const;
116 inline int GetNumNodes() const { return m_maxNodes
; };
117 inline int GetNodeCount() const { return m_num
; };
119 virtual void GetChildren(long id
, wxList
& list
);
120 virtual long GetNextNode(long id
);
121 virtual long GetNodeParent(long id
);
122 virtual long GetNodeX(long id
);
123 virtual long GetNodeY(long id
);
124 virtual void SetNodeX(long id
, long x
);
125 virtual void SetNodeY(long id
, long y
);
126 virtual void SetNodeName(long id
, const wxString
& name
);
127 virtual wxString
GetNodeName(long id
);
128 virtual void ActivateNode(long id
, bool active
);
129 virtual bool NodeActive(long id
);
130 virtual void SetClientData(long id
, long clientData
);
131 virtual long GetClientData(long id
) const;
133 virtual long AddChild(const wxString
& name
, const wxString
& parent
= "");
134 virtual long AddChild(const wxString
& name
, long parent
);
135 virtual long NameToId(const wxString
& name
);
139 wxStoredNode
* m_nodes
;
144 // For backward compatibility
145 #define wxStoredTree wxTreeLayoutStored