From: Robert Roebling Date: Mon, 16 Oct 2006 20:27:37 +0000 (+0000) Subject: [ 1578468 ] full support for "destroy on close" flag X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/fa96a36ecf0a167c9c2513867975ff18b4b57bcc [ 1578468 ] full support for "destroy on close" flag git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42061 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/aui/framemanager.h b/include/wx/aui/framemanager.h index b19cd3e26c..a72a431aef 100644 --- a/include/wx/aui/framemanager.h +++ b/include/wx/aui/framemanager.h @@ -218,6 +218,7 @@ public: bool IsRightDockable() const { return HasFlag(optionRightDockable); } bool IsFloatable() const { return HasFlag(optionFloatable); } bool IsMovable() const { return HasFlag(optionMovable); } + bool IsDestroyOnClose() const { return HasFlag(optionDestroyOnClose); } bool HasCaption() const { return HasFlag(optionCaption); } bool HasGripper() const { return HasFlag(optionGripper); } bool HasBorder() const { return HasFlag(optionPaneBorder); } @@ -427,6 +428,8 @@ public: int insert_level = wxAUI_INSERT_PANE); bool DetachPane(wxWindow* window); + + void ClosePane(wxPaneInfo& pane_info); wxString SavePaneInfo(wxPaneInfo& pane); void LoadPaneInfo(wxString pane_part, wxPaneInfo &pane); diff --git a/src/aui/framemanager.cpp b/src/aui/framemanager.cpp index a2bd4c0701..69657cfaf6 100644 --- a/src/aui/framemanager.cpp +++ b/src/aui/framemanager.cpp @@ -940,6 +940,40 @@ bool wxFrameManager::DetachPane(wxWindow* window) return false; } +// ClosePane() destroys or hides the pane depending on its +// flags +void wxFrameManager::ClosePane(wxPaneInfo& pane_info) +{ + // first, hide the window + if (pane_info.window && pane_info.window->IsShown()) { + pane_info.window->Show(false); + } + + // make sure that we are the parent of this window + if(pane_info.window && pane_info.window->GetParent() != m_frame) { + pane_info.window->Reparent(m_frame); + } + + // if we have a frame, destroy it + if(pane_info.frame) { + pane_info.frame->Destroy(); + pane_info.frame = NULL; + } + + // now we need to either destroy or hide the pane + if(pane_info.IsDestroyOnClose()) + { + wxWindow * window = pane_info.window; + DetachPane(window); + if(window) { + window->Destroy(); + } + } + else + { + pane_info.Hide(); + } +} // EscapeDelimiters() changes ";" into "\;" and "|" into "\|" // in the input string. This is an internal functions which is @@ -3117,15 +3151,9 @@ void wxFrameManager::OnFloatingPaneClosed(wxWindow* wnd, wxCloseEvent& evt) evt.Veto(); return; } - else + else { - // reparent the pane window back to us and - // prepare the frame window for destruction - if (pane.window->IsShown()) - pane.window->Show(false); - pane.window->Reparent(m_frame); - pane.frame = NULL; - pane.Hide(); + ClosePane(pane); } } @@ -3860,7 +3888,7 @@ void wxFrameManager::OnPaneButton(wxFrameManagerEvent& evt) if (!e.GetVeto()) { - pane.Hide(); + ClosePane(pane); Update(); } }