]>
git.saurik.com Git - wxWidgets.git/blob - interface/splitter.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxSplitterWindow class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxSplitterWindow
13 @ref overview_wxsplitterwindowoverview "wxSplitterWindow overview"
15 This class manages up to two subwindows. The current view can be
16 split into two programmatically (perhaps from a menu command), and unsplit
17 either programmatically or via the wxSplitterWindow user interface.
21 Draws a 3D effect border and sash.
23 Draws a 3D effect sash.
24 @style{wxSP_3DBORDER}:
25 Synonym for wxSP_BORDER.
27 Draws a standard border.
28 @style{wxSP_NOBORDER}:
30 @style{wxSP_NO_XP_THEME}:
31 Under Windows XP, switches off the attempt to draw the splitter
32 using Windows XP theming, so the borders and sash will take on the
34 @style{wxSP_PERMIT_UNSPLIT}:
35 Always allow to unsplit, even with the minimum pane size other than
37 @style{wxSP_LIVE_UPDATE}:
38 Don't draw XOR line but resize the child windows immediately.
47 class wxSplitterWindow
: public wxWindow
52 Constructor for creating the window.
55 The parent of the splitter window.
58 The window identifier.
67 The window style. See wxSplitterWindow.
72 @remarks After using this constructor, you must create either one or two
73 subwindows with the splitter window as parent, and
74 then call one of Initialize(),
76 SplitHorizontally() in order to set
79 @sa Initialize(), SplitVertically(),
80 SplitHorizontally(), Create()
83 wxSplitterWindow(wxWindow
* parent
, wxWindowID id
,
84 const wxPoint
& point
= wxDefaultPosition
,
85 const wxSize
& size
= wxDefaultSize
,
87 const wxString
& name
= "splitterWindow");
91 Destroys the wxSplitterWindow and its children.
96 Creation function, for two-step construction. See wxSplitterWindow() for
99 bool Create(wxWindow
* parent
, wxWindowID id
,
100 const wxPoint
& point
= wxDefaultPosition
,
101 const wxSize
& size
= wxDefaultSize
,
103 const wxString
& name
= "splitterWindow");
106 Returns the current minimum pane size (defaults to zero).
108 @sa SetMinimumPaneSize()
110 int GetMinimumPaneSize();
113 Returns the current sash gravity.
117 double GetSashGravity();
120 Returns the current sash position.
122 @sa SetSashPosition()
124 int GetSashPosition();
129 @sa SetSplitMode(), SplitVertically(),
135 Returns the left/top or only pane.
137 wxWindow
* GetWindow1();
140 Returns the right/bottom pane.
142 wxWindow
* GetWindow2();
145 Initializes the splitter window to have one pane. The child window is
146 shown if it is currently hidden.
149 The pane for the unsplit window.
151 @remarks This should be called if you wish to initially view only a
152 single pane in the splitter window.
154 @sa SplitVertically(), SplitHorizontally()
156 void Initialize(wxWindow
* window
);
159 Returns @true if the window is split, @false otherwise.
164 Application-overridable function called when the sash is double-clicked with
165 the left mouse button.
168 The x position of the mouse cursor.
171 The y position of the mouse cursor.
173 @remarks The default implementation of this function calls Unsplit if the
174 minimum pane size is zero.
178 virtual void OnDoubleClickSash(int x
, int y
);
181 Application-overridable function called when the sash position is changed by
182 user. It may return @false to prevent the change or @true to allow it.
184 @param newSashPosition
185 The new sash position (always positive or zero)
187 @remarks The default implementation of this function verifies that the
188 sizes of both panes of the splitter are greater than
191 virtual bool OnSashPositionChange(int newSashPosition
);
194 Application-overridable function called when the window is unsplit, either
195 programmatically or using the wxSplitterWindow user interface.
198 The window being removed.
200 @remarks The default implementation of this function simply hides
201 removed. You may wish to delete the window.
203 virtual void OnUnsplit(wxWindow
* removed
);
206 This function replaces one of the windows managed by the wxSplitterWindow with
207 another one. It is in general better to use it instead of calling Unsplit()
208 and then resplitting the window back because it will provoke much less flicker
209 (if any). It is valid to call this function whether the splitter has two
212 Both parameters should be non-@NULL and @e winOld must specify one of the
213 windows managed by the splitter. If the parameters are incorrect or the window
214 couldn't be replaced, @false is returned. Otherwise the function will return
215 @true, but please notice that it will not delete the replaced window and you
216 may wish to do it yourself.
218 @sa GetMinimumPaneSize()
220 bool ReplaceWindow(wxWindow
* winOld
, wxWindow
* winNew
);
223 Sets the minimum pane size.
226 Minimum pane size in pixels.
228 @remarks The default minimum pane size is zero, which means that either
229 pane can be reduced to zero by dragging the sash,
230 thus removing one of the panes. To prevent this
231 behaviour (and veto out-of-range sash dragging), set
232 a minimum size, for example 20 pixels. If the
233 wxSP_PERMIT_UNSPLIT style is used when a splitter
234 window is created, the window may be unsplit even if
235 minimum size is non-zero.
237 @sa GetMinimumPaneSize()
239 void SetMinimumPaneSize(int paneSize
);
242 Sets the sash gravity.
245 The sash gravity. Value between 0.0 and 1.0.
249 void SetSashGravity(double gravity
);
252 Sets the sash position.
255 The sash position in pixels.
258 If @true, resizes the panes and redraws the sash and border.
260 @remarks Does not currently check for an out-of-range value.
262 @sa GetSashPosition()
264 void SetSashPosition(int position
, const bool redraw
= @
true);
267 Sets the sash size. Normally, the sash size is determined according to the
269 of each platform, but the application can override this, for example to show
270 a thin sash that the user is not expected to drag. If @e size is more -1,
271 the custom sash size will be used.
273 void SetSashSize(int size
);
279 Can be wxSPLIT_VERTICAL or wxSPLIT_HORIZONTAL.
281 @remarks Only sets the internal variable; does not update the display.
283 @sa GetSplitMode(), SplitVertically(),
286 void SetSplitMode(int mode
);
289 Initializes the top and bottom panes of the splitter window. The
290 child windows are shown if they are currently hidden.
299 The initial position of the sash. If this value is
300 positive, it specifies the size of the upper pane. If it is negative, its
301 absolute value gives the size of the lower pane. Finally, specify 0 (default)
302 to choose the default position (half of the total window height).
304 @returns @true if successful, @false otherwise (the window was already
307 @remarks This should be called if you wish to initially view two panes.
308 It can also be called at any subsequent time, but the
309 application should check that the window is not
310 currently split using IsSplit.
312 @sa SplitVertically(), IsSplit(),
315 bool SplitHorizontally(wxWindow
* window1
, wxWindow
* window2
,
316 int sashPosition
= 0);
319 Initializes the left and right panes of the splitter window. The
320 child windows are shown if they are currently hidden.
329 The initial position of the sash. If this value is
330 positive, it specifies the size of the left pane. If it is negative, it is
331 absolute value gives the size of the right pane. Finally, specify 0 (default)
332 to choose the default position (half of the total window width).
334 @returns @true if successful, @false otherwise (the window was already
337 @remarks This should be called if you wish to initially view two panes.
338 It can also be called at any subsequent time, but the
339 application should check that the window is not
340 currently split using IsSplit.
342 @sa SplitHorizontally(), IsSplit(),
345 bool SplitVertically(wxWindow
* window1
, wxWindow
* window2
,
346 int sashPosition
= 0);
352 The pane to remove, or @NULL to remove the right or bottom pane.
354 @returns @true if successful, @false otherwise (the window was not split).
356 @remarks This call will not actually delete the pane being removed; it
357 calls OnUnsplit which can be overridden for the
358 desired behaviour. By default, the pane being removed
361 @sa SplitHorizontally(), SplitVertically(),
362 IsSplit(), OnUnsplit()
364 bool Unsplit(wxWindow
* toRemove
= @NULL
);
367 Causes any pending sizing of the sash and child panes to take place
370 Such resizing normally takes place in idle time, in order
371 to wait for layout to be completed. However, this can cause
372 unacceptable flicker as the panes are resized after the window has been
373 shown. To work around this, you can perform window layout (for
374 example by sending a size event to the parent window), and then
375 call this function, before showing the top-level window.
382 @class wxSplitterEvent
383 @wxheader{splitter.h}
385 This class represents the events generated by a splitter control. Also there is
386 only one event class, the data associated to the different events is not the
387 same and so not all accessor functions may be called for each event. The
388 documentation mentions the kind of event(s) for which the given accessor
389 function makes sense: calling it for other types of events will result
390 in assert failure (in debug mode) and will return meaningless results.
396 wxSplitterWindow, @ref overview_eventhandlingoverview "Event handling overview"
398 class wxSplitterEvent
: public wxNotifyEvent
402 Constructor. Used internally by wxWidgets only.
404 wxSplitterEvent(wxEventType eventType
= wxEVT_@NULL
,
405 wxSplitterWindow
* splitter
= @NULL
);
408 Returns the new sash position.
410 May only be called while processing
411 wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING and
412 wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED events.
414 int GetSashPosition();
417 Returns a pointer to the window being removed when a splitter window
420 May only be called while processing
421 wxEVT_COMMAND_SPLITTER_UNSPLIT events.
423 wxWindow
* GetWindowBeingRemoved();
426 Returns the x coordinate of the double-click point.
428 May only be called while processing
429 wxEVT_COMMAND_SPLITTER_DOUBLECLICKED events.
431 #define int GetX() /* implementation is private */
434 Returns the y coordinate of the double-click point.
436 May only be called while processing
437 wxEVT_COMMAND_SPLITTER_DOUBLECLICKED events.
439 #define int GetY() /* implementation is private */
442 In the case of wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED events,
443 sets the new sash position. In the case of
444 wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING events, sets the new
445 tracking bar position so visual feedback during dragging will
446 represent that change that will actually take place. Set to -1 from
447 the event handler code to prevent repositioning.
449 May only be called while processing
450 wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING and
451 wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED events.
456 void SetSashPosition(int pos
);