]>
Commit | Line | Data |
---|---|---|
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 | ||
64 | #include <wx/event.h> | |
65 | #include <wx/window.h> | |
66 | class wxScrollBar; | |
67 | ||
68 | ||
69 | #define wxEVT_DYNAMIC_SASH_BASE (((int)('d' - 'a') << 11) | ((int)('s' - 'a') << 6) | ((int)('h' - 'a') << 1)) | |
70 | #define wxEVT_DYNAMIC_SASH_SPLIT (wxEVT_DYNAMIC_SASH_BASE + 1) | |
71 | #define wxEVT_DYNAMIC_SASH_UNIFY (wxEVT_DYNAMIC_SASH_BASE + 2) | |
72 | ||
73 | #define EVT_DYNAMIC_SASH_SPLIT(id, func) EVT_CUSTOM(wxEVT_DYNAMIC_SASH_SPLIT, (id), (func)) | |
74 | #define EVT_DYNAMIC_SASH_UNIFY(id, func) EVT_CUSTOM(wxEVT_DYNAMIC_SASH_UNIFY, (id), (func)) | |
75 | ||
76 | ||
77 | /* | |
281de223 | 78 | wxDS_MANAGE_SCROLLBARS is a default style of wxDynamicSashWindow which |
eacb91fc VZ |
79 | will cause it to respond to scrollbar events for your application by |
80 | automatically scrolling the child view. | |
81 | */ | |
281de223 RD |
82 | #define wxDS_MANAGE_SCROLLBARS 0x0010 |
83 | ||
84 | ||
85 | /* | |
86 | wxDS_DRAG_CORNER style indicates that the views can also be resized by | |
87 | dragging the corner piece between the scrollbars, and which is reflected up | |
88 | to the frame if necessary. | |
89 | */ | |
90 | #define wxDS_DRAG_CORNER 0x0020 | |
eacb91fc VZ |
91 | |
92 | ||
93 | /* | |
94 | wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow | |
95 | whenever your view is being split by the user. It is your | |
96 | responsibility to handle this event by creating a new view window as | |
97 | a child of the wxDynamicSashWindow. wxDynamicSashWindow will | |
98 | automatically reparent it to the proper place in its window hierarchy. | |
99 | */ | |
936a13b5 | 100 | class WXDLLIMPEXP_GIZMOS wxDynamicSashSplitEvent : public wxCommandEvent { |
eacb91fc VZ |
101 | public: |
102 | wxDynamicSashSplitEvent(); | |
41286fd1 | 103 | wxDynamicSashSplitEvent(const wxDynamicSashSplitEvent& event): wxCommandEvent(event) { } |
eacb91fc VZ |
104 | wxDynamicSashSplitEvent(wxObject *target); |
105 | ||
41286fd1 JS |
106 | virtual wxEvent* Clone() const { return new wxDynamicSashSplitEvent(*this); } |
107 | ||
eacb91fc VZ |
108 | private: |
109 | DECLARE_DYNAMIC_CLASS(wxDynamicSashSplitEvent) | |
110 | }; | |
111 | ||
112 | /* | |
113 | wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow | |
114 | whenever the sash which splits your view and its sibling is being | |
115 | reunified such that your view is expanding to replace its sibling. | |
116 | You needn't do anything with this event if you are allowing | |
117 | wxDynamicSashWindow to manage your view's scrollbars, but it is useful | |
118 | if you are managing the scrollbars yourself so that you can keep | |
119 | the scrollbars' event handlers connected to your view's event handler | |
120 | class. | |
121 | */ | |
936a13b5 | 122 | class WXDLLIMPEXP_GIZMOS wxDynamicSashUnifyEvent : public wxCommandEvent { |
eacb91fc VZ |
123 | public: |
124 | wxDynamicSashUnifyEvent(); | |
41286fd1 | 125 | wxDynamicSashUnifyEvent(const wxDynamicSashUnifyEvent& event): wxCommandEvent(event) {} |
eacb91fc VZ |
126 | wxDynamicSashUnifyEvent(wxObject *target); |
127 | ||
41286fd1 JS |
128 | virtual wxEvent* Clone() const { return new wxDynamicSashUnifyEvent(*this); } |
129 | ||
eacb91fc | 130 | private: |
fde63257 | 131 | DECLARE_DYNAMIC_CLASS(wxDynamicSashUnifyEvent) |
eacb91fc VZ |
132 | }; |
133 | ||
cd72551c | 134 | typedef void (wxEvtHandler::*wxDynamicSashSplitEventFunction)(wxDynamicSashSplitEvent&); |
ba597ca8 | 135 | typedef void (wxEvtHandler::*wxDynamicSashUnifyEventFunction)(wxDynamicSashUnifyEvent&); |
cd72551c | 136 | |
eacb91fc VZ |
137 | /* |
138 | wxDynamicSashWindow. See above. | |
139 | */ | |
408ac1b8 | 140 | WXDLLIMPEXP_GIZMOS extern const wxChar* wxDynamicSashWindowNameStr; |
9e053640 | 141 | |
936a13b5 | 142 | class WXDLLIMPEXP_GIZMOS wxDynamicSashWindow : public wxWindow { |
eacb91fc VZ |
143 | public: |
144 | wxDynamicSashWindow(); | |
145 | wxDynamicSashWindow(wxWindow *parent, wxWindowID id, | |
146 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
281de223 | 147 | long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER, |
9e053640 | 148 | const wxString& name = wxDynamicSashWindowNameStr); |
eacb91fc VZ |
149 | virtual ~wxDynamicSashWindow(); |
150 | ||
151 | virtual bool Create(wxWindow *parent, wxWindowID id, | |
152 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
281de223 | 153 | long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER, |
9e053640 | 154 | const wxString& name = wxDynamicSashWindowNameStr); |
eacb91fc VZ |
155 | virtual wxScrollBar *GetHScrollBar(const wxWindow *child) const; |
156 | virtual wxScrollBar *GetVScrollBar(const wxWindow *child) const; | |
157 | ||
158 | /* This is overloaded from wxWindowBase. It's not here for you to | |
159 | call directly. */ | |
160 | virtual void AddChild(wxWindowBase *child); | |
161 | ||
162 | private: | |
163 | class wxDynamicSashWindowImpl *m_impl; | |
164 | ||
165 | DECLARE_DYNAMIC_CLASS(wxDynamicSashWindow) | |
166 | }; | |
167 | ||
168 | ||
169 | #endif |