[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - starmath/inc starmath/source

Caolán McNamara caolanm at redhat.com
Tue Feb 2 11:33:52 UTC 2016


 starmath/inc/ElementsDockingWindow.hxx    |    3 +
 starmath/source/ElementsDockingWindow.cxx |   56 ++++++++++++++++++++++++++----
 2 files changed, 51 insertions(+), 8 deletions(-)

New commits:
commit 51fd7649432aeb7a6cb5cbf3cec1e94b08412248
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Feb 2 11:28:53 2016 +0000

    Resolves: tdf#97495 fix SmElementsControl tooltips
    
    instead of setting a single tooltip for the whole
    panel area, wait for a tooltip request and specify
    the area to which it applies.
    
    Which is what other widgets that have different
    tooltip areas do, and maps much better to the gtk3
    tooltip system which functions like that too.
    
    Change-Id: I56f452562c3c4d9dcec4109a8ee6168f34619472
    (cherry picked from commit f6c3c942976d615972674c5a5e12337d07be104c)

diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx
index e57e50c..0933901 100644
--- a/starmath/inc/ElementsDockingWindow.hxx
+++ b/starmath/inc/ElementsDockingWindow.hxx
@@ -83,7 +83,8 @@ class SmElementsControl : public Control
 
     virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle&) override;
     virtual void MouseButtonDown(const MouseEvent& rMEvt) override;
-    virtual void MouseMove( const MouseEvent& rMEvt ) override;
+    virtual void MouseMove(const MouseEvent& rMEvt) override;
+    virtual void RequestHelp(const HelpEvent& rHEvt) override;
 
     typedef std::shared_ptr<SmElement>    SmElementPointer;
     typedef std::vector< SmElementPointer > SmElementList;
diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx
index d3dd525..a54ea2e 100644
--- a/starmath/source/ElementsDockingWindow.cxx
+++ b/starmath/source/ElementsDockingWindow.cxx
@@ -27,6 +27,7 @@
 #include <svl/stritem.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/sfxmodelfactory.hxx>
+#include <vcl/help.hxx>
 #include <vcl/settings.hxx>
 
 typedef tools::SvRef<SmDocShell> SmDocShellRef;
@@ -388,10 +389,55 @@ void SmElementsControl::Paint(vcl::RenderContext& rRenderContext, const Rectangl
     rRenderContext.Pop();
 }
 
+void SmElementsControl::RequestHelp(const HelpEvent& rHEvt)
+{
+    if (rHEvt.GetMode() & (HelpEventMode::BALLOON | HelpEventMode::QUICK))
+    {
+        SmElement* pHelpElement = mpCurrentElement;
+
+        if (!rHEvt.KeyboardActivated())
+        {
+            Point aHelpEventPos(ScreenToOutputPixel(rHEvt.GetMousePosPixel()));
+            for (size_t i = 0; i < maElementList.size() ; i++)
+            {
+                SmElement* pElement = maElementList[i].get();
+                Rectangle aRect(pElement->mBoxLocation, pElement->mBoxSize);
+                if (aRect.IsInside(aHelpEventPos))
+                {
+                    pHelpElement = pElement;
+                    break;
+                }
+            }
+        }
+
+        if (!pHelpElement)
+            return;
+
+        Rectangle aHelpRect(pHelpElement->mBoxLocation, pHelpElement->mBoxSize);
+        Point aPt = OutputToScreenPixel( aHelpRect.TopLeft() );
+        aHelpRect.Left() = aPt.X();
+        aHelpRect.Top()= aPt.Y();
+        aPt = OutputToScreenPixel( aHelpRect.BottomRight() );
+        aHelpRect.Right() = aPt.X();
+        aHelpRect.Bottom() = aPt.Y();
+
+        // get text and display it
+        OUString aStr = pHelpElement->getHelpText();
+        if (rHEvt.GetMode() & HelpEventMode::BALLOON)
+        {
+            Help::ShowBalloon(this, aHelpRect.Center(), aHelpRect, aStr);
+        }
+        else
+            Help::ShowQuickHelp(this, aHelpRect, aStr, aStr, QuickHelpFlags::CtrlText);
+        return;
+    }
+
+    Control::RequestHelp(rHEvt);
+}
+
 void SmElementsControl::MouseMove( const MouseEvent& rMouseEvent )
 {
     mpCurrentElement = nullptr;
-    OUString tooltip;
     if (Rectangle(Point(0, 0), GetOutputSizePixel()).IsInside(rMouseEvent.GetPosPixel()))
     {
         for (size_t i = 0; i < maElementList.size() ; i++)
@@ -405,17 +451,13 @@ void SmElementsControl::MouseMove( const MouseEvent& rMouseEvent )
                     mpCurrentElement = element;
                     LayoutOrPaintContents();
                     Invalidate();
-                    tooltip = element->getHelpText();
                 }
             }
         }
-    }
-    else
-    {
-        Control::MouseMove (rMouseEvent);
+        return;
     }
 
-    SetQuickHelpText(tooltip);
+    Control::MouseMove(rMouseEvent);
 }
 
 void SmElementsControl::MouseButtonDown(const MouseEvent& rMouseEvent)


More information about the Libreoffice-commits mailing list