1 /////////////////////////////////////////////////////////////////////////////
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
6 // Author: Julian Smart
10 // Copyright: (c) Julian Smart
11 // Licence: wxWindows licence
12 /////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_SPLITTREE_H_
15 #define _WX_SPLITTREE_H_
18 #pragma interface "splittree.h"
22 #define GIZMODLLEXPORT WXDLLEXPORT
24 #define GIZMODLLEXPORT
27 // Set this to 1 to use generic tree control (doesn't yet work properly)
28 #define USE_GENERIC_TREECTRL 0
31 #include "wx/treectrl.h"
32 #include "wx/splitter.h"
33 #include "wx/scrolwin.h"
35 #if USE_GENERIC_TREECTRL
36 #include "wx/generic/treectlg.h"
38 #define wxTreeCtrl wxGenericTreeCtrl
39 #define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
43 class wxRemotelyScrolledTreeCtrl
;
44 class wxThinSplitterWindow
;
45 class wxSplitterScrolledWindow
;
48 * wxRemotelyScrolledTreeCtrl
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.
55 class GIZMODLLEXPORT wxRemotelyScrolledTreeCtrl
: public wxTreeCtrl
57 DECLARE_CLASS(wxRemotelyScrolledTreeCtrl
)
59 wxRemotelyScrolledTreeCtrl(wxWindow
* parent
, wxWindowID id
, const wxPoint
& pt
= wxDefaultPosition
,
60 const wxSize
& sz
= wxDefaultSize
, long style
= wxTR_HAS_BUTTONS
);
61 ~wxRemotelyScrolledTreeCtrl();
64 void OnSize(wxSizeEvent
& event
);
65 void OnExpand(wxTreeEvent
& event
);
66 void OnScroll(wxScrollWinEvent
& event
);
67 void OnPaint(wxPaintEvent
& event
);
70 // Override this in case we're using the generic tree control.
71 // Calls to this should disable the vertical scrollbar.
73 // Number of pixels per user unit (0 or -1 for no scrollbar)
74 // Length of virtual canvas in user units
75 // Length of page in user units
76 virtual void SetScrollbars(int pixelsPerUnitX
, int pixelsPerUnitY
,
77 int noUnitsX
, int noUnitsY
,
78 int xPos
= 0, int yPos
= 0,
79 bool noRefresh
= FALSE
);
81 // In case we're using the generic tree control.
83 virtual void GetViewStart(int *x
, int *y
) const;
85 // In case we're using the generic tree control.
86 virtual void PrepareDC(wxDC
& dc
);
88 // In case we're using the generic tree control.
89 virtual int GetScrollPos(int orient
) const;
92 void HideVScrollbar();
94 // Calculate the tree overall size so we can set the scrollbar
96 void CalcTreeSize(wxRect
& rect
);
97 void CalcTreeSize(const wxTreeItemId
& id
, wxRect
& rect
);
99 // Adjust the containing wxScrolledWindow's scrollbars appropriately
100 void AdjustRemoteScrollbars();
102 // Find the scrolled window that contains this control
103 wxScrolledWindow
* GetScrolledWindow() const;
105 // Scroll to the given line (in scroll units where each unit is
106 // the height of an item)
107 void ScrollToLine(int posHoriz
, int posVert
);
111 // The companion window is one which will get notified when certain
112 // events happen such as node expansion
113 void SetCompanionWindow(wxWindow
* companion
) { m_companionWindow
= companion
; }
114 wxWindow
* GetCompanionWindow() const { return m_companionWindow
; }
117 DECLARE_EVENT_TABLE()
119 wxWindow
* m_companionWindow
;
123 * wxTreeCompanionWindow
125 * A window displaying values associated with tree control items.
128 class GIZMODLLEXPORT wxTreeCompanionWindow
: public wxWindow
131 DECLARE_CLASS(wxTreeCompanionWindow
)
133 wxTreeCompanionWindow(wxWindow
* parent
, wxWindowID id
= -1,
134 const wxPoint
& pos
= wxDefaultPosition
,
135 const wxSize
& sz
= wxDefaultSize
,
139 virtual void DrawItem(wxDC
& dc
, wxTreeItemId id
, const wxRect
& rect
);
142 void OnPaint(wxPaintEvent
& event
);
143 void OnScroll(wxScrollWinEvent
& event
);
144 void OnExpand(wxTreeEvent
& event
);
149 wxRemotelyScrolledTreeCtrl
* GetTreeCtrl() const { return m_treeCtrl
; };
150 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl
* treeCtrl
) { m_treeCtrl
= treeCtrl
; }
154 wxRemotelyScrolledTreeCtrl
* m_treeCtrl
;
156 DECLARE_EVENT_TABLE()
161 * wxThinSplitterWindow
163 * Implements a splitter with a less obvious sash
164 * than the usual one.
167 class GIZMODLLEXPORT wxThinSplitterWindow
: public wxSplitterWindow
170 DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow
)
172 wxThinSplitterWindow(wxWindow
* parent
, wxWindowID id
= -1,
173 const wxPoint
& pos
= wxDefaultPosition
,
174 const wxSize
& sz
= wxDefaultSize
,
175 long style
= wxSP_3D
| wxCLIP_CHILDREN
);
180 // Tests for x, y over sash. Overriding this allows us to increase
182 bool SashHitTest(int x
, int y
, int tolerance
= 2);
183 void DrawSash(wxDC
& dc
);
187 void OnSize(wxSizeEvent
& event
);
195 DECLARE_EVENT_TABLE()
199 * wxSplitterScrolledWindow
201 * This scrolled window is aware of the fact that one of its
202 * children is a splitter window. It passes on its scroll events
203 * (after some processing) to both splitter children for them
204 * scroll appropriately.
207 class GIZMODLLEXPORT wxSplitterScrolledWindow
: public wxScrolledWindow
210 DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow
)
212 wxSplitterScrolledWindow(wxWindow
* parent
, wxWindowID id
= -1,
213 const wxPoint
& pos
= wxDefaultPosition
,
214 const wxSize
& sz
= wxDefaultSize
,
221 void OnScroll(wxScrollWinEvent
& event
);
222 void OnSize(wxSizeEvent
& event
);
230 DECLARE_EVENT_TABLE()