diff options
-rw-r--r-- | include/sfx2/infobar.hxx | 17 | ||||
-rw-r--r-- | include/sfx2/viewfrm.hxx | 5 | ||||
-rw-r--r-- | sfx2/source/dialog/infobar.cxx | 51 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 47 |
4 files changed, 77 insertions, 43 deletions
diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx index 97671a968f05..3043a2f7c0b9 100644 --- a/include/sfx2/infobar.hxx +++ b/include/sfx2/infobar.hxx @@ -69,15 +69,18 @@ class SfxInfoBarWindow : public vcl::Window */ void addButton(PushButton* pButton); - // Colors - static basegfx::BColor getSuccessColor(); - static basegfx::BColor getDangerColor(); - static basegfx::BColor getWarningColor(); - private: DECL_LINK( CloseHandler, Button*, void ); }; + +enum class InfoBarType { + Info, + Success, + Warning, + Danger +}; + class SfxInfoBarContainerWindow : public vcl::Window { private: @@ -91,6 +94,10 @@ class SfxInfoBarContainerWindow : public vcl::Window VclPtr<SfxInfoBarWindow> appendInfoBar(const OUString& sId, const OUString& sMessage, + InfoBarType aInfoBarType, + WinBits nMessageStyle); + VclPtr<SfxInfoBarWindow> appendInfoBar(const OUString& sId, + const OUString& sMessage, const basegfx::BColor* pBackgroundColor, const basegfx::BColor* pForegroundColor, const basegfx::BColor* pMessageColor, diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx index ed8a994bc741..1ae2a58ba157 100644 --- a/include/sfx2/viewfrm.hxx +++ b/include/sfx2/viewfrm.hxx @@ -48,6 +48,7 @@ class Point; class Size; class SfxChildWindow; class SfxInfoBarWindow; +enum class InfoBarType; namespace sfx2 { @@ -172,6 +173,10 @@ public: */ VclPtr<SfxInfoBarWindow> AppendInfoBar(const OUString& sId, const OUString& sMessage, + InfoBarType aInfoBarType, + WinBits nMessageStyle = 0); + VclPtr<SfxInfoBarWindow> AppendInfoBar(const OUString& sId, + const OUString& sMessage, const basegfx::BColor* pBackgroundColor = nullptr, const basegfx::BColor* pForegroundColor = nullptr, const basegfx::BColor* pMessageColor = nullptr, 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 ) |