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