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