From 37144cf0f155bb7cea1972e934a4d083bca1b8ca Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 3 Jul 2004 15:49:29 +0000 Subject: [PATCH] Invalidate notebook best size when pages are added or removed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28154 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/bookctrl.h | 14 ++++++++++++-- samples/notebook/notebook.cpp | 10 +++------- samples/notebook/notebook.h | 3 --- src/common/bookctrl.cpp | 4 +++- src/generic/listbkg.cpp | 1 + src/gtk/notebook.cpp | 2 ++ src/gtk1/notebook.cpp | 2 ++ src/mac/carbon/notebmac.cpp | 3 +++ src/mac/classic/notebmac.cpp | 3 +++ src/msw/notebook.cpp | 2 ++ 10 files changed, 31 insertions(+), 13 deletions(-) diff --git a/include/wx/bookctrl.h b/include/wx/bookctrl.h index c64224e8f8..0f03436ae5 100644 --- a/include/wx/bookctrl.h +++ b/include/wx/bookctrl.h @@ -122,10 +122,19 @@ public: virtual bool DeletePage(size_t n); // remove one page from the notebook, without deleting it - virtual bool RemovePage(size_t n) { return DoRemovePage(n) != NULL; } + virtual bool RemovePage(size_t n) + { + InvalidateBestSize(); + return DoRemovePage(n) != NULL; + } // remove all pages and delete them - virtual bool DeleteAllPages() { WX_CLEAR_ARRAY(m_pages); return true; } + virtual bool DeleteAllPages() + { + InvalidateBestSize(); + WX_CLEAR_ARRAY(m_pages); + return true; + } // adds a new page to the control virtual bool AddPage(wxWindow *page, @@ -133,6 +142,7 @@ public: bool bSelect = false, int imageId = -1) { + InvalidateBestSize(); return InsertPage(GetPageCount(), page, text, bSelect, imageId); } diff --git a/samples/notebook/notebook.cpp b/samples/notebook/notebook.cpp index 8e196ba498..5e0d05be50 100644 --- a/samples/notebook/notebook.cpp +++ b/samples/notebook/notebook.cpp @@ -390,11 +390,8 @@ void MyFrame::ReInitNotebook() m_notebook->AddPage(page, str, false, m_notebook->GetIconIndex() ); } - if (m_sizerNotebook) - { - m_sizerTop->Remove(m_sizerNotebook); - } - + m_sizerTop->Remove(notebook); + delete notebook; // restore selection @@ -406,8 +403,7 @@ void MyFrame::ReInitNotebook() } - m_sizerNotebook = new wxBookCtrlSizer(m_notebook); - m_sizerTop->Add(m_sizerNotebook, 1, wxEXPAND | wxALL, 4); + m_sizerTop->Add(m_notebook, 1, wxEXPAND | wxALL, 4); m_sizerTop->Layout(); } diff --git a/samples/notebook/notebook.h b/samples/notebook/notebook.h index c79f79f980..a503874494 100644 --- a/samples/notebook/notebook.h +++ b/samples/notebook/notebook.h @@ -130,9 +130,6 @@ private: // Sizer that contains the notebook and controls on the left wxBoxSizer *m_sizerTop; - // Sizer for m_notebook - wxBookCtrlSizer *m_sizerNotebook; - wxImageList *m_imageList; DECLARE_EVENT_TABLE() diff --git a/src/common/bookctrl.cpp b/src/common/bookctrl.cpp index bf8a833434..508befd1bc 100644 --- a/src/common/bookctrl.cpp +++ b/src/common/bookctrl.cpp @@ -151,7 +151,8 @@ wxBookCtrl::InsertPage(size_t nPage, _T("invalid page index in wxBookCtrl::InsertPage()") ); m_pages.Insert(page, nPage); - + InvalidateBestSize(); + return true; } @@ -173,6 +174,7 @@ wxWindow *wxBookCtrl::DoRemovePage(size_t nPage) wxWindow *pageRemoved = m_pages[nPage]; m_pages.RemoveAt(nPage); + InvalidateBestSize(); return pageRemoved; } diff --git a/src/generic/listbkg.cpp b/src/generic/listbkg.cpp index f0d5305697..c75120bd59 100644 --- a/src/generic/listbkg.cpp +++ b/src/generic/listbkg.cpp @@ -396,6 +396,7 @@ wxListbook::InsertPage(size_t n, page->Hide(); } + InvalidateBestSize(); return true; } diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index c65f67eb77..1e73e040c1 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -560,6 +560,7 @@ bool wxNotebook::DeleteAllPages() wxASSERT_MSG( GetPageCount() == 0, _T("all pages must have been deleted") ); + InvalidateBestSize(); return wxNotebookBase::DeleteAllPages(); } @@ -701,6 +702,7 @@ bool wxNotebook::InsertPage( size_t position, gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page", GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this ); + InvalidateBestSize(); return TRUE; } diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index c65f67eb77..1e73e040c1 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -560,6 +560,7 @@ bool wxNotebook::DeleteAllPages() wxASSERT_MSG( GetPageCount() == 0, _T("all pages must have been deleted") ); + InvalidateBestSize(); return wxNotebookBase::DeleteAllPages(); } @@ -701,6 +702,7 @@ bool wxNotebook::InsertPage( size_t position, gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page", GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this ); + InvalidateBestSize(); return TRUE; } diff --git a/src/mac/carbon/notebmac.cpp b/src/mac/carbon/notebmac.cpp index 4867e34272..182bbb7f10 100644 --- a/src/mac/carbon/notebmac.cpp +++ b/src/mac/carbon/notebmac.cpp @@ -279,6 +279,7 @@ wxNotebookPage* wxNotebook::DoRemovePage(size_t nPage) if(m_nSelection >= 0) { m_pages[m_nSelection]->Show(true); } + InvalidateBestSize(); return page; } @@ -288,6 +289,7 @@ bool wxNotebook::DeleteAllPages() WX_CLEAR_ARRAY(m_pages) ; MacSetupTabs(); m_nSelection = -1 ; + InvalidateBestSize(); return TRUE; } @@ -345,6 +347,7 @@ bool wxNotebook::InsertPage(size_t nPage, if ( selNew != -1 ) SetSelection(selNew); + InvalidateBestSize(); return true; } diff --git a/src/mac/classic/notebmac.cpp b/src/mac/classic/notebmac.cpp index 9aa4fdf5b9..fbc6c4a092 100644 --- a/src/mac/classic/notebmac.cpp +++ b/src/mac/classic/notebmac.cpp @@ -353,6 +353,7 @@ wxNotebookPage* wxNotebook::DoRemovePage(size_t nPage) if(m_nSelection >= 0) { m_pages[m_nSelection]->Show(true); } + InvalidateBestSize(); return page; } @@ -362,6 +363,7 @@ bool wxNotebook::DeleteAllPages() WX_CLEAR_ARRAY(m_pages) ; MacSetupTabs(); m_nSelection = -1 ; + InvalidateBestSize(); return TRUE; } @@ -419,6 +421,7 @@ bool wxNotebook::InsertPage(size_t nPage, if ( selNew != -1 ) SetSelection(selNew); + InvalidateBestSize(); return true; } diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 36e746e7c8..7e3bbcbd49 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -553,6 +553,7 @@ bool wxNotebook::DeleteAllPages() m_nSelection = -1; + InvalidateBestSize(); return true; } @@ -669,6 +670,7 @@ bool wxNotebook::InsertPage(size_t nPage, if ( selNew != -1 ) SetSelection(selNew); + InvalidateBestSize(); return true; } -- 2.45.2