Kaydet (Commit) 95887e62 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

refactor ElementsDockingWindow to use RenderContext

Change-Id: I3a37883fc7688d4edd978e38e545e2386ae814b0
üst 73e45da4
...@@ -254,16 +254,16 @@ void SmElementsControl::setVerticalMode(bool bVerticalMode) ...@@ -254,16 +254,16 @@ void SmElementsControl::setVerticalMode(bool bVerticalMode)
mbVerticalMode = bVerticalMode; mbVerticalMode = bVerticalMode;
} }
void SmElementsControl::Paint(vcl::RenderContext& /*rRenderContext*/, const Rectangle&) void SmElementsControl::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{ {
Push(); rRenderContext.Push();
bool bOldVisibleState = mxScroll->IsVisible(); bool bOldVisibleState = mxScroll->IsVisible();
sal_Int32 nScrollbarWidth = bOldVisibleState ? GetSettings().GetStyleSettings().GetScrollBarSize() : 0; sal_Int32 nScrollbarWidth = bOldVisibleState ? GetSettings().GetStyleSettings().GetScrollBarSize() : 0;
sal_Int32 nControlWidth = GetOutputSizePixel().Width() - nScrollbarWidth; sal_Int32 nControlWidth = rRenderContext.GetOutputSizePixel().Width() - nScrollbarWidth;
sal_Int32 nControlHeight = GetOutputSizePixel().Height(); sal_Int32 nControlHeight = rRenderContext.GetOutputSizePixel().Height();
sal_Int32 boxX = maMaxElementDimensions.Width() + 10; sal_Int32 boxX = maMaxElementDimensions.Width() + 10;
sal_Int32 boxY = maMaxElementDimensions.Height() + 10; sal_Int32 boxY = maMaxElementDimensions.Height() + 10;
...@@ -278,7 +278,8 @@ void SmElementsControl::Paint(vcl::RenderContext& /*rRenderContext*/, const Rect ...@@ -278,7 +278,8 @@ void SmElementsControl::Paint(vcl::RenderContext& /*rRenderContext*/, const Rect
else else
perLine = nControlWidth / boxX; perLine = nControlWidth / boxX;
if(perLine <= 0) { if (perLine <= 0)
{
perLine = 1; perLine = 1;
} }
...@@ -297,11 +298,10 @@ void SmElementsControl::Paint(vcl::RenderContext& /*rRenderContext*/, const Rect ...@@ -297,11 +298,10 @@ void SmElementsControl::Paint(vcl::RenderContext& /*rRenderContext*/, const Rect
x += boxX; x += boxX;
y = 0; y = 0;
Rectangle aSelectionRectangle( Rectangle aSelectionRectangle(x + 5 - 1, y + 5,
x+5-1, y+5, x + 5 + 1, nControlHeight - 5);
x+5+1, nControlHeight - 5);
DrawRect(PixelToLogic(aSelectionRectangle)); rRenderContext.DrawRect(PixelToLogic(aSelectionRectangle));
x += 10; x += 10;
} }
else else
...@@ -309,20 +309,20 @@ void SmElementsControl::Paint(vcl::RenderContext& /*rRenderContext*/, const Rect ...@@ -309,20 +309,20 @@ void SmElementsControl::Paint(vcl::RenderContext& /*rRenderContext*/, const Rect
x = 0; x = 0;
y += boxY; y += boxY;
Rectangle aSelectionRectangle( Rectangle aSelectionRectangle(x + 5, y + 5 - 1,
x+5, y+5-1, nControlWidth - 5, y + 5 + 1);
nControlWidth - 5, y+5+1);
DrawRect(PixelToLogic(aSelectionRectangle)); rRenderContext.DrawRect(PixelToLogic(aSelectionRectangle));
y += 10; y += 10;
} }
} }
else else
{ {
Size aSizePixel = LogicToPixel(Size(element->getNode()->GetWidth(), element->getNode()->GetHeight())); Size aSizePixel = rRenderContext.LogicToPixel(Size(element->getNode()->GetWidth(),
if(mbVerticalMode) element->getNode()->GetHeight()));
if (mbVerticalMode)
{ {
if ( y + boxY > nControlHeight) if (y + boxY > nControlHeight)
{ {
x += boxX; x += boxX;
y = 0; y = 0;
...@@ -339,21 +339,23 @@ void SmElementsControl::Paint(vcl::RenderContext& /*rRenderContext*/, const Rect ...@@ -339,21 +339,23 @@ void SmElementsControl::Paint(vcl::RenderContext& /*rRenderContext*/, const Rect
if (mpCurrentElement == element) if (mpCurrentElement == element)
{ {
Push(); rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
SetFillColor( Color(230, 230, 230) ); rRenderContext.SetFillColor(Color(230, 230, 230));
SetLineColor( Color(230, 230, 230) ); rRenderContext.SetLineColor(Color(230, 230, 230));
DrawRect(PixelToLogic(Rectangle(x+2, y+2, x+boxX-2, y+boxY-2))); rRenderContext.DrawRect(PixelToLogic(Rectangle(x + 2, y + 2, x + boxX - 2, y + boxY - 2)));
Pop(); rRenderContext.Pop();
} }
Point location(x + ((boxX-aSizePixel.Width())/2), y + ((boxY-aSizePixel.Height())/2)); Point location(x + ((boxX - aSizePixel.Width()) / 2),
SmDrawingVisitor(*this, PixelToLogic(location), element->getNode().get()); y + ((boxY - aSizePixel.Height()) / 2));
SmDrawingVisitor(rRenderContext, PixelToLogic(location), element->getNode().get());
element->mBoxLocation = Point(x,y); element->mBoxLocation = Point(x,y);
element->mBoxSize = Size(boxX, boxY); element->mBoxSize = Size(boxX, boxY);
if(mbVerticalMode) if (mbVerticalMode)
y += boxY; y += boxY;
else else
x += boxX; x += boxX;
...@@ -380,7 +382,7 @@ void SmElementsControl::Paint(vcl::RenderContext& /*rRenderContext*/, const Rect ...@@ -380,7 +382,7 @@ void SmElementsControl::Paint(vcl::RenderContext& /*rRenderContext*/, const Rect
if (bOldVisibleState != mxScroll->IsVisible()) if (bOldVisibleState != mxScroll->IsVisible())
Invalidate(); Invalidate();
Pop(); rRenderContext.Pop();
} }
void SmElementsControl::MouseMove( const MouseEvent& rMouseEvent ) void SmElementsControl::MouseMove( const MouseEvent& rMouseEvent )
...@@ -735,7 +737,7 @@ IMPL_LINK( SmElementsDockingWindow, ElementSelectedHandle, ListBox*, pList) ...@@ -735,7 +737,7 @@ IMPL_LINK( SmElementsDockingWindow, ElementSelectedHandle, ListBox*, pList)
SmViewShell* SmElementsDockingWindow::GetView() SmViewShell* SmElementsDockingWindow::GetView()
{ {
SfxViewShell *pView = GetBindings().GetDispatcher()->GetFrame()->GetViewShell(); SfxViewShell* pView = GetBindings().GetDispatcher()->GetFrame()->GetViewShell();
return PTR_CAST(SmViewShell, pView); return PTR_CAST(SmViewShell, pView);
} }
...@@ -743,21 +745,7 @@ void SmElementsDockingWindow::Resize() ...@@ -743,21 +745,7 @@ void SmElementsDockingWindow::Resize()
{ {
bool bVertical = ( GetAlignment() == SfxChildAlignment::TOP || GetAlignment() == SfxChildAlignment::BOTTOM ); bool bVertical = ( GetAlignment() == SfxChildAlignment::TOP || GetAlignment() == SfxChildAlignment::BOTTOM );
mpElementsControl->setVerticalMode(bVertical); mpElementsControl->setVerticalMode(bVertical);
#if 0
sal_uInt32 aWidth = GetOutputSizePixel().Width();
sal_uInt32 aHeight = GetOutputSizePixel().Height();
sal_uInt32 aElementsSetsHeight = 23;
sal_uInt32 aPadding = 5;
Rectangle aRect1 = Rectangle(aPadding, aPadding, aWidth - aPadding, aElementsSetsHeight + aPadding);
mpElementListBox->SetPosSizePixel(aRect1.TopLeft(), aRect1.GetSize());
Rectangle aRect = Rectangle(aPadding, aElementsSetsHeight + aPadding + aPadding, aWidth - aPadding, aHeight - aPadding);
mpElementsControl->SetPosSizePixel(aRect.TopLeft(), aRect.GetSize());
#endif
SfxDockingWindow::Resize(); SfxDockingWindow::Resize();
Invalidate(); Invalidate();
} }
......
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