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_
17 #include "wx/gizmos/gizmos.h"
19 // Set this to 1 to use generic tree control (doesn't yet work properly)
20 #define USE_GENERIC_TREECTRL 0
23 #include "wx/treectrl.h"
24 #include "wx/splitter.h"
25 #include "wx/scrolwin.h"
27 #if USE_GENERIC_TREECTRL
28 #include "wx/generic/treectlg.h"
30 #define wxTreeCtrl wxGenericTreeCtrl
31 #define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
35 class wxRemotelyScrolledTreeCtrl
;
36 class wxThinSplitterWindow
;
37 class wxSplitterScrolledWindow
;
40 * wxRemotelyScrolledTreeCtrl
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.
47 class WXDLLIMPEXP_GIZMOS wxRemotelyScrolledTreeCtrl
: public wxTreeCtrl
49 DECLARE_CLASS(wxRemotelyScrolledTreeCtrl
)
51 wxRemotelyScrolledTreeCtrl(wxWindow
* parent
, wxWindowID id
, const wxPoint
& pt
= wxDefaultPosition
,
52 const wxSize
& sz
= wxDefaultSize
, long style
= wxTR_HAS_BUTTONS
);
53 ~wxRemotelyScrolledTreeCtrl();
56 void OnSize(wxSizeEvent
& event
);
57 void OnExpand(wxTreeEvent
& event
);
58 void OnScroll(wxScrollWinEvent
& event
);
59 void OnPaint(wxPaintEvent
& event
);
62 // Override this in case we're using the generic tree control.
63 // Calls to this should disable the vertical scrollbar.
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 );
73 // In case we're using the generic tree control.
75 virtual void GetViewStart(int *x
, int *y
) const;
77 // In case we're using the generic tree control.
78 virtual void PrepareDC(wxDC
& dc
);
80 // In case we're using the generic tree control.
81 virtual int GetScrollPos(int orient
) const;
84 void HideVScrollbar();
86 // Calculate the tree overall size so we can set the scrollbar
88 void CalcTreeSize(wxRect
& rect
);
89 void CalcTreeSize(const wxTreeItemId
& id
, wxRect
& rect
);
91 // Adjust the containing wxScrolledWindow's scrollbars appropriately
92 void AdjustRemoteScrollbars();
94 // Find the scrolled window that contains this control
95 wxScrolledWindow
* GetScrolledWindow() const;
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
);
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
; }
109 DECLARE_EVENT_TABLE()
111 wxWindow
* m_companionWindow
;
116 * wxTreeCompanionWindow
118 * A window displaying values associated with tree control items.
121 class WXDLLIMPEXP_GIZMOS wxTreeCompanionWindow
: public wxWindow
124 DECLARE_CLASS(wxTreeCompanionWindow
)
126 wxTreeCompanionWindow(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
127 const wxPoint
& pos
= wxDefaultPosition
,
128 const wxSize
& sz
= wxDefaultSize
,
132 virtual void DrawItem(wxDC
& dc
, wxTreeItemId id
, const wxRect
& rect
);
135 void OnPaint(wxPaintEvent
& event
);
136 void OnScroll(wxScrollWinEvent
& event
);
137 void OnExpand(wxTreeEvent
& event
);
142 wxRemotelyScrolledTreeCtrl
* GetTreeCtrl() const { return m_treeCtrl
; };
143 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl
* treeCtrl
) { m_treeCtrl
= treeCtrl
; }
147 wxRemotelyScrolledTreeCtrl
* m_treeCtrl
;
149 DECLARE_EVENT_TABLE()
154 * wxThinSplitterWindow
156 * Implements a splitter with a less obvious sash
157 * than the usual one.
160 class WXDLLIMPEXP_GIZMOS wxThinSplitterWindow
: public wxSplitterWindow
163 DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow
)
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();
174 // Tests for x, y over sash. Overriding this allows us to increase
176 bool SashHitTest(int x
, int y
, int tolerance
= 2);
177 void DrawSash(wxDC
& dc
);
181 void OnSize(wxSizeEvent
& event
);
190 wxBrush
* m_faceBrush
;
192 DECLARE_EVENT_TABLE()
196 * wxSplitterScrolledWindow
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.
204 class WXDLLIMPEXP_GIZMOS wxSplitterScrolledWindow
: public wxScrolledWindow
207 DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow
)
209 wxSplitterScrolledWindow(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
210 const wxPoint
& pos
= wxDefaultPosition
,
211 const wxSize
& sz
= wxDefaultSize
,
218 void OnScroll(wxScrollWinEvent
& event
);
219 void OnSize(wxSizeEvent
& event
);
227 DECLARE_EVENT_TABLE()