]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/gizmos/dynamicsash.h
more const correctness (slightly modified patch 1655991)
[wxWidgets.git] / contrib / include / wx / gizmos / dynamicsash.h
CommitLineData
eacb91fc
VZ
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
936a13b5 16#include "wx/gizmos/gizmos.h"
086ab766 17
f8a28015
VZ
18#if !wxUSE_MDI
19# error "wxUSE_MDI must be defined for gizmos to compile."
20#endif /* !wxUSE_MDI */
21
22
eacb91fc
VZ
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
281de223 54 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
eacb91fc
VZ
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
0ed0bcc8
VZ
69#include "wx/event.h"
70#include "wx/window.h"
eacb91fc 71
0ed0bcc8 72class WXDLLIMPEXP_CORE wxScrollBar;
eacb91fc 73
0ed0bcc8
VZ
74// ----------------------------------------------------------------------------
75// dynamic sash styles
76// ----------------------------------------------------------------------------
eacb91fc
VZ
77
78/*
281de223 79 wxDS_MANAGE_SCROLLBARS is a default style of wxDynamicSashWindow which
eacb91fc
VZ
80 will cause it to respond to scrollbar events for your application by
81 automatically scrolling the child view.
82*/
281de223
RD
83#define wxDS_MANAGE_SCROLLBARS 0x0010
84
85
86/*
87 wxDS_DRAG_CORNER style indicates that the views can also be resized by
88 dragging the corner piece between the scrollbars, and which is reflected up
89 to the frame if necessary.
90*/
91#define wxDS_DRAG_CORNER 0x0020
eacb91fc 92
0ed0bcc8
VZ
93/*
94 Default style for wxDynamicSashWindow.
95 */
96#define wxDS_DEFAULT wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER
97
98// ----------------------------------------------------------------------------
99// dynamic sash events
100// ----------------------------------------------------------------------------
101
102extern WXDLLIMPEXP_GIZMOS const wxEventType wxEVT_DYNAMIC_SASH_SPLIT;
103extern WXDLLIMPEXP_GIZMOS const wxEventType wxEVT_DYNAMIC_SASH_UNIFY;
104
105#define EVT_DYNAMIC_SASH_SPLIT(id, func) \
106 wx__DECLARE_EVT1(wxEVT_DYNAMIC_SASH_SPLIT, id, \
107 wxDynamicSashSplitEventHandler(func))
108
109#define EVT_DYNAMIC_SASH_UNIFY(id, func) \
110 wx__DECLARE_EVT1(wxEVT_DYNAMIC_SASH_UNIFY, id, \
111 wxDynamicSashUnifyEventHandler(func))
112
eacb91fc
VZ
113
114/*
115 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
116 whenever your view is being split by the user. It is your
117 responsibility to handle this event by creating a new view window as
118 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
119 automatically reparent it to the proper place in its window hierarchy.
120*/
0ed0bcc8
VZ
121class WXDLLIMPEXP_GIZMOS wxDynamicSashSplitEvent : public wxCommandEvent
122{
eacb91fc
VZ
123public:
124 wxDynamicSashSplitEvent();
0ed0bcc8
VZ
125 wxDynamicSashSplitEvent(const wxDynamicSashSplitEvent& event)
126 : wxCommandEvent(event) { }
eacb91fc
VZ
127 wxDynamicSashSplitEvent(wxObject *target);
128
41286fd1
JS
129 virtual wxEvent* Clone() const { return new wxDynamicSashSplitEvent(*this); }
130
eacb91fc
VZ
131private:
132 DECLARE_DYNAMIC_CLASS(wxDynamicSashSplitEvent)
133};
134
135/*
136 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
137 whenever the sash which splits your view and its sibling is being
138 reunified such that your view is expanding to replace its sibling.
139 You needn't do anything with this event if you are allowing
140 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
141 if you are managing the scrollbars yourself so that you can keep
142 the scrollbars' event handlers connected to your view's event handler
143 class.
144*/
0ed0bcc8
VZ
145class WXDLLIMPEXP_GIZMOS wxDynamicSashUnifyEvent : public wxCommandEvent
146{
eacb91fc
VZ
147public:
148 wxDynamicSashUnifyEvent();
41286fd1 149 wxDynamicSashUnifyEvent(const wxDynamicSashUnifyEvent& event): wxCommandEvent(event) {}
eacb91fc
VZ
150 wxDynamicSashUnifyEvent(wxObject *target);
151
41286fd1
JS
152 virtual wxEvent* Clone() const { return new wxDynamicSashUnifyEvent(*this); }
153
eacb91fc 154private:
fde63257 155 DECLARE_DYNAMIC_CLASS(wxDynamicSashUnifyEvent)
eacb91fc
VZ
156};
157
cd72551c 158typedef void (wxEvtHandler::*wxDynamicSashSplitEventFunction)(wxDynamicSashSplitEvent&);
ba597ca8 159typedef void (wxEvtHandler::*wxDynamicSashUnifyEventFunction)(wxDynamicSashUnifyEvent&);
cd72551c 160
0ed0bcc8
VZ
161#define wxDynamicSashSplitEventHandler(func) \
162 (wxObjectEventFunction)(wxEventFunction) \
163 wxStaticCastEvent(wxDynamicSashSplitEventFunction, &func)
164
165#define wxDynamicSashUnifyEventHandler(func) \
166 (wxObjectEventFunction)(wxEventFunction) \
167 wxStaticCastEvent(wxDynamicSashUnifyEventFunction, &func)
168
169#define wx__DECLARE_TREEEVT(evt, id, fn) \
170 wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_ ## evt, id, wxTreeEventHandler(fn))
171
172// ----------------------------------------------------------------------------
173// wxDynamicSashWindow itself
174// ----------------------------------------------------------------------------
175
408ac1b8 176WXDLLIMPEXP_GIZMOS extern const wxChar* wxDynamicSashWindowNameStr;
9e053640 177
0ed0bcc8
VZ
178class WXDLLIMPEXP_GIZMOS wxDynamicSashWindow : public wxWindow
179{
eacb91fc
VZ
180public:
181 wxDynamicSashWindow();
182 wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
183 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
0ed0bcc8 184 long style = wxDS_DEFAULT,
9e053640 185 const wxString& name = wxDynamicSashWindowNameStr);
eacb91fc
VZ
186 virtual ~wxDynamicSashWindow();
187
188 virtual bool Create(wxWindow *parent, wxWindowID id,
0ed0bcc8
VZ
189 const wxPoint& pos = wxDefaultPosition,
190 const wxSize& size = wxDefaultSize,
191 long style = wxDS_DEFAULT,
9e053640 192 const wxString& name = wxDynamicSashWindowNameStr);
eacb91fc
VZ
193 virtual wxScrollBar *GetHScrollBar(const wxWindow *child) const;
194 virtual wxScrollBar *GetVScrollBar(const wxWindow *child) const;
195
196 /* This is overloaded from wxWindowBase. It's not here for you to
197 call directly. */
198 virtual void AddChild(wxWindowBase *child);
199
200private:
201 class wxDynamicSashWindowImpl *m_impl;
202
203 DECLARE_DYNAMIC_CLASS(wxDynamicSashWindow)
204};
205
0ed0bcc8 206#endif // _WX_DYNAMICSASH_H_
eacb91fc 207