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"
19 #include <wx/string.h>
21 class WXDLLEXPORT wxTreeLayout
: public wxObject
23 DECLARE_ABSTRACT_CLASS(wxTreeLayout
)
29 virtual void GetChildren(long id
, wxList
& list
) = 0;
30 virtual long GetNextNode(long id
) = 0;
31 virtual long GetNodeParent(long id
) = 0;
32 virtual long GetNodeX(long id
) = 0;
33 virtual long GetNodeY(long id
) = 0;
34 virtual void SetNodeX(long id
, long x
) = 0;
35 virtual void SetNodeY(long id
, long y
) = 0;
36 virtual void ActivateNode(long id
, bool active
) = 0;
37 virtual bool NodeActive(long id
) = 0;
39 // Optional redefinition
40 void Initialize(void);
41 inline virtual void SetNodeName(long WXUNUSED(id
), const wxString
& WXUNUSED(name
)) {}
42 inline virtual wxString
GetNodeName(long WXUNUSED(id
)) { return wxString(""); }
43 virtual void GetNodeSize(long id
, long *x
, long *y
, wxDC
& dc
);
44 virtual void Draw(wxDC
& dc
);
45 virtual void DrawNodes(wxDC
& dc
);
46 virtual void DrawBranches(wxDC
& dc
);
47 virtual void DrawNode(long id
, wxDC
& dc
);
48 virtual void DrawBranch(long from
, long to
, wxDC
& dc
);
51 virtual void DoLayout(wxDC
& dc
, long topNode
= -1);
53 // Accessors -- don't redefine
54 inline void SetTopNode(long id
) { m_parentNode
= id
; }
55 inline long GetTopNode(void) const { return m_parentNode
; }
56 inline void SetSpacing(long x
, long y
) { m_xSpacing
= x
; m_ySpacing
= y
; }
57 inline long GetXSpacing(void) const { return m_xSpacing
; }
58 inline long GetYSpacing(void) const { return m_ySpacing
; }
59 inline void SetMargins(long x
, long y
) { m_leftMargin
= x
; m_topMargin
= y
; }
60 inline long GetTopMargin(void) const { return m_topMargin
; }
61 inline long GetLeftMargin(void) const { return m_leftMargin
; }
63 inline bool GetOrientation(void) const { return m_orientation
; }
64 inline void SetOrientation(bool orient
) { m_orientation
= orient
; }
67 void CalcLayout(long node_id
, int level
, wxDC
& dc
);
79 bool m_orientation
; // TRUE for top-to-bottom, FALSE for left-to-right
82 class WXDLLEXPORT wxStoredNode
93 * A version of wxTreeLayout with storage for nodes
96 class WXDLLEXPORT wxTreeLayoutStored
: public wxTreeLayout
98 DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored
)
100 wxTreeLayoutStored(int noNodes
= 200);
101 ~wxTreeLayoutStored(void);
102 void Initialize(int n
);
104 wxString
HitTest(wxMouseEvent
& event
, wxDC
& dc
);
105 wxStoredNode
* GetNode(long id
) const;
106 inline int GetNumNodes() const { return m_maxNodes
; };
107 inline int GetNodeCount() const { return m_num
; };
109 virtual void GetChildren(long id
, wxList
& list
);
110 virtual long GetNextNode(long id
);
111 virtual long GetNodeParent(long id
);
112 virtual long GetNodeX(long id
);
113 virtual long GetNodeY(long id
);
114 virtual void SetNodeX(long id
, long x
);
115 virtual void SetNodeY(long id
, long y
);
116 virtual void SetNodeName(long id
, const wxString
& name
);
117 virtual wxString
GetNodeName(long id
);
118 virtual void ActivateNode(long id
, bool active
);
119 virtual bool NodeActive(long id
);
120 virtual void SetClientData(long id
, long clientData
);
121 virtual long GetClientData(long id
) const;
123 virtual long AddChild(const wxString
& name
, const wxString
& parent
= "");
124 virtual long NameToId(const wxString
& name
);
128 wxStoredNode
* m_nodes
;
133 // For backward compatibility
134 #define wxStoredTree wxTreeLayoutStored