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
;
124 * wxTreeCompanionWindow
126 * A window displaying values associated with tree control items.
129 class GIZMODLLEXPORT wxTreeCompanionWindow
: public wxWindow
132 DECLARE_CLASS(wxTreeCompanionWindow
)
134 wxTreeCompanionWindow(wxWindow
* parent
, wxWindowID id
= -1,
135 const wxPoint
& pos
= wxDefaultPosition
,
136 const wxSize
& sz
= wxDefaultSize
,
140 virtual void DrawItem(wxDC
& dc
, wxTreeItemId id
, const wxRect
& rect
);
143 void OnPaint(wxPaintEvent
& event
);
144 void OnScroll(wxScrollWinEvent
& event
);
145 void OnExpand(wxTreeEvent
& event
);
150 wxRemotelyScrolledTreeCtrl
* GetTreeCtrl() const { return m_treeCtrl
; };
151 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl
* treeCtrl
) { m_treeCtrl
= treeCtrl
; }
155 wxRemotelyScrolledTreeCtrl
* m_treeCtrl
;
157 DECLARE_EVENT_TABLE()
162 * wxThinSplitterWindow
164 * Implements a splitter with a less obvious sash
165 * than the usual one.
168 class GIZMODLLEXPORT wxThinSplitterWindow
: public wxSplitterWindow
171 DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow
)
173 wxThinSplitterWindow(wxWindow
* parent
, wxWindowID id
= -1,
174 const wxPoint
& pos
= wxDefaultPosition
,
175 const wxSize
& sz
= wxDefaultSize
,
176 long style
= wxSP_3D
| wxCLIP_CHILDREN
);
181 // Tests for x, y over sash. Overriding this allows us to increase
183 bool SashHitTest(int x
, int y
, int tolerance
= 2);
184 void DrawSash(wxDC
& dc
);
188 void OnSize(wxSizeEvent
& event
);
196 DECLARE_EVENT_TABLE()
200 * wxSplitterScrolledWindow
202 * This scrolled window is aware of the fact that one of its
203 * children is a splitter window. It passes on its scroll events
204 * (after some processing) to both splitter children for them
205 * scroll appropriately.
208 class GIZMODLLEXPORT wxSplitterScrolledWindow
: public wxScrolledWindow
211 DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow
)
213 wxSplitterScrolledWindow(wxWindow
* parent
, wxWindowID id
= -1,
214 const wxPoint
& pos
= wxDefaultPosition
,
215 const wxSize
& sz
= wxDefaultSize
,
222 void OnScroll(wxScrollWinEvent
& event
);
223 void OnSize(wxSizeEvent
& event
);
231 DECLARE_EVENT_TABLE()