]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/splitter.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxSplitterWindow
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
12 wxSPLIT_HORIZONTAL
= 1,
19 wxSPLIT_DRAG_DRAGGING
,
20 wxSPLIT_DRAG_LEFT_DOWN
24 @class wxSplitterWindow
26 This class manages up to two subwindows. The current view can be split
27 into two programmatically (perhaps from a menu command), and unsplit
28 either programmatically or via the wxSplitterWindow user interface.
32 Draws a 3D effect border and sash.
33 @style{wxSP_THIN_SASH}
36 Draws a 3D effect sash (part of default style).
38 Synonym for wxSP_BORDER.
40 Draws a standard border.
43 @style{wxSP_NO_XP_THEME}
44 Under Windows XP, switches off the attempt to draw the splitter
45 using Windows XP theming, so the borders and sash will take on the
47 @style{wxSP_PERMIT_UNSPLIT}
48 Always allow to unsplit, even with the minimum pane size other than zero.
49 @style{wxSP_LIVE_UPDATE}
50 Don't draw XOR line but resize the child windows immediately.
54 @beginEventEmissionTable{wxSplitterEvent}
55 @event{EVT_SPLITTER_SASH_POS_CHANGING(id, func)}
56 The sash position is in the process of being changed.
57 May be used to modify the position of the tracking bar to properly
58 reflect the position that would be set if the drag were to be completed
59 at this point. Processes a @c wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING event.
60 @event{EVT_SPLITTER_SASH_POS_CHANGED(id, func)}
61 The sash position was changed. May be used to modify the sash position
62 before it is set, or to prevent the change from taking place.
63 Processes a @c wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED event.
64 @event{EVT_SPLITTER_UNSPLIT(id, func)}
65 The splitter has been just unsplit. Processes a @c wxEVT_COMMAND_SPLITTER_UNSPLIT event.
66 @event{EVT_SPLITTER_DCLICK(id, func)}
67 The sash was double clicked. The default behaviour is to unsplit the
68 window when this happens (unless the minimum pane size has been set
69 to a value greater than zero). Processes a @c wxEVT_COMMAND_SPLITTER_DOUBLECLICKED event.
76 @see wxSplitterEvent, @ref overview_splitterwindow
78 class wxSplitterWindow
: public wxWindow
87 Constructor for creating the window.
90 The parent of the splitter window.
92 The window identifier.
98 The window style. See wxSplitterWindow.
103 After using this constructor, you must create either one or two
104 subwindows with the splitter window as parent, and then call one
105 of Initialize(), SplitVertically() and SplitHorizontally() in order
107 You can create two windows, with one hidden when not being shown;
108 or you can create and delete the second pane on demand.
110 @see Initialize(), SplitVertically(), SplitHorizontally(), Create()
112 wxSplitterWindow(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
113 const wxPoint
& pos
= wxDefaultPosition
,
114 const wxSize
& size
= wxDefaultSize
,
115 long style
= wxSP_3D
,
116 const wxString
& name
= "splitterWindow");
119 Destroys the wxSplitterWindow and its children.
121 virtual ~wxSplitterWindow();
124 Creation function, for two-step construction.
125 See wxSplitterWindow() for details.
127 bool Create(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
128 const wxPoint
& point
= wxDefaultPosition
,
129 const wxSize
& size
= wxDefaultSize
, long style
= wxSP_3D
,
130 const wxString
& name
= "splitter");
133 Returns the current minimum pane size (defaults to zero).
135 @see SetMinimumPaneSize()
137 int GetMinimumPaneSize() const;
140 Returns the current sash gravity.
142 @see SetSashGravity()
144 double GetSashGravity() const;
147 Returns the current sash position.
149 @see SetSashPosition()
151 int GetSashPosition() const;
154 Returns the sash size in pixels.
156 The size of the sash is its width for a vertically split window and its
157 height for a horizontally split one. Its other direction is the same as
158 the client size of the window in the corresponding direction.
160 The sash size is platform-dependent because it conforms to the current
161 platform look-and-feel and cannot be changed.
163 int GetSashSize() const;
168 @see SetSplitMode(), SplitVertically(), SplitHorizontally().
170 wxSplitMode
GetSplitMode() const;
173 Returns the left/top or only pane.
175 wxWindow
* GetWindow1() const;
178 Returns the right/bottom pane.
180 wxWindow
* GetWindow2() const;
183 Initializes the splitter window to have one pane.
184 The child window is shown if it is currently hidden.
187 The pane for the unsplit window.
189 @remarks This should be called if you wish to initially view only a
190 single pane in the splitter window.
192 @see SplitVertically(), SplitHorizontally()
194 void Initialize(wxWindow
* window
);
197 Returns @true if the window is split, @false otherwise.
199 bool IsSplit() const;
202 Application-overridable function called when the sash is double-clicked with
203 the left mouse button.
206 The x position of the mouse cursor.
208 The y position of the mouse cursor.
210 @remarks The default implementation of this function calls Unsplit if the
211 minimum pane size is zero.
215 virtual void OnDoubleClickSash(int x
, int y
);
218 Application-overridable function called when the sash position is changed by
219 user. It may return @false to prevent the change or @true to allow it.
221 @param newSashPosition
222 The new sash position (always positive or zero)
224 @remarks The default implementation of this function verifies that the
225 sizes of both panes of the splitter are greater than
228 virtual bool OnSashPositionChange(int newSashPosition
);
231 Application-overridable function called when the window is unsplit, either
232 programmatically or using the wxSplitterWindow user interface.
235 The window being removed.
237 @remarks The default implementation of this function simply hides
238 removed. You may wish to delete the window.
240 virtual void OnUnsplit(wxWindow
* removed
);
243 This function replaces one of the windows managed by the wxSplitterWindow with
244 another one. It is in general better to use it instead of calling Unsplit()
245 and then resplitting the window back because it will provoke much less flicker
246 (if any). It is valid to call this function whether the splitter has two
249 Both parameters should be non-@NULL and @a winOld must specify one of the
250 windows managed by the splitter. If the parameters are incorrect or the window
251 couldn't be replaced, @false is returned. Otherwise the function will return
252 @true, but please notice that it will not delete the replaced window and you
253 may wish to do it yourself.
255 @see GetMinimumPaneSize()
257 bool ReplaceWindow(wxWindow
* winOld
, wxWindow
* winNew
);
260 Sets the minimum pane size.
263 Minimum pane size in pixels.
265 @remarks The default minimum pane size is zero, which means that either
266 pane can be reduced to zero by dragging the sash, thus
267 removing one of the panes. To prevent this behaviour
268 (and veto out-of-range sash dragging), set a minimum
269 size, for example 20 pixels. If the wxSP_PERMIT_UNSPLIT
270 style is used when a splitter window is created, the
271 window may be unsplit even if minimum size is non-zero.
273 @see GetMinimumPaneSize()
275 void SetMinimumPaneSize(int paneSize
);
278 Sets the sash gravity.
281 The sash gravity. Value between 0.0 and 1.0.
284 Gravity is real factor which controls position of sash while resizing
285 wxSplitterWindow. Gravity tells wxSplitterWindow how much will left/top
286 window grow while resizing.
288 - 0.0: only the bottom/right window is automatically resized
289 - 0.5: both windows grow by equal size
290 - 1.0: only left/top window grows
291 Gravity should be a real value between 0.0 and 1.0.
292 Default value of sash gravity is 0.0.
293 That value is compatible with previous (before gravity was introduced)
294 behaviour of wxSplitterWindow.
296 @see GetSashGravity()
298 void SetSashGravity(double gravity
);
301 Sets the sash position.
304 The sash position in pixels.
306 If @true, resizes the panes and redraws the sash and border.
308 @remarks Does not currently check for an out-of-range value.
310 @see GetSashPosition()
312 void SetSashPosition(int position
, bool redraw
= true);
318 Can be wxSPLIT_VERTICAL or wxSPLIT_HORIZONTAL.
320 @remarks Only sets the internal variable; does not update the display.
322 @see GetSplitMode(), SplitVertically(), SplitHorizontally().
324 void SetSplitMode(int mode
);
327 Initializes the top and bottom panes of the splitter window.
328 The child windows are shown if they are currently hidden.
335 The initial position of the sash. If this value is positive,
336 it specifies the size of the upper pane. If it is negative, its
337 absolute value gives the size of the lower pane.
338 Finally, specify 0 (default) to choose the default position
339 (half of the total window height).
341 @return @true if successful, @false otherwise (the window was already split).
343 @remarks This should be called if you wish to initially view two panes.
344 It can also be called at any subsequent time, but the application
345 should check that the window is not currently split using IsSplit().
347 @see SplitVertically(), IsSplit(), Unsplit()
349 virtual bool SplitHorizontally(wxWindow
* window1
, wxWindow
* window2
,
350 int sashPosition
= 0);
353 Initializes the left and right panes of the splitter window.
354 The child windows are shown if they are currently hidden.
361 The initial position of the sash. If this value is positive, it
362 specifies the size of the left pane. If it is negative, it is
363 absolute value gives the size of the right pane.
364 Finally, specify 0 (default) to choose the default position
365 (half of the total window width).
367 @return @true if successful, @false otherwise (the window was already split).
369 @remarks This should be called if you wish to initially view two panes.
370 It can also be called at any subsequent time, but the
371 application should check that the window is not currently
372 split using IsSplit().
374 @see SplitHorizontally(), IsSplit(), Unsplit().
376 virtual bool SplitVertically(wxWindow
* window1
, wxWindow
* window2
,
377 int sashPosition
= 0);
383 The pane to remove, or @NULL to remove the right or bottom pane.
385 @return @true if successful, @false otherwise (the window was not split).
387 @remarks This call will not actually delete the pane being removed; it
388 calls OnUnsplit() which can be overridden for the desired
389 behaviour. By default, the pane being removed is hidden.
391 @see SplitHorizontally(), SplitVertically(), IsSplit(), OnUnsplit()
393 bool Unsplit(wxWindow
* toRemove
= NULL
);
396 Causes any pending sizing of the sash and child panes to take place
399 Such resizing normally takes place in idle time, in order to wait for
400 layout to be completed. However, this can cause unacceptable flicker as
401 the panes are resized after the window has been shown.
402 To work around this, you can perform window layout (for example by
403 sending a size event to the parent window), and then call this function,
404 before showing the top-level window.
412 @class wxSplitterEvent
414 This class represents the events generated by a splitter control.
416 Also there is only one event class, the data associated to the different events
417 is not the same and so not all accessor functions may be called for each event.
418 The documentation mentions the kind of event(s) for which the given accessor
419 function makes sense: calling it for other types of events will result
420 in assert failure (in debug mode) and will return meaningless results.
422 @beginEventTable{wxSplitterEvent}
423 @event{EVT_SPLITTER_SASH_POS_CHANGING(id, func)}
424 The sash position is in the process of being changed.
425 May be used to modify the position of the tracking bar to properly
426 reflect the position that would be set if the drag were to be completed
427 at this point. Processes a @c wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING event.
428 @event{EVT_SPLITTER_SASH_POS_CHANGED(id, func)}
429 The sash position was changed. May be used to modify the sash position
430 before it is set, or to prevent the change from taking place.
431 Processes a @c wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED event.
432 @event{EVT_SPLITTER_UNSPLIT(id, func)}
433 The splitter has been just unsplit. Processes a @c wxEVT_COMMAND_SPLITTER_UNSPLIT event.
434 @event{EVT_SPLITTER_DCLICK(id, func)}
435 The sash was double clicked. The default behaviour is to unsplit the
436 window when this happens (unless the minimum pane size has been set
437 to a value greater than zero). Processes a @c wxEVT_COMMAND_SPLITTER_DOUBLECLICKED event.
443 @see wxSplitterWindow, @ref overview_events
445 class wxSplitterEvent
: public wxNotifyEvent
449 Constructor. Used internally by wxWidgets only.
451 wxSplitterEvent(wxEventType eventType
= wxEVT_NULL
,
452 wxSplitterWindow
* splitter
= NULL
);
455 Returns the new sash position.
457 May only be called while processing
458 @c wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING and
459 @c wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED events.
461 int GetSashPosition() const;
464 Returns a pointer to the window being removed when a splitter window
467 May only be called while processing
468 @c wxEVT_COMMAND_SPLITTER_UNSPLIT events.
470 wxWindow
* GetWindowBeingRemoved() const;
473 Returns the x coordinate of the double-click point.
475 May only be called while processing
476 @c wxEVT_COMMAND_SPLITTER_DOUBLECLICKED events.
481 Returns the y coordinate of the double-click point.
483 May only be called while processing
484 @c wxEVT_COMMAND_SPLITTER_DOUBLECLICKED events.
489 In the case of @c wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED events,
490 sets the new sash position.
491 In the case of @c wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING events,
492 sets the new tracking bar position so visual feedback during dragging will
493 represent that change that will actually take place. Set to -1 from
494 the event handler code to prevent repositioning.
496 May only be called while processing
497 @c wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING and
498 @c wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED events.
503 void SetSashPosition(int pos
);