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"
21 // Set this to 1 to use generic tree control (doesn't yet work properly)
22 #define USE_GENERIC_TREECTRL 0
25 #include "wx/treectrl.h"
26 #include "wx/splitter.h"
27 #include "wx/scrolwin.h"
29 #if USE_GENERIC_TREECTRL
30 #include "wx/generic/treectlg.h"
32 #define wxTreeCtrl wxGenericTreeCtrl
33 #define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
37 class wxRemotelyScrolledTreeCtrl
;
38 class wxThinSplitterWindow
;
39 class wxSplitterScrolledWindow
;
42 * wxRemotelyScrolledTreeCtrl
44 * This tree control disables its vertical scrollbar and catches scroll
45 * events passed by a scrolled window higher in the hierarchy.
46 * It also updates the scrolled window vertical scrollbar as appropriate.
49 class wxRemotelyScrolledTreeCtrl
: public wxTreeCtrl
51 DECLARE_CLASS(wxRemotelyScrolledTreeCtrl
)
53 wxRemotelyScrolledTreeCtrl(wxWindow
* parent
, wxWindowID id
, const wxPoint
& pt
= wxDefaultPosition
,
54 const wxSize
& sz
= wxDefaultSize
, long style
= wxTR_HAS_BUTTONS
);
55 ~wxRemotelyScrolledTreeCtrl();
58 void OnSize(wxSizeEvent
& event
);
59 void OnExpand(wxTreeEvent
& event
);
60 void OnScroll(wxScrollWinEvent
& event
);
63 // Override this in case we're using the generic tree control.
64 // Calls to this should disable the vertical scrollbar.
66 // Number of pixels per user unit (0 or -1 for no scrollbar)
67 // Length of virtual canvas in user units
68 // Length of page in user units
69 virtual void SetScrollbars(int pixelsPerUnitX
, int pixelsPerUnitY
,
70 int noUnitsX
, int noUnitsY
,
71 int xPos
= 0, int yPos
= 0,
72 bool noRefresh
= FALSE
);
74 // In case we're using the generic tree control.
76 virtual void GetViewStart(int *x
, int *y
) const;
78 // In case we're using the generic tree control.
79 virtual void PrepareDC(wxDC
& dc
);
82 void HideVScrollbar();
84 // Calculate the tree overall size so we can set the scrollbar
86 void CalcTreeSize(wxRect
& rect
);
87 void CalcTreeSize(wxTreeItemId
& id
, wxRect
& rect
);
89 // Adjust the containing wxScrolledWindow's scrollbars appropriately
90 void AdjustRemoteScrollbars();
92 // Find the scrolled window that contains this control
93 wxScrolledWindow
* GetScrolledWindow() const;
95 // Scroll to the given line (in scroll units where each unit is
96 // the height of an item)
97 void ScrollToLine(int posHoriz
, int posVert
);
104 * wxThinSplitterWindow
106 * Implements a splitter with a less obvious sash
107 * than the usual one.
110 class wxThinSplitterWindow
: public wxSplitterWindow
113 DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow
)
115 wxThinSplitterWindow(wxWindow
* parent
, wxWindowID id
= -1,
116 const wxPoint
& pos
= wxDefaultPosition
,
117 const wxSize
& sz
= wxDefaultSize
,
118 long style
= wxSP_3D
| wxCLIP_CHILDREN
);
123 // Tests for x, y over sash. Overriding this allows us to increase
125 bool SashHitTest(int x
, int y
, int tolerance
= 2);
126 void DrawSash(wxDC
& dc
);
130 void OnSize(wxSizeEvent
& event
);
138 DECLARE_EVENT_TABLE()
142 * wxSplitterScrolledWindow
144 * This scrolled window is aware of the fact that one of its
145 * children is a splitter window. It passes on its scroll events
146 * (after some processing) to both splitter children for them
147 * scroll appropriately.
150 class wxSplitterScrolledWindow
: public wxScrolledWindow
153 DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow
)
155 wxSplitterScrolledWindow(wxWindow
* parent
, wxWindowID id
= -1,
156 const wxPoint
& pos
= wxDefaultPosition
,
157 const wxSize
& sz
= wxDefaultSize
,
164 void OnScroll(wxScrollWinEvent
& event
);
165 void OnSize(wxSizeEvent
& event
);
173 DECLARE_EVENT_TABLE()