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
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;
}
// ----------------------------------------------------------------------------
// wxNotebook geometry
// ----------------------------------------------------------------------------
-int wxNotebook::HitTest(const wxPoint& pt) const
+int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
{
+ if ( flags )
+ *flags = wxNB_HITTEST_NOWHERE;
+
// first check that it is in this window at all
if ( !GetClientRect().Inside(pt) )
{
GetTabSize(n, &rectTabs.width, &rectTabs.height);
if ( rectTabs.Inside(pt) )
+ {
+ if ( flags )
+ {
+ // TODO: be more precise
+ *flags = wxNB_HITTEST_ONITEM;
+ }
+
return n;
+ }
// move the rectTabs to the next tab
if ( IsVertical() )
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);