]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/notebook/notebook.cpp
build a tarball when building the new docs
[wxWidgets.git] / samples / notebook / notebook.cpp
index 7293098e564e2e0cbbd47b75ea7cb789032f7743..f5ed8758e1a20eb77d8ac54a5b7a5f9e149ce4ae 100644 (file)
@@ -5,7 +5,7 @@
 // Modified by: Dimitri Schoolwerth
 // Created:     26/10/98
 // RCS-ID:      $Id$
-// Copyright:   (c) 1998-2002 wxWindows team
+// Copyright:   (c) 1998-2002 wxWidgets team
 // License:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
@@ -24,9 +24,6 @@
 #include "wx/artprov.h"
 #include "notebook.h"
 
-// Name of the Veto page
-#define VETO_PAGE_NAME wxT("Veto")
-
 IMPLEMENT_APP(MyApp)
 
 bool MyApp::OnInit()
@@ -36,15 +33,15 @@ bool MyApp::OnInit()
 
     // Problem with generic wxNotebook implementation whereby it doesn't size
     // properly unless you set the size again
-#if defined(__WIN16__) || defined(__WXMOTIF__)
+#if defined(__WXMOTIF__)
     int width, height;
     frame->GetSize(& width, & height);
-    frame->SetSize(-1, -1, width, height);
+    frame->SetSize(wxDefaultCoord, wxDefaultCoord, width, height);
 #endif
 
     frame->Show();
 
-    return TRUE;
+    return true;
 }
 
 MyNotebook::MyNotebook(wxWindow *parent, wxWindowID id,
@@ -54,77 +51,131 @@ MyNotebook::MyNotebook(wxWindow *parent, wxWindowID id,
     // Empty
 }
 
-void MyNotebook::CreateInitialPages()
+wxPanel *MyNotebook::CreatePage(const wxString&pageName)
 {
-    wxPanel *panel = (wxPanel *) NULL;
-    wxBoxSizer *sizerPanel = (wxBoxSizer *) NULL;
+    if
+    (
+        pageName.Contains(INSERTED_PAGE_NAME)
+        || pageName.Contains(ADDED_PAGE_NAME)
+    )
+    {
+        return CreateUserCreatedPage();
+    }
 
-    // Create and add some panels to the notebook
+    if (pageName == I_WAS_INSERTED_PAGE_NAME)
+    {
+        return CreateInsertPage();
+    }
 
+    if (pageName == VETO_PAGE_NAME)
+    {
+        return CreateVetoPage();
+    }
 
-    // Panel 1
-    panel = new wxPanel(this);
+    if (pageName == RADIOBUTTONS_PAGE_NAME)
+    {
+        return CreateRadioButtonsPage();
+    }
 
-    sizerPanel = new wxBoxSizer(wxVERTICAL);
-    sizerPanel->Add( new wxButton( panel, -1, wxT("Button") ) );
-    sizerPanel->Add( new wxTextCtrl(panel, -1, wxT("1234"),
-        wxDefaultPosition, wxSize(120, 150) ) );
-    panel->SetSizer(sizerPanel);
 
-    AddPage( panel, wxT("Controls without sizer"), TRUE, GetIconIndex() );
+    if (pageName == MAXIMIZED_BUTTON_PAGE_NAME)
+    {
+        return CreateBigButtonPage();
+    }
 
+    wxFAIL;
 
-    // Panel 2
-    panel = new wxPanel(this);
+    return (wxPanel *) NULL;
+}
+
+wxPanel *MyNotebook::CreateUserCreatedPage()
+{
+    wxPanel *panel = new wxPanel(this);
+
+    (void) new wxButton( panel, wxID_ANY, wxT("Button"),
+        wxPoint(10, 10), wxDefaultSize );
+
+    return panel;
+}
+
+wxPanel *MyNotebook::CreateRadioButtonsPage()
+{
+    wxPanel *panel = new wxPanel(this);
 
     wxString animals[] = { wxT("Fox"), wxT("Hare"), wxT("Rabbit"),
         wxT("Sabre-toothed tiger"), wxT("T Rex") };
-    wxRadioBox *radiobox1 = new wxRadioBox(panel, -1, wxT("Choose one"),
+
+    wxRadioBox *radiobox1 = new wxRadioBox(panel, wxID_ANY, wxT("Choose one"),
         wxDefaultPosition, wxDefaultSize, 5, animals, 2, wxRA_SPECIFY_ROWS);
 
     wxString computers[] = { wxT("Amiga"), wxT("Commodore 64"), wxT("PET"),
         wxT("Another") };
-    wxRadioBox *radiobox2 = new wxRadioBox(panel, -1,
+
+    wxRadioBox *radiobox2 = new wxRadioBox(panel, wxID_ANY,
         wxT("Choose your favourite"), wxDefaultPosition, wxDefaultSize,
         4, computers, 0, wxRA_SPECIFY_COLS);
 
-    sizerPanel = new wxBoxSizer(wxVERTICAL);
+    wxBoxSizer *sizerPanel = new wxBoxSizer(wxVERTICAL);
     sizerPanel->Add(radiobox1, 2, wxEXPAND);
     sizerPanel->Add(radiobox2, 1, wxEXPAND);
     panel->SetSizer(sizerPanel);
 
-    AddPage( panel, wxT("Radiobuttons"), FALSE, GetIconIndex() );
+    return panel;
+}
 
+wxPanel *MyNotebook::CreateVetoPage()
+{
+    wxPanel *panel = new wxPanel(this);
 
-    // Panel 3
-    panel = new wxPanel(this);
-    (void) new wxStaticText( panel, -1,
+    (void) new wxStaticText( panel, wxID_ANY,
         wxT("This page intentionally left blank"), wxPoint(10, 10) );
-    AddPage( panel, VETO_PAGE_NAME, FALSE, GetIconIndex() );
 
+    return panel;
+}
 
-    // Panel 4
-    panel = new wxPanel(this);
-    wxButton *buttonBig = new wxButton( panel, -1, wxT("Big button"),
-        wxPoint(0, 0), wxSize(480, 360) );
+wxPanel *MyNotebook::CreateBigButtonPage()
+{
+    wxPanel *panel = new wxPanel(this);
 
-    sizerPanel = new wxBoxSizer(wxVERTICAL);
+    wxButton *buttonBig = new wxButton(panel, wxID_ANY, wxT("Maximized button"));
+
+    wxBoxSizer *sizerPanel = new wxBoxSizer(wxVERTICAL);
     sizerPanel->Add(buttonBig, 1, wxEXPAND);
     panel->SetSizer(sizerPanel);
 
-    AddPage( panel, wxT("Big button"), FALSE, GetIconIndex() );
+    return panel;
+}
 
 
-    // Panel 5
-    panel = new wxPanel(this);
+wxPanel *MyNotebook::CreateInsertPage()
+{
+    wxPanel *panel = new wxPanel(this);
+
     panel->SetBackgroundColour( wxColour( wxT("MAROON") ) );
-    (void) new wxStaticText( panel, -1,
+    (void) new wxStaticText( panel, wxID_ANY,
         wxT("This page has been inserted, not added."), wxPoint(10, 10) );
-    InsertPage( 0, panel, wxT("Inserted"), FALSE, GetIconIndex() );
 
+    return panel;
+}
+
+void MyNotebook::CreateInitialPages()
+{
+    // Create and add some panels to the notebook
+
+    wxPanel *panel = CreateRadioButtonsPage();
+    AddPage( panel, RADIOBUTTONS_PAGE_NAME, false, GetIconIndex() );
+
+    panel = CreateVetoPage();
+    AddPage( panel, VETO_PAGE_NAME, false, GetIconIndex() );
 
-    SetSelection(2);
+    panel = CreateBigButtonPage();
+    AddPage( panel, MAXIMIZED_BUTTON_PAGE_NAME, false, GetIconIndex() );
 
+    panel = CreateInsertPage();
+    InsertPage( 0, panel, I_WAS_INSERTED_PAGE_NAME, false, GetIconIndex() );
+
+
+    SetSelection(1);
 }
 
 int MyNotebook::GetIconIndex() const
@@ -143,14 +194,39 @@ int MyNotebook::GetIconIndex() const
 
 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
                  long style)
-    : wxFrame((wxWindow *) NULL, -1, title, pos, size, style)
+    : wxFrame((wxWindow *) NULL, wxID_ANY, title, pos, size, style)
 {
     m_panel = (wxPanel *) NULL;
     m_notebook = (MyNotebook *) NULL;
-    m_imageList = (wxImageList *) NULL;
 
-    m_panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize,
-        wxTAB_TRAVERSAL|wxCLIP_CHILDREN|wxNO_BORDER);
+    // create a dummy image list with a few icons
+    wxSize imageSize(32, 32);
+
+    m_imageList
+        = new wxImageList( imageSize.GetWidth(), imageSize.GetHeight() );
+
+    m_imageList->Add
+        (
+            wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize)
+        );
+
+    m_imageList->Add
+        (
+            wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize)
+        );
+
+    m_imageList->Add
+        (
+            wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize)
+        );
+
+    m_imageList->Add
+        (
+            wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize)
+        );
+
+    m_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
+        wxTAB_TRAVERSAL | wxCLIP_CHILDREN | wxNO_BORDER | wxNO_FULL_REPAINT_ON_RESIZE);
 
     // Create remaining controls
 
@@ -164,27 +240,34 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
     };
 
     wxASSERT_MSG( WXSIZEOF(strOrientations) == ORIENT_MAX,
-                  wxT("forgot to update something") );
+                  wxT("Forgot to update something") );
 
     m_radioOrient = new wxRadioBox
-        (
-            m_panel, ID_RADIO_ORIENT,
-            wxT("&Tab orientation"),
-            wxDefaultPosition, wxDefaultSize,
-            WXSIZEOF(strOrientations), strOrientations,
-            1, wxRA_SPECIFY_COLS
-        );
+                    (
+                        m_panel, ID_RADIO_ORIENT,
+                        wxT("&Tab orientation"),
+                        wxDefaultPosition, wxDefaultSize,
+                        WXSIZEOF(strOrientations), strOrientations,
+                        1, wxRA_SPECIFY_COLS
+                    );
 
     m_chkShowImages = new wxCheckBox( m_panel, ID_CHK_SHOWIMAGES,
         wxT("&Show images") );
+#ifndef TEST_LISTBOOK
+    m_chkMultiLine = new wxCheckBox( m_panel, ID_CHK_MULTILINE,
+        wxT("&Multiple lines") );
+#endif // !TEST_LISTBOOK
 
     m_btnAddPage = new wxButton( m_panel, ID_BTN_ADD_PAGE, wxT("&Add page") );
 
     m_btnInsertPage = new wxButton( m_panel, ID_BTN_INSERT_PAGE,
         wxT("&Insert page") );
 
-    m_btnDeletePage = new wxButton( m_panel, ID_BTN_DELETE_PAGE,
-        wxT("&Delete page") );
+    m_btnDeleteCurPage = new wxButton( m_panel, ID_BTN_DELETE_CUR_PAGE,
+        wxT("&Delete current page") );
+
+    m_btnDeleteLastPage = new wxButton( m_panel, ID_BTN_DELETE_LAST_PAGE,
+        wxT("Delete las&t page") );
 
     m_btnNextPage = new wxButton( m_panel, ID_BTN_NEXT_PAGE,
         wxT("&Next page") );
@@ -192,15 +275,12 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
     m_btnExit = new wxButton( m_panel, wxID_OK, wxT("&Exit") );
     m_btnExit->SetDefault();
 
-    m_notebook = new MyNotebook(m_panel, ID_NOTEBOOK);
-
-    m_text = new wxTextCtrl(m_panel, -1, wxEmptyString,
+#if wxUSE_LOG
+    m_text = new wxTextCtrl(m_panel, wxID_ANY, wxEmptyString,
         wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
 
     m_logTargetOld = wxLog::SetActiveTarget( new wxLogTextCtrl(m_text) );
-
-    // Create the notebook's panels
-    m_notebook->CreateInitialPages();
+#endif // wxUSE_LOG
 
     // Set sizers
     m_sizerFrame = new wxBoxSizer(wxVERTICAL);
@@ -208,35 +288,39 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
     m_sizerTop = new wxBoxSizer(wxHORIZONTAL);
 
     wxBoxSizer *sizerLeft = new wxBoxSizer(wxVERTICAL);
-    {
-        sizerLeft->Add(m_radioOrient, 0, wxEXPAND);
-        sizerLeft->Add(m_chkShowImages, 0, wxEXPAND | wxTOP, 4);
+    sizerLeft->Add(m_radioOrient, 0, wxEXPAND);
+    sizerLeft->Add(m_chkShowImages, 0, wxEXPAND | wxTOP, 4);
+#ifndef TEST_LISTBOOK
+    sizerLeft->Add(m_chkMultiLine, 0, wxEXPAND | wxTOP, 4);
+#endif // !TEST_LISTBOOK
 
-        sizerLeft->Add(0, 0, 1); // Spacer
+    sizerLeft->Add(0, 0, 1); // Spacer
 
-        sizerLeft->Add(m_btnAddPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4);
-        sizerLeft->Add(m_btnInsertPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4);
-        sizerLeft->Add(m_btnDeletePage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4);
-        sizerLeft->Add(m_btnNextPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4);
+    sizerLeft->Add(m_btnAddPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4);
+    sizerLeft->Add(m_btnInsertPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4);
+    sizerLeft->Add(m_btnDeleteCurPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4);
+    sizerLeft->Add(m_btnDeleteLastPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4);
+    sizerLeft->Add(m_btnNextPage, 0, wxEXPAND | (wxTOP | wxBOTTOM), 4);
 
-        sizerLeft->Add(0, 0, 1); // Spacer
+    sizerLeft->Add(0, 0, 1); // Spacer
 
-        sizerLeft->Add(m_btnExit, 0, wxEXPAND);
-    }
+    sizerLeft->Add(m_btnExit, 0, wxEXPAND);
 
     m_sizerTop->Add(sizerLeft, 0, wxEXPAND | wxALL, 4);
 
 
     m_sizerFrame->Add(m_sizerTop, 1, wxEXPAND);
+#if wxUSE_LOG
     m_sizerFrame->Add(m_text, 0, wxEXPAND);
+#endif // wxUSE_LOG
 
     ReInitNotebook();
+    m_notebook->CreateInitialPages();
 
     m_panel->SetSizer(m_sizerFrame);
 
-    m_panel->SetAutoLayout(TRUE);
-
     m_sizerFrame->Fit(this);
+    m_sizerFrame->SetSizeHints(this);
 
     Centre(wxBOTH);
 
@@ -244,7 +328,16 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
 
 MyFrame::~MyFrame()
 {
+#if wxUSE_LOG
     delete wxLog::SetActiveTarget(m_logTargetOld);
+#endif // wxUSE_LOG
+
+    if (m_imageList)
+    {
+        delete m_imageList;
+        m_imageList = (wxImageList *) NULL;
+    }
+
 }
 
 void MyFrame::ReInitNotebook()
@@ -274,139 +367,118 @@ void MyFrame::ReInitNotebook()
             break;
     }
 
-    MyNotebook *notebook = m_notebook;
+#ifndef TEST_LISTBOOK
+    if ( m_chkMultiLine->IsChecked() )
+        flags |= wxNB_MULTILINE;
+#endif // !TEST_LISTBOOK
 
+    MyNotebook *notebook = m_notebook;
 
     m_notebook = new MyNotebook(m_panel, ID_NOTEBOOK,
                                 wxDefaultPosition, wxDefaultSize,
                                 flags);
 
-    CreateImageList();
+    if ( m_chkShowImages->IsChecked() )
+    {
+        m_notebook->SetImageList(m_imageList);
+    }
 
-    if ( notebook )
+    if (notebook)
     {
         int sel = notebook->GetSelection();
 
         int count = notebook->GetPageCount();
-        for ( int n = 0; n < count; n++ )
+        for (int n = 0; n < count; n++)
         {
-            wxNotebookPage *page = notebook->GetPage(0);
-            page->Reparent(m_notebook);
-
-            m_notebook->AddPage( page, notebook->GetPageText(0), FALSE,
-                m_notebook->GetIconIndex() );
-
-            notebook->RemovePage(0);
-        }
+            wxString str = notebook->GetPageText(n);
 
-        if (m_sizerNotebook)
-        {
-            m_sizerTop->Remove(m_sizerNotebook);
+            wxWindow *page = m_notebook->CreatePage(str);
+            m_notebook->AddPage(page, str, false, m_notebook->GetIconIndex() );
         }
 
+        m_sizerTop->Detach(notebook);
+        
         delete notebook;
 
         // restore selection
-        if ( sel != -1 )
+        if (sel != -1)
         {
             m_notebook->SetSelection(sel);
         }
-    }
 
-    m_sizerNotebook = new wxNotebookSizer(m_notebook);
-    m_sizerTop->Add(m_sizerNotebook, 1, wxEXPAND | wxALL, 4);
-    m_sizerTop->Layout();
-}
-
-void MyFrame::CreateImageList()
-{
-    if (m_imageList)
-    {
-        delete m_imageList;
-        m_imageList = (wxImageList *) NULL;
     }
 
-    if ( m_chkShowImages->IsChecked() )
-    {
-        // create a dummy image list with a few icons
-        wxSize size(32, 32);
-
-        m_imageList = new wxImageList( size.GetWidth(), size.GetHeight() );
-        
-        m_imageList->Add
-            (
-                wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, size)
-            );
-
-        m_imageList->Add
-            (
-                wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, size)
-            );
 
-        m_imageList->Add
-            (
-                wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, size)
-            );
-
-        m_imageList->Add
-            (
-                wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, size)
-            );
-
-        m_notebook->SetImageList(m_imageList);
-    }
+    m_sizerTop->Add(m_notebook, 1, wxEXPAND | wxALL, 4);
+    m_sizerTop->Layout();
 }
 
-
 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_RADIOBOX(ID_RADIO_ORIENT, MyFrame::OnCheckOrRadioBox)
     EVT_CHECKBOX(ID_CHK_SHOWIMAGES, MyFrame::OnCheckOrRadioBox)
+#ifndef TEST_LISTBOOK
+    EVT_CHECKBOX(ID_CHK_MULTILINE, MyFrame::OnCheckOrRadioBox)
+#endif // !TEST_LISTBOOK
 
     EVT_BUTTON(ID_BTN_ADD_PAGE, MyFrame::OnButtonAddPage)
     EVT_BUTTON(ID_BTN_INSERT_PAGE, MyFrame::OnButtonInsertPage)
-    EVT_BUTTON(ID_BTN_DELETE_PAGE, MyFrame::OnButtonDeletePage)
+    EVT_BUTTON(ID_BTN_DELETE_CUR_PAGE, MyFrame::OnButtonDeleteCurPage)
+    EVT_BUTTON(ID_BTN_DELETE_LAST_PAGE, MyFrame::OnButtonDeleteLastPage)
     EVT_BUTTON(ID_BTN_NEXT_PAGE, MyFrame::OnButtonNextPage)
     EVT_BUTTON(wxID_OK, MyFrame::OnButtonExit)
 
+    EVT_UPDATE_UI(ID_BTN_DELETE_CUR_PAGE, MyFrame::OnUpdateUIBtnDeleteCurPage)
+    EVT_UPDATE_UI(ID_BTN_DELETE_LAST_PAGE, MyFrame::OnUpdateUIBtnDeleteLastPage)
+
     EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, MyFrame::OnNotebook)
     EVT_NOTEBOOK_PAGE_CHANGING(ID_NOTEBOOK, MyFrame::OnNotebook)
 
     EVT_IDLE(MyFrame::OnIdle)
 END_EVENT_TABLE()
 
-void MyFrame::OnCheckOrRadioBox(wxCommandEvent& event)
+void MyFrame::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
 {
-        ReInitNotebook();
+    ReInitNotebook();
 }
 
 void MyFrame::OnButtonAddPage( wxCommandEvent& WXUNUSED(event) )
 {
-    static size_t s_pageAdded = 0;
+    static unsigned s_pageAdded = 0;
 
-    wxPanel *panel = new wxPanel( m_notebook, -1 );
-    (void) new wxButton( panel, -1, wxT("Button"),
-        wxPoint(10, 10), wxSize(-1, -1) );
+    wxPanel *panel = new wxPanel( m_notebook, wxID_ANY );
+    (void) new wxButton( panel, wxID_ANY, wxT("First button"),
+        wxPoint(10, 10), wxDefaultSize );
+    (void) new wxButton( panel, wxID_ANY, wxT("Second button"),
+        wxPoint(50, 100), wxDefaultSize );
 
-    m_notebook->AddPage(panel, wxString::Format(wxT("Added %u"),
-        ++s_pageAdded), FALSE, m_notebook->GetIconIndex() );
+    m_notebook->AddPage(panel, wxString::Format(ADDED_PAGE_NAME wxT("%u"),
+        ++s_pageAdded), true, m_notebook->GetIconIndex() );
 }
 
 void MyFrame::OnButtonInsertPage( wxCommandEvent& WXUNUSED(event) )
 {
-    static size_t s_pageIns = 0;
+    static unsigned s_pageIns = 0;
 
-    wxPanel *panel = new wxPanel( m_notebook, -1 );
-    (void) new wxButton( panel, -1, wxT("Button"),
-        wxPoint(10, 10), wxSize(-1, -1) );
+    wxPanel *panel = m_notebook->CreateUserCreatedPage();
 
     m_notebook->InsertPage( 0, panel,
-        wxString::Format(wxT("Inserted %u"), ++s_pageIns), FALSE,
+        wxString::Format(INSERTED_PAGE_NAME wxT("%u"), ++s_pageIns), false,
         m_notebook->GetIconIndex() );
 
     m_notebook->SetSelection(0);
 }
 
-void MyFrame::OnButtonDeletePage( wxCommandEvent& WXUNUSED(event) )
+void MyFrame::OnButtonDeleteLastPage( wxCommandEvent& WXUNUSED(event) )
+{
+    int page = m_notebook->GetPageCount();
+
+    if ( page != 0 )
+    {
+        m_notebook->DeletePage(page - 1);
+    }
+}
+
+void MyFrame::OnButtonDeleteCurPage( wxCommandEvent& WXUNUSED(event) )
 {
     int sel = m_notebook->GetSelection();
 
@@ -462,9 +534,11 @@ void MyFrame::OnNotebook(wxNotebookEvent& event)
     static int s_numNotebookEvents = 0;
 
     wxLogMessage(wxT("Notebook event #%d: %s (%d)"),
-        s_numNotebookEvents++, str, eventType);
+        s_numNotebookEvents++, str.c_str(), eventType);
 
+#if wxUSE_LOG
     m_text->SetInsertionPointEnd();
+#endif // wxUSE_LOG
 
     event.Skip();
 }
@@ -487,3 +561,13 @@ void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
         SetTitle(title);
     }
 }
+
+void MyFrame::OnUpdateUIBtnDeleteCurPage(wxUpdateUIEvent& event)
+{
+    event.Enable( m_notebook->GetSelection() != -1 );
+}
+
+void MyFrame::OnUpdateUIBtnDeleteLastPage(wxUpdateUIEvent& event)
+{
+    event.Enable( m_notebook->GetPageCount() != 0 );
+}