]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/bookctrl.cpp
Minor header cleaning.
[wxWidgets.git] / src / common / bookctrl.cpp
index ffae3d708da7c67332915c8397b6fb52c422a9ff..fef420180a359574454f991430996f4270b6a54e 100644 (file)
@@ -423,4 +423,52 @@ wxSize wxBookCtrlBase::GetControllerSize() const
     return size;
 }
 
+int wxBookCtrlBase::DoSetSelection(size_t n, int flags)
+{
+    wxCHECK_MSG( n < GetPageCount(), wxNOT_FOUND,
+                 wxT("invalid page index in wxBookCtrlBase::DoSetSelection()") );
+
+    const int oldSel = GetSelection();
+
+    if ( n != (size_t)oldSel )
+    {
+        wxBookCtrlBaseEvent *event = CreatePageChangingEvent();
+        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);
+            }
+        }
+
+        delete event;
+    }
+
+    return oldSel;
+}
+
+
 #endif // wxUSE_BOOKCTRL