diff --git a/include/wx/bookctrl.h b/include/wx/bookctrl.h index 2bdf599224..4cea68ba31 100644 --- a/include/wx/bookctrl.h +++ b/include/wx/bookctrl.h @@ -222,6 +222,12 @@ protected: // Lay out controls void DoSize(); +#if wxUSE_HELP + // Show the help for the corresponding page + void OnHelp(wxHelpEvent& event); +#endif // wxUSE_HELP + + // the array of all pages of this control wxArrayPages m_pages; diff --git a/src/common/bookctrl.cpp b/src/common/bookctrl.cpp index 9b7c964e24..0d86e64008 100644 --- a/src/common/bookctrl.cpp +++ b/src/common/bookctrl.cpp @@ -42,6 +42,9 @@ IMPLEMENT_ABSTRACT_CLASS(wxBookCtrlBase, wxControl) BEGIN_EVENT_TABLE(wxBookCtrlBase, wxControl) EVT_SIZE(wxBookCtrlBase::OnSize) +#if wxUSE_HELP + EVT_HELP(wxID_ANY, wxBookCtrlBase::OnHelp) +#endif // wxUSE_HELP END_EVENT_TABLE() // ---------------------------------------------------------------------------- @@ -158,6 +161,35 @@ wxSize wxBookCtrlBase::DoGetBestSize() const return best; } +#if wxUSE_HELP +void wxBookCtrlBase::OnHelp(wxHelpEvent& event) +{ + // find the corresponding page + wxWindow *page = NULL; + + if ( event.GetOrigin() == wxHelpEvent::Origin_HelpButton ) + { + // show help for the page under the mouse + const int pagePos = HitTest(ScreenToClient(event.GetPosition())); + + if ( pagePos != wxNOT_FOUND) + { + page = GetPage((size_t)pagePos); + } + } + + if ( !page ) + { + page = GetCurrentPage(); + } + + if ( !page || !page->GetEventHandler()->ProcessEvent(event) ) + { + event.Skip(); + } +} +#endif // wxUSE_HELP + // ---------------------------------------------------------------------------- // pages management // ----------------------------------------------------------------------------