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::SetSashPosition}\label{wxsplitterwindowsetsashposition}
\func{void}{SetSashPosition}{\param{int }{position}, \param{const bool}{ redraw = TRUE}}
// Doesn't actually delete the window.
bool Unsplit(wxWindow *toRemove = (wxWindow *) NULL);
+ // Replaces one of the windows with another one (neither old nor new
+ // parameter should be NULL)
+ bool ReplaceWindow(wxWindow *winOld, wxWindow *winNew);
+
// Is the window split?
bool IsSplit() const { return (m_windowTwo != NULL); }
if ( ! IsSplit() )
return FALSE;
+ wxWindow *win = NULL;
if ( toRemove == NULL || toRemove == m_windowTwo)
{
- wxWindow *win = m_windowTwo ;
+ win = m_windowTwo ;
m_windowTwo = (wxWindow *) NULL;
- OnUnsplit(win);
- m_sashPosition = 0;
- SizeWindows();
}
else if ( toRemove == m_windowOne )
{
- wxWindow *win = m_windowOne ;
+ win = m_windowOne ;
m_windowOne = m_windowTwo;
m_windowTwo = (wxWindow *) NULL;
- OnUnsplit(win);
- m_sashPosition = 0;
- SizeWindows();
}
else
{
return FALSE;
}
+ OnUnsplit(win);
+ m_sashPosition = 0;
+ SizeWindows();
+
+ return TRUE;
+}
+
+// Replace a window with another one
+bool wxSplitterWindow::ReplaceWindow(wxWindow *winOld, wxWindow *winNew)
+{
+ wxCHECK_MSG( winOld, FALSE, "use one of Split() functions instead" );
+ wxCHECK_MSG( winNew, FALSE, "use Unsplit() functions instead" );
+
+ if ( winOld == m_windowTwo )
+ {
+ m_windowTwo = winNew;
+ }
+ else if ( winOld == m_windowOne )
+ {
+ m_windowOne = winNew;
+ }
+ else
+ {
+ wxFAIL_MSG("splitter: attempt to replace a non-existent window");
+
+ return FALSE;
+ }
+
+ SizeWindows();
+
return TRUE;
}