]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/treelay.h
added MSLU reference to wxUSE_UNICODE
[wxWidgets.git] / include / wx / generic / treelay.h
CommitLineData
babc9758
JS
1///////////////////////////////////////////////////////////////////////////////
2// Name: treelay.h
3// Purpose: wxTreeLayout class
4// Author: Julian Smart
33ac7e6f 5// Modified by:
babc9758
JS
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
af49c4b8 15#if defined(__GNUG__) && !defined(__APPLE__)
babc9758
JS
16#pragma interface "wxtree.h"
17#endif
18
5438a566 19#ifndef WX_PRECOMP
8beeef5f 20#include "wx/object.h"
5438a566
VZ
21class wxList;
22class wxDC;
23class wxMouseEvent;
24#endif
25
8beeef5f 26#include "wx/string.h"
babc9758 27
d8eccede
GD
28#if wxUSE_TREELAYOUT
29
babc9758
JS
30class WXDLLEXPORT wxTreeLayout: public wxObject
31{
babc9758
JS
32public:
33 wxTreeLayout();
d8eccede 34 virtual ~wxTreeLayout() { }
33ac7e6f 35
babc9758
JS
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;
33ac7e6f 46
babc9758
JS
47 // Optional redefinition
48 void Initialize(void);
33ac7e6f 49 inline virtual void SetNodeName(long WXUNUSED(id), const wxString& WXUNUSED(name)) {}
2b5f62a0 50 inline virtual wxString GetNodeName(long WXUNUSED(id)) { return wxString(wxT("")); }
babc9758
JS
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);
33ac7e6f 57
babc9758
JS
58 // Don't redefine
59 virtual void DoLayout(wxDC& dc, long topNode = -1);
33ac7e6f 60
babc9758
JS
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; }
33ac7e6f 70
babc9758 71 inline bool GetOrientation(void) const { return m_orientation; }
f6bcfd97 72 inline void SetOrientation(bool orient) { m_orientation = orient; }
33ac7e6f 73
babc9758
JS
74private:
75 void CalcLayout(long node_id, int level, wxDC& dc);
33ac7e6f 76
babc9758
JS
77protected:
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
2b5f62a0
VZ
86
87private:
88 DECLARE_ABSTRACT_CLASS(wxTreeLayout)
babc9758
JS
89};
90
91class WXDLLEXPORT wxStoredNode
92{
93public:
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
94799627 105class WXDLLEXPORT wxTreeLayoutStored: public wxTreeLayout
babc9758 106{
babc9758 107public:
94799627 108 wxTreeLayoutStored(int noNodes = 200);
d8eccede 109 virtual ~wxTreeLayoutStored(void);
babc9758 110 void Initialize(int n);
33ac7e6f 111
babc9758
JS
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; };
33ac7e6f 116
babc9758
JS
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;
33ac7e6f 130
2b5f62a0 131 virtual long AddChild(const wxString& name, const wxString& parent = wxT(""));
c42a9182 132 virtual long AddChild(const wxString& name, long parent);
babc9758 133 virtual long NameToId(const wxString& name);
33ac7e6f 134
babc9758
JS
135 // Data members
136private:
137 wxStoredNode* m_nodes;
138 int m_num;
139 int m_maxNodes;
2b5f62a0
VZ
140
141private:
142 DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored)
22f3361e 143 DECLARE_NO_COPY_CLASS(wxTreeLayoutStored)
babc9758
JS
144};
145
146// For backward compatibility
94799627 147#define wxStoredTree wxTreeLayoutStored
babc9758 148
d8eccede
GD
149#endif
150 // wxUSE_TREELAYOUT
151
babc9758
JS
152#endif
153 // _WX_TREELAY_H_
33ac7e6f 154