From 3ad5e06b4aefdcef8a1ec2ec563540e055462e66 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 10 Feb 1999 13:38:12 +0000 Subject: [PATCH] wxSplitterWindow::ReplaceWindow() function added and documented git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1666 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/splitter.tex | 22 +++++++++++++++++++ include/wx/generic/splitter.h | 4 ++++ src/generic/splitter.cpp | 41 ++++++++++++++++++++++++++++------- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/docs/latex/wx/splitter.tex b/docs/latex/wx/splitter.tex index bf1087b6c8..d96ccb9551 100644 --- a/docs/latex/wx/splitter.tex +++ b/docs/latex/wx/splitter.tex @@ -205,10 +205,32 @@ user. It may return FALSE to prevent the change or TRUE to allow it. 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}} diff --git a/include/wx/generic/splitter.h b/include/wx/generic/splitter.h index d8ffcc0f37..951562b148 100644 --- a/include/wx/generic/splitter.h +++ b/include/wx/generic/splitter.h @@ -94,6 +94,10 @@ public: // 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); } diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index 9486d9425e..d43a1244d3 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -587,22 +587,17 @@ bool wxSplitterWindow::Unsplit(wxWindow *toRemove) 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 { @@ -611,6 +606,36 @@ bool wxSplitterWindow::Unsplit(wxWindow *toRemove) 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; } -- 2.45.2