wxWidgets/docs/latex/wx/splitter.tex

480 lines
17 KiB
TeX

\section{\class{wxSplitterWindow}}\label{wxsplitterwindow}
\overview{wxSplitterWindow overview}{wxsplitterwindowoverview}
This class manages up to two subwindows. The current view can be
split into two programmatically (perhaps from a menu command), and unsplit
either programmatically or via the wxSplitterWindow user interface.
\wxheading{Window styles}
\begin{twocollist}\itemsep=0pt
\twocolitem{\windowstyle{wxSP\_3D}}{Draws a 3D effect border and sash.}
\twocolitem{\windowstyle{wxSP\_3DSASH}}{Draws a 3D effect sash.}
\twocolitem{\windowstyle{wxSP\_3DBORDER}}{Synonym for wxSP\_BORDER.}
\twocolitem{\windowstyle{wxSP\_BORDER}}{Draws a standard border.}
\twocolitem{\windowstyle{wxSP\_NOBORDER}}{No border (default).}
\twocolitem{\windowstyle{wxSP\_NO\_XP\_THEME}}{Under Windows XP, switches off the attempt to draw the
splitter using Windows XP theming, so the borders and sash will take on the pre-XP look.}
\twocolitem{\windowstyle{wxSP\_PERMIT\_UNSPLIT}}{Always allow to
unsplit, even with the minimum pane size other than zero.}
\twocolitem{\windowstyle{wxSP\_LIVE\_UPDATE}}{Don't draw XOR line but resize the child windows immediately.}
\end{twocollist}
See also \helpref{window styles overview}{windowstyles}.
\wxheading{Derived from}
\helpref{wxWindow}{wxwindow}\\
\helpref{wxEvtHandler}{wxevthandler}\\
\helpref{wxObject}{wxobject}
\wxheading{Include files}
<wx/splitter.h>
\wxheading{Event handling}
To process input from a splitter control, use the following event handler
macros to direct input to member functions that take a
\helpref{wxSplitterEvent}{wxsplitterevent} argument.
\twocolwidtha{10cm}
\begin{twocollist}\itemsep=0pt
\twocolitem{{\bf EVT\_SPLITTER\_SASH\_POS\_CHANGING(id, func)}}{The sash
position is in the process of being changed. May be used to modify the
position of the tracking bar to properly reflect the position that
would be set if the drag were to be completed at this point. Processes
a wxEVT\_COMMAND\_SPLITTER\_SASH\_POS\_CHANGING event.}
\twocolitem{{\bf EVT\_SPLITTER\_SASH\_POS\_CHANGED(id, func)}}{The sash
position was changed. May be used to modify the sash position before
it is set, or to prevent the change from taking place.
Processes a wxEVT\_COMMAND\_SPLITTER\_SASH\_POS\_CHANGED event.}
\twocolitem{{\bf EVT\_SPLITTER\_UNSPLIT(id, func)}}{The splitter has been just
unsplit. Processes a wxEVT\_COMMAND\_SPLITTER\_UNSPLIT event.}
\twocolitem{{\bf EVT\_SPLITTER\_DCLICK(id, func)}}{The sash was double
clicked. The default behaviour is to unsplit the window when this happens
(unless the minimum pane size has been set to a value greater than zero).
Processes a wxEVT\_COMMAND\_SPLITTER\_DOUBLECLICKED event.}
\end{twocollist}%
\wxheading{See also}
\helpref{wxSplitterEvent}{wxsplitterevent}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxSplitterWindow::wxSplitterWindow}\label{wxsplitterwindowctor}
\func{}{wxSplitterWindow}{\void}
Default constructor.
\func{}{wxSplitterWindow}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
\param{const wxPoint\& }{point = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
\param{long }{style=wxSP\_3D}, \param{const wxString\&}{ name = "splitterWindow"}}
Constructor for creating the window.
\wxheading{Parameters}
\docparam{parent}{The parent of the splitter window.}
\docparam{id}{The window identifier.}
\docparam{pos}{The window position.}
\docparam{size}{The window size.}
\docparam{style}{The window style. See \helpref{wxSplitterWindow}{wxsplitterwindow}.}
\docparam{name}{The window name.}
\wxheading{Remarks}
After using this constructor, you must create either one or two subwindows
with the splitter window as parent, and then call one of \helpref{wxSplitterWindow::Initialize}{wxsplitterwindowinitialize},\rtfsp
\helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically} and \helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally} in
order to set the pane(s).
You can create two windows, with one hidden when not being shown; or you can
create and delete the second pane on demand.
\wxheading{See also}
\helpref{wxSplitterWindow::Initialize}{wxsplitterwindowinitialize}, \helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically},\rtfsp
\helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally},\rtfsp
\helpref{wxSplitterWindow::Create}{wxsplitterwindowcreate}
\membersection{wxSplitterWindow::\destruct{wxSplitterWindow}}\label{wxsplitterwindowdtor}
\func{}{\destruct{wxSplitterWindow}}{\void}
Destroys the wxSplitterWindow and its children.
\membersection{wxSplitterWindow::Create}\label{wxsplitterwindowcreate}
\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id}, \rtfsp
\param{const wxPoint\& }{point = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
\param{long }{style=wxSP\_3D}, \param{const wxString\&}{ name = "splitterWindow"}}
Creation function, for two-step construction. See \helpref{wxSplitterWindow::wxSplitterWindow}{wxsplitterwindowctor} for
details.
\membersection{wxSplitterWindow::GetMinimumPaneSize}\label{wxsplitterwindowgetminimumpanesize}
\constfunc{int}{GetMinimumPaneSize}{\void}
Returns the current minimum pane size (defaults to zero).
\wxheading{See also}
\helpref{wxSplitterWindow::SetMinimumPaneSize}{wxsplitterwindowsetminimumpanesize}
\membersection{wxSplitterWindow::GetSashGravity}\label{wxsplitterwindowgetsashgravity}
\func{double}{GetSashGravity}{\void}
Returns the current sash gravity.
\wxheading{See also}
\helpref{wxSplitterWindow::SetSashGravity}{wxsplitterwindowsetsashgravity}
\membersection{wxSplitterWindow::GetSashPosition}\label{wxsplitterwindowgetsashposition}
\func{int}{GetSashPosition}{\void}
Returns the current sash position.
\wxheading{See also}
\helpref{wxSplitterWindow::SetSashPosition}{wxsplitterwindowsetsashposition}
\membersection{wxSplitterWindow::GetSplitMode}\label{wxsplitterwindowgetsplitmode}
\constfunc{int}{GetSplitMode}{\void}
Gets the split mode.
\wxheading{See also}
\helpref{wxSplitterWindow::SetSplitMode}{wxsplitterwindowsetsplitmode}, \helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically},\rtfsp
\helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally}.
\membersection{wxSplitterWindow::GetWindow1}\label{wxsplitterwindowgetwindow1}
\constfunc{wxWindow*}{GetWindow1}{\void}
Returns the left/top or only pane.
\membersection{wxSplitterWindow::GetWindow2}\label{wxsplitterwindowgetwindow2}
\constfunc{wxWindow*}{GetWindow2}{\void}
Returns the right/bottom pane.
\membersection{wxSplitterWindow::Initialize}\label{wxsplitterwindowinitialize}
\func{void}{Initialize}{\param{wxWindow* }{window}}
Initializes the splitter window to have one pane. The child window is
shown if it is currently hidden.
\wxheading{Parameters}
\docparam{window}{The pane for the unsplit window.}
\wxheading{Remarks}
This should be called if you wish to initially view only a single pane in the splitter window.
\wxheading{See also}
\helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically},\rtfsp
\helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally}
\membersection{wxSplitterWindow::IsSplit}\label{wxsplitterwindowissplit}
\constfunc{bool}{IsSplit}{\void}
Returns true if the window is split, false otherwise.
\membersection{wxSplitterWindow::OnDoubleClickSash}\label{wxsplitterwindowondoubleclicksash}
\func{virtual void}{OnDoubleClickSash}{\param{int }{x}, \param{int }{y}}
Application-overridable function called when the sash is double-clicked with
the left mouse button.
\wxheading{Parameters}
\docparam{x}{The x position of the mouse cursor.}
\docparam{y}{The y position of the mouse cursor.}
\wxheading{Remarks}
The default implementation of this function calls \helpref{Unsplit}{wxsplitterwindowunsplit} if
the minimum pane size is zero.
\wxheading{See also}
\helpref{wxSplitterWindow::Unsplit}{wxsplitterwindowunsplit}
\membersection{wxSplitterWindow::OnUnsplit}\label{wxsplitterwindowonunsplit}
\func{virtual void}{OnUnsplit}{\param{wxWindow* }{removed}}
Application-overridable function called when the window is unsplit, either
programmatically or using the wxSplitterWindow user interface.
\wxheading{Parameters}
\docparam{removed}{The window being removed.}
\wxheading{Remarks}
The default implementation of this function simply hides {\it removed}. You
may wish to delete the window.
\membersection{wxSplitterWindow::OnSashPositionChange}\label{wxsplitterwindowonsashpositionchange}
\func{virtual bool}{OnSashPositionChange}{\param{int }{newSashPosition}}
Application-overridable function called when the sash position is changed by
user. It may return false to prevent the change or true to allow it.
\wxheading{Parameters}
\docparam{newSashPosition}{The new sash position (always positive or zero)}
\wxheading{Remarks}
The default implementation of this function verifies that the sizes of both
panes of the splitter are greater than minimum pane size.
\membersection{wxSplitterWindow::ReplaceWindow}\label{wxsplitterwindowreplacewindow}
\func{bool}{ReplaceWindow}{\param{wxWindow * }{winOld}, \param{wxWindow * }{winNew}}
This function replaces one of the windows managed by the wxSplitterWindow with
another one. It is in general better to use it instead of calling Unsplit()
and then resplitting the window back because it will provoke much less flicker
(if any). It is valid to call this function whether the splitter has two
windows or only one.
Both parameters should be non-NULL and {\it winOld} must specify one of the
windows managed by the splitter. If the parameters are incorrect or the window
couldn't be replaced, false is returned. Otherwise the function will return
true, but please notice that it will not delete the replaced window and you
may wish to do it yourself.
\wxheading{See also}
\helpref{wxSplitterWindow::GetMinimumPaneSize}{wxsplitterwindowgetminimumpanesize}
\wxheading{See also}
\helpref{wxSplitterWindow::Unsplit}{wxsplitterwindowunsplit}\\
\helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically}\\
\helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally}
\membersection{wxSplitterWindow::SetSashGravity}\label{wxsplitterwindowsetsashgravity}
\func{void}{SetSashGravity}{\param{double }{gravity}}
Sets the sash gravity.
\wxheading{Parameters}
\docparam{gravity}{The sash gravity. Value between 0.0 and 1.0.}
\wxheading{Remarks}
Gravity is real factor which controls position of sash while resizing wxSplitterWindow.
Gravity tells wxSplitterWindow how much will left/top window grow while resizing.
Example values:
\begin{itemize}\itemsep=0pt
\item{ 0.0 - only the bottom/right window is automaticaly resized}
\item{ 0.5 - both windows grow by equal size}
\item{ 1.0 - only left/top window grows}
\end{itemize}
Gravity should be real value betwwen 0.0 and 1.0.
Default value of sash gravity is 0.0. That value is compatible with previous
(before gravity was introduced) behaviour of wxSplitterWindow.
\wxheading{See also}
\helpref{wxSplitterWindow::GetSashGravity}{wxsplitterwindowgetsashgravity}
\membersection{wxSplitterWindow::SetSashPosition}\label{wxsplitterwindowsetsashposition}
\func{void}{SetSashPosition}{\param{int }{position}, \param{const bool}{ redraw = true}}
Sets the sash position.
\wxheading{Parameters}
\docparam{position}{The sash position in pixels.}
\docparam{redraw}{If true, resizes the panes and redraws the sash and border.}
\wxheading{Remarks}
Does not currently check for an out-of-range value.
\wxheading{See also}
\helpref{wxSplitterWindow::GetSashPosition}{wxsplitterwindowgetsashposition}
\membersection{wxSplitterWindow::SetMinimumPaneSize}\label{wxsplitterwindowsetminimumpanesize}
\func{void}{SetMinimumPaneSize}{\param{int }{paneSize}}
Sets the minimum pane size.
\wxheading{Parameters}
\docparam{paneSize}{Minimum pane size in pixels.}
\wxheading{Remarks}
The default minimum pane size is zero, which means that either pane can be reduced to zero by dragging
the sash, thus removing one of the panes. To prevent this behaviour (and veto out-of-range sash dragging),
set a minimum size, for example 20 pixels. If the wxSP\_PERMIT\_UNSPLIT style
is used when a splitter window is created, the window may be unsplit even
if minimum size is non-zero.
\wxheading{See also}
\helpref{wxSplitterWindow::GetMinimumPaneSize}{wxsplitterwindowgetminimumpanesize}
\membersection{wxSplitterWindow::SetSplitMode}\label{wxsplitterwindowsetsplitmode}
\func{void}{SetSplitMode}{\param{int }{mode}}
Sets the split mode.
\wxheading{Parameters}
\docparam{mode}{Can be wxSPLIT\_VERTICAL or wxSPLIT\_HORIZONTAL.}
\wxheading{Remarks}
Only sets the internal variable; does not update the display.
\wxheading{See also}
\helpref{wxSplitterWindow::GetSplitMode}{wxsplitterwindowgetsplitmode}, \helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically},\rtfsp
\helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally}.
\membersection{wxSplitterWindow::SplitHorizontally}\label{wxsplitterwindowsplithorizontally}
\func{bool}{SplitHorizontally}{\param{wxWindow* }{window1}, \param{wxWindow* }{window2},
\param{int}{ sashPosition = 0}}
Initializes the top and bottom panes of the splitter window. The
child windows are shown if they are currently hidden.
\wxheading{Parameters}
\docparam{window1}{The top pane.}
\docparam{window2}{The bottom pane.}
\docparam{sashPosition}{The initial position of the sash. If this value is
positive, it specifies the size of the upper pane. If it is negative, it is
absolute value gives the size of the lower pane. Finally, specify 0 (default)
to choose the default position (half of the total window height).}
\wxheading{Return value}
true if successful, false otherwise (the window was already split).
\wxheading{Remarks}
This should be called if you wish to initially view two panes. It can also be
called at any subsequent time, but the application should check that the
window is not currently split using \helpref{IsSplit}{wxsplitterwindowissplit}.
\wxheading{See also}
\helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically}, \helpref{wxSplitterWindow::IsSplit}{wxsplitterwindowissplit},\rtfsp
\helpref{wxSplitterWindow::Unsplit}{wxsplitterwindowunsplit}
\membersection{wxSplitterWindow::SplitVertically}\label{wxsplitterwindowsplitvertically}
\func{bool}{SplitVertically}{\param{wxWindow* }{window1}, \param{wxWindow* }{window2},
\param{int}{ sashPosition = 0}}
Initializes the left and right panes of the splitter window. The
child windows are shown if they are currently hidden.
\wxheading{Parameters}
\docparam{window1}{The left pane.}
\docparam{window2}{The right pane.}
\docparam{sashPosition}{The initial position of the sash. If this value is
positive, it specifies the size of the left pane. If it is negative, it is
absolute value gives the size of the right pane. Finally, specify 0 (default)
to choose the default position (half of the total window width).}
\wxheading{Return value}
true if successful, false otherwise (the window was already split).
\wxheading{Remarks}
This should be called if you wish to initially view two panes. It can also be called at any subsequent time,
but the application should check that the window is not currently split using \helpref{IsSplit}{wxsplitterwindowissplit}.
\wxheading{See also}
\helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally}, \helpref{wxSplitterWindow::IsSplit}{wxsplitterwindowissplit},\rtfsp
\helpref{wxSplitterWindow::Unsplit}{wxsplitterwindowunsplit}.
\membersection{wxSplitterWindow::Unsplit}\label{wxsplitterwindowunsplit}
\func{bool}{Unsplit}{\param{wxWindow* }{toRemove = NULL}}
Unsplits the window.
\wxheading{Parameters}
\docparam{toRemove}{The pane to remove, or NULL to remove the right or bottom pane.}
\wxheading{Return value}
true if successful, false otherwise (the window was not split).
\wxheading{Remarks}
This call will not actually delete the pane being removed; it calls \helpref{OnUnsplit}{wxsplitterwindowonunsplit}\rtfsp
which can be overridden for the desired behaviour. By default, the pane being removed is hidden.
\wxheading{See also}
\helpref{wxSplitterWindow::SplitHorizontally}{wxsplitterwindowsplithorizontally}, \helpref{wxSplitterWindow::SplitVertically}{wxsplitterwindowsplitvertically},\rtfsp
\helpref{wxSplitterWindow::IsSplit}{wxsplitterwindowissplit}, \helpref{wxSplitterWindow::OnUnsplit}{wxsplitterwindowonunsplit}
\membersection{wxSplitterWindow::UpdateSize}\label{wxsplitterwindowupdatesize}
\func{void}{UpdateSize}{\void}
Causes any pending sizing of the sash and child panes to take place
immediately.
Such resizing normally takes place in idle time, in order
to wait for layout to be completed. However, this can cause
unacceptable flicker as the panes are resized after the window has been
shown. To work around this, you can perform window layout (for
example by sending a size event to the parent window), and then
call this function, before showing the top-level window.