diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-02-17 12:21:47 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-02-17 13:45:45 +0100 |
commit | 7decc4193028f27354556a007a99088c1ea0b32e (patch) | |
tree | f61d3217cecc360ec64056250cb918db54b7bcad /sfx2 | |
parent | f3b0bd89a892d15179b9d6133c43e64bfcebbdf9 (diff) |
sfx2 infobar: allow setting the back/foreground color
It would be easier to set these after the infobar is created, but the
infobar is shown right after creating it, so that way the infobar would
be always yellow for a short period of time -> annoying flashing.
Change-Id: Ie23efd2fd1bba624cf2921f11a6fc40014ac4215
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/infobar.cxx | 56 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 4 |
2 files changed, 42 insertions, 18 deletions
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index a3c7f54de736..f34f23cfcfa5 100644 --- a/sfx2/source/dialog/infobar.cxx +++ b/sfx2/source/dialog/infobar.cxx @@ -54,13 +54,21 @@ void lclDetermineLightDarkColor(BColor& rLightColor, BColor& rDarkColor) class SfxCloseButton : public PushButton { + basegfx::BColor m_aBackgroundColor; + basegfx::BColor m_aForegroundColor; + public: explicit SfxCloseButton(vcl::Window* pParent) : PushButton(pParent, 0) - {} + { + lclDetermineLightDarkColor(m_aBackgroundColor, m_aForegroundColor); + } virtual ~SfxCloseButton() {} virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) override; + + void setBackgroundColor(const basegfx::BColor& rColor); + void setForegroundColor(const basegfx::BColor& rColor); }; void SfxCloseButton::Paint(vcl::RenderContext& rRenderContext, const Rectangle&) @@ -73,10 +81,6 @@ void SfxCloseButton::Paint(vcl::RenderContext& rRenderContext, const Rectangle&) drawinglayer::primitive2d::Primitive2DContainer aSeq(2); - BColor aLightColor; - BColor aDarkColor; - lclDetermineLightDarkColor(aLightColor, aDarkColor); - // Light background B2DPolygon aPolygon; aPolygon.append(B2DPoint(aRect.Left(), aRect.Top())); @@ -86,10 +90,10 @@ void SfxCloseButton::Paint(vcl::RenderContext& rRenderContext, const Rectangle&) aPolygon.setClosed(true); PolyPolygonColorPrimitive2D* pBack = - new PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), aLightColor); + new PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), m_aBackgroundColor); aSeq[0] = pBack; - LineAttribute aLineAttribute(aDarkColor, 2.0); + LineAttribute aLineAttribute(m_aForegroundColor, 2.0); // Cross B2DPolyPolygon aCross; @@ -112,16 +116,40 @@ void SfxCloseButton::Paint(vcl::RenderContext& rRenderContext, const Rectangle&) pProcessor->process(aSeq); } +void SfxCloseButton::setBackgroundColor(const basegfx::BColor& rColor) +{ + m_aBackgroundColor = rColor; +} + +void SfxCloseButton::setForegroundColor(const basegfx::BColor& rColor) +{ + m_aForegroundColor = rColor; +} + } // anonymous namespace SfxInfoBarWindow::SfxInfoBarWindow(vcl::Window* pParent, const OUString& sId, - const OUString& sMessage) : + const OUString& sMessage, + const basegfx::BColor* pBackgroundColor, + const basegfx::BColor* pForegroundColor ) : Window(pParent, 0), m_sId(sId), m_pMessage(VclPtr<FixedText>::Create(this, 0)), m_pCloseBtn(VclPtr<SfxCloseButton>::Create(this)), m_aActionBtns() { + lclDetermineLightDarkColor(m_aBackgroundColor, m_aForegroundColor); + if (pBackgroundColor) + { + m_aBackgroundColor = *pBackgroundColor; + static_cast<SfxCloseButton*>(m_pCloseBtn.get())->setBackgroundColor(m_aBackgroundColor); + } + if (pForegroundColor) + { + m_aForegroundColor = *pForegroundColor; + static_cast<SfxCloseButton*>(m_pCloseBtn.get())->setForegroundColor(m_aForegroundColor); + } + sal_Int32 nScaleFactor = GetDPIScaleFactor(); long nWidth = pParent->GetSizePixel().getWidth(); SetPosSizePixel(Point(0, 0), Size(nWidth, INFO_BAR_BASE_HEIGHT * nScaleFactor)); @@ -170,10 +198,6 @@ void SfxInfoBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle drawinglayer::primitive2d::Primitive2DContainer aSeq(2); - BColor aLightColor; - BColor aDarkColor; - lclDetermineLightDarkColor(aLightColor, aDarkColor); - // Light background B2DPolygon aPolygon; aPolygon.append(B2DPoint(aRect.Left(), aRect.Top())); @@ -183,10 +207,10 @@ void SfxInfoBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle aPolygon.setClosed(true); PolyPolygonColorPrimitive2D* pBack = - new PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), aLightColor); + new PolyPolygonColorPrimitive2D(B2DPolyPolygon(aPolygon), m_aBackgroundColor); aSeq[0] = pBack; - LineAttribute aLineAttribute(aDarkColor, 1.0); + LineAttribute aLineAttribute(m_aForegroundColor, 1.0); // Bottom dark line B2DPolygon aPolygonBottom; @@ -253,11 +277,11 @@ void SfxInfoBarContainerWindow::dispose() Window::dispose(); } -SfxInfoBarWindow* SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sMessage) +SfxInfoBarWindow* SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sMessage, const basegfx::BColor* pBackgroundColor, const basegfx::BColor* pForegroundColor) { Size aSize = GetSizePixel(); - VclPtrInstance<SfxInfoBarWindow> pInfoBar(this, sId, sMessage); + VclPtrInstance<SfxInfoBarWindow> pInfoBar(this, sId, sMessage, pBackgroundColor, pForegroundColor); pInfoBar->SetPosPixel(Point(0, aSize.getHeight())); pInfoBar->Show(); m_pInfoBars.push_back(pInfoBar); diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 05850854d60a..068bbcd891bb 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -3191,7 +3191,7 @@ void SfxViewFrame::SetViewFrame( SfxViewFrame* pFrame ) SfxGetpApp()->SetViewFrame_Impl( pFrame ); } -SfxInfoBarWindow* SfxViewFrame::AppendInfoBar( const OUString& sId, const OUString& sMessage ) +SfxInfoBarWindow* SfxViewFrame::AppendInfoBar( const OUString& sId, const OUString& sMessage, const basegfx::BColor* pBackgroundColor, const basegfx::BColor* pForegroundColor ) { const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId(); @@ -3203,7 +3203,7 @@ SfxInfoBarWindow* SfxViewFrame::AppendInfoBar( const OUString& sId, const OUStri if (pChild) { SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow()); - SfxInfoBarWindow* pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage); + SfxInfoBarWindow* pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage, pBackgroundColor, pForegroundColor); ShowChildWindow(nId); return pInfoBar; } |