]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/gizmos/dynamicsash.h
splitted gizmos library into gizmos and gizmos_xrc in order to fix broken compilation...
[wxWidgets.git] / contrib / include / wx / gizmos / dynamicsash.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dynamicsash.h
3 // Purpose: A window which can be dynamically split to an arbitrary depth
4 // and later reunified through the user interface
5 // Author: Matt Kimball
6 // Modified by:
7 // Created: 7/15/2001
8 // RCS-ID: $Id$
9 // Copyright: (c) 2001 Matt Kimball
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WX_DYNAMICSASH_H_
14 #define _WX_DYNAMICSASH_H_
15
16 #include "wx/gizmos/gizmos.h"
17
18 /*
19
20 wxDynamicSashWindow
21
22 wxDynamicSashWindow widgets manages the way other widgets are viewed.
23 When a wxDynamicSashWindow is first shown, it will contain one child
24 view, a viewport for that child, and a pair of scrollbars to allow the
25 user to navigate the child view area. Next to each scrollbar is a small
26 tab. By clicking on either tab and dragging to the appropriate spot, a
27 user can split the view area into two smaller views separated by a
28 draggable sash. Later, when the user wishes to reunify the two subviews,
29 the user simply drags the sash to the side of the window.
30 wxDynamicSashWindow will automatically reparent the appropriate child
31 view back up the window hierarchy, and the wxDynamicSashWindow will have
32 only one child view once again.
33
34 As an application developer, you will simply create a wxDynamicSashWindow
35 using either the Create() function or the more complex constructor
36 provided below, and then create a view window whose parent is the
37 wxDynamicSashWindow. The child should respond to
38 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
39 constructing a new view window whose parent is also the
40 wxDynamicSashWindow. That's it! Now your users can dynamically split
41 and reunify the view you provided.
42
43 If you wish to handle the scrollbar events for your view, rather than
44 allowing wxDynamicSashWindow to do it for you, things are a bit more
45 complex. (You might want to handle scrollbar events yourself, if,
46 for instance, you wish to scroll a subwindow of the view you add to
47 your wxDynamicSashWindow object, rather than scrolling the whole view.)
48 In this case, you will need to construct your wxDynamicSashWindow without
49 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
50 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
51 controls and call SetEventHanler() on them to redirect the scrolling
52 events whenever your window is reparented by wxDyanmicSashWindow.
53 You will need to set the scrollbars' event handler at three times:
54
55 * When your view is created
56 * When your view receives a wxDynamicSashSplitEvent
57 * When your view receives a wxDynamicSashUnifyEvent
58
59 See the dynsash_switch sample application for an example which does this.
60
61 */
62
63
64 #include "wx/event.h"
65 #include "wx/window.h"
66
67 class WXDLLIMPEXP_CORE wxScrollBar;
68
69 // ----------------------------------------------------------------------------
70 // dynamic sash styles
71 // ----------------------------------------------------------------------------
72
73 /*
74 wxDS_MANAGE_SCROLLBARS is a default style of wxDynamicSashWindow which
75 will cause it to respond to scrollbar events for your application by
76 automatically scrolling the child view.
77 */
78 #define wxDS_MANAGE_SCROLLBARS 0x0010
79
80
81 /*
82 wxDS_DRAG_CORNER style indicates that the views can also be resized by
83 dragging the corner piece between the scrollbars, and which is reflected up
84 to the frame if necessary.
85 */
86 #define wxDS_DRAG_CORNER 0x0020
87
88 /*
89 Default style for wxDynamicSashWindow.
90 */
91 #define wxDS_DEFAULT wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER
92
93 // ----------------------------------------------------------------------------
94 // dynamic sash events
95 // ----------------------------------------------------------------------------
96
97 extern WXDLLIMPEXP_GIZMOS const wxEventType wxEVT_DYNAMIC_SASH_SPLIT;
98 extern WXDLLIMPEXP_GIZMOS const wxEventType wxEVT_DYNAMIC_SASH_UNIFY;
99
100 #define EVT_DYNAMIC_SASH_SPLIT(id, func) \
101 wx__DECLARE_EVT1(wxEVT_DYNAMIC_SASH_SPLIT, id, \
102 wxDynamicSashSplitEventHandler(func))
103
104 #define EVT_DYNAMIC_SASH_UNIFY(id, func) \
105 wx__DECLARE_EVT1(wxEVT_DYNAMIC_SASH_UNIFY, id, \
106 wxDynamicSashUnifyEventHandler(func))
107
108
109 /*
110 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
111 whenever your view is being split by the user. It is your
112 responsibility to handle this event by creating a new view window as
113 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
114 automatically reparent it to the proper place in its window hierarchy.
115 */
116 class WXDLLIMPEXP_GIZMOS wxDynamicSashSplitEvent : public wxCommandEvent
117 {
118 public:
119 wxDynamicSashSplitEvent();
120 wxDynamicSashSplitEvent(const wxDynamicSashSplitEvent& event)
121 : wxCommandEvent(event) { }
122 wxDynamicSashSplitEvent(wxObject *target);
123
124 virtual wxEvent* Clone() const { return new wxDynamicSashSplitEvent(*this); }
125
126 private:
127 DECLARE_DYNAMIC_CLASS(wxDynamicSashSplitEvent)
128 };
129
130 /*
131 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
132 whenever the sash which splits your view and its sibling is being
133 reunified such that your view is expanding to replace its sibling.
134 You needn't do anything with this event if you are allowing
135 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
136 if you are managing the scrollbars yourself so that you can keep
137 the scrollbars' event handlers connected to your view's event handler
138 class.
139 */
140 class WXDLLIMPEXP_GIZMOS wxDynamicSashUnifyEvent : public wxCommandEvent
141 {
142 public:
143 wxDynamicSashUnifyEvent();
144 wxDynamicSashUnifyEvent(const wxDynamicSashUnifyEvent& event): wxCommandEvent(event) {}
145 wxDynamicSashUnifyEvent(wxObject *target);
146
147 virtual wxEvent* Clone() const { return new wxDynamicSashUnifyEvent(*this); }
148
149 private:
150 DECLARE_DYNAMIC_CLASS(wxDynamicSashUnifyEvent)
151 };
152
153 typedef void (wxEvtHandler::*wxDynamicSashSplitEventFunction)(wxDynamicSashSplitEvent&);
154 typedef void (wxEvtHandler::*wxDynamicSashUnifyEventFunction)(wxDynamicSashUnifyEvent&);
155
156 #define wxDynamicSashSplitEventHandler(func) \
157 (wxObjectEventFunction)(wxEventFunction) \
158 wxStaticCastEvent(wxDynamicSashSplitEventFunction, &func)
159
160 #define wxDynamicSashUnifyEventHandler(func) \
161 (wxObjectEventFunction)(wxEventFunction) \
162 wxStaticCastEvent(wxDynamicSashUnifyEventFunction, &func)
163
164 #define wx__DECLARE_TREEEVT(evt, id, fn) \
165 wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_ ## evt, id, wxTreeEventHandler(fn))
166
167 // ----------------------------------------------------------------------------
168 // wxDynamicSashWindow itself
169 // ----------------------------------------------------------------------------
170
171 WXDLLIMPEXP_GIZMOS extern const wxChar* wxDynamicSashWindowNameStr;
172
173 class WXDLLIMPEXP_GIZMOS wxDynamicSashWindow : public wxWindow
174 {
175 public:
176 wxDynamicSashWindow();
177 wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
178 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
179 long style = wxDS_DEFAULT,
180 const wxString& name = wxDynamicSashWindowNameStr);
181 virtual ~wxDynamicSashWindow();
182
183 virtual bool Create(wxWindow *parent, wxWindowID id,
184 const wxPoint& pos = wxDefaultPosition,
185 const wxSize& size = wxDefaultSize,
186 long style = wxDS_DEFAULT,
187 const wxString& name = wxDynamicSashWindowNameStr);
188 virtual wxScrollBar *GetHScrollBar(const wxWindow *child) const;
189 virtual wxScrollBar *GetVScrollBar(const wxWindow *child) const;
190
191 /* This is overloaded from wxWindowBase. It's not here for you to
192 call directly. */
193 virtual void AddChild(wxWindowBase *child);
194
195 private:
196 class wxDynamicSashWindowImpl *m_impl;
197
198 DECLARE_DYNAMIC_CLASS(wxDynamicSashWindow)
199 };
200
201 #endif // _WX_DYNAMICSASH_H_
202