X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/22a35096a0a9c3fe4d3d32b8d68a361126ef9677..7738af5957ace396793ee291a280d5a3dbd4821f:/src/univ/notebook.cpp diff --git a/src/univ/notebook.cpp b/src/univ/notebook.cpp index 237b4b73e2..392f13c4aa 100644 --- a/src/univ/notebook.cpp +++ b/src/univ/notebook.cpp @@ -36,6 +36,29 @@ #include "wx/univ/renderer.h" +// ---------------------------------------------------------------------------- +// wxStdNotebookInputHandler: translates SPACE and ENTER keys and the left mouse +// click into button press/release actions +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxStdNotebookInputHandler : public wxStdInputHandler +{ +public: + wxStdNotebookInputHandler(wxInputHandler *inphand); + + virtual bool HandleKey(wxInputConsumer *consumer, + const wxKeyEvent& event, + bool pressed); + virtual bool HandleMouse(wxInputConsumer *consumer, + const wxMouseEvent& event); + virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event); + virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event); + virtual bool HandleActivation(wxInputConsumer *consumer, bool activated); + +protected: + void HandleFocusChange(wxInputConsumer *consumer); +}; + // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- @@ -130,7 +153,7 @@ bool wxNotebook::Create(wxWindow *parent, m_sizePad = GetRenderer()->GetTabPadding(); - SetBestSize(size); + SetInitialSize(size); CreateInputHandler(wxINP_HANDLER_NOTEBOOK); @@ -210,7 +233,7 @@ wxNotebook::~wxNotebook() // wxNotebook page switching // ---------------------------------------------------------------------------- -int wxNotebook::SetSelection(size_t nPage) +int wxNotebook::DoSetSelection(size_t nPage, int flags) { wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, _T("invalid notebook page") ); @@ -220,15 +243,13 @@ int wxNotebook::SetSelection(size_t 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() ) + if ( flags & SetSelection_SendEvent ) { - // program doesn't allow the page change - return m_sel; + if ( !SendPageChangingEvent(nPage) ) + { + // program doesn't allow the page change + return m_sel; + } } // we need to change m_sel first, before calling RefreshTab() below as @@ -274,9 +295,11 @@ int wxNotebook::SetSelection(size_t nPage) m_pages[m_sel]->Show(); } - // event handling - event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED); - GetEventHandler()->ProcessEvent(event); + if ( flags & SetSelection_SendEvent ) + { + // event handling + SendPageChangedEvent(selOld); + } return selOld; } @@ -1319,6 +1342,14 @@ bool wxNotebook::PerformAction(const wxControlAction& action, return true; } +/* static */ +wxInputHandler *wxNotebook::GetStdInputHandler(wxInputHandler *handlerDef) +{ + static wxStdNotebookInputHandler s_handler(handlerDef); + + return &s_handler; +} + // ---------------------------------------------------------------------------- // wxStdNotebookInputHandler // ----------------------------------------------------------------------------