]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/gizmos/dynamicsash.h
added support for colour cursors in wxGTK (patch 1655576)
[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
eacb91fc
VZ
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
281de223 49 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
eacb91fc
VZ
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
0ed0bcc8
VZ
64#include "wx/event.h"
65#include "wx/window.h"
eacb91fc 66
0ed0bcc8 67class WXDLLIMPEXP_CORE wxScrollBar;
eacb91fc 68
0ed0bcc8
VZ
69// ----------------------------------------------------------------------------
70// dynamic sash styles
71// ----------------------------------------------------------------------------
eacb91fc
VZ
72
73/*
281de223 74 wxDS_MANAGE_SCROLLBARS is a default style of wxDynamicSashWindow which
eacb91fc
VZ
75 will cause it to respond to scrollbar events for your application by
76 automatically scrolling the child view.
77*/
281de223
RD
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
eacb91fc 87
0ed0bcc8
VZ
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
97extern WXDLLIMPEXP_GIZMOS const wxEventType wxEVT_DYNAMIC_SASH_SPLIT;
98extern 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
eacb91fc
VZ
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*/
0ed0bcc8
VZ
116class WXDLLIMPEXP_GIZMOS wxDynamicSashSplitEvent : public wxCommandEvent
117{
eacb91fc
VZ
118public:
119 wxDynamicSashSplitEvent();
0ed0bcc8
VZ
120 wxDynamicSashSplitEvent(const wxDynamicSashSplitEvent& event)
121 : wxCommandEvent(event) { }
eacb91fc
VZ
122 wxDynamicSashSplitEvent(wxObject *target);
123
41286fd1
JS
124 virtual wxEvent* Clone() const { return new wxDynamicSashSplitEvent(*this); }
125
eacb91fc
VZ
126private:
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*/
0ed0bcc8
VZ
140class WXDLLIMPEXP_GIZMOS wxDynamicSashUnifyEvent : public wxCommandEvent
141{
eacb91fc
VZ
142public:
143 wxDynamicSashUnifyEvent();
41286fd1 144 wxDynamicSashUnifyEvent(const wxDynamicSashUnifyEvent& event): wxCommandEvent(event) {}
eacb91fc
VZ
145 wxDynamicSashUnifyEvent(wxObject *target);
146
41286fd1
JS
147 virtual wxEvent* Clone() const { return new wxDynamicSashUnifyEvent(*this); }
148
eacb91fc 149private:
fde63257 150 DECLARE_DYNAMIC_CLASS(wxDynamicSashUnifyEvent)
eacb91fc
VZ
151};
152
cd72551c 153typedef void (wxEvtHandler::*wxDynamicSashSplitEventFunction)(wxDynamicSashSplitEvent&);
ba597ca8 154typedef void (wxEvtHandler::*wxDynamicSashUnifyEventFunction)(wxDynamicSashUnifyEvent&);
cd72551c 155
0ed0bcc8
VZ
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
408ac1b8 171WXDLLIMPEXP_GIZMOS extern const wxChar* wxDynamicSashWindowNameStr;
9e053640 172
0ed0bcc8
VZ
173class WXDLLIMPEXP_GIZMOS wxDynamicSashWindow : public wxWindow
174{
eacb91fc
VZ
175public:
176 wxDynamicSashWindow();
177 wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
178 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
0ed0bcc8 179 long style = wxDS_DEFAULT,
9e053640 180 const wxString& name = wxDynamicSashWindowNameStr);
eacb91fc
VZ
181 virtual ~wxDynamicSashWindow();
182
183 virtual bool Create(wxWindow *parent, wxWindowID id,
0ed0bcc8
VZ
184 const wxPoint& pos = wxDefaultPosition,
185 const wxSize& size = wxDefaultSize,
186 long style = wxDS_DEFAULT,
9e053640 187 const wxString& name = wxDynamicSashWindowNameStr);
eacb91fc
VZ
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
195private:
196 class wxDynamicSashWindowImpl *m_impl;
197
198 DECLARE_DYNAMIC_CLASS(wxDynamicSashWindow)
199};
200
0ed0bcc8 201#endif // _WX_DYNAMICSASH_H_
eacb91fc 202