+ if (m_aPages.GetCount() == 0)
+ {
+ m_nSelection = -1;
+ m_tabView->SetTabSelection(-1, FALSE);
+ }
+ else if (m_nSelection > -1)
+ {
+ m_nSelection = -1;
+ m_tabView->SetTabSelection((int) (long) GetPage(0), FALSE);
+ if (m_nSelection != 0)
+ ChangePage(-1, 0);
+ }
+
+ RefreshLayout(FALSE);
+
+ return TRUE;
+}
+
+bool wxNotebook::DeletePage(wxNotebookPage* page)
+{
+ int pagePos = FindPagePosition(page);
+ if (pagePos > -1)
+ return DeletePage(pagePos);
+ else
+ return FALSE;
+}
+
+// remove one page from the notebook
+bool wxNotebook::RemovePage(int nPage)
+{
+ wxCHECK( IS_VALID_PAGE(nPage), FALSE );
+
+ m_aPages[nPage]->Show(FALSE);
+ // m_aPages[nPage]->Lower();
+
+ wxNotebookPage* pPage = GetPage(nPage);
+ m_tabView->RemoveTab((int) (long) pPage);
+
+ m_aPages.Remove(nPage);
+
+ if (m_aPages.GetCount() == 0)
+ {
+ m_nSelection = -1;
+ m_tabView->SetTabSelection(-1, TRUE);
+ }
+ else if (m_nSelection > -1)
+ {
+ // Only change the selection if the page we
+ // deleted was the selection.
+ if (nPage == m_nSelection)
+ {
+ m_nSelection = -1;
+ // Select the first tab. Generates a ChangePage.
+ m_tabView->SetTabSelection((int) (long) GetPage(0), TRUE);
+ }
+ else
+ {
+ // We must adjust which tab we think is selected.
+ // If greater than the page we deleted, it must be moved down
+ // a notch.
+ if (m_nSelection > nPage)
+ m_nSelection -- ;
+ }
+ }
+
+ RefreshLayout(FALSE);
+