]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/gizmos/dynamicsash.h
fixed typo (missing comma) in MIME test
[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 #ifdef GIZMOISDLL
17 #define GIZMODLLEXPORT WXDLLEXPORT
18 #else
19 #define GIZMODLLEXPORT
20 #endif
21
22
23 /*
24
25 wxDynamicSashWindow
26
27 wxDynamicSashWindow widgets manages the way other widgets are viewed.
28 When a wxDynamicSashWindow is first shown, it will contain one child
29 view, a viewport for that child, and a pair of scrollbars to allow the
30 user to navigate the child view area. Next to each scrollbar is a small
31 tab. By clicking on either tab and dragging to the appropriate spot, a
32 user can split the view area into two smaller views separated by a
33 draggable sash. Later, when the user wishes to reunify the two subviews,
34 the user simply drags the sash to the side of the window.
35 wxDynamicSashWindow will automatically reparent the appropriate child
36 view back up the window hierarchy, and the wxDynamicSashWindow will have
37 only one child view once again.
38
39 As an application developer, you will simply create a wxDynamicSashWindow
40 using either the Create() function or the more complex constructor
41 provided below, and then create a view window whose parent is the
42 wxDynamicSashWindow. The child should respond to
43 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
44 constructing a new view window whose parent is also the
45 wxDynamicSashWindow. That's it! Now your users can dynamically split
46 and reunify the view you provided.
47
48 If you wish to handle the scrollbar events for your view, rather than
49 allowing wxDynamicSashWindow to do it for you, things are a bit more
50 complex. (You might want to handle scrollbar events yourself, if,
51 for instance, you wish to scroll a subwindow of the view you add to
52 your wxDynamicSashWindow object, rather than scrolling the whole view.)
53 In this case, you will need to construct your wxDynamicSashWindow without
54 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
55 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
56 controls and call SetEventHanler() on them to redirect the scrolling
57 events whenever your window is reparented by wxDyanmicSashWindow.
58 You will need to set the scrollbars' event handler at three times:
59
60 * When your view is created
61 * When your view receives a wxDynamicSashSplitEvent
62 * When your view receives a wxDynamicSashUnifyEvent
63
64 See the dynsash_switch sample application for an example which does this.
65
66 */
67
68
69 #include <wx/event.h>
70 #include <wx/window.h>
71 class wxScrollBar;
72
73
74 #define wxEVT_DYNAMIC_SASH_BASE (((int)('d' - 'a') << 11) | ((int)('s' - 'a') << 6) | ((int)('h' - 'a') << 1))
75 #define wxEVT_DYNAMIC_SASH_SPLIT (wxEVT_DYNAMIC_SASH_BASE + 1)
76 #define wxEVT_DYNAMIC_SASH_UNIFY (wxEVT_DYNAMIC_SASH_BASE + 2)
77
78 #define EVT_DYNAMIC_SASH_SPLIT(id, func) EVT_CUSTOM(wxEVT_DYNAMIC_SASH_SPLIT, (id), (func))
79 #define EVT_DYNAMIC_SASH_UNIFY(id, func) EVT_CUSTOM(wxEVT_DYNAMIC_SASH_UNIFY, (id), (func))
80
81
82 /*
83 wxDS_MANAGE_SCROLLBARS is a default style of wxDynamicSashWindow which
84 will cause it to respond to scrollbar events for your application by
85 automatically scrolling the child view.
86 */
87 #define wxDS_MANAGE_SCROLLBARS 0x0010
88
89
90 /*
91 wxDS_DRAG_CORNER style indicates that the views can also be resized by
92 dragging the corner piece between the scrollbars, and which is reflected up
93 to the frame if necessary.
94 */
95 #define wxDS_DRAG_CORNER 0x0020
96
97
98 /*
99 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
100 whenever your view is being split by the user. It is your
101 responsibility to handle this event by creating a new view window as
102 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
103 automatically reparent it to the proper place in its window hierarchy.
104 */
105 class GIZMODLLEXPORT wxDynamicSashSplitEvent : public wxCommandEvent {
106 public:
107 wxDynamicSashSplitEvent();
108 wxDynamicSashSplitEvent(const wxDynamicSashSplitEvent& event): wxCommandEvent(event) { }
109 wxDynamicSashSplitEvent(wxObject *target);
110
111 virtual wxEvent* Clone() const { return new wxDynamicSashSplitEvent(*this); }
112
113 private:
114 DECLARE_DYNAMIC_CLASS(wxDynamicSashSplitEvent)
115 };
116
117 /*
118 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
119 whenever the sash which splits your view and its sibling is being
120 reunified such that your view is expanding to replace its sibling.
121 You needn't do anything with this event if you are allowing
122 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
123 if you are managing the scrollbars yourself so that you can keep
124 the scrollbars' event handlers connected to your view's event handler
125 class.
126 */
127 class GIZMODLLEXPORT wxDynamicSashUnifyEvent : public wxCommandEvent {
128 public:
129 wxDynamicSashUnifyEvent();
130 wxDynamicSashUnifyEvent(const wxDynamicSashUnifyEvent& event): wxCommandEvent(event) {}
131 wxDynamicSashUnifyEvent(wxObject *target);
132
133 virtual wxEvent* Clone() const { return new wxDynamicSashUnifyEvent(*this); }
134
135 private:
136 DECLARE_DYNAMIC_CLASS(wxDynamicSashUnifyEvent);
137 };
138
139 typedef void (wxEvtHandler::*wxDynamicSashSplitEventFunction)(wxDynamicSashSplitEvent&);
140 typedef void (wxEvtHandler::*wxDynamicSashUnifyEventFunction)(wxDynamicSashSplitEvent&);
141
142 /*
143 wxDynamicSashWindow. See above.
144 */
145 class GIZMODLLEXPORT wxDynamicSashWindow : public wxWindow {
146 public:
147 wxDynamicSashWindow();
148 wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
149 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
150 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
151 const wxString& name = "dynamicSashWindow");
152 virtual ~wxDynamicSashWindow();
153
154 virtual bool Create(wxWindow *parent, wxWindowID id,
155 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
156 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
157 const wxString& name = "dynamicSashWindow");
158 virtual wxScrollBar *GetHScrollBar(const wxWindow *child) const;
159 virtual wxScrollBar *GetVScrollBar(const wxWindow *child) const;
160
161 /* This is overloaded from wxWindowBase. It's not here for you to
162 call directly. */
163 virtual void AddChild(wxWindowBase *child);
164
165 private:
166 class wxDynamicSashWindowImpl *m_impl;
167
168 DECLARE_DYNAMIC_CLASS(wxDynamicSashWindow)
169 };
170
171
172 #endif