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