]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/splitter.tex
reSWIGged
[wxWidgets.git] / docs / latex / wx / splitter.tex
1 \section{\class{wxSplitterWindow}}\label{wxsplitterwindow}
2
3 \overview{wxSplitterWindow overview}{wxsplitterwindowoverview}
4
5 This class manages up to two subwindows. The current view can be
6 split into two programmatically (perhaps from a menu command), and unsplit
7 either programmatically or via the wxSplitterWindow user interface.
8
9 \wxheading{Window styles}
10
11 \begin{twocollist}\itemsep=0pt
12 \twocolitem{\windowstyle{wxSP\_3D}}{Draws a 3D effect border and sash.}
13 \twocolitem{\windowstyle{wxSP\_3DSASH}}{Draws a 3D effect sash.}
14 \twocolitem{\windowstyle{wxSP\_3DBORDER}}{Synonym for wxSP\_BORDER.}
15 \twocolitem{\windowstyle{wxSP\_BORDER}}{Draws a standard border.}
16 \twocolitem{\windowstyle{wxSP\_NOBORDER}}{No border (default).}
17 \twocolitem{\windowstyle{wxSP\_NO\_XP\_THEME}}{Under Windows XP, switches off the attempt to draw the
18 splitter using Windows XP theming, so the borders and sash will take on the pre-XP look.}
19 \twocolitem{\windowstyle{wxSP\_PERMIT\_UNSPLIT}}{Always allow to
20 unsplit, even with the minimum pane size other than zero.}
21 \twocolitem{\windowstyle{wxSP\_LIVE\_UPDATE}}{Don't draw XOR line but resize the child windows immediately.}
22 \end{twocollist}
23
24 See also \helpref{window styles overview}{windowstyles}.
25
26 \wxheading{Derived from}
27
28 \helpref{wxWindow}{wxwindow}\\
29 \helpref{wxEvtHandler}{wxevthandler}\\
30 \helpref{wxObject}{wxobject}
31
32 \wxheading{Include files}
33
34 <wx/splitter.h>
35
36 \wxheading{Event handling}
37
38 To process input from a splitter control, use the following event handler
39 macros to direct input to member functions that take a
40 \helpref{wxSplitterEvent}{wxsplitterevent} argument.
41
42 \twocolwidtha{10cm}
43 \begin{twocollist}\itemsep=0pt
44 \twocolitem{{\bf EVT\_SPLITTER\_SASH\_POS\_CHANGING(id, func)}}{The sash
45 position is in the process of being changed. May be used to modify the
46 position of the tracking bar to properly reflect the position that
47 would be set if the drag were to be completed at this point. Processes
48 a wxEVT\_COMMAND\_SPLITTER\_SASH\_POS\_CHANGING event.}
49 \twocolitem{{\bf EVT\_SPLITTER\_SASH\_POS\_CHANGED(id, func)}}{The sash
50 position was changed. May be used to modify the sash position before
51 it is set, or to prevent the change from taking place.
52 Processes a wxEVT\_COMMAND\_SPLITTER\_SASH\_POS\_CHANGED event.}
53 \twocolitem{{\bf EVT\_SPLITTER\_UNSPLIT(id, func)}}{The splitter has been just
54 unsplit. Processes a wxEVT\_COMMAND\_SPLITTER\_UNSPLIT event.}
55 \twocolitem{{\bf EVT\_SPLITTER\_DCLICK(id, func)}}{The sash was double
56 clicked. The default behaviour is to unsplit the window when this happens
57 (unless the minimum pane size has been set to a value greater than zero).
58 Processes a wxEVT\_COMMAND\_SPLITTER\_DOUBLECLICKED event.}
59 \end{twocollist}%
60
61 \wxheading{See also}
62
63 \helpref{wxSplitterEvent}{wxsplitterevent}
64
65 \latexignore{\rtfignore{\wxheading{Members}}}
66
67 \membersection{wxSplitterWindow::wxSplitterWindow}\label{wxsplitterwindowconstr}
68
69 \func{}{wxSplitterWindow}{\void}
70
71 Default constructor.
72
73 \func{}{wxSplitterWindow}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
74 \param{const wxPoint\& }{point = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
75 \param{long }{style=wxSP\_3D}, \param{const wxString\&}{ name = "splitterWindow"}}
76
77 Constructor for creating the window.
78
79 \wxheading{Parameters}
80
81 \docparam{parent}{The parent of the splitter window.}
82
83 \docparam{id}{The window identifier.}
84
85 \docparam{pos}{The window position.}
86
87 \docparam{size}{The window size.}
88
89 \docparam{style}{The window style. See \helpref{wxSplitterWindow}{wxsplitterwindow}.}
90
91 \docparam{name}{The window name.}
92
93 \wxheading{Remarks}
94
95 After using this constructor, you must create either one or two subwindows
96 with the splitter window as parent, and then call one of \helpref{wxSplitterWindow::Initialize}{wxsplitterwindowinitialize},\rtfsp
97 \helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically} and \helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally} in
98 order to set the pane(s).
99
100 You can create two windows, with one hidden when not being shown; or you can
101 create and delete the second pane on demand.
102
103 \wxheading{See also}
104
105 \helpref{wxSplitterWindow::Initialize}{wxsplitterwindowinitialize}, \helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically},\rtfsp
106 \helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally},\rtfsp
107 \helpref{wxSplitterWindow::Create}{wxsplitterwindowcreate}
108
109 \membersection{wxSplitterWindow::\destruct{wxSplitterWindow}}
110
111 \func{}{\destruct{wxSplitterWindow}}{\void}
112
113 Destroys the wxSplitterWindow and its children.
114
115 \membersection{wxSplitterWindow::Create}\label{wxsplitterwindowcreate}
116
117 \func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id}, \param{int }{x},\rtfsp
118 \param{const wxPoint\& }{point = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
119 \param{long }{style=wxSP\_3D}, \param{const wxString\&}{ name = "splitterWindow"}}
120
121 Creation function, for two-step construction. See \helpref{wxSplitterWindow::wxSplitterWindow}{wxsplitterwindowconstr} for
122 details.
123
124 \membersection{wxSplitterWindow::GetMinimumPaneSize}\label{wxsplitterwindowgetminimumpanesize}
125
126 \constfunc{int}{GetMinimumPaneSize}{\void}
127
128 Returns the current minimum pane size (defaults to zero).
129
130 \wxheading{See also}
131
132 \helpref{wxSplitterWindow::SetMinimumPaneSize}{wxsplitterwindowsetminimumpanesize}
133
134 \membersection{wxSplitterWindow::GetSashPosition}\label{wxsplitterwindowgetsashposition}
135
136 \func{int}{GetSashPosition}{\void}
137
138 Returns the current sash position.
139
140 \wxheading{See also}
141
142 \helpref{wxSplitterWindow::SetSashPosition}{wxsplitterwindowsetsashposition}
143
144 \membersection{wxSplitterWindow::GetSplitMode}\label{wxsplitterwindowgetsplitmode}
145
146 \constfunc{int}{GetSplitMode}{\void}
147
148 Gets the split mode.
149
150 \wxheading{See also}
151
152 \helpref{wxSplitterWindow::SetSplitMode}{wxsplitterwindowsetsplitmode}, \helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically},\rtfsp
153 \helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally}.
154
155 \membersection{wxSplitterWindow::GetWindow1}\label{wxsplitterwindowgetwindow1}
156
157 \constfunc{wxWindow*}{GetWindow1}{\void}
158
159 Returns the left/top or only pane.
160
161 \membersection{wxSplitterWindow::GetWindow2}\label{wxsplitterwindowgetwindow2}
162
163 \constfunc{wxWindow*}{GetWindow2}{\void}
164
165 Returns the right/bottom pane.
166
167 \membersection{wxSplitterWindow::Initialize}\label{wxsplitterwindowinitialize}
168
169 \func{void}{Initialize}{\param{wxWindow* }{window}}
170
171 Initializes the splitter window to have one pane.
172
173 \wxheading{Parameters}
174
175 \docparam{window}{The pane for the unsplit window.}
176
177 \wxheading{Remarks}
178
179 This should be called if you wish to initially view only a single pane in the splitter window.
180
181 \wxheading{See also}
182
183 \helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically},\rtfsp
184 \helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally}
185
186 \membersection{wxSplitterWindow::IsSplit}\label{wxsplitterwindowissplit}
187
188 \constfunc{bool}{IsSplit}{\void}
189
190 Returns true if the window is split, false otherwise.
191
192 \membersection{wxSplitterWindow::OnDoubleClickSash}\label{wxsplitterwindowondoubleclicksash}
193
194 \func{virtual void}{OnDoubleClickSash}{\param{int }{x}, \param{int }{y}}
195
196 Application-overridable function called when the sash is double-clicked with
197 the left mouse button.
198
199 \wxheading{Parameters}
200
201 \docparam{x}{The x position of the mouse cursor.}
202
203 \docparam{y}{The y position of the mouse cursor.}
204
205 \wxheading{Remarks}
206
207 The default implementation of this function calls \helpref{Unsplit}{wxsplitterwindowunsplit} if
208 the minimum pane size is zero.
209
210 \wxheading{See also}
211
212 \helpref{wxSplitterWindow::Unsplit}{wxsplitterwindowunsplit}
213
214 \membersection{wxSplitterWindow::OnUnsplit}\label{wxsplitterwindowonunsplit}
215
216 \func{virtual void}{OnUnsplit}{\param{wxWindow* }{removed}}
217
218 Application-overridable function called when the window is unsplit, either
219 programmatically or using the wxSplitterWindow user interface.
220
221 \wxheading{Parameters}
222
223 \docparam{removed}{The window being removed.}
224
225 \wxheading{Remarks}
226
227 The default implementation of this function simply hides {\it removed}. You
228 may wish to delete the window.
229
230 \membersection{wxSplitterWindow::OnSashPositionChange}\label{wxsplitterwindowonsashpositionchange}
231
232 \func{virtual bool}{OnSashPositionChange}{\param{int }{newSashPosition}}
233
234 Application-overridable function called when the sash position is changed by
235 user. It may return false to prevent the change or true to allow it.
236
237 \wxheading{Parameters}
238
239 \docparam{newSashPosition}{The new sash position (always positive or zero)}
240
241 \wxheading{Remarks}
242
243 The default implementation of this function verifies that the sizes of both
244 panes of the splitter are greater than minimum pane size.
245
246 \membersection{wxSplitterWindow::ReplaceWindow}\label{wxsplitterwindowreplacewindow}
247
248 \func{bool}{ReplaceWindow}{\param{wxWindow * }{winOld}, \param{wxWindow * }{winNew}}
249
250 This function replaces one of the windows managed by the wxSplitterWindow with
251 another one. It is in general better to use it instead of calling Unsplit()
252 and then resplitting the window back because it will provoke much less flicker
253 (if any). It is valid to call this function whether the splitter has two
254 windows or only one.
255
256 Both parameters should be non-NULL and {\it winOld} must specify one of the
257 windows managed by the splitter. If the parameters are incorrect or the window
258 couldn't be replaced, false is returned. Otherwise the function will return
259 true, but please notice that it will not delete the replaced window and you
260 may wish to do it yourself.
261
262 \wxheading{See also}
263
264 \helpref{wxSplitterWindow::GetMinimumPaneSize}{wxsplitterwindowgetminimumpanesize}
265
266 \wxheading{See also}
267
268 \helpref{wxSplitterWindow::Unsplit}{wxsplitterwindowunsplit}\\
269 \helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically}\\
270 \helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally}
271
272 \membersection{wxSplitterWindow::SetSashPosition}\label{wxsplitterwindowsetsashposition}
273
274 \func{void}{SetSashPosition}{\param{int }{position}, \param{const bool}{ redraw = true}}
275
276 Sets the sash position.
277
278 \wxheading{Parameters}
279
280 \docparam{position}{The sash position in pixels.}
281
282 \docparam{redraw}{If true, resizes the panes and redraws the sash and border.}
283
284 \wxheading{Remarks}
285
286 Does not currently check for an out-of-range value.
287
288 \wxheading{See also}
289
290 \helpref{wxSplitterWindow::GetSashPosition}{wxsplitterwindowgetsashposition}
291
292 \membersection{wxSplitterWindow::SetMinimumPaneSize}\label{wxsplitterwindowsetminimumpanesize}
293
294 \func{void}{SetMinimumPaneSize}{\param{int }{paneSize}}
295
296 Sets the minimum pane size.
297
298 \wxheading{Parameters}
299
300 \docparam{paneSize}{Minimum pane size in pixels.}
301
302 \wxheading{Remarks}
303
304 The default minimum pane size is zero, which means that either pane can be reduced to zero by dragging
305 the sash, thus removing one of the panes. To prevent this behaviour (and veto out-of-range sash dragging),
306 set a minimum size, for example 20 pixels. If the wxSP\_PERMIT\_UNSPLIT style
307 is used when a splitter window is created, the window may be unsplit even
308 if minimum size is non-zero.
309
310 \wxheading{See also}
311
312 \helpref{wxSplitterWindow::GetMinimumPaneSize}{wxsplitterwindowgetminimumpanesize}
313
314 \membersection{wxSplitterWindow::SetSplitMode}\label{wxsplitterwindowsetsplitmode}
315
316 \func{void}{SetSplitMode}{\param{int }{mode}}
317
318 Sets the split mode.
319
320 \wxheading{Parameters}
321
322 \docparam{mode}{Can be wxSPLIT\_VERTICAL or wxSPLIT\_HORIZONTAL.}
323
324 \wxheading{Remarks}
325
326 Only sets the internal variable; does not update the display.
327
328 \wxheading{See also}
329
330 \helpref{wxSplitterWindow::GetSplitMode}{wxsplitterwindowgetsplitmode}, \helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically},\rtfsp
331 \helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally}.
332
333 \membersection{wxSplitterWindow::SplitHorizontally}\label{wxsplitterwindowsplithorizontally}
334
335 \func{bool}{SplitHorizontally}{\param{wxWindow* }{window1}, \param{wxWindow* }{window2},
336 \param{int}{ sashPosition = 0}}
337
338 Initializes the top and bottom panes of the splitter window.
339
340 \wxheading{Parameters}
341
342 \docparam{window1}{The top pane.}
343
344 \docparam{window2}{The bottom pane.}
345
346 \docparam{sashPosition}{The initial position of the sash. If this value is
347 positive, it specifies the size of the upper pane. If it is negative, it is
348 absolute value gives the size of the lower pane. Finally, specify 0 (default)
349 to choose the default position (half of the total window height).}
350
351 \wxheading{Return value}
352
353 true if successful, false otherwise (the window was already split).
354
355 \wxheading{Remarks}
356
357 This should be called if you wish to initially view two panes. It can also be
358 called at any subsequent time, but the application should check that the
359 window is not currently split using \helpref{IsSplit}{wxsplitterwindowissplit}.
360
361 \wxheading{See also}
362
363 \helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically}, \helpref{wxSplitterWindow::IsSplit}{wxsplitterwindowissplit},\rtfsp
364 \helpref{wxSplitterWindow::Unsplit}{wxsplitterwindowunsplit}
365
366 \membersection{wxSplitterWindow::SplitVertically}\label{wxsplitterwindowsplitvertically}
367
368 \func{bool}{SplitVertically}{\param{wxWindow* }{window1}, \param{wxWindow* }{window2},
369 \param{int}{ sashPosition = 0}}
370
371 Initializes the left and right panes of the splitter window.
372
373 \wxheading{Parameters}
374
375 \docparam{window1}{The left pane.}
376
377 \docparam{window2}{The right pane.}
378
379 \docparam{sashPosition}{The initial position of the sash. If this value is
380 positive, it specifies the size of the left pane. If it is negative, it is
381 absolute value gives the size of the right pane. Finally, specify 0 (default)
382 to choose the default position (half of the total window width).}
383
384 \wxheading{Return value}
385
386 true if successful, false otherwise (the window was already split).
387
388 \wxheading{Remarks}
389
390 This should be called if you wish to initially view two panes. It can also be called at any subsequent time,
391 but the application should check that the window is not currently split using \helpref{IsSplit}{wxsplitterwindowissplit}.
392
393 \wxheading{See also}
394
395 \helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally}, \helpref{wxSplitterWindow::IsSplit}{wxsplitterwindowissplit},\rtfsp
396 \helpref{wxSplitterWindow::Unsplit}{wxsplitterwindowunsplit}.
397
398 \membersection{wxSplitterWindow::Unsplit}\label{wxsplitterwindowunsplit}
399
400 \func{bool}{Unsplit}{\param{wxWindow* }{toRemove = NULL}}
401
402 Unsplits the window.
403
404 \wxheading{Parameters}
405
406 \docparam{toRemove}{The pane to remove, or NULL to remove the right or bottom pane.}
407
408 \wxheading{Return value}
409
410 true if successful, false otherwise (the window was not split).
411
412 \wxheading{Remarks}
413
414 This call will not actually delete the pane being removed; it calls \helpref{OnUnsplit}{wxsplitterwindowonunsplit}\rtfsp
415 which can be overridden for the desired behaviour. By default, the pane being removed is hidden.
416
417 \wxheading{See also}
418
419 \helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally}, \helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically},\rtfsp
420 \helpref{wxSplitterWindow::IsSplit}{wxsplitterwindowissplit}, \helpref{wxSplitterWindow::OnUnsplit}{wxsplitterwindowonunsplit}
421
422 \membersection{wxSplitterWindow::UpdateSize}\label{wxsplitterwindowupdatesize}
423
424 \func{void}{UpdateSize}{\void}
425
426 Causes any pending sizing of the sash and child panes to take place
427 immediately.
428
429 Such resizing normally takes place in idle time, in order
430 to wait for layout to be completed. However, this can cause
431 unacceptable flicker as the panes are resized after the window has been
432 shown. To work around this, you can perform window layout (for
433 example by sending a size event to the parent window), and then
434 call this function, before showing the top-level window.
435