summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-06-13 21:42:35 +0200
committerTomaž Vajngerl <quikee@gmail.com>2013-06-13 22:44:00 +0200
commit6372309a0d285f4a176dbcded3f18b72220e123a (patch)
treeee93b61e9d7db3a2c6fed37cfdf4b93a61b47980 /starmath
parent6934312f617ccd86d0467e38129c2e5d861241b5 (diff)
Starmath: ElementsDockingWindow vertical orientation of elements
Change-Id: I4161cacc95576a5f34205c92482a38bb60ecc9f2
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/ElementsDockingWindow.hxx5
-rw-r--r--starmath/source/ElementsDockingWindow.cxx93
2 files changed, 79 insertions, 19 deletions
diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx
index c338bdaf6ca9..c46cf7948e28 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 1ad05fc2f141..7e8d331fe801 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: */