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 #if defined(__GNUG__) && !defined(__APPLE__)
18 #pragma interface "splittree.h"
21 #include "wx/gizmos/gizmos.h"
23 // Set this to 1 to use generic tree control (doesn't yet work properly)
24 #define USE_GENERIC_TREECTRL 0
27 #include "wx/treectrl.h"
28 #include "wx/splitter.h"
29 #include "wx/scrolwin.h"
31 #if USE_GENERIC_TREECTRL
32 #include "wx/generic/treectlg.h"
34 #define wxTreeCtrl wxGenericTreeCtrl
35 #define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
39 class wxRemotelyScrolledTreeCtrl
;
40 class wxThinSplitterWindow
;
41 class wxSplitterScrolledWindow
;
44 * wxRemotelyScrolledTreeCtrl
46 * This tree control disables its vertical scrollbar and catches scroll
47 * events passed by a scrolled window higher in the hierarchy.
48 * It also updates the scrolled window vertical scrollbar as appropriate.
51 class WXDLLIMPEXP_GIZMOS wxRemotelyScrolledTreeCtrl
: public wxTreeCtrl
53 DECLARE_CLASS(wxRemotelyScrolledTreeCtrl
)
55 wxRemotelyScrolledTreeCtrl(wxWindow
* parent
, wxWindowID id
, const wxPoint
& pt
= wxDefaultPosition
,
56 const wxSize
& sz
= wxDefaultSize
, long style
= wxTR_HAS_BUTTONS
);
57 ~wxRemotelyScrolledTreeCtrl();
60 void OnSize(wxSizeEvent
& event
);
61 void OnExpand(wxTreeEvent
& event
);
62 void OnScroll(wxScrollWinEvent
& event
);
63 void OnPaint(wxPaintEvent
& event
);
66 // Override this in case we're using the generic tree control.
67 // Calls to this should disable the vertical scrollbar.
69 // Number of pixels per user unit (0 or -1 for no scrollbar)
70 // Length of virtual canvas in user units
71 // Length of page in user units
72 virtual void SetScrollbars(int pixelsPerUnitX
, int pixelsPerUnitY
,
73 int noUnitsX
, int noUnitsY
,
74 int xPos
= 0, int yPos
= 0,
75 bool noRefresh
= false );
77 // In case we're using the generic tree control.
79 virtual void GetViewStart(int *x
, int *y
) const;
81 // In case we're using the generic tree control.
82 virtual void PrepareDC(wxDC
& dc
);
84 // In case we're using the generic tree control.
85 virtual int GetScrollPos(int orient
) const;
88 void HideVScrollbar();
90 // Calculate the tree overall size so we can set the scrollbar
92 void CalcTreeSize(wxRect
& rect
);
93 void CalcTreeSize(const wxTreeItemId
& id
, wxRect
& rect
);
95 // Adjust the containing wxScrolledWindow's scrollbars appropriately
96 void AdjustRemoteScrollbars();
98 // Find the scrolled window that contains this control
99 wxScrolledWindow
* GetScrolledWindow() const;
101 // Scroll to the given line (in scroll units where each unit is
102 // the height of an item)
103 void ScrollToLine(int posHoriz
, int posVert
);
107 // The companion window is one which will get notified when certain
108 // events happen such as node expansion
109 void SetCompanionWindow(wxWindow
* companion
) { m_companionWindow
= companion
; }
110 wxWindow
* GetCompanionWindow() const { return m_companionWindow
; }
113 DECLARE_EVENT_TABLE()
115 wxWindow
* m_companionWindow
;
120 * wxTreeCompanionWindow
122 * A window displaying values associated with tree control items.
125 class WXDLLIMPEXP_GIZMOS wxTreeCompanionWindow
: public wxWindow
128 DECLARE_CLASS(wxTreeCompanionWindow
)
130 wxTreeCompanionWindow(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
131 const wxPoint
& pos
= wxDefaultPosition
,
132 const wxSize
& sz
= wxDefaultSize
,
136 virtual void DrawItem(wxDC
& dc
, wxTreeItemId id
, const wxRect
& rect
);
139 void OnPaint(wxPaintEvent
& event
);
140 void OnScroll(wxScrollWinEvent
& event
);
141 void OnExpand(wxTreeEvent
& event
);
146 wxRemotelyScrolledTreeCtrl
* GetTreeCtrl() const { return m_treeCtrl
; };
147 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl
* treeCtrl
) { m_treeCtrl
= treeCtrl
; }
151 wxRemotelyScrolledTreeCtrl
* m_treeCtrl
;
153 DECLARE_EVENT_TABLE()
158 * wxThinSplitterWindow
160 * Implements a splitter with a less obvious sash
161 * than the usual one.
164 class WXDLLIMPEXP_GIZMOS wxThinSplitterWindow
: public wxSplitterWindow
167 DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow
)
169 wxThinSplitterWindow(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
170 const wxPoint
& pos
= wxDefaultPosition
,
171 const wxSize
& sz
= wxDefaultSize
,
172 long style
= wxSP_3D
| wxCLIP_CHILDREN
);
173 ~wxThinSplitterWindow();
178 // Tests for x, y over sash. Overriding this allows us to increase
180 bool SashHitTest(int x
, int y
, int tolerance
= 2);
181 void DrawSash(wxDC
& dc
);
185 void OnSize(wxSizeEvent
& event
);
194 wxBrush
* m_faceBrush
;
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 WXDLLIMPEXP_GIZMOS wxSplitterScrolledWindow
: public wxScrolledWindow
211 DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow
)
213 wxSplitterScrolledWindow(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
214 const wxPoint
& pos
= wxDefaultPosition
,
215 const wxSize
& sz
= wxDefaultSize
,
222 void OnScroll(wxScrollWinEvent
& event
);
223 void OnSize(wxSizeEvent
& event
);
231 DECLARE_EVENT_TABLE()