]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/splitter.h
Fix html documentation warnings.
[wxWidgets.git] / interface / wx / splitter.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: splitter.h
e54c96f1 3// Purpose: interface of wxSplitterWindow
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
8ff9b17d 8
7106fc46
RD
9#define wxSP_NOBORDER 0x0000
10#define wxSP_THIN_SASH 0x0000 // NB: the default is 3D sash
11#define wxSP_NOSASH 0x0010
12#define wxSP_PERMIT_UNSPLIT 0x0040
13#define wxSP_LIVE_UPDATE 0x0080
14#define wxSP_3DSASH 0x0100
15#define wxSP_3DBORDER 0x0200
16#define wxSP_NO_XP_THEME 0x0400
17#define wxSP_BORDER wxSP_3DBORDER
18#define wxSP_3D (wxSP_3DBORDER | wxSP_3DSASH)
19
20
8ff9b17d
RD
21enum wxSplitMode
22{
23 wxSPLIT_HORIZONTAL = 1,
24 wxSPLIT_VERTICAL
25};
26
27enum
28{
29 wxSPLIT_DRAG_NONE,
30 wxSPLIT_DRAG_DRAGGING,
31 wxSPLIT_DRAG_LEFT_DOWN
32};
33
23324ae1
FM
34/**
35 @class wxSplitterWindow
7c913512 36
e725ba4f
FM
37 This class manages up to two subwindows. The current view can be split
38 into two programmatically (perhaps from a menu command), and unsplit
23324ae1 39 either programmatically or via the wxSplitterWindow user interface.
7c913512 40
23324ae1 41 @beginStyleTable
8c6791e4 42 @style{wxSP_3D}
23324ae1 43 Draws a 3D effect border and sash.
278f584f
VZ
44 @style{wxSP_THIN_SASH}
45 Draws a thin sash.
8c6791e4 46 @style{wxSP_3DSASH}
278f584f 47 Draws a 3D effect sash (part of default style).
8c6791e4 48 @style{wxSP_3DBORDER}
23324ae1 49 Synonym for wxSP_BORDER.
8c6791e4 50 @style{wxSP_BORDER}
23324ae1 51 Draws a standard border.
8c6791e4 52 @style{wxSP_NOBORDER}
23324ae1 53 No border (default).
8c6791e4 54 @style{wxSP_NO_XP_THEME}
23324ae1
FM
55 Under Windows XP, switches off the attempt to draw the splitter
56 using Windows XP theming, so the borders and sash will take on the
57 pre-XP look.
8c6791e4 58 @style{wxSP_PERMIT_UNSPLIT}
e725ba4f 59 Always allow to unsplit, even with the minimum pane size other than zero.
8c6791e4 60 @style{wxSP_LIVE_UPDATE}
23324ae1
FM
61 Don't draw XOR line but resize the child windows immediately.
62 @endStyleTable
7c913512 63
e725ba4f 64
3051a44a 65 @beginEventEmissionTable{wxSplitterEvent}
e725ba4f
FM
66 @event{EVT_SPLITTER_SASH_POS_CHANGING(id, func)}
67 The sash position is in the process of being changed.
68 May be used to modify the position of the tracking bar to properly
69 reflect the position that would be set if the drag were to be completed
ce7fe42e 70 at this point. Processes a @c wxEVT_SPLITTER_SASH_POS_CHANGING event.
e725ba4f
FM
71 @event{EVT_SPLITTER_SASH_POS_CHANGED(id, func)}
72 The sash position was changed. May be used to modify the sash position
73 before it is set, or to prevent the change from taking place.
ce7fe42e 74 Processes a @c wxEVT_SPLITTER_SASH_POS_CHANGED event.
e725ba4f 75 @event{EVT_SPLITTER_UNSPLIT(id, func)}
ce7fe42e 76 The splitter has been just unsplit. Processes a @c wxEVT_SPLITTER_UNSPLIT event.
e725ba4f
FM
77 @event{EVT_SPLITTER_DCLICK(id, func)}
78 The sash was double clicked. The default behaviour is to unsplit the
79 window when this happens (unless the minimum pane size has been set
ce7fe42e 80 to a value greater than zero). Processes a @c wxEVT_SPLITTER_DOUBLECLICKED event.
e725ba4f
FM
81 @endEventTable
82
83
23324ae1
FM
84 @library{wxcore}
85 @category{miscwnd}
7c913512 86
e725ba4f 87 @see wxSplitterEvent, @ref overview_splitterwindow
23324ae1
FM
88*/
89class wxSplitterWindow : public wxWindow
90{
91public:
671600d8
RR
92 /**
93 Default constructor
94 */
95 wxSplitterWindow();
e725ba4f 96
23324ae1
FM
97 /**
98 Constructor for creating the window.
3c4f71cc 99
7c913512 100 @param parent
4cc4bfaf 101 The parent of the splitter window.
7c913512 102 @param id
4cc4bfaf 103 The window identifier.
7c913512 104 @param pos
4cc4bfaf 105 The window position.
7c913512 106 @param size
4cc4bfaf 107 The window size.
7c913512 108 @param style
4cc4bfaf 109 The window style. See wxSplitterWindow.
7c913512 110 @param name
4cc4bfaf 111 The window name.
3c4f71cc 112
e725ba4f
FM
113 @remarks
114 After using this constructor, you must create either one or two
115 subwindows with the splitter window as parent, and then call one
116 of Initialize(), SplitVertically() and SplitHorizontally() in order
117 to set the pane(s).
118 You can create two windows, with one hidden when not being shown;
119 or you can create and delete the second pane on demand.
3c4f71cc 120
e725ba4f 121 @see Initialize(), SplitVertically(), SplitHorizontally(), Create()
23324ae1 122 */
11e3af6e 123 wxSplitterWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
e725ba4f 124 const wxPoint& pos = wxDefaultPosition,
7c913512 125 const wxSize& size = wxDefaultSize,
4cc4bfaf 126 long style = wxSP_3D,
7c913512 127 const wxString& name = "splitterWindow");
23324ae1
FM
128
129 /**
130 Destroys the wxSplitterWindow and its children.
131 */
adaaa686 132 virtual ~wxSplitterWindow();
23324ae1
FM
133
134 /**
e725ba4f
FM
135 Creation function, for two-step construction.
136 See wxSplitterWindow() for details.
23324ae1 137 */
5267aefd 138 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
23324ae1 139 const wxPoint& point = wxDefaultPosition,
5267aefd
FM
140 const wxSize& size = wxDefaultSize, long style = wxSP_3D,
141 const wxString& name = "splitter");
23324ae1
FM
142
143 /**
144 Returns the current minimum pane size (defaults to zero).
3c4f71cc 145
4cc4bfaf 146 @see SetMinimumPaneSize()
23324ae1 147 */
328f5751 148 int GetMinimumPaneSize() const;
23324ae1
FM
149
150 /**
151 Returns the current sash gravity.
3c4f71cc 152
4cc4bfaf 153 @see SetSashGravity()
23324ae1 154 */
adaaa686 155 double GetSashGravity() const;
23324ae1
FM
156
157 /**
158 Returns the current sash position.
3c4f71cc 159
4cc4bfaf 160 @see SetSashPosition()
23324ae1 161 */
adaaa686 162 int GetSashPosition() const;
23324ae1 163
26696222 164 /**
c0430d96
VZ
165 Returns the default sash size in pixels or 0 if it is invisible.
166
167 @see GetDefaultSashSize(), IsSashInvisible()
168 */
169 int GetSashSize() const;
170
171 /**
172 Returns the default sash size in pixels.
26696222
VZ
173
174 The size of the sash is its width for a vertically split window and its
175 height for a horizontally split one. Its other direction is the same as
176 the client size of the window in the corresponding direction.
177
c0430d96
VZ
178 The default sash size is platform-dependent because it conforms to the
179 current platform look-and-feel and cannot be changed.
180
181 @since 2.9.4
26696222 182 */
c0430d96 183 int GetDefaultSashSize() const;
26696222 184
23324ae1
FM
185 /**
186 Gets the split mode.
3c4f71cc 187
e725ba4f 188 @see SetSplitMode(), SplitVertically(), SplitHorizontally().
23324ae1 189 */
5267aefd 190 wxSplitMode GetSplitMode() const;
23324ae1
FM
191
192 /**
193 Returns the left/top or only pane.
194 */
328f5751 195 wxWindow* GetWindow1() const;
23324ae1
FM
196
197 /**
198 Returns the right/bottom pane.
199 */
328f5751 200 wxWindow* GetWindow2() const;
23324ae1
FM
201
202 /**
e725ba4f
FM
203 Initializes the splitter window to have one pane.
204 The child window is shown if it is currently hidden.
3c4f71cc 205
7c913512 206 @param window
4cc4bfaf 207 The pane for the unsplit window.
3c4f71cc 208
23324ae1 209 @remarks This should be called if you wish to initially view only a
4cc4bfaf 210 single pane in the splitter window.
3c4f71cc 211
4cc4bfaf 212 @see SplitVertically(), SplitHorizontally()
23324ae1
FM
213 */
214 void Initialize(wxWindow* window);
215
c0430d96
VZ
216 /**
217 Returns @true if the sash is invisible even when the window is split, @false otherwise.
218
219 @remark This is a shortcut for HasFlag(wxSP_NOSASH)
220
221 @see SetSashInvisible()
222
223 @since 2.9.4
224 */
225 bool IsSashInvisible() const;
226
23324ae1
FM
227 /**
228 Returns @true if the window is split, @false otherwise.
229 */
328f5751 230 bool IsSplit() const;
23324ae1
FM
231
232 /**
233 Application-overridable function called when the sash is double-clicked with
234 the left mouse button.
3c4f71cc 235
7c913512 236 @param x
4cc4bfaf 237 The x position of the mouse cursor.
7c913512 238 @param y
4cc4bfaf 239 The y position of the mouse cursor.
3c4f71cc 240
23324ae1 241 @remarks The default implementation of this function calls Unsplit if the
4cc4bfaf 242 minimum pane size is zero.
3c4f71cc 243
4cc4bfaf 244 @see Unsplit()
23324ae1
FM
245 */
246 virtual void OnDoubleClickSash(int x, int y);
247
248 /**
7c913512 249 Application-overridable function called when the sash position is changed by
23324ae1 250 user. It may return @false to prevent the change or @true to allow it.
3c4f71cc 251
7c913512 252 @param newSashPosition
4cc4bfaf 253 The new sash position (always positive or zero)
3c4f71cc 254
23324ae1 255 @remarks The default implementation of this function verifies that the
4cc4bfaf
FM
256 sizes of both panes of the splitter are greater than
257 minimum pane size.
23324ae1
FM
258 */
259 virtual bool OnSashPositionChange(int newSashPosition);
260
261 /**
262 Application-overridable function called when the window is unsplit, either
263 programmatically or using the wxSplitterWindow user interface.
3c4f71cc 264
7c913512 265 @param removed
4cc4bfaf 266 The window being removed.
3c4f71cc 267
23324ae1 268 @remarks The default implementation of this function simply hides
4cc4bfaf 269 removed. You may wish to delete the window.
23324ae1
FM
270 */
271 virtual void OnUnsplit(wxWindow* removed);
272
273 /**
274 This function replaces one of the windows managed by the wxSplitterWindow with
275 another one. It is in general better to use it instead of calling Unsplit()
276 and then resplitting the window back because it will provoke much less flicker
277 (if any). It is valid to call this function whether the splitter has two
278 windows or only one.
e725ba4f 279
4cc4bfaf 280 Both parameters should be non-@NULL and @a winOld must specify one of the
23324ae1
FM
281 windows managed by the splitter. If the parameters are incorrect or the window
282 couldn't be replaced, @false is returned. Otherwise the function will return
283 @true, but please notice that it will not delete the replaced window and you
284 may wish to do it yourself.
3c4f71cc 285
4cc4bfaf 286 @see GetMinimumPaneSize()
23324ae1 287 */
4cc4bfaf 288 bool ReplaceWindow(wxWindow* winOld, wxWindow* winNew);
23324ae1
FM
289
290 /**
291 Sets the minimum pane size.
3c4f71cc 292
7c913512 293 @param paneSize
4cc4bfaf 294 Minimum pane size in pixels.
3c4f71cc 295
23324ae1 296 @remarks The default minimum pane size is zero, which means that either
4cc4bfaf
FM
297 pane can be reduced to zero by dragging the sash, thus
298 removing one of the panes. To prevent this behaviour
299 (and veto out-of-range sash dragging), set a minimum
300 size, for example 20 pixels. If the wxSP_PERMIT_UNSPLIT
301 style is used when a splitter window is created, the
302 window may be unsplit even if minimum size is non-zero.
3c4f71cc 303
4cc4bfaf 304 @see GetMinimumPaneSize()
23324ae1
FM
305 */
306 void SetMinimumPaneSize(int paneSize);
307
308 /**
7c913512 309 Sets the sash gravity.
3c4f71cc 310
7c913512 311 @param gravity
4cc4bfaf 312 The sash gravity. Value between 0.0 and 1.0.
3c4f71cc 313
e725ba4f
FM
314 @remarks
315 Gravity is real factor which controls position of sash while resizing
316 wxSplitterWindow. Gravity tells wxSplitterWindow how much will left/top
317 window grow while resizing.
318 Example values:
319 - 0.0: only the bottom/right window is automatically resized
320 - 0.5: both windows grow by equal size
321 - 1.0: only left/top window grows
322 Gravity should be a real value between 0.0 and 1.0.
323 Default value of sash gravity is 0.0.
324 That value is compatible with previous (before gravity was introduced)
325 behaviour of wxSplitterWindow.
326
4cc4bfaf 327 @see GetSashGravity()
23324ae1
FM
328 */
329 void SetSashGravity(double gravity);
330
331 /**
332 Sets the sash position.
3c4f71cc 333
7c913512 334 @param position
4cc4bfaf 335 The sash position in pixels.
7c913512 336 @param redraw
4cc4bfaf 337 If @true, resizes the panes and redraws the sash and border.
3c4f71cc 338
23324ae1 339 @remarks Does not currently check for an out-of-range value.
3c4f71cc 340
4cc4bfaf 341 @see GetSashPosition()
23324ae1 342 */
5267aefd 343 void SetSashPosition(int position, bool redraw = true);
23324ae1 344
23324ae1
FM
345 /**
346 Sets the split mode.
3c4f71cc 347
7c913512 348 @param mode
4cc4bfaf 349 Can be wxSPLIT_VERTICAL or wxSPLIT_HORIZONTAL.
3c4f71cc 350
23324ae1 351 @remarks Only sets the internal variable; does not update the display.
3c4f71cc 352
e725ba4f 353 @see GetSplitMode(), SplitVertically(), SplitHorizontally().
23324ae1
FM
354 */
355 void SetSplitMode(int mode);
356
c0430d96
VZ
357 /**
358 Sets whether the sash should be invisible, even when the window is
359 split.
360
361 When the sash is invisible, it doesn't appear on the screen at all and,
362 in particular, doesn't allow the user to resize the windows.
363
364 @remarks Only sets the internal variable; does not update the display.
365
366 @param invisible
367 If @true, the sash is always invisible, else it is shown when the
368 window is split.
369
370 @see IsSashInvisible()
371
372 @since 2.9.4
373 */
374 void SetSashInvisible(bool invisible=true);
375
23324ae1 376 /**
e725ba4f
FM
377 Initializes the top and bottom panes of the splitter window.
378 The child windows are shown if they are currently hidden.
3c4f71cc 379
7c913512 380 @param window1
4cc4bfaf 381 The top pane.
7c913512 382 @param window2
4cc4bfaf 383 The bottom pane.
7c913512 384 @param sashPosition
e725ba4f
FM
385 The initial position of the sash. If this value is positive,
386 it specifies the size of the upper pane. If it is negative, its
387 absolute value gives the size of the lower pane.
388 Finally, specify 0 (default) to choose the default position
389 (half of the total window height).
3c4f71cc 390
e725ba4f 391 @return @true if successful, @false otherwise (the window was already split).
3c4f71cc 392
23324ae1 393 @remarks This should be called if you wish to initially view two panes.
e725ba4f
FM
394 It can also be called at any subsequent time, but the application
395 should check that the window is not currently split using IsSplit().
3c4f71cc 396
e725ba4f 397 @see SplitVertically(), IsSplit(), Unsplit()
23324ae1 398 */
fadc2df6
FM
399 virtual bool SplitHorizontally(wxWindow* window1, wxWindow* window2,
400 int sashPosition = 0);
23324ae1
FM
401
402 /**
e725ba4f
FM
403 Initializes the left and right panes of the splitter window.
404 The child windows are shown if they are currently hidden.
3c4f71cc 405
7c913512 406 @param window1
4cc4bfaf 407 The left pane.
7c913512 408 @param window2
4cc4bfaf 409 The right pane.
7c913512 410 @param sashPosition
e725ba4f
FM
411 The initial position of the sash. If this value is positive, it
412 specifies the size of the left pane. If it is negative, it is
413 absolute value gives the size of the right pane.
414 Finally, specify 0 (default) to choose the default position
415 (half of the total window width).
3c4f71cc 416
e725ba4f 417 @return @true if successful, @false otherwise (the window was already split).
3c4f71cc 418
23324ae1 419 @remarks This should be called if you wish to initially view two panes.
4cc4bfaf 420 It can also be called at any subsequent time, but the
e725ba4f
FM
421 application should check that the window is not currently
422 split using IsSplit().
3c4f71cc 423
e725ba4f 424 @see SplitHorizontally(), IsSplit(), Unsplit().
23324ae1 425 */
fadc2df6
FM
426 virtual bool SplitVertically(wxWindow* window1, wxWindow* window2,
427 int sashPosition = 0);
23324ae1
FM
428
429 /**
430 Unsplits the window.
3c4f71cc 431
7c913512 432 @param toRemove
4cc4bfaf 433 The pane to remove, or @NULL to remove the right or bottom pane.
3c4f71cc 434
d29a9a8a 435 @return @true if successful, @false otherwise (the window was not split).
3c4f71cc 436
23324ae1 437 @remarks This call will not actually delete the pane being removed; it
e725ba4f 438 calls OnUnsplit() which can be overridden for the desired
4cc4bfaf 439 behaviour. By default, the pane being removed is hidden.
3c4f71cc 440
e725ba4f 441 @see SplitHorizontally(), SplitVertically(), IsSplit(), OnUnsplit()
23324ae1 442 */
4cc4bfaf 443 bool Unsplit(wxWindow* toRemove = NULL);
23324ae1
FM
444
445 /**
446 Causes any pending sizing of the sash and child panes to take place
447 immediately.
e725ba4f
FM
448
449 Such resizing normally takes place in idle time, in order to wait for
450 layout to be completed. However, this can cause unacceptable flicker as
451 the panes are resized after the window has been shown.
452 To work around this, you can perform window layout (for example by
453 sending a size event to the parent window), and then call this function,
454 before showing the top-level window.
23324ae1
FM
455 */
456 void UpdateSize();
457};
458
459
e54c96f1 460
23324ae1
FM
461/**
462 @class wxSplitterEvent
7c913512 463
e725ba4f
FM
464 This class represents the events generated by a splitter control.
465
466 Also there is only one event class, the data associated to the different events
467 is not the same and so not all accessor functions may be called for each event.
468 The documentation mentions the kind of event(s) for which the given accessor
23324ae1
FM
469 function makes sense: calling it for other types of events will result
470 in assert failure (in debug mode) and will return meaningless results.
7c913512 471
e725ba4f
FM
472 @beginEventTable{wxSplitterEvent}
473 @event{EVT_SPLITTER_SASH_POS_CHANGING(id, func)}
474 The sash position is in the process of being changed.
475 May be used to modify the position of the tracking bar to properly
476 reflect the position that would be set if the drag were to be completed
ce7fe42e 477 at this point. Processes a @c wxEVT_SPLITTER_SASH_POS_CHANGING event.
e725ba4f
FM
478 @event{EVT_SPLITTER_SASH_POS_CHANGED(id, func)}
479 The sash position was changed. May be used to modify the sash position
480 before it is set, or to prevent the change from taking place.
ce7fe42e 481 Processes a @c wxEVT_SPLITTER_SASH_POS_CHANGED event.
e725ba4f 482 @event{EVT_SPLITTER_UNSPLIT(id, func)}
ce7fe42e 483 The splitter has been just unsplit. Processes a @c wxEVT_SPLITTER_UNSPLIT event.
e725ba4f
FM
484 @event{EVT_SPLITTER_DCLICK(id, func)}
485 The sash was double clicked. The default behaviour is to unsplit the
486 window when this happens (unless the minimum pane size has been set
ce7fe42e 487 to a value greater than zero). Processes a @c wxEVT_SPLITTER_DOUBLECLICKED event.
e725ba4f
FM
488 @endEventTable
489
23324ae1
FM
490 @library{wxcore}
491 @category{events}
7c913512 492
830b7aa7 493 @see wxSplitterWindow, @ref overview_events
23324ae1
FM
494*/
495class wxSplitterEvent : public wxNotifyEvent
496{
497public:
498 /**
499 Constructor. Used internally by wxWidgets only.
500 */
4cc4bfaf
FM
501 wxSplitterEvent(wxEventType eventType = wxEVT_NULL,
502 wxSplitterWindow* splitter = NULL);
23324ae1
FM
503
504 /**
505 Returns the new sash position.
e725ba4f 506
23324ae1 507 May only be called while processing
ce7fe42e
VZ
508 @c wxEVT_SPLITTER_SASH_POS_CHANGING and
509 @c wxEVT_SPLITTER_SASH_POS_CHANGED events.
23324ae1 510 */
328f5751 511 int GetSashPosition() const;
23324ae1
FM
512
513 /**
514 Returns a pointer to the window being removed when a splitter window
515 is unsplit.
e725ba4f 516
23324ae1 517 May only be called while processing
ce7fe42e 518 @c wxEVT_SPLITTER_UNSPLIT events.
23324ae1 519 */
328f5751 520 wxWindow* GetWindowBeingRemoved() const;
23324ae1
FM
521
522 /**
523 Returns the x coordinate of the double-click point.
e725ba4f 524
23324ae1 525 May only be called while processing
ce7fe42e 526 @c wxEVT_SPLITTER_DOUBLECLICKED events.
23324ae1 527 */
328f5751 528 int GetX() const;
23324ae1
FM
529
530 /**
531 Returns the y coordinate of the double-click point.
e725ba4f 532
23324ae1 533 May only be called while processing
ce7fe42e 534 @c wxEVT_SPLITTER_DOUBLECLICKED events.
23324ae1 535 */
328f5751 536 int GetY() const;
23324ae1
FM
537
538 /**
ce7fe42e 539 In the case of @c wxEVT_SPLITTER_SASH_POS_CHANGED events,
e725ba4f 540 sets the new sash position.
ce7fe42e 541 In the case of @c wxEVT_SPLITTER_SASH_POS_CHANGING events,
e725ba4f 542 sets the new tracking bar position so visual feedback during dragging will
23324ae1
FM
543 represent that change that will actually take place. Set to -1 from
544 the event handler code to prevent repositioning.
e725ba4f 545
23324ae1 546 May only be called while processing
ce7fe42e
VZ
547 @c wxEVT_SPLITTER_SASH_POS_CHANGING and
548 @c wxEVT_SPLITTER_SASH_POS_CHANGED events.
3c4f71cc 549
7c913512 550 @param pos
4cc4bfaf 551 New sash position.
23324ae1
FM
552 */
553 void SetSashPosition(int pos);
554};
e54c96f1 555
7106fc46 556
ce7fe42e
VZ
557wxEventType wxEVT_SPLITTER_SASH_POS_CHANGED;
558wxEventType wxEVT_SPLITTER_SASH_POS_CHANGING;
559wxEventType wxEVT_SPLITTER_DOUBLECLICKED;
560wxEventType wxEVT_SPLITTER_UNSPLIT;