]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/treelay.h
Removed cacheing option
[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
28class WXDLLEXPORT wxTreeLayout: public wxObject
29{
30 DECLARE_ABSTRACT_CLASS(wxTreeLayout)
31
32public:
33 wxTreeLayout();
33ac7e6f 34
babc9758
JS
35 // Redefine these
36 virtual void GetChildren(long id, wxList& list) = 0;
37 virtual long GetNextNode(long id) = 0;
38 virtual long GetNodeParent(long id) = 0;
39 virtual long GetNodeX(long id) = 0;
40 virtual long GetNodeY(long id) = 0;
41 virtual void SetNodeX(long id, long x) = 0;
42 virtual void SetNodeY(long id, long y) = 0;
43 virtual void ActivateNode(long id, bool active) = 0;
44 virtual bool NodeActive(long id) = 0;
33ac7e6f 45
babc9758
JS
46 // Optional redefinition
47 void Initialize(void);
33ac7e6f
KB
48 inline virtual void SetNodeName(long WXUNUSED(id), const wxString& WXUNUSED(name)) {}
49 inline virtual wxString GetNodeName(long WXUNUSED(id)) { return wxString(""); }
babc9758
JS
50 virtual void GetNodeSize(long id, long *x, long *y, wxDC& dc);
51 virtual void Draw(wxDC& dc);
52 virtual void DrawNodes(wxDC& dc);
53 virtual void DrawBranches(wxDC& dc);
54 virtual void DrawNode(long id, wxDC& dc);
55 virtual void DrawBranch(long from, long to, wxDC& dc);
33ac7e6f 56
babc9758
JS
57 // Don't redefine
58 virtual void DoLayout(wxDC& dc, long topNode = -1);
33ac7e6f 59
babc9758
JS
60 // Accessors -- don't redefine
61 inline void SetTopNode(long id) { m_parentNode = id; }
62 inline long GetTopNode(void) const { return m_parentNode; }
63 inline void SetSpacing(long x, long y) { m_xSpacing = x; m_ySpacing = y; }
64 inline long GetXSpacing(void) const { return m_xSpacing; }
65 inline long GetYSpacing(void) const { return m_ySpacing; }
66 inline void SetMargins(long x, long y) { m_leftMargin = x; m_topMargin = y; }
67 inline long GetTopMargin(void) const { return m_topMargin; }
68 inline long GetLeftMargin(void) const { return m_leftMargin; }
33ac7e6f 69
babc9758 70 inline bool GetOrientation(void) const { return m_orientation; }
f6bcfd97 71 inline void SetOrientation(bool orient) { m_orientation = orient; }
33ac7e6f 72
babc9758
JS
73private:
74 void CalcLayout(long node_id, int level, wxDC& dc);
33ac7e6f 75
babc9758 76 // Members
33ac7e6f 77
babc9758
JS
78protected:
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
89class WXDLLEXPORT wxStoredNode
90{
91public:
92 wxString m_name;
93 long m_x, m_y;
94 long m_parentId;
95 bool m_active;
96 long m_clientData;
97};
98
99/*
100 * A version of wxTreeLayout with storage for nodes
101 */
102
94799627 103class WXDLLEXPORT wxTreeLayoutStored: public wxTreeLayout
babc9758 104{
94799627 105 DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored)
babc9758 106public:
94799627
JS
107 wxTreeLayoutStored(int noNodes = 200);
108 ~wxTreeLayoutStored(void);
babc9758 109 void Initialize(int n);
33ac7e6f 110
babc9758
JS
111 wxString HitTest(wxMouseEvent& event, wxDC& dc);
112 wxStoredNode* GetNode(long id) const;
113 inline int GetNumNodes() const { return m_maxNodes; };
114 inline int GetNodeCount() const { return m_num; };
33ac7e6f 115
babc9758
JS
116 virtual void GetChildren(long id, wxList& list);
117 virtual long GetNextNode(long id);
118 virtual long GetNodeParent(long id);
119 virtual long GetNodeX(long id);
120 virtual long GetNodeY(long id);
121 virtual void SetNodeX(long id, long x);
122 virtual void SetNodeY(long id, long y);
123 virtual void SetNodeName(long id, const wxString& name);
124 virtual wxString GetNodeName(long id);
125 virtual void ActivateNode(long id, bool active);
126 virtual bool NodeActive(long id);
127 virtual void SetClientData(long id, long clientData);
128 virtual long GetClientData(long id) const;
33ac7e6f 129
babc9758
JS
130 virtual long AddChild(const wxString& name, const wxString& parent = "");
131 virtual long NameToId(const wxString& name);
33ac7e6f 132
babc9758
JS
133 // Data members
134private:
135 wxStoredNode* m_nodes;
136 int m_num;
137 int m_maxNodes;
138};
139
140// For backward compatibility
94799627 141#define wxStoredTree wxTreeLayoutStored
babc9758
JS
142
143#endif
144 // _WX_TREELAY_H_
33ac7e6f 145