implemented page close event for wxAuiNotebook
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43122 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
5d3aeb0f57
commit
3fd8c98854
@ -463,6 +463,7 @@ protected:
|
||||
#ifndef SWIG
|
||||
|
||||
BEGIN_DECLARE_EVENT_TYPES()
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, 0)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 0)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 0)
|
||||
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 0)
|
||||
@ -476,7 +477,9 @@ typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&);
|
||||
|
||||
#define wxAuiNotebookEventHandler(func) \
|
||||
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
|
||||
|
||||
|
||||
#define EVT_AUINOTEBOOK_PAGE_CLOSE(winid, fn) \
|
||||
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, winid, wxAuiNotebookEventHandler(fn))
|
||||
#define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
|
||||
wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
|
||||
#define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
|
||||
@ -495,6 +498,7 @@ typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&);
|
||||
#else
|
||||
|
||||
// wxpython/swig event work
|
||||
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE;
|
||||
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED;
|
||||
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING;
|
||||
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON;
|
||||
@ -504,6 +508,7 @@ typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&);
|
||||
%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND;
|
||||
|
||||
%pythoncode {
|
||||
EVT_AUINOTEBOOK_PAGE_CLOSE = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, 1 )
|
||||
EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 1 )
|
||||
EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 1 )
|
||||
EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 1 )
|
||||
|
@ -138,6 +138,7 @@ private:
|
||||
void OnRestorePerspective(wxCommandEvent& evt);
|
||||
void OnSettings(wxCommandEvent& evt);
|
||||
void OnAllowNotebookDnD(wxAuiNotebookEvent& evt);
|
||||
void OnNotebookPageClose(wxAuiNotebookEvent& evt);
|
||||
void OnExit(wxCommandEvent& evt);
|
||||
void OnAbout(wxCommandEvent& evt);
|
||||
|
||||
@ -619,6 +620,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
MyFrame::OnRestorePerspective)
|
||||
EVT_AUI_PANECLOSE(MyFrame::OnPaneClose)
|
||||
EVT_AUINOTEBOOK_ALLOW_DND(wxID_ANY, MyFrame::OnAllowNotebookDnD)
|
||||
EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, MyFrame::OnNotebookPageClose)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
@ -1208,6 +1210,20 @@ void MyFrame::OnRestorePerspective(wxCommandEvent& evt)
|
||||
m_mgr.LoadPerspective(m_perspectives.Item(evt.GetId() - ID_FirstPerspective));
|
||||
}
|
||||
|
||||
void MyFrame::OnNotebookPageClose(wxAuiNotebookEvent& evt)
|
||||
{
|
||||
wxAuiNotebook* ctrl = (wxAuiNotebook*)evt.GetEventObject();
|
||||
if (ctrl->GetPage(evt.GetSelection())->IsKindOf(CLASSINFO(wxHtmlWindow)))
|
||||
{
|
||||
int res = wxMessageBox(wxT("Are you sure you want to close/hide this notebook page?"),
|
||||
wxT("wxAUI"),
|
||||
wxYES_NO,
|
||||
this);
|
||||
if (res != wxYES)
|
||||
evt.Veto();
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::OnAllowNotebookDnD(wxAuiNotebookEvent& evt)
|
||||
{
|
||||
// for the purpose of this test application, explicitly
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user