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