]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/gizmos/splittree.h
more const correctness (slightly modified patch 1655991)
[wxWidgets.git] / contrib / include / wx / gizmos / splittree.h
CommitLineData
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
936a13b5 17#include "wx/gizmos/gizmos.h"
086ab766 18
58580a7e
JS
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
35class wxRemotelyScrolledTreeCtrl;
36class wxThinSplitterWindow;
37class 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
936a13b5 47class WXDLLIMPEXP_GIZMOS wxRemotelyScrolledTreeCtrl: public wxTreeCtrl
58580a7e 48{
7f60145d 49 DECLARE_CLASS(wxRemotelyScrolledTreeCtrl)
58580a7e
JS
50public:
51 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
52 const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS);
7f60145d 53 ~wxRemotelyScrolledTreeCtrl();
58580a7e
JS
54
55//// Events
7f60145d
RD
56 void OnSize(wxSizeEvent& event);
57 void OnExpand(wxTreeEvent& event);
58580a7e 58 void OnScroll(wxScrollWinEvent& event);
7f60145d 59 void OnPaint(wxPaintEvent& event);
58580a7e
JS
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,
a2d49353 71 bool noRefresh = false );
58580a7e
JS
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
43bcf4c9
JS
80 // In case we're using the generic tree control.
81 virtual int GetScrollPos(int orient) const;
82
58580a7e 83//// Helpers
7f60145d 84 void HideVScrollbar();
58580a7e 85
7f60145d
RD
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);
58580a7e 90
7f60145d
RD
91 // Adjust the containing wxScrolledWindow's scrollbars appropriately
92 void AdjustRemoteScrollbars();
58580a7e 93
7f60145d
RD
94 // Find the scrolled window that contains this control
95 wxScrolledWindow* GetScrolledWindow() const;
58580a7e
JS
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
1a584f14
JS
101//// Accessors
102
7f60145d
RD
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; }
1a584f14
JS
107
108
58580a7e
JS
109 DECLARE_EVENT_TABLE()
110protected:
7f60145d
RD
111 wxWindow* m_companionWindow;
112 bool m_drawRowLines;
58580a7e
JS
113};
114
1a584f14
JS
115/*
116 * wxTreeCompanionWindow
117 *
118 * A window displaying values associated with tree control items.
119 */
120
936a13b5 121class WXDLLIMPEXP_GIZMOS wxTreeCompanionWindow: public wxWindow
1a584f14
JS
122{
123public:
124 DECLARE_CLASS(wxTreeCompanionWindow)
125
a2d49353 126 wxTreeCompanionWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
1a584f14
JS
127 const wxPoint& pos = wxDefaultPosition,
128 const wxSize& sz = wxDefaultSize,
129 long style = 0);
130
131//// Overrides
7f60145d 132 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect);
1a584f14
JS
133
134//// Events
7f60145d 135 void OnPaint(wxPaintEvent& event);
1a584f14 136 void OnScroll(wxScrollWinEvent& event);
7f60145d 137 void OnExpand(wxTreeEvent& event);
1a584f14
JS
138
139//// Operations
140
141//// Accessors
7f60145d
RD
142 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; };
143 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl) { m_treeCtrl = treeCtrl; }
1a584f14
JS
144
145//// Data members
146protected:
7f60145d 147 wxRemotelyScrolledTreeCtrl* m_treeCtrl;
1a584f14
JS
148
149 DECLARE_EVENT_TABLE()
150};
151
152
58580a7e
JS
153/*
154 * wxThinSplitterWindow
155 *
156 * Implements a splitter with a less obvious sash
157 * than the usual one.
158 */
159
936a13b5 160class WXDLLIMPEXP_GIZMOS wxThinSplitterWindow: public wxSplitterWindow
58580a7e
JS
161{
162public:
163 DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow)
164
a2d49353 165 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
58580a7e
JS
166 const wxPoint& pos = wxDefaultPosition,
167 const wxSize& sz = wxDefaultSize,
168 long style = wxSP_3D | wxCLIP_CHILDREN);
0199503b 169 ~wxThinSplitterWindow();
58580a7e
JS
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);
7f60145d 177 void DrawSash(wxDC& dc);
58580a7e
JS
178
179//// Events
086ab766 180
58580a7e
JS
181 void OnSize(wxSizeEvent& event);
182
183//// Operations
184
185//// Accessors
186
187//// Data members
188protected:
0199503b
RD
189 wxPen* m_facePen;
190 wxBrush* m_faceBrush;
191
58580a7e
JS
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
936a13b5 204class WXDLLIMPEXP_GIZMOS wxSplitterScrolledWindow: public wxScrolledWindow
58580a7e
JS
205{
206public:
207 DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow)
208
a2d49353 209 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
58580a7e
JS
210 const wxPoint& pos = wxDefaultPosition,
211 const wxSize& sz = wxDefaultSize,
212 long style = 0);
213
214//// Overrides
215
216//// Events
086ab766 217
58580a7e
JS
218 void OnScroll(wxScrollWinEvent& event);
219 void OnSize(wxSizeEvent& event);
220
221//// Operations
222
223//// Accessors
224
225//// Data members
226public:
227 DECLARE_EVENT_TABLE()
228};
229
230#endif
231 // _SPLITTREE_H_