Kaydet (Commit) 6372309a authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Starmath: ElementsDockingWindow vertical orientation of elements

Change-Id: I4161cacc95576a5f34205c92482a38bb60ecc9f2
üst 6934312f
......@@ -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
......
......@@ -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,21 +198,44 @@ 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;
}
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())
{
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);
......@@ -214,20 +243,32 @@ void SmElementsControl::Paint(const Rectangle&)
DrawRect(PixelToLogic(aSelectionRectangle));
y += 10;
}
}
else
{
Size aSizePixel = LogicToPixel(Size(element->getNode()->GetWidth(), element->getNode()->GetHeight()));
if(mbVerticalMode)
{
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);
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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment