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