]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/gizmos/splittree.h
fix for stupid segfault
[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 void OnPaint(wxPaintEvent& event);
68
69 //// Overrides
70 // Override this in case we're using the generic tree control.
71 // Calls to this should disable the vertical scrollbar.
72
73 // Number of pixels per user unit (0 or -1 for no scrollbar)
74 // Length of virtual canvas in user units
75 // Length of page in user units
76 virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
77 int noUnitsX, int noUnitsY,
78 int xPos = 0, int yPos = 0,
79 bool noRefresh = FALSE );
80
81 // In case we're using the generic tree control.
82 // Get the view start
83 virtual void GetViewStart(int *x, int *y) const;
84
85 // In case we're using the generic tree control.
86 virtual void PrepareDC(wxDC& dc);
87
88 // In case we're using the generic tree control.
89 virtual int GetScrollPos(int orient) const;
90
91 //// Helpers
92 void HideVScrollbar();
93
94 // Calculate the tree overall size so we can set the scrollbar
95 // correctly
96 void CalcTreeSize(wxRect& rect);
97 void CalcTreeSize(const wxTreeItemId& id, wxRect& rect);
98
99 // Adjust the containing wxScrolledWindow's scrollbars appropriately
100 void AdjustRemoteScrollbars();
101
102 // Find the scrolled window that contains this control
103 wxScrolledWindow* GetScrolledWindow() const;
104
105 // Scroll to the given line (in scroll units where each unit is
106 // the height of an item)
107 void ScrollToLine(int posHoriz, int posVert);
108
109 //// Accessors
110
111 // The companion window is one which will get notified when certain
112 // events happen such as node expansion
113 void SetCompanionWindow(wxWindow* companion) { m_companionWindow = companion; }
114 wxWindow* GetCompanionWindow() const { return m_companionWindow; }
115
116
117 DECLARE_EVENT_TABLE()
118 protected:
119 wxWindow* m_companionWindow;
120 bool m_drawRowLines;
121 };
122
123 /*
124 * wxTreeCompanionWindow
125 *
126 * A window displaying values associated with tree control items.
127 */
128
129 class GIZMODLLEXPORT wxTreeCompanionWindow: public wxWindow
130 {
131 public:
132 DECLARE_CLASS(wxTreeCompanionWindow)
133
134 wxTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
135 const wxPoint& pos = wxDefaultPosition,
136 const wxSize& sz = wxDefaultSize,
137 long style = 0);
138
139 //// Overrides
140 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect);
141
142 //// Events
143 void OnPaint(wxPaintEvent& event);
144 void OnScroll(wxScrollWinEvent& event);
145 void OnExpand(wxTreeEvent& event);
146
147 //// Operations
148
149 //// Accessors
150 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; };
151 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl) { m_treeCtrl = treeCtrl; }
152
153 //// Data members
154 protected:
155 wxRemotelyScrolledTreeCtrl* m_treeCtrl;
156
157 DECLARE_EVENT_TABLE()
158 };
159
160
161 /*
162 * wxThinSplitterWindow
163 *
164 * Implements a splitter with a less obvious sash
165 * than the usual one.
166 */
167
168 class GIZMODLLEXPORT wxThinSplitterWindow: public wxSplitterWindow
169 {
170 public:
171 DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow)
172
173 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
174 const wxPoint& pos = wxDefaultPosition,
175 const wxSize& sz = wxDefaultSize,
176 long style = wxSP_3D | wxCLIP_CHILDREN);
177
178 //// Overrides
179
180 void SizeWindows();
181 // Tests for x, y over sash. Overriding this allows us to increase
182 // the tolerance.
183 bool SashHitTest(int x, int y, int tolerance = 2);
184 void DrawSash(wxDC& dc);
185
186 //// Events
187
188 void OnSize(wxSizeEvent& event);
189
190 //// Operations
191
192 //// Accessors
193
194 //// Data members
195 protected:
196 DECLARE_EVENT_TABLE()
197 };
198
199 /*
200 * wxSplitterScrolledWindow
201 *
202 * This scrolled window is aware of the fact that one of its
203 * children is a splitter window. It passes on its scroll events
204 * (after some processing) to both splitter children for them
205 * scroll appropriately.
206 */
207
208 class GIZMODLLEXPORT wxSplitterScrolledWindow: public wxScrolledWindow
209 {
210 public:
211 DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow)
212
213 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
214 const wxPoint& pos = wxDefaultPosition,
215 const wxSize& sz = wxDefaultSize,
216 long style = 0);
217
218 //// Overrides
219
220 //// Events
221
222 void OnScroll(wxScrollWinEvent& event);
223 void OnSize(wxSizeEvent& event);
224
225 //// Operations
226
227 //// Accessors
228
229 //// Data members
230 public:
231 DECLARE_EVENT_TABLE()
232 };
233
234 #endif
235 // _SPLITTREE_H_