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