]> git.saurik.com Git - wxWidgets.git/commitdiff
send more page change events (patch 750521); document this behaviour
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Jul 2003 21:40:59 +0000 (21:40 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Jul 2003 21:40:59 +0000 (21:40 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21720 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/univ/notebook.h
src/univ/notebook.cpp

index 3b3ef0c0c7be0da62871d58d5c8b4a08ee9a17fe..a8f78f0bb0f111a721a1962338e228cad0f4ca0d 100644 (file)
@@ -193,9 +193,6 @@ protected:
     // get our client size from the page size
     wxSize GetSizeForPage(const wxSize& size) const;
 
-    // change thep age and send events about it (can be vetoed by user code)
-    void ChangePage(int nPage);
-
     // scroll the tabs so that the first page shown becomes the given one
     void ScrollTo(int page);
 
index 84c4761c5ff5eba5fbb5cf7ba628cd83eaf08813..5865b1baf4bdbfd5a48797d29535cc95e21ec9f0 100644 (file)
@@ -212,6 +212,17 @@ int wxNotebook::SetSelection(int nPage)
         return m_sel;
     }
 
+    // event handling
+    wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
+    event.SetSelection(nPage);
+    event.SetOldSelection(m_sel);
+    event.SetEventObject(this);
+    if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() )
+    {
+        // program doesn't allow the page change
+        return m_sel;
+    }
+
     // we need to change m_sel first, before calling RefreshTab() below as
     // otherwise the previously selected tab wouldn't be redrawn properly under
     // wxGTK which calls Refresh() immediately and not during the next event
@@ -255,33 +266,11 @@ int wxNotebook::SetSelection(int nPage)
         m_pages[m_sel]->Show();
     }
 
-    return selOld;
-}
-
-void wxNotebook::ChangePage(int nPage)
-{
-    wxCHECK_RET( IS_VALID_PAGE(nPage), _T("invalid notebook page") );
-
-    if ( (size_t)nPage == m_sel )
-    {
-        // nothing to do
-        return;
-    }
-
-    wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
-    event.SetSelection(nPage);
-    event.SetOldSelection(m_sel);
-    event.SetEventObject(this);
-    if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() )
-    {
-        // program doesn't allow the page change
-        return;
-    }
-
-    SetSelection(nPage);
-
+    // event handling
     event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
     GetEventHandler()->ProcessEvent(event);
+
+    return selOld;
 }
 
 // ----------------------------------------------------------------------------
@@ -1303,11 +1292,11 @@ bool wxNotebook::PerformAction(const wxControlAction& action,
                                const wxString& strArg)
 {
     if ( action == wxACTION_NOTEBOOK_NEXT )
-        ChangePage(GetNextPage(TRUE));
+        SetSelection(GetNextPage(TRUE));
     else if ( action == wxACTION_NOTEBOOK_PREV )
-        ChangePage(GetNextPage(FALSE));
+        SetSelection(GetNextPage(FALSE));
     else if ( action == wxACTION_NOTEBOOK_GOTO )
-        ChangePage((int)numArg);
+        SetSelection((int)numArg);
     else
         return wxControl::PerformAction(action, numArg, strArg);