]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/gizmos/splittree.h
check for wxUSE_MDI which is needed by this code (patch 1656080)
[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 #include "wx/gizmos/gizmos.h"
18
19 // Set this to 1 to use generic tree control (doesn't yet work properly)
20 #define USE_GENERIC_TREECTRL 0
21
22 #include "wx/wx.h"
23 #include "wx/treectrl.h"
24 #include "wx/splitter.h"
25 #include "wx/scrolwin.h"
26
27 #if USE_GENERIC_TREECTRL
28 #include "wx/generic/treectlg.h"
29 #ifndef wxTreeCtrl
30 #define wxTreeCtrl wxGenericTreeCtrl
31 #define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
32 #endif
33 #endif
34
35 class wxRemotelyScrolledTreeCtrl;
36 class wxThinSplitterWindow;
37 class wxSplitterScrolledWindow;
38
39 /*
40 * wxRemotelyScrolledTreeCtrl
41 *
42 * This tree control disables its vertical scrollbar and catches scroll
43 * events passed by a scrolled window higher in the hierarchy.
44 * It also updates the scrolled window vertical scrollbar as appropriate.
45 */
46
47 class WXDLLIMPEXP_GIZMOS wxRemotelyScrolledTreeCtrl: public wxTreeCtrl
48 {
49 DECLARE_CLASS(wxRemotelyScrolledTreeCtrl)
50 public:
51 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
52 const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS);
53 ~wxRemotelyScrolledTreeCtrl();
54
55 //// Events
56 void OnSize(wxSizeEvent& event);
57 void OnExpand(wxTreeEvent& event);
58 void OnScroll(wxScrollWinEvent& event);
59 void OnPaint(wxPaintEvent& event);
60
61 //// Overrides
62 // Override this in case we're using the generic tree control.
63 // Calls to this should disable the vertical scrollbar.
64
65 // Number of pixels per user unit (0 or -1 for no scrollbar)
66 // Length of virtual canvas in user units
67 // Length of page in user units
68 virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
69 int noUnitsX, int noUnitsY,
70 int xPos = 0, int yPos = 0,
71 bool noRefresh = false );
72
73 // In case we're using the generic tree control.
74 // Get the view start
75 virtual void GetViewStart(int *x, int *y) const;
76
77 // In case we're using the generic tree control.
78 virtual void PrepareDC(wxDC& dc);
79
80 // In case we're using the generic tree control.
81 virtual int GetScrollPos(int orient) const;
82
83 //// Helpers
84 void HideVScrollbar();
85
86 // Calculate the tree overall size so we can set the scrollbar
87 // correctly
88 void CalcTreeSize(wxRect& rect);
89 void CalcTreeSize(const wxTreeItemId& id, wxRect& rect);
90
91 // Adjust the containing wxScrolledWindow's scrollbars appropriately
92 void AdjustRemoteScrollbars();
93
94 // Find the scrolled window that contains this control
95 wxScrolledWindow* GetScrolledWindow() const;
96
97 // Scroll to the given line (in scroll units where each unit is
98 // the height of an item)
99 void ScrollToLine(int posHoriz, int posVert);
100
101 //// Accessors
102
103 // The companion window is one which will get notified when certain
104 // events happen such as node expansion
105 void SetCompanionWindow(wxWindow* companion) { m_companionWindow = companion; }
106 wxWindow* GetCompanionWindow() const { return m_companionWindow; }
107
108
109 DECLARE_EVENT_TABLE()
110 protected:
111 wxWindow* m_companionWindow;
112 bool m_drawRowLines;
113 };
114
115 /*
116 * wxTreeCompanionWindow
117 *
118 * A window displaying values associated with tree control items.
119 */
120
121 class WXDLLIMPEXP_GIZMOS wxTreeCompanionWindow: public wxWindow
122 {
123 public:
124 DECLARE_CLASS(wxTreeCompanionWindow)
125
126 wxTreeCompanionWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
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 WXDLLIMPEXP_GIZMOS wxThinSplitterWindow: public wxSplitterWindow
161 {
162 public:
163 DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow)
164
165 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
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 wxPen* m_facePen;
190 wxBrush* m_faceBrush;
191
192 DECLARE_EVENT_TABLE()
193 };
194
195 /*
196 * wxSplitterScrolledWindow
197 *
198 * This scrolled window is aware of the fact that one of its
199 * children is a splitter window. It passes on its scroll events
200 * (after some processing) to both splitter children for them
201 * scroll appropriately.
202 */
203
204 class WXDLLIMPEXP_GIZMOS wxSplitterScrolledWindow: public wxScrolledWindow
205 {
206 public:
207 DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow)
208
209 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
210 const wxPoint& pos = wxDefaultPosition,
211 const wxSize& sz = wxDefaultSize,
212 long style = 0);
213
214 //// Overrides
215
216 //// Events
217
218 void OnScroll(wxScrollWinEvent& event);
219 void OnSize(wxSizeEvent& event);
220
221 //// Operations
222
223 //// Accessors
224
225 //// Data members
226 public:
227 DECLARE_EVENT_TABLE()
228 };
229
230 #endif
231 // _SPLITTREE_H_