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