]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/splitter.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxSplitterWindow
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxSplitterWindow
12 @ref overview_wxsplitterwindowoverview "wxSplitterWindow overview"
14 This class manages up to two subwindows. The current view can be
15 split into two programmatically (perhaps from a menu command), and unsplit
16 either programmatically or via the wxSplitterWindow user interface.
20 Draws a 3D effect border and sash.
21 @style{wxSP_THIN_SASH}
24 Draws a 3D effect sash (part of default style).
26 Synonym for wxSP_BORDER.
28 Draws a standard border.
31 @style{wxSP_NO_XP_THEME}
32 Under Windows XP, switches off the attempt to draw the splitter
33 using Windows XP theming, so the borders and sash will take on the
35 @style{wxSP_PERMIT_UNSPLIT}
36 Always allow to unsplit, even with the minimum pane size other than
38 @style{wxSP_LIVE_UPDATE}
39 Don't draw XOR line but resize the child windows immediately.
47 class wxSplitterWindow
: public wxWindow
56 Constructor for creating the window.
59 The parent of the splitter window.
61 The window identifier.
67 The window style. See wxSplitterWindow.
71 @remarks After using this constructor, you must create either one or two
72 subwindows with the splitter window as parent, and then
73 call one of Initialize(),
75 SplitHorizontally() in order to set the
78 @see Initialize(), SplitVertically(),
79 SplitHorizontally(), Create()
81 wxSplitterWindow(wxWindow
* parent
, wxWindowID id
,
82 const wxPoint
& point
= wxDefaultPosition
,
83 const wxSize
& size
= wxDefaultSize
,
85 const wxString
& name
= "splitterWindow");
88 Destroys the wxSplitterWindow and its children.
93 Creation function, for two-step construction. See wxSplitterWindow() for
96 bool Create(wxWindow
* parent
, wxWindowID id
,
97 const wxPoint
& point
= wxDefaultPosition
,
98 const wxSize
& size
= wxDefaultSize
,
100 const wxString
& name
= "splitterWindow");
103 Returns the current minimum pane size (defaults to zero).
105 @see SetMinimumPaneSize()
107 int GetMinimumPaneSize() const;
110 Returns the current sash gravity.
112 @see SetSashGravity()
114 double GetSashGravity();
117 Returns the current sash position.
119 @see SetSashPosition()
121 int GetSashPosition();
126 @see SetSplitMode(), SplitVertically(),
129 int GetSplitMode() const;
132 Returns the left/top or only pane.
134 wxWindow
* GetWindow1() const;
137 Returns the right/bottom pane.
139 wxWindow
* GetWindow2() const;
142 Initializes the splitter window to have one pane. The child window is
143 shown if it is currently hidden.
146 The pane for the unsplit window.
148 @remarks This should be called if you wish to initially view only a
149 single pane in the splitter window.
151 @see SplitVertically(), SplitHorizontally()
153 void Initialize(wxWindow
* window
);
156 Returns @true if the window is split, @false otherwise.
158 bool IsSplit() const;
161 Application-overridable function called when the sash is double-clicked with
162 the left mouse button.
165 The x position of the mouse cursor.
167 The y position of the mouse cursor.
169 @remarks The default implementation of this function calls Unsplit if the
170 minimum pane size is zero.
174 virtual void OnDoubleClickSash(int x
, int y
);
177 Application-overridable function called when the sash position is changed by
178 user. It may return @false to prevent the change or @true to allow it.
180 @param newSashPosition
181 The new sash position (always positive or zero)
183 @remarks The default implementation of this function verifies that the
184 sizes of both panes of the splitter are greater than
187 virtual bool OnSashPositionChange(int newSashPosition
);
190 Application-overridable function called when the window is unsplit, either
191 programmatically or using the wxSplitterWindow user interface.
194 The window being removed.
196 @remarks The default implementation of this function simply hides
197 removed. You may wish to delete the window.
199 virtual void OnUnsplit(wxWindow
* removed
);
202 This function replaces one of the windows managed by the wxSplitterWindow with
203 another one. It is in general better to use it instead of calling Unsplit()
204 and then resplitting the window back because it will provoke much less flicker
205 (if any). It is valid to call this function whether the splitter has two
207 Both parameters should be non-@NULL and @a winOld must specify one of the
208 windows managed by the splitter. If the parameters are incorrect or the window
209 couldn't be replaced, @false is returned. Otherwise the function will return
210 @true, but please notice that it will not delete the replaced window and you
211 may wish to do it yourself.
213 @see GetMinimumPaneSize()
215 bool ReplaceWindow(wxWindow
* winOld
, wxWindow
* winNew
);
218 Sets the minimum pane size.
221 Minimum pane size in pixels.
223 @remarks The default minimum pane size is zero, which means that either
224 pane can be reduced to zero by dragging the sash, thus
225 removing one of the panes. To prevent this behaviour
226 (and veto out-of-range sash dragging), set a minimum
227 size, for example 20 pixels. If the wxSP_PERMIT_UNSPLIT
228 style is used when a splitter window is created, the
229 window may be unsplit even if minimum size is non-zero.
231 @see GetMinimumPaneSize()
233 void SetMinimumPaneSize(int paneSize
);
236 Sets the sash gravity.
239 The sash gravity. Value between 0.0 and 1.0.
241 @see GetSashGravity()
243 void SetSashGravity(double gravity
);
246 Sets the sash position.
249 The sash position in pixels.
251 If @true, resizes the panes and redraws the sash and border.
253 @remarks Does not currently check for an out-of-range value.
255 @see GetSashPosition()
257 void SetSashPosition(int position
, const bool redraw
= true);
260 Sets the sash size. Normally, the sash size is determined according to the
262 of each platform, but the application can override this, for example to show
263 a thin sash that the user is not expected to drag. If @a size is more -1,
264 the custom sash size will be used.
266 void SetSashSize(int size
);
272 Can be wxSPLIT_VERTICAL or wxSPLIT_HORIZONTAL.
274 @remarks Only sets the internal variable; does not update the display.
276 @see GetSplitMode(), SplitVertically(),
279 void SetSplitMode(int mode
);
282 Initializes the top and bottom panes of the splitter window. The
283 child windows are shown if they are currently hidden.
290 The initial position of the sash. If this value is
291 positive, it specifies the size of the upper pane. If it is negative, its
292 absolute value gives the size of the lower pane. Finally, specify 0
294 to choose the default position (half of the total window height).
296 @return @true if successful, @false otherwise (the window was already
299 @remarks This should be called if you wish to initially view two panes.
300 It can also be called at any subsequent time, but the
301 application should check that the window is not
302 currently split using IsSplit.
304 @see SplitVertically(), IsSplit(),
307 bool SplitHorizontally(wxWindow
* window1
, wxWindow
* window2
,
308 int sashPosition
= 0);
311 Initializes the left and right panes of the splitter window. The
312 child windows are shown if they are currently hidden.
319 The initial position of the sash. If this value is
320 positive, it specifies the size of the left pane. If it is negative, it is
321 absolute value gives the size of the right pane. Finally, specify 0
323 to choose the default position (half of the total window width).
325 @return @true if successful, @false otherwise (the window was already
328 @remarks This should be called if you wish to initially view two panes.
329 It can also be called at any subsequent time, but the
330 application should check that the window is not
331 currently split using IsSplit.
333 @see SplitHorizontally(), IsSplit(),
336 bool SplitVertically(wxWindow
* window1
, wxWindow
* window2
,
337 int sashPosition
= 0);
343 The pane to remove, or @NULL to remove the right or bottom pane.
345 @return @true if successful, @false otherwise (the window was not split).
347 @remarks This call will not actually delete the pane being removed; it
348 calls OnUnsplit which can be overridden for the desired
349 behaviour. By default, the pane being removed is hidden.
351 @see SplitHorizontally(), SplitVertically(),
352 IsSplit(), OnUnsplit()
354 bool Unsplit(wxWindow
* toRemove
= NULL
);
357 Causes any pending sizing of the sash and child panes to take place
359 Such resizing normally takes place in idle time, in order
360 to wait for layout to be completed. However, this can cause
361 unacceptable flicker as the panes are resized after the window has been
362 shown. To work around this, you can perform window layout (for
363 example by sending a size event to the parent window), and then
364 call this function, before showing the top-level window.
372 @class wxSplitterEvent
374 This class represents the events generated by a splitter control. Also there is
375 only one event class, the data associated to the different events is not the
376 same and so not all accessor functions may be called for each event. The
377 documentation mentions the kind of event(s) for which the given accessor
378 function makes sense: calling it for other types of events will result
379 in assert failure (in debug mode) and will return meaningless results.
384 @see wxSplitterWindow, @ref overview_eventhandlingoverview
386 class wxSplitterEvent
: public wxNotifyEvent
390 Constructor. Used internally by wxWidgets only.
392 wxSplitterEvent(wxEventType eventType
= wxEVT_NULL
,
393 wxSplitterWindow
* splitter
= NULL
);
396 Returns the new sash position.
397 May only be called while processing
398 wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING and
399 wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED events.
401 int GetSashPosition() const;
404 Returns a pointer to the window being removed when a splitter window
406 May only be called while processing
407 wxEVT_COMMAND_SPLITTER_UNSPLIT events.
409 wxWindow
* GetWindowBeingRemoved() const;
412 Returns the x coordinate of the double-click point.
413 May only be called while processing
414 wxEVT_COMMAND_SPLITTER_DOUBLECLICKED events.
419 Returns the y coordinate of the double-click point.
420 May only be called while processing
421 wxEVT_COMMAND_SPLITTER_DOUBLECLICKED events.
426 In the case of wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED events,
427 sets the new sash position. In the case of
428 wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING events, sets the new
429 tracking bar position so visual feedback during dragging will
430 represent that change that will actually take place. Set to -1 from
431 the event handler code to prevent repositioning.
432 May only be called while processing
433 wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING and
434 wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED events.
439 void SetSashPosition(int pos
);