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:
@@ -193,9 +193,6 @@ protected:
|
|||||||
// get our client size from the page size
|
// get our client size from the page size
|
||||||
wxSize GetSizeForPage(const wxSize& size) const;
|
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
|
// scroll the tabs so that the first page shown becomes the given one
|
||||||
void ScrollTo(int page);
|
void ScrollTo(int page);
|
||||||
|
|
||||||
|
@@ -212,6 +212,17 @@ int wxNotebook::SetSelection(int nPage)
|
|||||||
return m_sel;
|
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
|
// we need to change m_sel first, before calling RefreshTab() below as
|
||||||
// otherwise the previously selected tab wouldn't be redrawn properly under
|
// otherwise the previously selected tab wouldn't be redrawn properly under
|
||||||
// wxGTK which calls Refresh() immediately and not during the next event
|
// 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();
|
m_pages[m_sel]->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
return selOld;
|
// event handling
|
||||||
}
|
|
||||||
|
|
||||||
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.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
|
event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
|
||||||
GetEventHandler()->ProcessEvent(event);
|
GetEventHandler()->ProcessEvent(event);
|
||||||
|
|
||||||
|
return selOld;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -1303,11 +1292,11 @@ bool wxNotebook::PerformAction(const wxControlAction& action,
|
|||||||
const wxString& strArg)
|
const wxString& strArg)
|
||||||
{
|
{
|
||||||
if ( action == wxACTION_NOTEBOOK_NEXT )
|
if ( action == wxACTION_NOTEBOOK_NEXT )
|
||||||
ChangePage(GetNextPage(TRUE));
|
SetSelection(GetNextPage(TRUE));
|
||||||
else if ( action == wxACTION_NOTEBOOK_PREV )
|
else if ( action == wxACTION_NOTEBOOK_PREV )
|
||||||
ChangePage(GetNextPage(FALSE));
|
SetSelection(GetNextPage(FALSE));
|
||||||
else if ( action == wxACTION_NOTEBOOK_GOTO )
|
else if ( action == wxACTION_NOTEBOOK_GOTO )
|
||||||
ChangePage((int)numArg);
|
SetSelection((int)numArg);
|
||||||
else
|
else
|
||||||
return wxControl::PerformAction(action, numArg, strArg);
|
return wxControl::PerformAction(action, numArg, strArg);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user