]> git.saurik.com Git - wxWidgets.git/commitdiff
Invalidate notebook best size when pages are added or removed
authorRobin Dunn <robin@alldunn.com>
Sat, 3 Jul 2004 15:49:29 +0000 (15:49 +0000)
committerRobin Dunn <robin@alldunn.com>
Sat, 3 Jul 2004 15:49:29 +0000 (15:49 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28154 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/bookctrl.h
samples/notebook/notebook.cpp
samples/notebook/notebook.h
src/common/bookctrl.cpp
src/generic/listbkg.cpp
src/gtk/notebook.cpp
src/gtk1/notebook.cpp
src/mac/carbon/notebmac.cpp
src/mac/classic/notebmac.cpp
src/msw/notebook.cpp

index c64224e8f8066c670aab6912c32c996b2e2f7e54..0f03436ae50acb39797404be7a51d37f9c75d233 100644 (file)
@@ -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);
     }
 
index 8e196ba498f4a27f7a5a99bd49b1e2aa56eabfe0..5e0d05be50a008448f98f213712704386554376a 100644 (file)
@@ -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();
 }
 
index c79f79f980e2f120ddc41ef87ab638d26d715a79..a503874494a05234cfdd666d047d8fec400a6c12 100644 (file)
@@ -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()
index bf8a83343440d814fcd28e01348a0eb7a880554d..508befd1bc48f0a04d56c52c9e109e68f0ef7b69 100644 (file)
@@ -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;
 }
index f0d53056976b41066f4b9a08bc1860336f91c414..c75120bd5951fe5eb2245567fadc5a4ee6183baf 100644 (file)
@@ -396,6 +396,7 @@ wxListbook::InsertPage(size_t n,
         page->Hide();
     }
 
+    InvalidateBestSize();
     return true;
 }
 
index c65f67eb77fcc11f558211bd8f5ce843154e008f..1e73e040c1994a5f671e2220f63ec5642652acf3 100644 (file)
@@ -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;
 }
 
index c65f67eb77fcc11f558211bd8f5ce843154e008f..1e73e040c1994a5f671e2220f63ec5642652acf3 100644 (file)
@@ -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;
 }
 
index 4867e34272abb377281da5907abe4d40c8f968c3..182bbb7f108ac968af7a7dcfa5c30576b78d6f80 100644 (file)
@@ -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;
 }
 
index 9aa4fdf5b96f001144107d8ee302e7826bfc7469..fbc6c4a0922659c49a48af908afeaa52d6c45337 100644 (file)
@@ -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;
 }
 
index 36e746e7c82141cccebd7fcd3fe94130c20a9e1e..7e3bbcbd498ab9f82c0ad9c6ca198d48b1139d64 100644 (file)
@@ -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;
 }