a better fix for notebook page not being refreshed after Delete()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16561 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-08-16 22:57:04 +00:00
parent dba860d9e4
commit 43a997b6e2

View File

@@ -320,16 +320,36 @@ wxNotebookPage *wxNotebook::DoRemovePage(int nPage)
} }
else // notebook still not empty else // notebook still not empty
{ {
// refresh the selected page and change it if it became invalid // change the selected page if it was deleted or became invalid
int selNew;
if ( m_nSelection == GetPageCount() ) if ( m_nSelection == GetPageCount() )
{ {
m_nSelection--; // last page deleted, make the new last page the new selection
selNew = m_nSelection - 1;
}
else if ( nPage <= m_nSelection )
{
// we must show another page, even if it has the same index
selNew = m_nSelection;
}
else // nothing changes for the currently selected page
{
selNew = -1;
// we still must refresh the current page: this needs to be done
// for some unknown reason if the tab control shows the up-down
// control (i.e. when there are too many pages) -- otherwise after
// deleting a page nothing at all is shown
m_pages[m_nSelection]->Refresh();
} }
// force ChangePage() to really do something if ( selNew != -1 )
int sel = m_nSelection; {
// m_nSelection must be always valid so reset it before calling
// SetSelection()
m_nSelection = -1; m_nSelection = -1;
SetSelection(sel); SetSelection(selNew);
}
} }
return pageRemoved; return pageRemoved;