]> git.saurik.com Git - wxWidgets.git/commitdiff
show help for the page under mouse when the [?] button is used to request help
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 26 May 2006 02:23:24 +0000 (02:23 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 26 May 2006 02:23:24 +0000 (02:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39342 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/bookctrl.h
src/common/bookctrl.cpp

index 2bdf599224611932d5f80228cbe9bd3710eaba04..4cea68ba31230c34f62e8833596c8277466017e6 100644 (file)
@@ -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;
 
index 9b7c964e242e3a40d5dfaf02192fce812257ba29..0d86e640080dfee71efd9e8690f47d5e6b936504 100644 (file)
@@ -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
 // ----------------------------------------------------------------------------