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

Thomas Arnhold thomas at arnhold.org
Tue May 27 16:43:37 PDT 2014


 starmath/inc/ElementsDockingWindow.hxx    |   11 +++-
 starmath/source/ElementsDockingWindow.cxx |   67 +++++++++++++++++++++++++-----
 2 files changed, 66 insertions(+), 12 deletions(-)

New commits:
commit 8e9a261b6d605ead0de82397c2493254ba5815fd
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Tue May 27 23:19:53 2014 +0200

    Resolves: fdo#65583 Elements Dock window needs scroll bar
    
    Based on the patch on Bugzilla by
    Marcos Paulo de Souza <marcos.souza.org at gmail.com>
    
    Change-Id: I215b83894f228b1cc8908f98858b85c8d5378ddb

diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx
index 752954e..e2ab95c 100644
--- a/starmath/inc/ElementsDockingWindow.hxx
+++ b/starmath/inc/ElementsDockingWindow.hxx
@@ -16,11 +16,14 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
+
 #ifndef INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
 #define INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
 
+#include <boost/scoped_ptr.hpp>
 #include <sfx2/dockwin.hxx>
 #include <svx/dlgctrl.hxx>
+#include <vcl/scrbar.hxx>
 
 #include <document.hxx>
 #include <node.hxx>
@@ -67,7 +70,6 @@ public:
 
 class SmElementsControl : public Control
 {
-
     static const sal_uInt16 aUnaryBinaryOperatorsList[][2];
     static const sal_uInt16 aRelationsList[][2];
     static const sal_uInt16 aSetOperations[][2];
@@ -95,6 +97,7 @@ class SmElementsControl : public Control
     SmElementList maElementList;
     Size          maMaxElementDimensions;
     bool          mbVerticalMode;
+    boost::scoped_ptr< ScrollBar > mpScroll;
 
     void addElement(const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText);
 
@@ -113,6 +116,9 @@ public:
     void setVerticalMode(bool bVertical);
 
     void SetSelectHdl(const Link& rLink)   { aSelectHdlLink = rLink; }
+
+    DECL_LINK( ScrollHdl, void* );
+    void DoScroll(long nDelta);
 };
 
 class SmElementsDockingWindow : public SfxDockingWindow
@@ -151,7 +157,6 @@ protected:
     virtual ~SmElementsDockingWindowWrapper();
 };
 
-
-#endif // _SYMBOLDOCKINGWINDOW_HXX_
+#endif // INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx
index d46f350..2b14ac2 100644
--- a/starmath/source/ElementsDockingWindow.cxx
+++ b/starmath/source/ElementsDockingWindow.cxx
@@ -27,6 +27,7 @@
 
 #include <svl/stritem.hxx>
 #include <sfx2/dispatch.hxx>
+#include <vcl/settings.hxx>
 
 typedef tools::SvRef<SmDocShell> SmDocShellRef;
 
@@ -217,8 +218,12 @@ SmElementsControl::SmElementsControl(Window *pParent, const ResId& rResId)
     , maCurrentSetId(0)
     , mpCurrentElement(NULL)
     , mbVerticalMode(true)
+    , mpScroll(new ScrollBar(this, WB_VERT))
 {
     maFormat.SetBaseSize(PixelToLogic(Size(0, 24)));
+
+    mpScroll->SetScrollHdl( LINK(this, SmElementsControl, ScrollHdl) );
+    mpScroll->Show();
 }
 
 SmElementsControl::~SmElementsControl()
@@ -240,27 +245,34 @@ void SmElementsControl::Paint(const Rectangle&)
     SetLayoutMode( TEXT_LAYOUT_BIDI_LTR );
     SetDigitLanguage( LANGUAGE_ENGLISH );
 
+    bool bOldVisibleState = mpScroll->IsVisible();
+
+    sal_Int32 nScrollbarWidth = bOldVisibleState ? GetSettings().GetStyleSettings().GetScrollBarSize() : 0;
+
+    sal_Int32 nControlWidth = GetOutputSizePixel().Width() - nScrollbarWidth;
+    sal_Int32 nControlHeight = GetOutputSizePixel().Height();
+
     sal_Int32 boxX = maMaxElementDimensions.Width()  + 10;
     sal_Int32 boxY = maMaxElementDimensions.Height() + 10;
 
     sal_Int32 x = 0;
-    sal_Int32 y = 0;
+    sal_Int32 y = -mpScroll->GetThumbPos();
 
     sal_Int32 perLine = 0;
 
     if (mbVerticalMode)
-        perLine = GetOutputSizePixel().Height() / boxY;
+        perLine = nControlHeight / boxY;
     else
-        perLine = GetOutputSizePixel().Width()  / boxX;
+        perLine = nControlWidth / boxX;
 
     if(perLine <= 0) {
         perLine = 1;
     }
 
     if (mbVerticalMode)
-        boxY = GetOutputSizePixel().Height() / perLine;
+        boxY = nControlHeight / perLine;
     else
-        boxX = GetOutputSizePixel().Width() / perLine;
+        boxX = nControlWidth / perLine;
 
     for (sal_uInt16 i = 0; i < maElementList.size() ; i++)
     {
@@ -274,7 +286,7 @@ void SmElementsControl::Paint(const Rectangle&)
 
                 Rectangle aSelectionRectangle(
                     x+5-1, y+5,
-                    x+5+1, GetOutputSizePixel().Height() - 5);
+                    x+5+1, nControlHeight - 5);
 
                 DrawRect(PixelToLogic(aSelectionRectangle));
                 x += 10;
@@ -286,7 +298,7 @@ void SmElementsControl::Paint(const Rectangle&)
 
                 Rectangle aSelectionRectangle(
                     x+5,                              y+5-1,
-                    GetOutputSizePixel().Width() - 5, y+5+1);
+                    nControlWidth - 5, y+5+1);
 
                 DrawRect(PixelToLogic(aSelectionRectangle));
                 y += 10;
@@ -297,7 +309,7 @@ void SmElementsControl::Paint(const Rectangle&)
             Size aSizePixel = LogicToPixel(Size(element->getNode()->GetWidth(), element->getNode()->GetHeight()));
             if(mbVerticalMode)
             {
-                if ( y + boxY > GetOutputSizePixel().Height())
+                if ( y + boxY > nControlHeight)
                 {
                     x += boxX;
                     y = 0;
@@ -305,7 +317,7 @@ void SmElementsControl::Paint(const Rectangle&)
             }
             else
             {
-                if ( x + boxX > GetOutputSizePixel().Width())
+                if ( x + boxX > nControlWidth)
                 {
                     x = 0;
                     y += boxY;
@@ -335,6 +347,26 @@ void SmElementsControl::Paint(const Rectangle&)
         }
     }
 
+    sal_Int32 nTotalControlHeight = y + boxY + mpScroll->GetThumbPos();
+
+    if (nTotalControlHeight > GetOutputSizePixel().Height())
+    {
+        mpScroll->SetRangeMax(nTotalControlHeight);
+        mpScroll->SetPosSizePixel(Point(nControlWidth, 0), Size(nScrollbarWidth, nControlHeight));
+        mpScroll->SetVisibleSize(nControlHeight);
+        mpScroll->Show();
+    }
+    else
+    {
+        mpScroll->SetThumbPos(0);
+        mpScroll->Hide();
+    }
+
+    // If scrollbar visibility changed, we have to go through the
+    // calculation once more, see nScrollbarWidth
+    if (bOldVisibleState != mpScroll->IsVisible())
+        Invalidate();
+
     Pop();
 }
 
@@ -390,6 +422,21 @@ void SmElementsControl::MouseButtonDown(const MouseEvent& rMouseEvent)
     }
 }
 
+IMPL_LINK_NOARG( SmElementsControl, ScrollHdl )
+{
+    DoScroll(mpScroll->GetDelta());
+    return 0;
+}
+
+void SmElementsControl::DoScroll(long nDelta)
+{
+    Point aNewPoint = mpScroll->GetPosPixel();
+    Rectangle aRect(Point(), GetOutputSize());
+    aRect.Right() -= mpScroll->GetSizePixel().Width();
+    Scroll( 0, -nDelta, aRect );
+    mpScroll->SetPosPixel(aNewPoint);
+}
+
 void SmElementsControl::addSeparator()
 {
     SmElementPointer pElement(new SmElementSeparator());
@@ -578,6 +625,8 @@ void SmElementsDockingWindow::ToggleFloatingMode()
 
     if (GetFloatingWindow())
         GetFloatingWindow()->SetMinOutputSizePixel( Size(100, 100) );
+
+    Invalidate();
 }
 
 void SmElementsDockingWindow::EndDocking( const Rectangle& rReactangle, bool bFloatMode)


More information about the Libreoffice-commits mailing list