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