added wxBookCtrl::ChangeSelection() which is the same as SetSelection() but doesn't send the page change events (second part of patch 1553551)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41738 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-10-08 17:37:23 +00:00
parent 982a44cc9f
commit 1d6fcbcc70
30 changed files with 447 additions and 224 deletions

View 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->m_skipNextPageChangeEvent)
{
// this event was programatically generated by ChangeSelection() and thus must
// be skipped
notebook->m_skipNextPageChangeEvent = false;
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
{
// 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();