]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/treelay.h
changed wxUSE_DRAGIMAG to wxUSE_DRAGIMAGE and use it everywhere now
[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
19#include <wx/string.h>
20
21class WXDLLEXPORT wxTreeLayout: public wxObject
22{
23 DECLARE_ABSTRACT_CLASS(wxTreeLayout)
24
25public:
26 wxTreeLayout();
33ac7e6f 27
babc9758
JS
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;
33ac7e6f 38
babc9758
JS
39 // Optional redefinition
40 void Initialize(void);
33ac7e6f
KB
41 inline virtual void SetNodeName(long WXUNUSED(id), const wxString& WXUNUSED(name)) {}
42 inline virtual wxString GetNodeName(long WXUNUSED(id)) { return wxString(""); }
babc9758
JS
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);
33ac7e6f 49
babc9758
JS
50 // Don't redefine
51 virtual void DoLayout(wxDC& dc, long topNode = -1);
33ac7e6f 52
babc9758
JS
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; }
33ac7e6f 62
babc9758 63 inline bool GetOrientation(void) const { return m_orientation; }
f6bcfd97 64 inline void SetOrientation(bool orient) { m_orientation = orient; }
33ac7e6f 65
babc9758
JS
66private:
67 void CalcLayout(long node_id, int level, wxDC& dc);
33ac7e6f 68
babc9758 69 // Members
33ac7e6f 70
babc9758
JS
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
94799627 96class WXDLLEXPORT wxTreeLayoutStored: public wxTreeLayout
babc9758 97{
94799627 98 DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored)
babc9758 99public:
94799627
JS
100 wxTreeLayoutStored(int noNodes = 200);
101 ~wxTreeLayoutStored(void);
babc9758 102 void Initialize(int n);
33ac7e6f 103
babc9758
JS
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; };
33ac7e6f 108
babc9758
JS
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;
33ac7e6f 122
babc9758
JS
123 virtual long AddChild(const wxString& name, const wxString& parent = "");
124 virtual long NameToId(const wxString& name);
33ac7e6f 125
babc9758
JS
126 // Data members
127private:
128 wxStoredNode* m_nodes;
129 int m_num;
130 int m_maxNodes;
131};
132
133// For backward compatibility
94799627 134#define wxStoredTree wxTreeLayoutStored
babc9758
JS
135
136#endif
137 // _WX_TREELAY_H_
33ac7e6f 138