]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/treelay.h
Unicode compilation fix.
[wxWidgets.git] / include / wx / generic / 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/string.h"
27
28 #if wxUSE_TREELAYOUT
29
30 class WXDLLEXPORT wxTreeLayout: public wxObject
31 {
32 public:
33 wxTreeLayout();
34 virtual ~wxTreeLayout() { }
35
36 // Redefine these
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;
46
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);
57
58 // Don't redefine
59 virtual void DoLayout(wxDC& dc, long topNode = -1);
60
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; }
70
71 inline bool GetOrientation(void) const { return m_orientation; }
72 inline void SetOrientation(bool orient) { m_orientation = orient; }
73
74 private:
75 void CalcLayout(long node_id, int level, wxDC& dc);
76
77 protected:
78 long m_parentNode;
79 long m_lastY;
80 long m_lastX;
81 long m_xSpacing;
82 long m_ySpacing;
83 long m_topMargin;
84 long m_leftMargin;
85 bool m_orientation; // TRUE for top-to-bottom, FALSE for left-to-right
86
87 private:
88 DECLARE_ABSTRACT_CLASS(wxTreeLayout)
89 };
90
91 class WXDLLEXPORT wxStoredNode
92 {
93 public:
94 wxString m_name;
95 long m_x, m_y;
96 long m_parentId;
97 bool m_active;
98 long m_clientData;
99 };
100
101 /*
102 * A version of wxTreeLayout with storage for nodes
103 */
104
105 class WXDLLEXPORT wxTreeLayoutStored: public wxTreeLayout
106 {
107 public:
108 wxTreeLayoutStored(int noNodes = 200);
109 virtual ~wxTreeLayoutStored(void);
110 void Initialize(int n);
111
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; };
116
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;
130
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);
134
135 // Data members
136 private:
137 wxStoredNode* m_nodes;
138 int m_num;
139 int m_maxNodes;
140
141 private:
142 DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored)
143 };
144
145 // For backward compatibility
146 #define wxStoredTree wxTreeLayoutStored
147
148 #endif
149 // wxUSE_TREELAYOUT
150
151 #endif
152 // _WX_TREELAY_H_
153