Merge branch 'notebook-add-page-events'

Harmonize events sent by wxNotebook::AddPage(): they are now sent only
when adding any page except the first one if it is selected in all
ports.

See https://github.com/wxWidgets/wxWidgets/pull/1192
This commit is contained in:
Vadim Zeitlin
2019-01-30 17:38:51 +01:00
6 changed files with 76 additions and 23 deletions

View File

@@ -154,12 +154,8 @@ bool wxNotebook::InsertPage(size_t n, wxWindow *page, const wxString& text,
// reenable firing qt signals as internal wx initialization was completed
m_qtTabWidget->blockSignals(false);
m_selection = m_qtTabWidget->currentIndex();
if (bSelect && GetPageCount() > 1)
{
SetSelection( n );
}
DoSetSelectionAfterInsertion(n, bSelect);
return true;
}
@@ -180,27 +176,31 @@ bool wxNotebook::DeleteAllPages()
return true;
}
int wxNotebook::DoSetSelection(size_t page, int flags)
int wxNotebook::SetSelection(size_t page)
{
wxCHECK_MSG(page < GetPageCount(), wxNOT_FOUND, "invalid notebook index");
int selOld = GetSelection();
// do not fire signals for certain methods (i.e. ChangeSelection
if ( !(flags & SetSelection_SendEvent) )
{
m_qtTabWidget->blockSignals(true);
}
// change the QTabWidget selected page:
m_selection = page;
m_qtTabWidget->setCurrentIndex( page );
if ( !(flags & SetSelection_SendEvent) )
{
m_qtTabWidget->blockSignals(false);
}
return selOld;
}
int wxNotebook::ChangeSelection(size_t nPage)
{
// ChangeSelection() is not supposed to generate events, unlike
// SetSelection().
m_qtTabWidget->blockSignals(true);
const int selOld = SetSelection(nPage);
m_qtTabWidget->blockSignals(false);
return selOld;
}
wxWindow *wxNotebook::DoRemovePage(size_t page)
{