]>
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); | |
59 | void OnPaint(wxPaintEvent& event); | |
60 | void OnExpand(wxTreeEvent& event); | |
61 | void OnScroll(wxScrollWinEvent& event); | |
62 | ||
63 | //// Overrides | |
64 | // Override this in case we're using the generic tree control. | |
65 | // Calls to this should disable the vertical scrollbar. | |
66 | ||
67 | // Number of pixels per user unit (0 or -1 for no scrollbar) | |
68 | // Length of virtual canvas in user units | |
69 | // Length of page in user units | |
70 | virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, | |
71 | int noUnitsX, int noUnitsY, | |
72 | int xPos = 0, int yPos = 0, | |
73 | bool noRefresh = FALSE ); | |
74 | ||
75 | // In case we're using the generic tree control. | |
76 | // Get the view start | |
77 | virtual void GetViewStart(int *x, int *y) const; | |
78 | ||
79 | // In case we're using the generic tree control. | |
80 | virtual void PrepareDC(wxDC& dc); | |
81 | ||
82 | //// Helpers | |
83 | void HideVScrollbar(); | |
84 | ||
85 | // Calculate the tree overall size so we can set the scrollbar | |
86 | // correctly | |
87 | void CalcTreeSize(wxRect& rect); | |
88 | void CalcTreeSize(wxTreeItemId& id, wxRect& rect); | |
89 | ||
90 | // Adjust the containing wxScrolledWindow's scrollbars appropriately | |
91 | void AdjustRemoteScrollbars(); | |
92 | ||
93 | // Find the scrolled window that contains this control | |
94 | wxScrolledWindow* GetScrolledWindow() const; | |
95 | ||
96 | // Scroll to the given line (in scroll units where each unit is | |
97 | // the height of an item) | |
98 | void ScrollToLine(int posHoriz, int posVert); | |
99 | ||
100 | DECLARE_EVENT_TABLE() | |
101 | protected: | |
102 | }; | |
103 | ||
104 | /* | |
105 | * wxThinSplitterWindow | |
106 | * | |
107 | * Implements a splitter with a less obvious sash | |
108 | * than the usual one. | |
109 | */ | |
110 | ||
111 | class wxThinSplitterWindow: public wxSplitterWindow | |
112 | { | |
113 | public: | |
114 | DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow) | |
115 | ||
116 | wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1, | |
117 | const wxPoint& pos = wxDefaultPosition, | |
118 | const wxSize& sz = wxDefaultSize, | |
119 | long style = wxSP_3D | wxCLIP_CHILDREN); | |
120 | ||
121 | //// Overrides | |
122 | ||
123 | void SizeWindows(); | |
124 | // Tests for x, y over sash. Overriding this allows us to increase | |
125 | // the tolerance. | |
126 | bool SashHitTest(int x, int y, int tolerance = 2); | |
127 | void DrawSash(wxDC& dc); | |
128 | ||
129 | //// Events | |
130 | ||
131 | void OnSize(wxSizeEvent& event); | |
132 | ||
133 | //// Operations | |
134 | ||
135 | //// Accessors | |
136 | ||
137 | //// Data members | |
138 | protected: | |
139 | DECLARE_EVENT_TABLE() | |
140 | }; | |
141 | ||
142 | /* | |
143 | * wxSplitterScrolledWindow | |
144 | * | |
145 | * This scrolled window is aware of the fact that one of its | |
146 | * children is a splitter window. It passes on its scroll events | |
147 | * (after some processing) to both splitter children for them | |
148 | * scroll appropriately. | |
149 | */ | |
150 | ||
151 | class wxSplitterScrolledWindow: public wxScrolledWindow | |
152 | { | |
153 | public: | |
154 | DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow) | |
155 | ||
156 | wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1, | |
157 | const wxPoint& pos = wxDefaultPosition, | |
158 | const wxSize& sz = wxDefaultSize, | |
159 | long style = 0); | |
160 | ||
161 | //// Overrides | |
162 | ||
163 | //// Events | |
164 | ||
165 | void OnScroll(wxScrollWinEvent& event); | |
166 | void OnSize(wxSizeEvent& event); | |
167 | ||
168 | //// Operations | |
169 | ||
170 | //// Accessors | |
171 | ||
172 | //// Data members | |
173 | public: | |
174 | DECLARE_EVENT_TABLE() | |
175 | }; | |
176 | ||
177 | #endif | |
178 | // _SPLITTREE_H_ |