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
);
69 // Override this in case we're using the generic tree control.
70 // Calls to this should disable the vertical scrollbar.
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
);
80 // In case we're using the generic tree control.
82 virtual void GetViewStart(int *x
, int *y
) const;
84 // In case we're using the generic tree control.
85 virtual void PrepareDC(wxDC
& dc
);
87 // In case we're using the generic tree control.
88 virtual int GetScrollPos(int orient
) const;
91 void HideVScrollbar();
93 // Calculate the tree overall size so we can set the scrollbar
95 void CalcTreeSize(wxRect
& rect
);
96 void CalcTreeSize(const wxTreeItemId
& id
, wxRect
& rect
);
98 // Adjust the containing wxScrolledWindow's scrollbars appropriately
99 void AdjustRemoteScrollbars();
101 // Find the scrolled window that contains this control
102 wxScrolledWindow
* GetScrolledWindow() const;
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
);
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
; }
116 DECLARE_EVENT_TABLE()
118 wxWindow
* m_companionWindow
;
122 * wxTreeCompanionWindow
124 * A window displaying values associated with tree control items.
127 class GIZMODLLEXPORT wxTreeCompanionWindow
: public wxWindow
130 DECLARE_CLASS(wxTreeCompanionWindow
)
132 wxTreeCompanionWindow(wxWindow
* parent
, wxWindowID id
= -1,
133 const wxPoint
& pos
= wxDefaultPosition
,
134 const wxSize
& sz
= wxDefaultSize
,
138 virtual void DrawItem(wxDC
& dc
, wxTreeItemId id
, const wxRect
& rect
);
141 void OnPaint(wxPaintEvent
& event
);
142 void OnScroll(wxScrollWinEvent
& event
);
143 void OnExpand(wxTreeEvent
& event
);
148 wxRemotelyScrolledTreeCtrl
* GetTreeCtrl() const { return m_treeCtrl
; };
149 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl
* treeCtrl
) { m_treeCtrl
= treeCtrl
; }
153 wxRemotelyScrolledTreeCtrl
* m_treeCtrl
;
155 DECLARE_EVENT_TABLE()
160 * wxThinSplitterWindow
162 * Implements a splitter with a less obvious sash
163 * than the usual one.
166 class GIZMODLLEXPORT wxThinSplitterWindow
: public wxSplitterWindow
169 DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow
)
171 wxThinSplitterWindow(wxWindow
* parent
, wxWindowID id
= -1,
172 const wxPoint
& pos
= wxDefaultPosition
,
173 const wxSize
& sz
= wxDefaultSize
,
174 long style
= wxSP_3D
| wxCLIP_CHILDREN
);
179 // Tests for x, y over sash. Overriding this allows us to increase
181 bool SashHitTest(int x
, int y
, int tolerance
= 2);
182 void DrawSash(wxDC
& dc
);
186 void OnSize(wxSizeEvent
& event
);
194 DECLARE_EVENT_TABLE()
198 * wxSplitterScrolledWindow
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.
206 class GIZMODLLEXPORT wxSplitterScrolledWindow
: public wxScrolledWindow
209 DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow
)
211 wxSplitterScrolledWindow(wxWindow
* parent
, wxWindowID id
= -1,
212 const wxPoint
& pos
= wxDefaultPosition
,
213 const wxSize
& sz
= wxDefaultSize
,
220 void OnScroll(wxScrollWinEvent
& event
);
221 void OnSize(wxSizeEvent
& event
);
229 DECLARE_EVENT_TABLE()