]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxBookCtrl::ChangeSelection() which is the same as SetSelection() but doesn...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 8 Oct 2006 17:37:23 +0000 (17:37 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 8 Oct 2006 17:37:23 +0000 (17:37 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41738 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

30 files changed:
docs/latex/wx/notebook.tex
docs/latex/wx/treebook.tex
include/wx/bookctrl.h
include/wx/choicebk.h
include/wx/cocoa/notebook.h
include/wx/generic/notebook.h
include/wx/gtk/notebook.h
include/wx/gtk1/notebook.h
include/wx/listbook.h
include/wx/mac/carbon/notebook.h
include/wx/msw/notebook.h
include/wx/os2/notebook.h
include/wx/palmos/notebook.h
include/wx/toolbook.h
include/wx/treebook.h
include/wx/univ/notebook.h
samples/notebook/notebook.cpp
samples/notebook/notebook.h
src/common/bookctrl.cpp
src/generic/choicbkg.cpp
src/generic/listbkg.cpp
src/generic/toolbkg.cpp
src/generic/treebkg.cpp
src/gtk/notebook.cpp
src/gtk1/notebook.cpp
src/mac/carbon/notebmac.cpp
src/msw/notebook.cpp
src/os2/notebook.cpp
src/palmos/notebook.cpp
src/univ/notebook.cpp

index 5b382764547ed0493a61d0f1530c2fe1506d7a3e..038be5568b608c6385de1a27667ca77bc05cafb1 100644 (file)
@@ -404,8 +404,21 @@ Sets the selection for the given page, returning the previous selection.
 
 The call to this function generates the page changing events.
 
+This function is deprecated and should not be used in new code. Please use the
+\helpref{ChangeSelection}{wxnotebookchangeselection} function instead.
+
 \wxheading{See also}
 
 \helpref{wxNotebook::GetSelection}{wxnotebookgetselection}
 
 
+
+\membersection{wxNotebook::ChangeSelection}\label{wxnotebookchangeselection}
+
+\func{int}{ChangeSelection}{\param{size\_t}{ page}}
+
+Changes the selection for the given page, returning the previous selection.
+
+The call to this function \emph{does not} generate the page changing events.
+This is the only difference with \helpref{SetSelection}{wxnotebooksetselection}.
+See \helpref{this topic}{progevent} for more info.
index 426c402e4d3c2a1e4dedf0363c551f8b3f6cc558..7541ba0245776d088dd3479f58d03ca16a991832 100644 (file)
@@ -271,7 +271,21 @@ Sets the selection for the given page, returning the previous selection.
 
 The call to this function generates the page changing events.
 
+This function is deprecated and should not be used in new code. Please use the
+\helpref{ChangeSelection}{wxtreebookchangeselection} function instead.
+
 \wxheading{See also}
 
 \helpref{wxTreebook::GetSelection}{wxtreebookgetselection}
 
+
+
+\membersection{wxTreebook::ChangeSelection}\label{wxtreebookchangeselection}
+
+\func{int}{ChangeSelection}{\param{size\_t}{ page}}
+
+Changes the selection for the given page, returning the previous selection.
+
+The call to this function \emph{does not} generate the page changing events.
+This is the only difference with \helpref{SetSelection}{wxtreebooksetselection}.
+See \helpref{this topic}{progevent} for more info.
index 2d5c4ad04ae2f1b32c02dbdf9110d151c076e806..85d769d71ae392e31ffec88662acb1cfbffe124f 100644 (file)
@@ -26,6 +26,7 @@
 WX_DEFINE_EXPORTED_ARRAY_PTR(wxWindow *, wxArrayPages);
 
 class WXDLLEXPORT wxImageList;
+class WXDLLEXPORT wxBookCtrlBaseEvent;
 
 // ----------------------------------------------------------------------------
 // constants
@@ -194,6 +195,9 @@ public:
     // NB: this function will generate PAGE_CHANGING/ED events
     virtual int SetSelection(size_t n) = 0;
 
+    // acts as SetSelection but does not generate events
+    virtual int ChangeSelection(size_t n) = 0;
+
 
     // cycle thru the pages
     void AdvanceSelection(bool forward = true)
@@ -218,6 +222,22 @@ public:
     virtual bool HasMultiplePages() const { return true; }
 
 protected:
+    // typically, wxBookCtrl-derived classes will use DoSetSelection() function
+    // to implement SetSelection() and ChangeSelection() functions.
+    // these flags make DoSetSelection() more readable
+    enum
+    {
+        SetSelection_SendEvent = 1
+    };
+
+    // if using DoSetSelection() for implementing [Set|Change]Selection,
+    // then override UpdateSelectedPage() and MakeChangedEvent()
+    virtual int DoSetSelection(size_t nPage, int flags, wxBookCtrlBaseEvent &event);
+    virtual void UpdateSelectedPage(size_t WXUNUSED(newsel))
+        { wxFAIL_MSG(wxT("Override this function!")); }
+    virtual void MakeChangedEvent(wxBookCtrlBaseEvent &WXUNUSED(event))
+        { wxFAIL_MSG(wxT("Override this function!")); }
+
     // Should we accept NULL page pointers in Add/InsertPage()?
     //
     // Default is no but derived classes may override it if they can treat NULL
index 6c215fc7645c10f27cbcd008e6d9fd77b261b09c..06a071c237598a74f11ba0edf616634aa89ed420 100644 (file)
 
 class WXDLLEXPORT wxChoice;
 
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
+
+
 // ----------------------------------------------------------------------------
 // wxChoicebook
 // ----------------------------------------------------------------------------
@@ -64,7 +68,8 @@ public:
                             const wxString& text,
                             bool bSelect = false,
                             int imageId = -1);
-    virtual int SetSelection(size_t n);
+    virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
+    virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
     virtual void SetImageList(wxImageList *imageList);
 
     virtual bool DeleteAllPages();
@@ -78,6 +83,19 @@ protected:
     // get the size which the choice control should have
     virtual wxSize GetControllerSize() const;
 
+    int DoSetSelection(size_t nPage, int flags = 0);
+
+    void UpdateSelectedPage(size_t newsel)
+    {
+        m_selection = newsel;
+        GetChoiceCtrl()->Select(newsel);
+    }
+
+    void MakeChangedEvent(wxBookCtrlBaseEvent &event)
+    {
+        event.SetEventType(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED);
+    }
+
     // event handlers
     void OnChoiceSelected(wxCommandEvent& event);
 
@@ -116,9 +134,6 @@ private:
     DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxChoicebookEvent)
 };
 
-extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
-extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
-
 typedef void (wxEvtHandler::*wxChoicebookEventFunction)(wxChoicebookEvent&);
 
 #define wxChoicebookEventHandler(func) \
index 5ba76c2d38f62d68dce3df97be426567257ff071..97cfd33c4ce11e4144a0f4ecad863dcee6ddb29f 100644 (file)
@@ -62,6 +62,9 @@ public:
     // get the currently selected page
     int GetSelection() const;
 
+    // changes selected page without sending events
+    int ChangeSelection(size_t nPage);
+
     // set/get the title of a page
     bool SetPageText(size_t nPage, const wxString& strText);
     wxString GetPageText(size_t nPage) const;
index 691392929878269fbc77bf9e33750c9fb5053b88..116286eb1ed33b18399af991235fe72d5f3b2737 100644 (file)
@@ -68,6 +68,9 @@ public:
     // get the currently selected page
   int GetSelection() const { return m_nSelection; }
 
+    // changes selected page without sending events
+  int ChangeSelection(size_t nPage);
+
     // set/get the title of a page
   bool SetPageText(size_t nPage, const wxString& strText);
   wxString GetPageText(size_t nPage) const;
index 8965c2d2f6f1581fb8b38327f69edc3285e51559..d58bbdf345a817ee7111fafc342b4984b99291a3 100644 (file)
@@ -52,10 +52,13 @@ public:
     // set the currently selected page, return the index of the previously
     // selected one (or -1 on error)
     // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
-  int SetSelection(size_t nPage);
+    int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
     // get the currently selected page
   int GetSelection() const;
 
+  // changes selected page without sending events
+  int ChangeSelection(size_t nPage) { return DoSetSelection(nPage); }
+
     // set/get the title of a page
   bool SetPageText(size_t nPage, const wxString& strText);
   wxString GetPageText(size_t nPage) const;
@@ -120,6 +123,9 @@ public:
     // flag set to true while we're inside "switch_page" callback
     bool m_inSwitchPage;
 
+    // flag set to true when the switch-page signal has been programatically generated
+    bool m_skipNextPageChangeEvent;
+
 protected:
     // set all page's attributes
     virtual void DoApplyWidgetStyle(GtkRcStyle *style);
@@ -128,6 +134,8 @@ protected:
     // remove one page from the notebook but do not destroy it
     virtual wxNotebookPage *DoRemovePage(size_t nPage);
 
+    int DoSetSelection(size_t nPage, int flags = 0);
+
 private:
     // the padding set by SetPadding()
     int m_padding;
index 27eccbbe23c8b5e012c9af44b7579ecd5617bd2d..9acd18e4603a17c5a9429b67396af3448232e5e2 100644 (file)
@@ -52,9 +52,12 @@ public:
     // set the currently selected page, return the index of the previously
     // selected one (or -1 on error)
     // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
-  int SetSelection(size_t nPage);
+    int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
     // get the currently selected page
-  int GetSelection() const;
+    int GetSelection() const;
+
+    // changes selected page without sending events
+    int ChangeSelection(size_t nPage) { return DoSetSelection(nPage); }
 
     // set/get the title of a page
   bool SetPageText(size_t nPage, const wxString& strText);
@@ -126,10 +129,15 @@ public:
     // flag set to true while we're inside "switch_page" callback
     bool m_inSwitchPage;
 
+    // flag set to true when the switch-page signal has been programatically generated
+    bool m_skipNextPageChangeEvent;
+
 protected:
     // remove one page from the notebook but do not destroy it
     virtual wxNotebookPage *DoRemovePage(size_t nPage);
 
+    int DoSetSelection(size_t nPage, int flags = 0);
+
 private:
     // the padding set by SetPadding()
     int m_padding;
index b8022730f76c444daa5aa6f39cb6bbd9771489a5..b62da59d47ebe748eb41808172ccd529f22cd83b 100644 (file)
@@ -21,6 +21,9 @@
 class WXDLLEXPORT wxListView;
 class WXDLLEXPORT wxListEvent;
 
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
+
 // ----------------------------------------------------------------------------
 // wxListbook
 // ----------------------------------------------------------------------------
@@ -65,7 +68,8 @@ public:
                             const wxString& text,
                             bool bSelect = false,
                             int imageId = -1);
-    virtual int SetSelection(size_t n);
+    virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
+    virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
     virtual void SetImageList(wxImageList *imageList);
 
     virtual bool DeleteAllPages();
@@ -81,6 +85,15 @@ protected:
     // return the page corresponding to the tab at the specified position
     virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
 
+    int DoSetSelection(size_t nPage, int flags = 0);
+
+    void UpdateSelectedPage(size_t newsel);
+
+    void MakeChangedEvent(wxBookCtrlBaseEvent &event)
+    {
+        event.SetEventType(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED);
+    }
+
     // event handlers
     void OnListSelected(wxListEvent& event);
     void OnSize(wxSizeEvent& event);
@@ -120,9 +133,6 @@ private:
     DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxListbookEvent)
 };
 
-extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
-extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
-
 typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&);
 
 #define wxListbookEventHandler(func) \
index 299b438dbee6292a8be1fc9cc4bf18eafdceff4e..859bbc9beefaf50117c86dff615d8e0c4f55ce49 100644 (file)
@@ -57,10 +57,13 @@ public:
     // set the currently selected page, return the index of the previously
     // selected one (or -1 on error)
     // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
-  int SetSelection(size_t nPage);
+  int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
     // get the currently selected page
   int GetSelection() const { return m_nSelection; }
 
+    // changes selected page without sending events
+  int ChangeSelection(size_t nPage) { return DoSetSelection(nPage); }
+
     // set/get the title of a page
   bool SetPageText(size_t nPage, const wxString& strText);
   wxString GetPageText(size_t nPage) const;
@@ -125,6 +128,8 @@ protected:
   void ChangePage(int nOldSel, int nSel); // change pages
   void MacSetupTabs();
 
+  int DoSetSelection(size_t nPage, int flags = 0);
+
   // the icon indices
   wxArrayInt m_images;
 
index 2075b5fe62daf52222daecab016d6aae44d418ed..0b99f664d5db93e90c328489ab7fd41de9339c79 100644 (file)
@@ -92,6 +92,9 @@ public:
     // get the currently selected page
   int GetSelection() const { return m_nSelection; }
 
+    // changes selected page without sending events
+  int ChangeSelection(size_t nPage);
+
     // set/get the title of a page
   bool SetPageText(size_t nPage, const wxString& strText);
   wxString GetPageText(size_t nPage) const;
@@ -193,6 +196,9 @@ protected:
   // common part of all ctors
   void Init();
 
+  // hides m_nSelection-th page, shows the newsel-th one and updates m_nSelection
+  void UpdateSelection(size_t newsel);
+
   // remove one page from the notebook, without deleting
   virtual wxNotebookPage *DoRemovePage(size_t nPage);
 
index 30a3a810312a7f3415f97070f156a997206e8003..af22bc4b54fb96a71ebf4179441e7cbb0914c7e5 100644 (file)
@@ -66,6 +66,9 @@ public:
     //
     int      SetSelection(size_t nPage);
 
+    // changes selected page without sending events
+    int ChangeSelection(size_t nPage);
+
     //
     // Get the currently selected page
     //
index b06f9552f68f061d9189a1888ba158b2ba007644..f4ef524cda0bfd9530b3aa52933e0178c87b7870 100644 (file)
@@ -87,6 +87,9 @@ public:
     // get the currently selected page
     int GetSelection() const { return m_nSelection; }
 
+    // changes the selected page without sending events
+    int ChangeSelection(size_t nPage);
+
     // set/get the title of a page
     bool SetPageText(size_t nPage, const wxString& strText);
     wxString GetPageText(size_t nPage) const;
index 1227d824837951435af12105a4597bc7ae58f1c5..097ccff314d525c43766af71c48e5e0821244d39 100644 (file)
 class WXDLLEXPORT wxToolBarBase;
 class WXDLLEXPORT wxCommandEvent;
 
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED;
+extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING;
+
+
 // Use wxButtonToolBar
 #define wxBK_BUTTONBAR            0x0100
 
@@ -69,7 +73,8 @@ public:
                             const wxString& text,
                             bool bSelect = false,
                             int imageId = -1);
-    virtual int SetSelection(size_t n);
+    virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
+    virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
     virtual void SetImageList(wxImageList *imageList);
 
     virtual bool DeleteAllPages();
@@ -96,6 +101,19 @@ protected:
     void OnSize(wxSizeEvent& event);
     void OnIdle(wxIdleEvent& event);
 
+    int DoSetSelection(size_t nPage, int flags = 0);
+
+    void UpdateSelectedPage(size_t newsel)
+    {
+        m_selection = newsel;
+        GetToolBar()->ToggleTool(newsel + 1, true);
+    }
+
+    void MakeChangedEvent(wxBookCtrlBaseEvent &event)
+    {
+        event.SetEventType(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED);
+    }
+
     // the currently selected page or wxNOT_FOUND if none
     int m_selection;
 
@@ -137,9 +155,6 @@ private:
     DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxToolbookEvent)
 };
 
-extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED;
-extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING;
-
 typedef void (wxEvtHandler::*wxToolbookEventFunction)(wxToolbookEvent&);
 
 #define wxToolbookEventHandler(func) \
index 578ec3ade3a36eb126b735c9ce8ac1b74a3d1971..5334073d4403454d6e18c30759c4366030835eda 100644 (file)
@@ -133,7 +133,8 @@ public:
     virtual int GetPageImage(size_t n) const;
     virtual bool SetPageImage(size_t n, int imageId);
     virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
-    virtual int SetSelection(size_t n);
+    virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
+    virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
     virtual void SetImageList(wxImageList *imageList);
     virtual void AssignImageList(wxImageList *imageList);
     virtual bool DeleteAllPages();
@@ -188,7 +189,7 @@ private:
                          int imageId = wxNOT_FOUND);
 
     // Sets selection in the tree control and updates the page being shown.
-    int DoSetSelection(size_t pos);
+    int DoSetSelection(size_t pos, int flags = 0);
 
     // Returns currently shown page. In a case when selected the node
     // has empty (NULL) page finds first (sub)child with not-empty page.
index c87ad704fbe427636566c849741831167a0fe769..44befbf909fa97960f8093849f4a8797e11d39c7 100644 (file)
@@ -63,9 +63,12 @@ public:
     // implement wxNotebookBase pure virtuals
     // --------------------------------------
 
-    virtual int SetSelection(size_t nPage);
+    virtual int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
     virtual int GetSelection() const { return (int) m_sel; }
 
+    // changes selected page without sending events
+    int ChangeSelection(size_t nPage) { return DoSetSelection(nPage); }
+
     virtual bool SetPageText(size_t nPage, const wxString& strText);
     virtual wxString GetPageText(size_t nPage) const;
 
@@ -134,6 +137,8 @@ protected:
                            int width, int height,
                            int sizeFlags = wxSIZE_AUTO);
 
+    int DoSetSelection(size_t nPage, int flags = 0);
+
     // common part of all ctors
     void Init();
 
index 4149cd884a6ef085027e13acf8ac31f24bcf4514..4e5737b60f557db03ede25d028e97930b6d82fbb 100644 (file)
@@ -265,6 +265,8 @@ MyFrame::MyFrame()
     menuPageOperations->Append(ID_ADD_PAGE_BEFORE, wxT("Insert page &before\tAlt-B"));
     menuPageOperations->Append(ID_ADD_SUB_PAGE, wxT("Add s&ub page\tAlt-U"));
 #endif
+    menuPageOperations->AppendSeparator();
+    menuPageOperations->Append(ID_GO_HOME, wxT("Go to the first page\tCtrl-F"));
 
     wxMenu *menuOperations = new wxMenu;
 #if wxUSE_HELP
@@ -517,6 +519,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_MENU(ID_DELETE_CUR_PAGE, MyFrame::OnDeleteCurPage)
     EVT_MENU(ID_DELETE_LAST_PAGE, MyFrame::OnDeleteLastPage)
     EVT_MENU(ID_NEXT_PAGE, MyFrame::OnNextPage)
+    EVT_MENU(ID_GO_HOME, MyFrame::OnGoHome)
 
 #if wxUSE_HELP
     EVT_MENU(ID_CONTEXT_HELP, MyFrame::OnContextHelp)
@@ -788,6 +791,18 @@ void MyFrame::OnNextPage(wxCommandEvent& WXUNUSED(event))
     }
 }
 
+void MyFrame::OnGoHome(wxCommandEvent& WXUNUSED(event))
+{
+    wxBookCtrlBase *currBook = GetCurrentBook();
+
+    if ( currBook )
+    {
+        // ChangeSelection shouldn't send any events, SetSelection() should
+        currBook->ChangeSelection(0);
+        //currBook->SetSelection(0);
+    }
+}
+
 void MyFrame::OnIdle( wxIdleEvent& WXUNUSED(event) )
 {
     static int s_nPages = wxNOT_FOUND;
index 68b732e7b4db6251b7dde612f8e9a2b917c75c65..41d44068c868c27777c403f6c5ec43ba80634d05 100644 (file)
@@ -48,6 +48,7 @@ public:
     void OnDeleteCurPage(wxCommandEvent& event);
     void OnDeleteLastPage(wxCommandEvent& event);
     void OnNextPage(wxCommandEvent& event);
+    void OnGoHome(wxCommandEvent &event);
 
     void OnAddSubPage(wxCommandEvent& event);
     void OnAddPageBefore(wxCommandEvent& event);
@@ -147,6 +148,7 @@ enum ID_COMMANDS
     ID_NEXT_PAGE,
     ID_ADD_PAGE_BEFORE,
     ID_ADD_SUB_PAGE,
+    ID_GO_HOME,
 
 #if wxUSE_HELP
     ID_CONTEXT_HELP,
index ffae3d708da7c67332915c8397b6fb52c422a9ff..d194cc20a9ccee7da88a2fd2b711b5fa8d4f9113 100644 (file)
@@ -423,4 +423,49 @@ wxSize wxBookCtrlBase::GetControllerSize() const
     return size;
 }
 
+int wxBookCtrlBase::DoSetSelection(size_t n, int flags, wxBookCtrlBaseEvent &event)
+{
+    wxCHECK_MSG( n < GetPageCount(), wxNOT_FOUND,
+                 wxT("invalid page index in wxBookCtrlBase::DoSetSelection()") );
+
+    const int oldSel = GetSelection();
+
+    if ( oldSel != wxNOT_FOUND && n != (size_t)oldSel )
+    {
+        bool allowed = false;
+
+        if ( flags & SetSelection_SendEvent )
+        {
+            event.SetSelection(n);
+            event.SetOldSelection(oldSel);
+            event.SetEventObject(this);
+
+            allowed = !GetEventHandler()->ProcessEvent(event) || event.IsAllowed();
+        }
+
+        if ( !(flags & SetSelection_SendEvent) || allowed)
+        {
+            if ( oldSel != wxNOT_FOUND )
+                m_pages[oldSel]->Hide();
+
+            wxWindow *page = m_pages[n];
+            page->SetSize(GetPageRect());
+            page->Show();
+
+            // change selection now to ignore the selection change event
+            UpdateSelectedPage(n);
+
+            if ( flags & SetSelection_SendEvent )
+            {
+                // program allows the page change
+                MakeChangedEvent(event);
+                (void)GetEventHandler()->ProcessEvent(event);
+            }
+        }
+    }
+
+    return oldSel;
+}
+
+
 #endif // wxUSE_BOOKCTRL
index 445d0f575ae443b171ac1c283a55bc775fba098c..d74d0b575fc218ce485d1bfe802c4c27d02e7b72 100644 (file)
@@ -209,39 +209,10 @@ int wxChoicebook::GetSelection() const
     return m_selection;
 }
 
-int wxChoicebook::SetSelection(size_t n)
+int wxChoicebook::DoSetSelection(size_t n, int flags)
 {
-    wxCHECK_MSG( IS_VALID_PAGE(n), wxNOT_FOUND,
-                 wxT("invalid page index in wxChoicebook::SetSelection()") );
-
-    const int oldSel = m_selection;
-
-    if ( int(n) != m_selection )
-    {
-        wxChoicebookEvent event(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, m_windowId);
-        event.SetSelection(n);
-        event.SetOldSelection(m_selection);
-        event.SetEventObject(this);
-        if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
-        {
-            if ( m_selection != wxNOT_FOUND )
-                m_pages[m_selection]->Hide();
-
-            wxWindow *page = m_pages[n];
-            page->SetSize(GetPageRect());
-            page->Show();
-
-            // change m_selection now to ignore the selection change event
-            m_selection = n;
-            GetChoiceCtrl()->Select(n);
-
-            // program allows the page change
-            event.SetEventType(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED);
-            (void)GetEventHandler()->ProcessEvent(event);
-        }
-    }
-
-    return oldSel;
+    wxChoicebookEvent event(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, m_windowId);
+    return wxBookCtrlBase::DoSetSelection(n, flags, event);
 }
 
 // ----------------------------------------------------------------------------
index b21319248af1c8f24cc9b5311e9696a893e56460..9f725353c00dd7678be1182b8e62b7473654255a 100644 (file)
@@ -262,45 +262,22 @@ void wxListbook::SetImageList(wxImageList *imageList)
 // selection
 // ----------------------------------------------------------------------------
 
+void wxListbook::UpdateSelectedPage(size_t newsel)
+{
+    m_selection = newsel;
+    GetListView()->Select(newsel);
+    GetListView()->Focus(newsel);
+}
+
 int wxListbook::GetSelection() const
 {
     return m_selection;
 }
 
-int wxListbook::SetSelection(size_t n)
+int wxListbook::DoSetSelection(size_t n, int flags)
 {
-    wxCHECK_MSG( IS_VALID_PAGE(n), wxNOT_FOUND,
-                 wxT("invalid page index in wxListbook::SetSelection()") );
-
-    const int oldSel = m_selection;
-
-    if ( int(n) != m_selection )
-    {
-        wxListbookEvent event(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, m_windowId);
-        event.SetSelection(n);
-        event.SetOldSelection(m_selection);
-        event.SetEventObject(this);
-        if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
-        {
-            if ( m_selection != wxNOT_FOUND )
-                m_pages[m_selection]->Hide();
-
-            wxWindow *page = m_pages[n];
-            page->SetSize(GetPageRect());
-            page->Show();
-
-            // change m_selection now to ignore the selection change event
-            m_selection = n;
-            GetListView()->Select(n);
-            GetListView()->Focus(n);
-
-            // program allows the page change
-            event.SetEventType(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED);
-            (void)GetEventHandler()->ProcessEvent(event);
-        }
-    }
-
-    return oldSel;
+    wxListbookEvent event(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, m_windowId);
+    return wxBookCtrlBase::DoSetSelection(n, flags, event);
 }
 
 // ----------------------------------------------------------------------------
index f85a27462b292f95280132d4fade61b5d15aa972..fbfbd0b0bc1a04c237e3e1ddedf8c499c4af2498 100644 (file)
@@ -245,39 +245,10 @@ int wxToolbook::GetSelection() const
     return m_selection;
 }
 
-int wxToolbook::SetSelection(size_t n)
+int wxToolbook::DoSetSelection(size_t n, int flags)
 {
-    wxCHECK_MSG( IS_VALID_PAGE(n), wxNOT_FOUND,
-                 wxT("invalid page index in wxToolbook::SetSelection()") );
-
-    const int oldSel = m_selection;
-
-    if ( int(n) != m_selection )
-    {
-        wxToolbookEvent event(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, m_windowId);
-        event.SetSelection(n);
-        event.SetOldSelection(m_selection);
-        event.SetEventObject(this);
-        if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
-        {
-            if ( m_selection != wxNOT_FOUND )
-                m_pages[m_selection]->Hide();
-
-            wxWindow *page = m_pages[n];
-            page->SetSize(GetPageRect());
-            page->Show();
-
-            // change m_selection now to ignore the selection change event
-            m_selection = n;
-            GetToolBar()->ToggleTool(n + 1, true);
-
-            // program allows the page change
-            event.SetEventType(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED);
-            (void)GetEventHandler()->ProcessEvent(event);
-        }
-    }
-
-    return oldSel;
+    wxToolbookEvent event(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, m_windowId);
+    return wxBookCtrlBase::DoSetSelection(n, flags, event);
 }
 
 // Not part of the wxBookctrl API, but must be called in OnIdle or
index 2bcb1da8dd2e683d1bc44468a26a39f34788456c..8f34b7ef4d762fd339f1f255b79567e8c1fa101b 100644 (file)
@@ -432,7 +432,9 @@ void wxTreebook::DoInternalRemovePageRange(size_t pagePos, size_t subCount)
             // actually shown page (the first (sub)child with page != NULL) is
             // already deleted
             m_actualSelection = m_selection;
-            DoSetSelection(m_selection);
+
+            // send event as documented
+            DoSetSelection(m_selection, SetSelection_SendEvent);
         }
         //else: nothing to do -- selection is before the deleted node
     }
@@ -583,34 +585,32 @@ int wxTreebook::GetSelection() const
    return m_selection;
 }
 
-int wxTreebook::SetSelection(size_t pagePos)
-{
-   if ( (size_t)m_selection != pagePos )
-       return DoSetSelection(pagePos);
-
-   return m_selection;
-}
-
-int wxTreebook::DoSetSelection(size_t pagePos)
+int wxTreebook::DoSetSelection(size_t pagePos, int flags)
 {
     wxCHECK_MSG( IS_VALID_PAGE(pagePos), wxNOT_FOUND,
-                 wxT("invalid page index in wxListbook::SetSelection()") );
+                 wxT("invalid page index in wxListbook::DoSetSelection()") );
     wxASSERT_MSG( GetPageCount() == DoInternalGetPageCount(),
                   wxT("wxTreebook logic error: m_treeIds and m_pages not in sync!"));
 
+    wxTreebookEvent event(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, m_windowId);
     const int oldSel = m_selection;
     wxTreeCtrl *tree = GetTreeCtrl();
+    bool allowed = false;
 
-    wxTreebookEvent event(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, m_windowId);
-    event.SetEventObject(this);
-    event.SetSelection(pagePos);
-    event.SetOldSelection(m_selection);
-
-    // don't send the event if the old and new pages are the same; do send it
-    // otherwise and be prepared for it to be vetoed
-    if ( (int)pagePos == m_selection ||
-            !GetEventHandler()->ProcessEvent(event) ||
-                event.IsAllowed() )
+    if (flags & SetSelection_SendEvent)
+    {
+        event.SetEventObject(this);
+        event.SetSelection(pagePos);
+        event.SetOldSelection(m_selection);
+
+        // don't send the event if the old and new pages are the same; do send it
+        // otherwise and be prepared for it to be vetoed
+        allowed = (int)pagePos == m_selection ||
+                  !GetEventHandler()->ProcessEvent(event) ||
+                  event.IsAllowed();
+    }
+
+    if ( !(flags & SetSelection_SendEvent) || allowed )
     {
         // hide the previously shown page
         wxTreebookPage * const oldPage = DoGetCurrentPage();
@@ -644,11 +644,14 @@ int wxTreebook::DoSetSelection(size_t pagePos)
 
         tree->SelectItem(DoInternalGetPage(pagePos));
 
-        // notify about the (now completed) page change
-        event.SetEventType(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED);
-        (void)GetEventHandler()->ProcessEvent(event);
+        if (flags & SetSelection_SendEvent)
+        {
+            // notify about the (now completed) page change
+            event.SetEventType(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED);
+            (void)GetEventHandler()->ProcessEvent(event);
+        }
     }
-    else // page change vetoed
+    else if ( (flags & SetSelection_SendEvent) && !allowed) // page change vetoed
     {
         // tree selection might have already had changed
         if ( oldSel != wxNOT_FOUND )
index 9c4b4a3932ff9a185f19c4c85cfc05f849c2eed1..27105979a5abb27b6f0be173151585269bf84fa9 100644 (file)
@@ -104,28 +104,43 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
 
     int old = notebook->GetSelection();
 
-    wxNotebookEvent eventChanging( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING,
-                                   notebook->GetId(), page, old );
-    eventChanging.SetEventObject( notebook );
 
-    if ( (notebook->GetEventHandler()->ProcessEvent(eventChanging)) &&
-         !eventChanging.IsAllowed() )
-    {
-        /* program doesn't allow the page change */
-        g_signal_stop_emission_by_name (notebook->m_widget,
-                                        "switch_page");
-    }
-    else // change allowed
+    if (notebook->m_skipNextPageChangeEvent)
     {
+        // this event was programatically generated by ChangeSelection() and thus must
+        // be skipped
+        notebook->m_skipNextPageChangeEvent = false;
+
         // make wxNotebook::GetSelection() return the correct (i.e. consistent
         // with wxNotebookEvent::GetSelection()) value even though the page is
         // not really changed in GTK+
         notebook->m_selection = page;
+    }
+    else
+    {
+        wxNotebookEvent eventChanging( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING,
+                                    notebook->GetId(), page, old );
+        eventChanging.SetEventObject( notebook );
 
-        wxNotebookEvent eventChanged( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
-                                      notebook->GetId(), page, old );
-        eventChanged.SetEventObject( notebook );
-        notebook->GetEventHandler()->ProcessEvent( eventChanged );
+        if ( (notebook->GetEventHandler()->ProcessEvent(eventChanging)) &&
+            !eventChanging.IsAllowed() )
+        {
+            /* program doesn't allow the page change */
+            g_signal_stop_emission_by_name (notebook->m_widget,
+                                            "switch_page");
+        }
+        else // change allowed
+        {
+            // make wxNotebook::GetSelection() return the correct (i.e. consistent
+            // with wxNotebookEvent::GetSelection()) value even though the page is
+            // not really changed in GTK+
+            notebook->m_selection = page;
+
+            wxNotebookEvent eventChanged( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
+                                        notebook->GetId(), page, old );
+            eventChanged.SetEventObject( notebook );
+            notebook->GetEventHandler()->ProcessEvent( eventChanged );
+        }
     }
 
     notebook->m_inSwitchPage = false;
@@ -289,6 +304,7 @@ void wxNotebook::Init()
 {
     m_padding = 0;
     m_inSwitchPage = false;
+    m_skipNextPageChangeEvent = false;
 
     m_imageList = (wxImageList *) NULL;
     m_selection = -1;
@@ -414,7 +430,7 @@ wxGtkNotebookPage* wxNotebook::GetNotebookPage( int page ) const
     return m_pagesData.Item(page)->GetData();
 }
 
-int wxNotebook::SetSelection( size_t page )
+int wxNotebook::DoSetSelection( size_t page, int flags )
 {
     wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
 
@@ -422,10 +438,23 @@ int wxNotebook::SetSelection( size_t page )
 
     int selOld = GetSelection();
 
+    if ( !(flags & SetSelection_SendEvent) )
+        m_skipNextPageChangeEvent = true;
+
     // cache the selection
     m_selection = page;
     gtk_notebook_set_current_page( GTK_NOTEBOOK(m_widget), page );
 
+#ifdef __WXDEBUG__
+    if ( !(flags & SetSelection_SendEvent) )
+    {
+        // gtk_notebook_set_current_page will emit the switch-page signal which will be
+        // caught by our gtk_notebook_page_change_callback which should have reset the
+        // flag to false:
+        wxASSERT(!m_skipNextPageChangeEvent);
+    }
+#endif // __WXDEBUG__
+
     wxNotebookPage *client = GetPage(page);
     if ( client )
         client->SetFocus();
index ffa2e2a428bf8a16929db78aed1438a7af6ab6d4..7c51c6d91bbeeaa655bb08b9baa8d64a8c5665b7 100644 (file)
@@ -105,28 +105,42 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
 
     int old = notebook->GetSelection();
 
-    wxNotebookEvent eventChanging( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING,
-                                   notebook->GetId(), page, old );
-    eventChanging.SetEventObject( notebook );
-
-    if ( (notebook->GetEventHandler()->ProcessEvent(eventChanging)) &&
-         !eventChanging.IsAllowed() )
-    {
-        /* program doesn't allow the page change */
-        gtk_signal_emit_stop_by_name( GTK_OBJECT(notebook->m_widget),
-                                      "switch_page" );
-    }
-    else // change allowed
+    if (notebook->m_skipNextPageChangeEvent)
     {
+        // this event was programatically generated by ChangeSelection() and thus must
+        // be skipped
+        notebook->m_skipNextPageChangeEvent = false;
+
         // make wxNotebook::GetSelection() return the correct (i.e. consistent
         // with wxNotebookEvent::GetSelection()) value even though the page is
         // not really changed in GTK+
         notebook->m_selection = page;
+    }
+    else
+    {
+        wxNotebookEvent eventChanging( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING,
+                                       notebook->GetId(), page, old );
+        eventChanging.SetEventObject( notebook );
 
-        wxNotebookEvent eventChanged( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
-                                      notebook->GetId(), page, old );
-        eventChanged.SetEventObject( notebook );
-        notebook->GetEventHandler()->ProcessEvent( eventChanged );
+        if ( (notebook->GetEventHandler()->ProcessEvent(eventChanging)) &&
+              !eventChanging.IsAllowed() )
+        {
+            /* program doesn't allow the page change */
+            g_signal_stop_emission_by_name (notebook->m_widget,
+                                            "switch_page");
+        }
+        else // change allowed
+        {
+            // make wxNotebook::GetSelection() return the correct (i.e. consistent
+            // with wxNotebookEvent::GetSelection()) value even though the page is
+            // not really changed in GTK+
+            notebook->m_selection = page;
+
+            wxNotebookEvent eventChanged( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
+                                          notebook->GetId(), page, old );
+            eventChanged.SetEventObject( notebook );
+            notebook->GetEventHandler()->ProcessEvent( eventChanged );
+        }
     }
 
     notebook->m_inSwitchPage = FALSE;
@@ -417,7 +431,7 @@ wxGtkNotebookPage* wxNotebook::GetNotebookPage( int page ) const
     return m_pagesData.Item(page)->GetData();
 }
 
-int wxNotebook::SetSelection( size_t page )
+int wxNotebook::DoSetSelection( size_t page, int flags )
 {
     wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
 
@@ -425,10 +439,23 @@ int wxNotebook::SetSelection( size_t page )
 
     int selOld = GetSelection();
 
+    if ( !(flags & SetSelection_SendEvent) )
+        m_skipNextPageChangeEvent = true;
+
     // cache the selection
     m_selection = page;
     gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), page );
 
+#ifdef __WXDEBUG__
+    if ( !(flags & SetSelection_SendEvent) )
+    {
+            // gtk_notebook_set_current_page will emit the switch-page signal which will be
+            // caught by our gtk_notebook_page_change_callback which should have reset the
+            // flag to false:
+        wxASSERT(!m_skipNextPageChangeEvent);
+    }
+#endif // __WXDEBUG__
+
     wxNotebookPage *client = GetPage(page);
     if ( client )
         client->SetFocus();
index 414bc978f95366947ab30371d039c703e670ad7e..9d90682bc0e0edda80008210f817d75217da8110 100644 (file)
@@ -160,25 +160,27 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
     return DoGetSizeFromClientSize( sizePage );
 }
 
-int wxNotebook::SetSelection(size_t nPage)
+int wxNotebook::DoSetSelection(size_t nPage, int flags = 0)
 {
-    wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("SetSelection: invalid notebook page") );
+    wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("DoSetSelection: invalid notebook page") );
 
     if ( int(nPage) != m_nSelection )
     {
-        wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
-        event.SetSelection(nPage);
-        event.SetOldSelection(m_nSelection);
-        event.SetEventObject(this);
-        if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
+        if (flags & SetSelection_SendEvent)
         {
-            // program allows the page change
-            event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
-            (void)GetEventHandler()->ProcessEvent(event);
+            wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
+            event.SetSelection(nPage);
+            event.SetOldSelection(m_nSelection);
+            event.SetEventObject(this);
+            if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
+            {
+                // program allows the page change
+                event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
+                (void)GetEventHandler()->ProcessEvent(event);
 
-            ChangePage(m_nSelection, nPage);
+                ChangePage(m_nSelection, nPage);
+            }
         }
-    }
 
     return m_nSelection;
 }
@@ -226,6 +228,11 @@ bool wxNotebook::SetPageImage(size_t nPage, int nImage)
 
         MacSetupTabs() ;
     }
+        else
+        {
+            ChangePage(m_nSelection, nPage);
+        }
+    }
 
     return true;
 }
index cd19ed2b0d0e419e9282cab664a5899257498d8a..1efd29f383ef3da22ece0dde65d8e3d37fa8f166 100644 (file)
@@ -462,6 +462,44 @@ int wxNotebook::SetSelection(size_t nPage)
     return m_nSelection;
 }
 
+void wxNotebook::UpdateSelection(size_t newsel)
+{
+    if ( m_nSelection != -1 )
+        m_pages[m_nSelection]->Show(false);
+
+    if ( newsel != -1 )
+    {
+        wxNotebookPage *pPage = m_pages[newsel];
+        pPage->Show(true);
+    }
+
+    // Changing the page should give the focus to it but, as per bug report
+    // http://sf.net/tracker/index.php?func=detail&aid=1150659&group_id=9863&atid=109863,
+    // we should not set the focus to it directly since it erroneously
+    // selects radio buttons and breaks keyboard handling for a notebook's
+    // scroll buttons. So give focus to the notebook and not the page.
+
+    // but don't do this is the notebook is hidden
+    if ( ::IsWindowVisible(GetHwnd()) )
+        SetFocus();
+
+    m_nSelection = newsel;
+}
+
+int wxNotebook::ChangeSelection(size_t nPage)
+{
+    wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
+
+    if ( int(nPage) != m_nSelection )
+    {
+        TabCtrl_SetCurSel(GetHwnd(), nPage);
+
+        UpdateSelection(nPage);
+    }
+
+    return m_nSelection;
+}
+
 bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
 {
     wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("notebook page out of range") );
@@ -1030,35 +1068,14 @@ void wxNotebook::OnSize(wxSizeEvent& event)
 
 void wxNotebook::OnSelChange(wxNotebookEvent& event)
 {
-  // is it our tab control?
-  if ( event.GetEventObject() == this )
-  {
-      int sel = event.GetOldSelection();
-      if ( sel != -1 )
-        m_pages[sel]->Show(false);
-
-      sel = event.GetSelection();
-      if ( sel != -1 )
-      {
-        wxNotebookPage *pPage = m_pages[sel];
-        pPage->Show(true);
-      }
-
-      // Changing the page should give the focus to it but, as per bug report
-      // http://sf.net/tracker/index.php?func=detail&aid=1150659&group_id=9863&atid=109863,
-      // we should not set the focus to it directly since it erroneously
-      // selects radio buttons and breaks keyboard handling for a notebook's
-      // scroll buttons. So give focus to the notebook and not the page.
-
-      // but don't do this is the notebook is hidden
-      if ( ::IsWindowVisible(GetHwnd()) )
-        SetFocus();
-
-      m_nSelection = sel;
-  }
+    // is it our tab control?
+    if ( event.GetEventObject() == this )
+    {
+        UpdateSelection(event.GetSelection());
+    }
 
-  // we want to give others a chance to process this message as well
-  event.Skip();
+    // we want to give others a chance to process this message as well
+    event.Skip();
 }
 
 void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
index 26f5212468d4ef390b9c00fc2c39f0d21883b91b..e0051d4fd4b0b4eccbeac8626e36a78b8fe77c4b 100644 (file)
@@ -243,6 +243,22 @@ int wxNotebook::SetSelection( size_t nPage )
     return nPage;
 } // end of wxNotebook::SetSelection
 
+int wxNotebook::ChangeSelection( size_t nPage )
+{
+    wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
+
+    if (nPage != (size_t)m_nSelection)
+    {
+        ::WinSendMsg( GetHWND()
+                ,BKM_TURNTOPAGE
+                ,MPFROMLONG((ULONG)m_alPageId[nPage])
+                        ,(MPARAM)0
+                    );
+    }
+    m_nSelection = nPage;
+    return nPage;
+}
+
 bool wxNotebook::SetPageText( size_t nPage,
                               const wxString& rsStrText )
 {
index 0fb00011a3e36fd8ee18d5dc09de6faa90bba571..2f73ee9e9d2ee2769a789c0969442487eb86c98d 100644 (file)
@@ -194,6 +194,11 @@ int wxNotebook::SetSelection(size_t nPage)
     return 0;
 }
 
+int wxNotebook::ChangeSelection(size_t nPage)
+{
+    return 0;
+}
+
 bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
 {
     return false;
index be60137093c8c447e18bf5325cf3c91447ee72b2..7a72aaf22ec8967032253878c83bc7a954a697ed 100644 (file)
@@ -233,7 +233,7 @@ wxNotebook::~wxNotebook()
 // wxNotebook page switching
 // ----------------------------------------------------------------------------
 
-int wxNotebook::SetSelection(size_t nPage)
+int wxNotebook::DoSetSelection(size_t nPage, int flags = 0)
 {
     wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, _T("invalid notebook page") );
 
@@ -243,15 +243,18 @@ int wxNotebook::SetSelection(size_t 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() )
+    if (flags & SetSelection_SendEvent)
     {
-        // program doesn't allow the page change
-        return m_sel;
+        // event handling
+        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
@@ -297,9 +300,12 @@ int wxNotebook::SetSelection(size_t nPage)
         m_pages[m_sel]->Show();
     }
 
-    // event handling
-    event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
-    GetEventHandler()->ProcessEvent(event);
+    if (flags & SetSelection_SendEvent)
+    {
+        // event handling
+        event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
+        GetEventHandler()->ProcessEvent(event);
+    }
 
     return selOld;
 }