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
This commit is contained in:
Robin Dunn 2004-07-03 15:49:29 +00:00
parent 5d91a08807
commit 37144cf0f1
10 changed files with 31 additions and 13 deletions

View 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);
}

View 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();
}

View 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()

View 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;
}

View File

@ -396,6 +396,7 @@ wxListbook::InsertPage(size_t n,
page->Hide();
}
InvalidateBestSize();
return true;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}