]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/gizmos/splittree.h
Changes needed to solve wxPython's OOR problem for the wxOGL shapes.
[wxWidgets.git] / contrib / include / wx / gizmos / splittree.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: splittree.h
3 // Purpose: Classes to achieve a remotely-scrolled tree in a splitter
4 // window that can be scrolled by a scrolled window higher in the
5 // hierarchy
6 // Author: Julian Smart
7 // Modified by:
8 // Created: 8/7/2000
9 // RCS-ID: $Id$
10 // Copyright: (c) Julian Smart
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
13
14 #ifndef _WX_SPLITTREE_H_
15 #define _WX_SPLITTREE_H_
16
17 #ifdef __GNUG__
18 #pragma interface "splittree.h"
19 #endif
20
21 #ifdef GIZMOISDLL
22 #define GIZMODLLEXPORT WXDLLEXPORT
23 #else
24 #define GIZMODLLEXPORT
25 #endif
26
27 // Set this to 1 to use generic tree control (doesn't yet work properly)
28 #define USE_GENERIC_TREECTRL 0
29
30 #include "wx/wx.h"
31 #include "wx/treectrl.h"
32 #include "wx/splitter.h"
33 #include "wx/scrolwin.h"
34
35 #if USE_GENERIC_TREECTRL
36 #include "wx/generic/treectlg.h"
37 #ifndef wxTreeCtrl
38 #define wxTreeCtrl wxGenericTreeCtrl
39 #define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
40 #endif
41 #endif
42
43 class wxRemotelyScrolledTreeCtrl;
44 class wxThinSplitterWindow;
45 class wxSplitterScrolledWindow;
46
47 /*
48 * wxRemotelyScrolledTreeCtrl
49 *
50 * This tree control disables its vertical scrollbar and catches scroll
51 * events passed by a scrolled window higher in the hierarchy.
52 * It also updates the scrolled window vertical scrollbar as appropriate.
53 */
54
55 class GIZMODLLEXPORT wxRemotelyScrolledTreeCtrl: public wxTreeCtrl
56 {
57 DECLARE_CLASS(wxRemotelyScrolledTreeCtrl)
58 public:
59 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
60 const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS);
61 ~wxRemotelyScrolledTreeCtrl();
62
63 //// Events
64 void OnSize(wxSizeEvent& event);
65 void OnExpand(wxTreeEvent& event);
66 void OnScroll(wxScrollWinEvent& event);
67
68 //// Overrides
69 // Override this in case we're using the generic tree control.
70 // Calls to this should disable the vertical scrollbar.
71
72 // Number of pixels per user unit (0 or -1 for no scrollbar)
73 // Length of virtual canvas in user units
74 // Length of page in user units
75 virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
76 int noUnitsX, int noUnitsY,
77 int xPos = 0, int yPos = 0,
78 bool noRefresh = FALSE );
79
80 // In case we're using the generic tree control.
81 // Get the view start
82 virtual void GetViewStart(int *x, int *y) const;
83
84 // In case we're using the generic tree control.
85 virtual void PrepareDC(wxDC& dc);
86
87 // In case we're using the generic tree control.
88 virtual int GetScrollPos(int orient) const;
89
90 //// Helpers
91 void HideVScrollbar();
92
93 // Calculate the tree overall size so we can set the scrollbar
94 // correctly
95 void CalcTreeSize(wxRect& rect);
96 void CalcTreeSize(const wxTreeItemId& id, wxRect& rect);
97
98 // Adjust the containing wxScrolledWindow's scrollbars appropriately
99 void AdjustRemoteScrollbars();
100
101 // Find the scrolled window that contains this control
102 wxScrolledWindow* GetScrolledWindow() const;
103
104 // Scroll to the given line (in scroll units where each unit is
105 // the height of an item)
106 void ScrollToLine(int posHoriz, int posVert);
107
108 //// Accessors
109
110 // The companion window is one which will get notified when certain
111 // events happen such as node expansion
112 void SetCompanionWindow(wxWindow* companion) { m_companionWindow = companion; }
113 wxWindow* GetCompanionWindow() const { return m_companionWindow; }
114
115
116 DECLARE_EVENT_TABLE()
117 protected:
118 wxWindow* m_companionWindow;
119 };
120
121 /*
122 * wxTreeCompanionWindow
123 *
124 * A window displaying values associated with tree control items.
125 */
126
127 class GIZMODLLEXPORT wxTreeCompanionWindow: public wxWindow
128 {
129 public:
130 DECLARE_CLASS(wxTreeCompanionWindow)
131
132 wxTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
133 const wxPoint& pos = wxDefaultPosition,
134 const wxSize& sz = wxDefaultSize,
135 long style = 0);
136
137 //// Overrides
138 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect);
139
140 //// Events
141 void OnPaint(wxPaintEvent& event);
142 void OnScroll(wxScrollWinEvent& event);
143 void OnExpand(wxTreeEvent& event);
144
145 //// Operations
146
147 //// Accessors
148 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; };
149 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl) { m_treeCtrl = treeCtrl; }
150
151 //// Data members
152 protected:
153 wxRemotelyScrolledTreeCtrl* m_treeCtrl;
154
155 DECLARE_EVENT_TABLE()
156 };
157
158
159 /*
160 * wxThinSplitterWindow
161 *
162 * Implements a splitter with a less obvious sash
163 * than the usual one.
164 */
165
166 class GIZMODLLEXPORT wxThinSplitterWindow: public wxSplitterWindow
167 {
168 public:
169 DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow)
170
171 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
172 const wxPoint& pos = wxDefaultPosition,
173 const wxSize& sz = wxDefaultSize,
174 long style = wxSP_3D | wxCLIP_CHILDREN);
175
176 //// Overrides
177
178 void SizeWindows();
179 // Tests for x, y over sash. Overriding this allows us to increase
180 // the tolerance.
181 bool SashHitTest(int x, int y, int tolerance = 2);
182 void DrawSash(wxDC& dc);
183
184 //// Events
185
186 void OnSize(wxSizeEvent& event);
187
188 //// Operations
189
190 //// Accessors
191
192 //// Data members
193 protected:
194 DECLARE_EVENT_TABLE()
195 };
196
197 /*
198 * wxSplitterScrolledWindow
199 *
200 * This scrolled window is aware of the fact that one of its
201 * children is a splitter window. It passes on its scroll events
202 * (after some processing) to both splitter children for them
203 * scroll appropriately.
204 */
205
206 class GIZMODLLEXPORT wxSplitterScrolledWindow: public wxScrolledWindow
207 {
208 public:
209 DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow)
210
211 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
212 const wxPoint& pos = wxDefaultPosition,
213 const wxSize& sz = wxDefaultSize,
214 long style = 0);
215
216 //// Overrides
217
218 //// Events
219
220 void OnScroll(wxScrollWinEvent& event);
221 void OnSize(wxSizeEvent& event);
222
223 //// Operations
224
225 //// Accessors
226
227 //// Data members
228 public:
229 DECLARE_EVENT_TABLE()
230 };
231
232 #endif
233 // _SPLITTREE_H_