]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch [ 843287 ] wxNotebook remove page problems
authorJulian Smart <julian@anthemion.co.uk>
Thu, 11 Dec 2003 11:18:42 +0000 (11:18 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 11 Dec 2003 11:18:42 +0000 (11:18 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24763 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/notebook.cpp

index 094a91b3579eac49fcb9fe454b8b9e71f222ad40..7f4a3e3f17e58944607a4aee921bf0629775eb5d 100644 (file)
@@ -496,37 +496,35 @@ wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage)
     }
     else // notebook still not empty
     {
     }
     else // notebook still not empty
     {
-        // change the selected page if it was deleted or became invalid
-        int selNew;
-        if ( m_nSelection == int(GetPageCount()) )
+        int selNew = TabCtrl_GetCurSel(m_hwnd);
+        if (selNew != -1)
         {
         {
-            // last page deleted, make the new last page the new selection
-            selNew = m_nSelection - 1;
+            // No selection change, just refresh the current selection.
+            // Because it could be that the slection index changed 
+            // we need to update it. 
+            // Note: this does not mean the selection it self changed.
+            m_nSelection = selNew;
+            m_pages[m_nSelection]->Refresh();
         }
         }
-        else if ( int(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
-            if (m_nSelection >= 0)
-                m_pages[m_nSelection]->Refresh();
-        }
-
-        if ( selNew != -1 )
+        else if (int(nPage) == m_nSelection)
         {
         {
+            // The selection was deleted.
+            
+            // Determine new selection.
+            if (m_nSelection == int(GetPageCount()))
+                selNew = m_nSelection - 1;
+            else
+                selNew = m_nSelection;
+            
             // m_nSelection must be always valid so reset it before calling
             // SetSelection()
             m_nSelection = -1;
             SetSelection(selNew);
         }
             // m_nSelection must be always valid so reset it before calling
             // SetSelection()
             m_nSelection = -1;
             SetSelection(selNew);
         }
+        else
+        {
+            wxFAIL; // Windows did not behave ok.
+        }
     }
 
     return pageRemoved;
     }
 
     return pageRemoved;