[Libreoffice-commits] core.git: starmath/inc starmath/source

Tomaž Vajngerl quikee at gmail.com
Thu Jun 13 13:44:28 PDT 2013


 starmath/inc/ElementsDockingWindow.hxx    |    5 +
 starmath/source/ElementsDockingWindow.cxx |   93 +++++++++++++++++++++++-------
 2 files changed, 79 insertions(+), 19 deletions(-)

New commits:
commit 6372309a0d285f4a176dbcded3f18b72220e123a
Author: Tomaž Vajngerl <quikee at gmail.com>
Date:   Thu Jun 13 21:42:35 2013 +0200

    Starmath: ElementsDockingWindow vertical orientation of elements
    
    Change-Id: I4161cacc95576a5f34205c92482a38bb60ecc9f2

diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx
index c338bda..c46cf79 100644
--- a/starmath/inc/ElementsDockingWindow.hxx
+++ b/starmath/inc/ElementsDockingWindow.hxx
@@ -88,6 +88,7 @@ class SmElementsControl : public Control
 
     SmElementList maElementList;
     Size          maMaxElementDimensions;
+    bool          mbVerticalMode;
 
     void addElement(OUString aElementVisual, OUString aElementSource);
 
@@ -102,6 +103,8 @@ public:
 
     void setElementSetId(sal_uInt16 aSetId);
 
+    void setVerticalMode(bool bVertical);
+
     void SetSelectHdl(const Link& rLink)   { aSelectHdlLink = rLink; }
 };
 
@@ -124,6 +127,8 @@ public:
                              SfxChildWindow* pChildWindow,
                              Window* pParent );
     ~SmElementsDockingWindow();
+
+    virtual void EndDocking( const Rectangle& rReactangle, sal_Bool bFloatMode);
 };
 
 class SmElementsDockingWindowWrapper : public SfxChildWindow
diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx
index 1ad05fc..7e8d331 100644
--- a/starmath/source/ElementsDockingWindow.cxx
+++ b/starmath/source/ElementsDockingWindow.cxx
@@ -172,11 +172,17 @@ const sal_uInt16 SmElementsControl::aOthers[] =
 SmElementsControl::SmElementsControl(Window *pParent, const ResId& rResId) :
     Control(pParent, rResId),
     mpDocShell(new SmDocShell(SFXOBJECTSHELL_STD_NORMAL)),
-    mpCurrentElement(NULL)
+    mpCurrentElement(NULL),
+    mbVerticalMode(true)
 {
     maFormat.SetBaseSize(PixelToLogic(Size(0, 24)));
 }
 
+void SmElementsControl::setVerticalMode(bool bVerticalMode)
+{
+    mbVerticalMode = bVerticalMode;
+}
+
 void SmElementsControl::Paint(const Rectangle&)
 {
     Push();
@@ -192,42 +198,77 @@ void SmElementsControl::Paint(const Rectangle&)
     sal_Int32 x = 0;
     sal_Int32 y = 0;
 
-    sal_Int32 perLine = GetOutputSizePixel().Width() / boxX;
+    sal_Int32 perLine = 0;
+
+    if (mbVerticalMode)
+        perLine = GetOutputSizePixel().Height() / boxY;
+    else
+        perLine = GetOutputSizePixel().Width()  / boxX;
 
     if(perLine <= 0) {
         perLine = 1;
     }
 
-    boxX = GetOutputSizePixel().Width() / perLine;
+    if (mbVerticalMode)
+        boxY = GetOutputSizePixel().Height() / perLine;
+    else
+        boxX = GetOutputSizePixel().Width() / perLine;
 
     for (sal_uInt16 i = 0; i < maElementList.size() ; i++)
     {
         SmElement* element = maElementList[i].get();
         if (element->isSeparator())
         {
-            x = 0;
-            y += boxY;
-            Rectangle aSelectionRectangle(
-                x+5, y+5-1,
-                GetOutputSizePixel().Width() - 5, y+5+1);
-
-            DrawRect(PixelToLogic(aSelectionRectangle));
-            y += 10;
+            if (mbVerticalMode)
+            {
+                x += boxX;
+                y = 0;
+
+                Rectangle aSelectionRectangle(
+                    x+5-1, y+5,
+                    x+5+1, GetOutputSizePixel().Height() - 5);
+
+                DrawRect(PixelToLogic(aSelectionRectangle));
+                x += 10;
+            }
+            else
+            {
+                x = 0;
+                y += boxY;
+
+                Rectangle aSelectionRectangle(
+                    x+5,                              y+5-1,
+                    GetOutputSizePixel().Width() - 5, y+5+1);
+
+                DrawRect(PixelToLogic(aSelectionRectangle));
+                y += 10;
+            }
         }
         else
         {
             Size aSizePixel = LogicToPixel(Size(element->getNode()->GetWidth(), element->getNode()->GetHeight()));
-            if ( x + boxX > GetOutputSizePixel().Width())
+            if(mbVerticalMode)
             {
-                x = 0;
-                y += boxY;
+                if ( y + boxY > GetOutputSizePixel().Height())
+                {
+                    x += boxX;
+                    y = 0;
+                }
+            }
+            else
+            {
+                if ( x + boxX > GetOutputSizePixel().Width())
+                {
+                    x = 0;
+                    y += boxY;
+                }
             }
 
             if (mpCurrentElement == element)
             {
                 Push();
-                SetFillColor( Color(230,230,230) );
-                SetLineColor( Color(230,230,230) );
+                SetFillColor( Color(230, 230, 230) );
+                SetLineColor( Color(230, 230, 230) );
 
                 DrawRect(PixelToLogic(Rectangle(x+2, y+2, x+boxX-2, y+boxY-2)));
                 Pop();
@@ -239,10 +280,13 @@ void SmElementsControl::Paint(const Rectangle&)
             element->mBoxLocation = Point(x,y);
             element->mBoxSize     = Size(boxX, boxY);
 
-            x += boxX;
+            if(mbVerticalMode)
+                y += boxY;
+            else
+                x += boxX;
         }
-
     }
+
     Pop();
 }
 
@@ -448,12 +492,21 @@ SmElementsDockingWindow::SmElementsDockingWindow(SfxBindings* pInputBindings, Sf
 
     maElementListBox.SelectEntry(OUString(SmResId(RID_CATEGORY_UNARY_BINARY_OPERATORS)));
     maElementsControl.setElementSetId(RID_CATEGORY_UNARY_BINARY_OPERATORS);
+
+    Invalidate();
 }
 
 SmElementsDockingWindow::~SmElementsDockingWindow ()
 {
 }
 
+void SmElementsDockingWindow::EndDocking( const Rectangle& rReactangle, sal_Bool bFloatMode)
+{
+    SfxDockingWindow::EndDocking(rReactangle, bFloatMode);
+    bool bVertical = ( GetAlignment() == SFX_ALIGN_TOP || GetAlignment() == SFX_ALIGN_BOTTOM );
+    maElementsControl.setVerticalMode(bVertical);
+}
+
 IMPL_LINK( SmElementsDockingWindow, SelectClickHdl, SmElement*, pElement)
 {
     SmViewShell* pViewSh = GetView();
@@ -490,6 +543,9 @@ SmViewShell* SmElementsDockingWindow::GetView()
 
 void SmElementsDockingWindow::Resize()
 {
+    bool bVertical = ( GetAlignment() == SFX_ALIGN_TOP || GetAlignment() == SFX_ALIGN_BOTTOM );
+    maElementsControl.setVerticalMode(bVertical);
+
     sal_uInt32 aWidth  = GetOutputSizePixel().Width();
     sal_uInt32 aHeight = GetOutputSizePixel().Height();
 
@@ -525,5 +581,4 @@ SmElementsDockingWindowWrapper::~SmElementsDockingWindowWrapper()
 {
 }
 
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list