diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2017-02-01 10:14:59 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2017-02-01 10:29:37 +0000 |
commit | e78be1c18fc0a3f893023e3086d8cdb5e6d5a6b9 (patch) | |
tree | 8c9c6e46415a11d0ef5be3fc90dfb7046378306b /sfx2 | |
parent | bbd34216dca07bb37b9188147c42e64bbf875d54 (diff) |
InfoBar: Introduce different types
Makes it easier to push various infobars without specifiying the
colors manually.
Change-Id: I0f861ba02409a42ba2ae767a1ca7634eaf0e7aef
Reviewed-on: https://gerrit.libreoffice.org/33777
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/infobar.cxx | 51 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 47 |
2 files changed, 60 insertions, 38 deletions
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index 4d5ba0147fbe..c80825be9c72 100644 --- a/sfx2/source/dialog/infobar.cxx +++ b/sfx2/source/dialog/infobar.cxx @@ -254,24 +254,6 @@ void SfxInfoBarWindow::Resize() m_pMessage->SetPosSizePixel(aMessagePosition, aMessageSize); } -basegfx::BColor SfxInfoBarWindow::getSuccessColor() -{ - // Green - return basegfx::BColor(0.0, 0.5, 0.0); -} - -basegfx::BColor SfxInfoBarWindow::getWarningColor() -{ - // Orange - return basegfx::BColor(1.0, 0.5, 0.0); -} - -basegfx::BColor SfxInfoBarWindow::getDangerColor() -{ - // Red - return basegfx::BColor(0.5, 0.0, 0.0); -} - IMPL_LINK_NOARG(SfxInfoBarWindow, CloseHandler, Button*, void) { static_cast<SfxInfoBarContainerWindow*>(GetParent())->removeInfoBar(this); @@ -299,6 +281,39 @@ void SfxInfoBarContainerWindow::dispose() VclPtr<SfxInfoBarWindow> SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, const OUString& sMessage, + InfoBarType aInfoBarType, + WinBits nMessageStyle) +{ + basegfx::BColor pBackgroundColor; + basegfx::BColor pForegroundColor; + basegfx::BColor pMessageColor; + switch (aInfoBarType) + { + case InfoBarType::Info: // yellow + pBackgroundColor = constLightColor; + // Use defaults for foreground & message color + break; + case InfoBarType::Success: // green + pBackgroundColor = basegfx::BColor(0.0, 0.5, 0.0); + pForegroundColor = basegfx::BColor(1.0, 1.0, 1.0); + pMessageColor = basegfx::BColor(1.0, 1.0, 01.0); + break; + case InfoBarType::Warning: // orange + pBackgroundColor = basegfx::BColor(1.0, 0.5, 0.0); + pForegroundColor = basegfx::BColor(1.0, 1.0, 1.0); + pMessageColor = basegfx::BColor(1.0, 1.0, 01.0); + break; + case InfoBarType::Danger: // red + pBackgroundColor = basegfx::BColor(0.5, 0.0, 0.0); + pForegroundColor = basegfx::BColor(1.0, 1.0, 1.0); + pMessageColor = basegfx::BColor(1.0, 1.0, 01.0); + break; + } + return appendInfoBar(sId, sMessage, &pBackgroundColor, &pForegroundColor, &pMessageColor, nMessageStyle); +} + +VclPtr<SfxInfoBarWindow> SfxInfoBarContainerWindow::appendInfoBar(const OUString& sId, + const OUString& sMessage, const basegfx::BColor* pBackgroundColor, const basegfx::BColor* pForegroundColor, const basegfx::BColor* pMessageColor, diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 5e74b85f6b75..27b90a67a513 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1180,23 +1180,22 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) rBind.Invalidate( SID_EDITDOC ); SignatureState nSignatureState = GetObjectShell()->GetDocumentSignatureState(); - basegfx::BColor aBackgroundColor; - basegfx::BColor aForegroundColor(1.0, 1.0, 1.0); + InfoBarType aInfoBarType(InfoBarType::Info); OUString sMessage(""); switch (nSignatureState) { case SignatureState::BROKEN: sMessage = SfxResId(STR_SIGNATURE_BROKEN); - aBackgroundColor = SfxInfoBarWindow::getDangerColor(); + aInfoBarType = InfoBarType::Danger; break; case SignatureState::NOTVALIDATED: sMessage = SfxResId(STR_SIGNATURE_NOTVALIDATED); - aBackgroundColor = SfxInfoBarWindow::getWarningColor(); + aInfoBarType = InfoBarType::Warning; break; case SignatureState::PARTIAL_OK: sMessage = SfxResId(STR_SIGNATURE_PARTIAL_OK); - aBackgroundColor = SfxInfoBarWindow::getWarningColor(); + aInfoBarType = InfoBarType::Warning; break; default: break; @@ -1204,7 +1203,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) if (!sMessage.isEmpty()) { - auto pInfoBar = AppendInfoBar("signature", sMessage, &aBackgroundColor, &aForegroundColor); + auto pInfoBar = AppendInfoBar("signature", sMessage, aInfoBarType); VclPtrInstance<PushButton> xBtn(&GetWindow()); xBtn->SetText(SfxResId(STR_SIGNATURE_SHOW)); xBtn->SetSizePixel(xBtn->GetOptimalSize()); @@ -3098,6 +3097,21 @@ void SfxViewFrame::SetViewFrame( SfxViewFrame* pFrame ) SfxGetpApp()->SetViewFrame_Impl( pFrame ); } +VclPtr<SfxInfoBarWindow> SfxViewFrame::AppendInfoBar(const OUString& sId, + const OUString& sMessage, + InfoBarType aInfoBarType, + WinBits nMessageStyle) +{ + SfxChildWindow* pChild = GetChildWindow(SfxInfoBarContainerChild::GetChildWindowId()); + if (!pChild) + return nullptr; + + SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow()); + auto pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage, aInfoBarType, nMessageStyle); + ShowChildWindow(SfxInfoBarContainerChild::GetChildWindowId()); + return pInfoBar; +} + VclPtr<SfxInfoBarWindow> SfxViewFrame::AppendInfoBar( const OUString& sId, const OUString& sMessage, const basegfx::BColor* pBackgroundColor, @@ -3105,21 +3119,14 @@ VclPtr<SfxInfoBarWindow> SfxViewFrame::AppendInfoBar( const OUString& sId, const basegfx::BColor* pMessageColor, WinBits nMessageStyle ) { - const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId(); - - // Make sure the InfoBar container is visible - if (!HasChildWindow(nId)) - ToggleChildWindow(nId); + SfxChildWindow* pChild = GetChildWindow(SfxInfoBarContainerChild::GetChildWindowId()); + if (!pChild) + return nullptr; - SfxChildWindow* pChild = GetChildWindow(nId); - if (pChild) - { - SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow()); - auto pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage, pBackgroundColor, pForegroundColor, pMessageColor, nMessageStyle); - ShowChildWindow(nId); - return pInfoBar; - } - return nullptr; + SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow()); + auto pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage, pBackgroundColor, pForegroundColor, pMessageColor, nMessageStyle); + ShowChildWindow(SfxInfoBarContainerChild::GetChildWindowId()); + return pInfoBar; } void SfxViewFrame::RemoveInfoBar( const OUString& sId ) |