]> git.saurik.com Git - wxWidgets.git/commitdiff
[ 1578468 ] full support for "destroy on close" flag
authorRobert Roebling <robert@roebling.de>
Mon, 16 Oct 2006 20:27:37 +0000 (20:27 +0000)
committerRobert Roebling <robert@roebling.de>
Mon, 16 Oct 2006 20:27:37 +0000 (20:27 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42061 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/aui/framemanager.h
src/aui/framemanager.cpp

index b19cd3e26caf7b5428dde1626b36b1ece2cf8e7d..a72a431aeffedddf4fc00bdbcaace9c1ae1c0d5f 100644 (file)
@@ -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);
index a2bd4c07011f42b588d0df7f4714b38b89e0a30e..69657cfaf6f3fc94020ea9b10327bfa0499c91cc 100644 (file)
@@ -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();
         }
     }