diff --git a/samples/aui/auidemo.cpp b/samples/aui/auidemo.cpp index 6eeee9a118..f8fd21cca1 100644 --- a/samples/aui/auidemo.cpp +++ b/samples/aui/auidemo.cpp @@ -24,6 +24,7 @@ #include "wx/dataobj.h" #include "wx/dcclient.h" #include "wx/bmpbuttn.h" +#include "wx/log.h" #include "wx/menu.h" #include "wx/toolbar.h" #include "wx/statusbr.h" @@ -98,6 +99,8 @@ class MyFrame : public wxFrame ID_NotebookArtSimple, ID_NotebookAlignTop, ID_NotebookAlignBottom, + ID_NotebookNewTab, + ID_NotebookDeleteTab, ID_SampleItem, @@ -158,6 +161,9 @@ private: void OnNotebookFlag(wxCommandEvent& evt); void OnUpdateUI(wxUpdateUIEvent& evt); + void OnNotebookNewTab(wxCommandEvent& evt); + void OnNotebookDeleteTab(wxCommandEvent& evt); + void OnPaneClose(wxAuiManagerEvent& evt); private: @@ -605,6 +611,8 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(ID_NotebookArtSimple, MyFrame::OnNotebookFlag) EVT_MENU(ID_NotebookAlignTop, MyFrame::OnTabAlignment) EVT_MENU(ID_NotebookAlignBottom, MyFrame::OnTabAlignment) + EVT_MENU(ID_NotebookNewTab, MyFrame::OnNotebookNewTab) + EVT_MENU(ID_NotebookDeleteTab, MyFrame::OnNotebookDeleteTab) EVT_MENU(ID_NoGradient, MyFrame::OnGradient) EVT_MENU(ID_VerticalGradient, MyFrame::OnGradient) EVT_MENU(ID_HorizontalGradient, MyFrame::OnGradient) @@ -733,6 +741,9 @@ MyFrame::MyFrame(wxWindow* parent, notebook_menu->AppendCheckItem(ID_NotebookScrollButtons, _("Scroll Buttons Visible")); notebook_menu->AppendCheckItem(ID_NotebookWindowList, _("Window List Button Visible")); notebook_menu->AppendCheckItem(ID_NotebookTabFixedWidth, _("Fixed-width Tabs")); + notebook_menu->AppendSeparator(); + notebook_menu->Append(ID_NotebookNewTab, _("Add a &New Tab")); + notebook_menu->Append(ID_NotebookDeleteTab, _("&Delete Last Tab")); m_perspectives_menu = new wxMenu; m_perspectives_menu->Append(ID_CreatePerspective, _("Create Perspective")); @@ -1300,6 +1311,36 @@ void MyFrame::OnUpdateUI(wxUpdateUIEvent& event) } } + +void MyFrame::OnNotebookNewTab(wxCommandEvent& WXUNUSED(evt)) +{ + auto* const book = + wxCheckCast(m_mgr.GetPane("notebook_content").window); + + book->AddPage(new wxTextCtrl(book, wxID_ANY, "New Tab", + wxDefaultPosition, wxDefaultSize, + wxTE_MULTILINE | wxNO_BORDER), + wxString::Format("Tab %zu", book->GetPageCount() + 1), + true /* select */); +} + + +void MyFrame::OnNotebookDeleteTab(wxCommandEvent& WXUNUSED(evt)) +{ + auto* const book = + wxCheckCast(m_mgr.GetPane("notebook_content").window); + + auto numPages = book->GetPageCount(); + if ( !numPages ) + { + wxLogWarning("No pages to delete."); + return; + } + + book->DeletePage(numPages - 1); +} + + void MyFrame::OnPaneClose(wxAuiManagerEvent& evt) { if (evt.pane->name == "test10")