X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9804d5404a9607cda3d08ec8225f52f78b78bc72..6a8cbe1b9202ee5eb7a8bfa9b2ce66afeadfad6a:/src/gtk1/notebook.cpp diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index ffa2e2a428..37fa1fd8e5 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -105,28 +105,33 @@ 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 + { + 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; @@ -244,7 +249,7 @@ static gint gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk event.SetCurrentFocus( notebook ); wxNotebookPage *client = notebook->GetPage(sel); - if ( !client->GetEventHandler()->ProcessEvent( event ) ) + if ( !client->HandleWindowEvent( event ) ) { client->SetFocus(); } @@ -282,9 +287,9 @@ static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child ) // 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() @@ -417,7 +422,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 +430,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();