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 #include "wx/object.h"
22 #include "wx/deprecated/setup.h"
23 #include "wx/string.h"
27 class WXDLLIMPEXP_DEPRECATED wxTreeLayout
: public wxObject
31 virtual ~wxTreeLayout() { }
34 virtual void GetChildren(long id
, wxList
& list
) = 0;
35 virtual long GetNextNode(long id
) = 0;
36 virtual long GetNodeParent(long id
) = 0;
37 virtual long GetNodeX(long id
) = 0;
38 virtual long GetNodeY(long id
) = 0;
39 virtual void SetNodeX(long id
, long x
) = 0;
40 virtual void SetNodeY(long id
, long y
) = 0;
41 virtual void ActivateNode(long id
, bool active
) = 0;
42 virtual bool NodeActive(long id
) = 0;
44 // Optional redefinition
45 void Initialize(void);
46 inline virtual void SetNodeName(long WXUNUSED(id
), const wxString
& WXUNUSED(name
)) {}
47 inline virtual wxString
GetNodeName(long WXUNUSED(id
)) { return wxString(wxT("")); }
48 virtual void GetNodeSize(long id
, long *x
, long *y
, wxDC
& dc
);
49 virtual void Draw(wxDC
& dc
);
50 virtual void DrawNodes(wxDC
& dc
);
51 virtual void DrawBranches(wxDC
& dc
);
52 virtual void DrawNode(long id
, wxDC
& dc
);
53 virtual void DrawBranch(long from
, long to
, wxDC
& dc
);
56 virtual void DoLayout(wxDC
& dc
, long topNode
= -1);
58 // Accessors -- don't redefine
59 inline void SetTopNode(long id
) { m_parentNode
= id
; }
60 inline long GetTopNode(void) const { return m_parentNode
; }
61 inline void SetSpacing(long x
, long y
) { m_xSpacing
= x
; m_ySpacing
= y
; }
62 inline long GetXSpacing(void) const { return m_xSpacing
; }
63 inline long GetYSpacing(void) const { return m_ySpacing
; }
64 inline void SetMargins(long x
, long y
) { m_leftMargin
= x
; m_topMargin
= y
; }
65 inline long GetTopMargin(void) const { return m_topMargin
; }
66 inline long GetLeftMargin(void) const { return m_leftMargin
; }
68 inline bool GetOrientation(void) const { return m_orientation
; }
69 inline void SetOrientation(bool orient
) { m_orientation
= orient
; }
72 void CalcLayout(long node_id
, int level
, wxDC
& dc
);
82 bool m_orientation
; // true for top-to-bottom, false for left-to-right
85 DECLARE_ABSTRACT_CLASS(wxTreeLayout
)
88 class WXDLLIMPEXP_DEPRECATED wxStoredNode
99 * A version of wxTreeLayout with storage for nodes
102 class WXDLLIMPEXP_DEPRECATED wxTreeLayoutStored
: public wxTreeLayout
105 wxTreeLayoutStored(int noNodes
= 200);
106 virtual ~wxTreeLayoutStored(void);
107 void Initialize(int n
);
109 wxString
HitTest(wxMouseEvent
& event
, wxDC
& dc
);
110 wxStoredNode
* GetNode(long id
) const;
111 inline int GetNumNodes() const { return m_maxNodes
; };
112 inline int GetNodeCount() const { return m_num
; };
114 virtual void GetChildren(long id
, wxList
& list
);
115 virtual long GetNextNode(long id
);
116 virtual long GetNodeParent(long id
);
117 virtual long GetNodeX(long id
);
118 virtual long GetNodeY(long id
);
119 virtual void SetNodeX(long id
, long x
);
120 virtual void SetNodeY(long id
, long y
);
121 virtual void SetNodeName(long id
, const wxString
& name
);
122 virtual wxString
GetNodeName(long id
);
123 virtual void ActivateNode(long id
, bool active
);
124 virtual bool NodeActive(long id
);
125 virtual void SetClientData(long id
, long clientData
);
126 virtual long GetClientData(long id
) const;
128 virtual long AddChild(const wxString
& name
, const wxString
& parent
= wxT(""));
129 virtual long AddChild(const wxString
& name
, long parent
);
130 virtual long NameToId(const wxString
& name
);
134 wxStoredNode
* m_nodes
;
139 DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored
)
140 DECLARE_NO_COPY_CLASS(wxTreeLayoutStored
)
143 // For backward compatibility
144 #define wxStoredTree wxTreeLayoutStored