]> git.saurik.com Git - wxWidgets.git/blobdiff - src/aui/auibook.cpp
implemented page close event for wxAuiNotebook
[wxWidgets.git] / src / aui / auibook.cpp
index bc7f8fb218abde90295cecb68d420d74d8a10312..82d4a4717c67d8b2ebc989333d48529b2d061260 100644 (file)
@@ -35,6 +35,7 @@
 WX_DEFINE_OBJARRAY(wxAuiNotebookPageArray)
 WX_DEFINE_OBJARRAY(wxAuiTabContainerButtonArray)
 
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE)
 DEFINE_EVENT_TYPE(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING)
 DEFINE_EVENT_TYPE(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED)
 DEFINE_EVENT_TYPE(wxEVT_COMMAND_AUINOTEBOOK_BUTTON)
@@ -2533,6 +2534,17 @@ void wxAuiNotebook::OnTabButton(wxCommandEvent& command_evt)
         {
             wxWindow* close_wnd = tabs->GetWindowFromIdx(selection);
 
+
+            // ask owner if it's ok to close the tab
+            wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, m_windowId);
+            e.SetSelection(m_tabs.GetIdxFromWindow(close_wnd));
+            e.SetOldSelection(evt.GetSelection());
+            e.SetEventObject(this);
+            GetEventHandler()->ProcessEvent(e);
+            if (!e.IsAllowed())
+                return;
+
+
             if (close_wnd->IsKindOf(CLASSINFO(wxAuiMDIChildFrame)))
             {
                 close_wnd->Close();