]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/gizmos/splittree.h
Moved line-drawing to splittree implementation.
[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 };
121
122 /*
123 * wxTreeCompanionWindow
124 *
125 * A window displaying values associated with tree control items.
126 */
127
128 class GIZMODLLEXPORT wxTreeCompanionWindow: public wxWindow
129 {
130 public:
131 DECLARE_CLASS(wxTreeCompanionWindow)
132
133 wxTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
134 const wxPoint& pos = wxDefaultPosition,
135 const wxSize& sz = wxDefaultSize,
136 long style = 0);
137
138 //// Overrides
139 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect);
140
141 //// Events
142 void OnPaint(wxPaintEvent& event);
143 void OnScroll(wxScrollWinEvent& event);
144 void OnExpand(wxTreeEvent& event);
145
146 //// Operations
147
148 //// Accessors
149 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; };
150 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl) { m_treeCtrl = treeCtrl; }
151
152 //// Data members
153 protected:
154 wxRemotelyScrolledTreeCtrl* m_treeCtrl;
155
156 DECLARE_EVENT_TABLE()
157 };
158
159
160 /*
161 * wxThinSplitterWindow
162 *
163 * Implements a splitter with a less obvious sash
164 * than the usual one.
165 */
166
167 class GIZMODLLEXPORT wxThinSplitterWindow: public wxSplitterWindow
168 {
169 public:
170 DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow)
171
172 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
173 const wxPoint& pos = wxDefaultPosition,
174 const wxSize& sz = wxDefaultSize,
175 long style = wxSP_3D | wxCLIP_CHILDREN);
176
177 //// Overrides
178
179 void SizeWindows();
180 // Tests for x, y over sash. Overriding this allows us to increase
181 // the tolerance.
182 bool SashHitTest(int x, int y, int tolerance = 2);
183 void DrawSash(wxDC& dc);
184
185 //// Events
186
187 void OnSize(wxSizeEvent& event);
188
189 //// Operations
190
191 //// Accessors
192
193 //// Data members
194 protected:
195 DECLARE_EVENT_TABLE()
196 };
197
198 /*
199 * wxSplitterScrolledWindow
200 *
201 * This scrolled window is aware of the fact that one of its
202 * children is a splitter window. It passes on its scroll events
203 * (after some processing) to both splitter children for them
204 * scroll appropriately.
205 */
206
207 class GIZMODLLEXPORT wxSplitterScrolledWindow: public wxScrolledWindow
208 {
209 public:
210 DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow)
211
212 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
213 const wxPoint& pos = wxDefaultPosition,
214 const wxSize& sz = wxDefaultSize,
215 long style = 0);
216
217 //// Overrides
218
219 //// Events
220
221 void OnScroll(wxScrollWinEvent& event);
222 void OnSize(wxSizeEvent& event);
223
224 //// Operations
225
226 //// Accessors
227
228 //// Data members
229 public:
230 DECLARE_EVENT_TABLE()
231 };
232
233 #endif
234 // _SPLITTREE_H_