]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/treelay.h
forgotten method declaration
[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
15#ifdef __GNUG__
16#pragma interface "wxtree.h"
17#endif
18
5438a566
VZ
19#ifndef WX_PRECOMP
20#include <wx/object.h>
21class wxList;
22class wxDC;
23class wxMouseEvent;
24#endif
25
babc9758
JS
26#include <wx/string.h>
27
d8eccede
GD
28#if wxUSE_TREELAYOUT
29
babc9758
JS
30class WXDLLEXPORT wxTreeLayout: public wxObject
31{
32 DECLARE_ABSTRACT_CLASS(wxTreeLayout)
33
34public:
35 wxTreeLayout();
d8eccede 36 virtual ~wxTreeLayout() { }
33ac7e6f 37
babc9758
JS
38 // Redefine these
39 virtual void GetChildren(long id, wxList& list) = 0;
40 virtual long GetNextNode(long id) = 0;
41 virtual long GetNodeParent(long id) = 0;
42 virtual long GetNodeX(long id) = 0;
43 virtual long GetNodeY(long id) = 0;
44 virtual void SetNodeX(long id, long x) = 0;
45 virtual void SetNodeY(long id, long y) = 0;
46 virtual void ActivateNode(long id, bool active) = 0;
47 virtual bool NodeActive(long id) = 0;
33ac7e6f 48
babc9758
JS
49 // Optional redefinition
50 void Initialize(void);
33ac7e6f
KB
51 inline virtual void SetNodeName(long WXUNUSED(id), const wxString& WXUNUSED(name)) {}
52 inline virtual wxString GetNodeName(long WXUNUSED(id)) { return wxString(""); }
babc9758
JS
53 virtual void GetNodeSize(long id, long *x, long *y, wxDC& dc);
54 virtual void Draw(wxDC& dc);
55 virtual void DrawNodes(wxDC& dc);
56 virtual void DrawBranches(wxDC& dc);
57 virtual void DrawNode(long id, wxDC& dc);
58 virtual void DrawBranch(long from, long to, wxDC& dc);
33ac7e6f 59
babc9758
JS
60 // Don't redefine
61 virtual void DoLayout(wxDC& dc, long topNode = -1);
33ac7e6f 62
babc9758
JS
63 // Accessors -- don't redefine
64 inline void SetTopNode(long id) { m_parentNode = id; }
65 inline long GetTopNode(void) const { return m_parentNode; }
66 inline void SetSpacing(long x, long y) { m_xSpacing = x; m_ySpacing = y; }
67 inline long GetXSpacing(void) const { return m_xSpacing; }
68 inline long GetYSpacing(void) const { return m_ySpacing; }
69 inline void SetMargins(long x, long y) { m_leftMargin = x; m_topMargin = y; }
70 inline long GetTopMargin(void) const { return m_topMargin; }
71 inline long GetLeftMargin(void) const { return m_leftMargin; }
33ac7e6f 72
babc9758 73 inline bool GetOrientation(void) const { return m_orientation; }
f6bcfd97 74 inline void SetOrientation(bool orient) { m_orientation = orient; }
33ac7e6f 75
babc9758
JS
76private:
77 void CalcLayout(long node_id, int level, wxDC& dc);
33ac7e6f 78
babc9758 79 // Members
33ac7e6f 80
babc9758
JS
81protected:
82 long m_parentNode;
83 long m_lastY;
84 long m_lastX;
85 long m_xSpacing;
86 long m_ySpacing;
87 long m_topMargin;
88 long m_leftMargin;
89 bool m_orientation; // TRUE for top-to-bottom, FALSE for left-to-right
90};
91
92class WXDLLEXPORT wxStoredNode
93{
94public:
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
94799627 106class WXDLLEXPORT wxTreeLayoutStored: public wxTreeLayout
babc9758 107{
94799627 108 DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored)
babc9758 109public:
94799627 110 wxTreeLayoutStored(int noNodes = 200);
d8eccede 111 virtual ~wxTreeLayoutStored(void);
babc9758 112 void Initialize(int n);
33ac7e6f 113
babc9758
JS
114 wxString HitTest(wxMouseEvent& event, wxDC& dc);
115 wxStoredNode* GetNode(long id) const;
116 inline int GetNumNodes() const { return m_maxNodes; };
117 inline int GetNodeCount() const { return m_num; };
33ac7e6f 118
babc9758
JS
119 virtual void GetChildren(long id, wxList& list);
120 virtual long GetNextNode(long id);
121 virtual long GetNodeParent(long id);
122 virtual long GetNodeX(long id);
123 virtual long GetNodeY(long id);
124 virtual void SetNodeX(long id, long x);
125 virtual void SetNodeY(long id, long y);
126 virtual void SetNodeName(long id, const wxString& name);
127 virtual wxString GetNodeName(long id);
128 virtual void ActivateNode(long id, bool active);
129 virtual bool NodeActive(long id);
130 virtual void SetClientData(long id, long clientData);
131 virtual long GetClientData(long id) const;
33ac7e6f 132
babc9758
JS
133 virtual long AddChild(const wxString& name, const wxString& parent = "");
134 virtual long NameToId(const wxString& name);
33ac7e6f 135
babc9758
JS
136 // Data members
137private:
138 wxStoredNode* m_nodes;
139 int m_num;
140 int m_maxNodes;
141};
142
143// For backward compatibility
94799627 144#define wxStoredTree wxTreeLayoutStored
babc9758 145
d8eccede
GD
146#endif
147 // wxUSE_TREELAYOUT
148
babc9758
JS
149#endif
150 // _WX_TREELAY_H_
33ac7e6f 151