]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/notebook.cpp
adjusting to changed ownership (font is only created in the GetFont call of wxTextAttr)
[wxWidgets.git] / src / gtk1 / notebook.cpp
index ffa2e2a428bf8a16929db78aed1438a7af6ab6d4..37fa1fd8e565945fb5fe4fe847125c7b08dbedd8 100644 (file)
@@ -105,28 +105,33 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
 
     int old = notebook->GetSelection();
 
 
     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;
         // 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
+    {
+        if ( !notebook->SendPageChangingEvent(page) )
+        {
+            // program doesn't allow the page change
+            gtk_signal_emit_stop_by_name(GTK_OBJECT(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->SendPageChangedEvent(old);
+        }
     }
 
     notebook->m_inSwitchPage = FALSE;
     }
 
     notebook->m_inSwitchPage = FALSE;
@@ -244,7 +249,7 @@ static gint gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk
         event.SetCurrentFocus( notebook );
 
         wxNotebookPage *client = notebook->GetPage(sel);
         event.SetCurrentFocus( notebook );
 
         wxNotebookPage *client = notebook->GetPage(sel);
-        if ( !client->GetEventHandler()->ProcessEvent( event ) )
+        if ( !client->HandleWindowEvent( event ) )
         {
              client->SetFocus();
         }
         {
              client->SetFocus();
         }
@@ -282,9 +287,9 @@ static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child )
 // wxNotebook
 //-----------------------------------------------------------------------------
 
 // wxNotebook
 //-----------------------------------------------------------------------------
 
-IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxBookCtrlBase)
 
 
-BEGIN_EVENT_TABLE(wxNotebook, wxControl)
+BEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase)
     EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
 END_EVENT_TABLE()
 
     EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
 END_EVENT_TABLE()
 
@@ -417,7 +422,7 @@ wxGtkNotebookPage* wxNotebook::GetNotebookPage( int page ) const
     return m_pagesData.Item(page)->GetData();
 }
 
     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") );
 
 {
     wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
 
@@ -425,10 +430,23 @@ int wxNotebook::SetSelection( size_t page )
 
     int selOld = GetSelection();
 
 
     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 );
 
     // 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();
     wxNotebookPage *client = GetPage(page);
     if ( client )
         client->SetFocus();