]>
Commit | Line | Data |
---|---|---|
58580a7e JS |
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__ | |
7f60145d | 18 | #pragma interface "splittree.h" |
58580a7e JS |
19 | #endif |
20 | ||
086ab766 RD |
21 | #ifdef GIZMOISDLL |
22 | #define GIZMODLLEXPORT WXDLLEXPORT | |
23 | #else | |
24 | #define GIZMODLLEXPORT | |
25 | #endif | |
26 | ||
58580a7e JS |
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 | ||
086ab766 | 55 | class GIZMODLLEXPORT wxRemotelyScrolledTreeCtrl: public wxTreeCtrl |
58580a7e | 56 | { |
7f60145d | 57 | DECLARE_CLASS(wxRemotelyScrolledTreeCtrl) |
58580a7e JS |
58 | public: |
59 | wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition, | |
60 | const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS); | |
7f60145d | 61 | ~wxRemotelyScrolledTreeCtrl(); |
58580a7e JS |
62 | |
63 | //// Events | |
7f60145d RD |
64 | void OnSize(wxSizeEvent& event); |
65 | void OnExpand(wxTreeEvent& event); | |
58580a7e | 66 | void OnScroll(wxScrollWinEvent& event); |
7f60145d | 67 | void OnPaint(wxPaintEvent& event); |
58580a7e JS |
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 | ||
43bcf4c9 JS |
88 | // In case we're using the generic tree control. |
89 | virtual int GetScrollPos(int orient) const; | |
90 | ||
58580a7e | 91 | //// Helpers |
7f60145d | 92 | void HideVScrollbar(); |
58580a7e | 93 | |
7f60145d RD |
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); | |
58580a7e | 98 | |
7f60145d RD |
99 | // Adjust the containing wxScrolledWindow's scrollbars appropriately |
100 | void AdjustRemoteScrollbars(); | |
58580a7e | 101 | |
7f60145d RD |
102 | // Find the scrolled window that contains this control |
103 | wxScrolledWindow* GetScrolledWindow() const; | |
58580a7e JS |
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 | ||
1a584f14 JS |
109 | //// Accessors |
110 | ||
7f60145d RD |
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; } | |
1a584f14 JS |
115 | |
116 | ||
58580a7e JS |
117 | DECLARE_EVENT_TABLE() |
118 | protected: | |
7f60145d RD |
119 | wxWindow* m_companionWindow; |
120 | bool m_drawRowLines; | |
58580a7e JS |
121 | }; |
122 | ||
1a584f14 JS |
123 | /* |
124 | * wxTreeCompanionWindow | |
125 | * | |
126 | * A window displaying values associated with tree control items. | |
127 | */ | |
128 | ||
086ab766 | 129 | class GIZMODLLEXPORT wxTreeCompanionWindow: public wxWindow |
1a584f14 JS |
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 | |
7f60145d | 140 | virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect); |
1a584f14 JS |
141 | |
142 | //// Events | |
7f60145d | 143 | void OnPaint(wxPaintEvent& event); |
1a584f14 | 144 | void OnScroll(wxScrollWinEvent& event); |
7f60145d | 145 | void OnExpand(wxTreeEvent& event); |
1a584f14 JS |
146 | |
147 | //// Operations | |
148 | ||
149 | //// Accessors | |
7f60145d RD |
150 | wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; }; |
151 | void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl) { m_treeCtrl = treeCtrl; } | |
1a584f14 JS |
152 | |
153 | //// Data members | |
154 | protected: | |
7f60145d | 155 | wxRemotelyScrolledTreeCtrl* m_treeCtrl; |
1a584f14 JS |
156 | |
157 | DECLARE_EVENT_TABLE() | |
158 | }; | |
159 | ||
160 | ||
58580a7e JS |
161 | /* |
162 | * wxThinSplitterWindow | |
163 | * | |
164 | * Implements a splitter with a less obvious sash | |
165 | * than the usual one. | |
166 | */ | |
167 | ||
086ab766 | 168 | class GIZMODLLEXPORT wxThinSplitterWindow: public wxSplitterWindow |
58580a7e JS |
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); | |
7f60145d | 184 | void DrawSash(wxDC& dc); |
58580a7e JS |
185 | |
186 | //// Events | |
086ab766 | 187 | |
58580a7e JS |
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 | ||
086ab766 | 208 | class GIZMODLLEXPORT wxSplitterScrolledWindow: public wxScrolledWindow |
58580a7e JS |
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 | |
086ab766 | 221 | |
58580a7e JS |
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_ |