send more page change events (patch 750521); document this behaviour

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21720 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2003-07-06 21:40:59 +00:00
parent 65bc172c97
commit 01c6f3724e
2 changed files with 17 additions and 31 deletions

View File

@ -193,9 +193,6 @@ protected:
// get our client size from the page size
wxSize GetSizeForPage(const wxSize& size) const;
// change thep age and send events about it (can be vetoed by user code)
void ChangePage(int nPage);
// scroll the tabs so that the first page shown becomes the given one
void ScrollTo(int page);

View File

@ -212,6 +212,17 @@ int wxNotebook::SetSelection(int nPage)
return m_sel;
}
// event handling
wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
event.SetSelection(nPage);
event.SetOldSelection(m_sel);
event.SetEventObject(this);
if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() )
{
// program doesn't allow the page change
return m_sel;
}
// we need to change m_sel first, before calling RefreshTab() below as
// otherwise the previously selected tab wouldn't be redrawn properly under
// wxGTK which calls Refresh() immediately and not during the next event
@ -255,33 +266,11 @@ int wxNotebook::SetSelection(int nPage)
m_pages[m_sel]->Show();
}
return selOld;
}
void wxNotebook::ChangePage(int nPage)
{
wxCHECK_RET( IS_VALID_PAGE(nPage), _T("invalid notebook page") );
if ( (size_t)nPage == m_sel )
{
// nothing to do
return;
}
wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
event.SetSelection(nPage);
event.SetOldSelection(m_sel);
event.SetEventObject(this);
if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() )
{
// program doesn't allow the page change
return;
}
SetSelection(nPage);
// event handling
event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
GetEventHandler()->ProcessEvent(event);
return selOld;
}
// ----------------------------------------------------------------------------
@ -1303,11 +1292,11 @@ bool wxNotebook::PerformAction(const wxControlAction& action,
const wxString& strArg)
{
if ( action == wxACTION_NOTEBOOK_NEXT )
ChangePage(GetNextPage(TRUE));
SetSelection(GetNextPage(TRUE));
else if ( action == wxACTION_NOTEBOOK_PREV )
ChangePage(GetNextPage(FALSE));
SetSelection(GetNextPage(FALSE));
else if ( action == wxACTION_NOTEBOOK_GOTO )
ChangePage((int)numArg);
SetSelection((int)numArg);
else
return wxControl::PerformAction(action, numArg, strArg);