]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/deprecated/treelay.h
a87818356e38c179ecea3fa59f9b02aaebecd1f5
[wxWidgets.git] / contrib / include / wx / deprecated / treelay.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: treelay.h
3 // Purpose: wxTreeLayout class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 7/4/98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TREELAY_H_
13 #define _WX_TREELAY_H_
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "wxtree.h"
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/object.h"
21 class wxList;
22 class wxDC;
23 class wxMouseEvent;
24 #endif
25
26 #include "wx/deprecated/setup.h"
27 #include "wx/string.h"
28
29 #if wxUSE_TREELAYOUT
30
31 class WXDLLEXPORT wxTreeLayout: public wxObject
32 {
33 public:
34 wxTreeLayout();
35 virtual ~wxTreeLayout() { }
36
37 // Redefine these
38 virtual void GetChildren(long id, wxList& list) = 0;
39 virtual long GetNextNode(long id) = 0;
40 virtual long GetNodeParent(long id) = 0;
41 virtual long GetNodeX(long id) = 0;
42 virtual long GetNodeY(long id) = 0;
43 virtual void SetNodeX(long id, long x) = 0;
44 virtual void SetNodeY(long id, long y) = 0;
45 virtual void ActivateNode(long id, bool active) = 0;
46 virtual bool NodeActive(long id) = 0;
47
48 // Optional redefinition
49 void Initialize(void);
50 inline virtual void SetNodeName(long WXUNUSED(id), const wxString& WXUNUSED(name)) {}
51 inline virtual wxString GetNodeName(long WXUNUSED(id)) { return wxString(wxT("")); }
52 virtual void GetNodeSize(long id, long *x, long *y, wxDC& dc);
53 virtual void Draw(wxDC& dc);
54 virtual void DrawNodes(wxDC& dc);
55 virtual void DrawBranches(wxDC& dc);
56 virtual void DrawNode(long id, wxDC& dc);
57 virtual void DrawBranch(long from, long to, wxDC& dc);
58
59 // Don't redefine
60 virtual void DoLayout(wxDC& dc, long topNode = -1);
61
62 // Accessors -- don't redefine
63 inline void SetTopNode(long id) { m_parentNode = id; }
64 inline long GetTopNode(void) const { return m_parentNode; }
65 inline void SetSpacing(long x, long y) { m_xSpacing = x; m_ySpacing = y; }
66 inline long GetXSpacing(void) const { return m_xSpacing; }
67 inline long GetYSpacing(void) const { return m_ySpacing; }
68 inline void SetMargins(long x, long y) { m_leftMargin = x; m_topMargin = y; }
69 inline long GetTopMargin(void) const { return m_topMargin; }
70 inline long GetLeftMargin(void) const { return m_leftMargin; }
71
72 inline bool GetOrientation(void) const { return m_orientation; }
73 inline void SetOrientation(bool orient) { m_orientation = orient; }
74
75 private:
76 void CalcLayout(long node_id, int level, wxDC& dc);
77
78 protected:
79 long m_parentNode;
80 long m_lastY;
81 long m_lastX;
82 long m_xSpacing;
83 long m_ySpacing;
84 long m_topMargin;
85 long m_leftMargin;
86 bool m_orientation; // TRUE for top-to-bottom, FALSE for left-to-right
87
88 private:
89 DECLARE_ABSTRACT_CLASS(wxTreeLayout)
90 };
91
92 class WXDLLEXPORT wxStoredNode
93 {
94 public:
95 wxString m_name;
96 long m_x, m_y;
97 long m_parentId;
98 bool m_active;
99 long m_clientData;
100 };
101
102 /*
103 * A version of wxTreeLayout with storage for nodes
104 */
105
106 class WXDLLEXPORT wxTreeLayoutStored: public wxTreeLayout
107 {
108 public:
109 wxTreeLayoutStored(int noNodes = 200);
110 virtual ~wxTreeLayoutStored(void);
111 void Initialize(int n);
112
113 wxString HitTest(wxMouseEvent& event, wxDC& dc);
114 wxStoredNode* GetNode(long id) const;
115 inline int GetNumNodes() const { return m_maxNodes; };
116 inline int GetNodeCount() const { return m_num; };
117
118 virtual void GetChildren(long id, wxList& list);
119 virtual long GetNextNode(long id);
120 virtual long GetNodeParent(long id);
121 virtual long GetNodeX(long id);
122 virtual long GetNodeY(long id);
123 virtual void SetNodeX(long id, long x);
124 virtual void SetNodeY(long id, long y);
125 virtual void SetNodeName(long id, const wxString& name);
126 virtual wxString GetNodeName(long id);
127 virtual void ActivateNode(long id, bool active);
128 virtual bool NodeActive(long id);
129 virtual void SetClientData(long id, long clientData);
130 virtual long GetClientData(long id) const;
131
132 virtual long AddChild(const wxString& name, const wxString& parent = wxT(""));
133 virtual long AddChild(const wxString& name, long parent);
134 virtual long NameToId(const wxString& name);
135
136 // Data members
137 private:
138 wxStoredNode* m_nodes;
139 int m_num;
140 int m_maxNodes;
141
142 private:
143 DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored)
144 DECLARE_NO_COPY_CLASS(wxTreeLayoutStored)
145 };
146
147 // For backward compatibility
148 #define wxStoredTree wxTreeLayoutStored
149
150 #endif
151 // wxUSE_TREELAYOUT
152
153 #endif
154 // _WX_TREELAY_H_
155