diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-08-10 19:46:59 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-08-15 21:00:29 +0200 |
commit | a6a2cc8f0e6501b92988accee2c3674dcfb05a2f (patch) | |
tree | 1f84dcedd125567402f9cddb49791987abe5d0ba | |
parent | 757b2438b172b3ef4560e533b3ce2a10f699f2bd (diff) |
Fix wizard step text styling
Moves all the SetTextColor handing into ApplySettings and just
changes the ControlBackground depending on step state.
Change-Id: I96234b6353afada7bc77e2f641a160c1cf25f48d
Reviewed-on: https://gerrit.libreoffice.org/58857
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | include/svtools/hyperlabel.hxx | 4 | ||||
-rw-r--r-- | svtools/source/control/hyperlabel.cxx | 75 | ||||
-rw-r--r-- | svtools/source/control/roadmap.cxx | 34 |
3 files changed, 46 insertions, 67 deletions
diff --git a/include/svtools/hyperlabel.hxx b/include/svtools/hyperlabel.hxx index e7bc9d6c30b5..bd86801724ae 100644 --- a/include/svtools/hyperlabel.hxx +++ b/include/svtools/hyperlabel.hxx @@ -42,9 +42,6 @@ namespace svt virtual void GetFocus() override; virtual void LoseFocus() override; - void DeactivateHyperMode(vcl::Font aFont, const Color aColor); - void ActivateHyperMode(vcl::Font aFont, const Color aColor); - void implInit(); using FixedText::CalcMinimumSize; @@ -55,6 +52,7 @@ namespace svt virtual void dispose() override; virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; void SetID( sal_Int16 ID ); sal_Int16 GetID() const; diff --git a/svtools/source/control/hyperlabel.cxx b/svtools/source/control/hyperlabel.cxx index 2cebdc20d27a..0552bdb54ea7 100644 --- a/svtools/source/control/hyperlabel.cxx +++ b/svtools/source/control/hyperlabel.cxx @@ -77,56 +77,33 @@ namespace svt void HyperLabel::ToggleBackgroundColor( const Color& _rGBColor ) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); SetControlBackground( _rGBColor ); - if (_rGBColor == COL_TRANSPARENT) - SetTextColor( rStyleSettings.GetFieldTextColor( ) ); - else - SetTextColor( rStyleSettings.GetHighlightTextColor( ) ); } - void HyperLabel::MouseMove( const MouseEvent& rMEvt ) { vcl::Font aFont = GetControlFont( ); - const Color aColor = GetTextColor(); - if (rMEvt.IsLeaveWindow()) - { - DeactivateHyperMode(aFont, aColor); - } - else + bool bHyperMode = false; + if (!rMEvt.IsLeaveWindow() && IsEnabled() && m_pImpl->bInteractive) { Point aPoint = GetPointerPosPixel(); if (aPoint.X() < m_pImpl->m_aMinSize.Width()) - { - if ( IsEnabled() && (m_pImpl->bInteractive) ) - { - ActivateHyperMode( aFont, aColor); - return; - } - } - DeactivateHyperMode(aFont, aColor); + bHyperMode = true; } - } - void HyperLabel::ActivateHyperMode(vcl::Font aFont, const Color aColor) - { - aFont.SetUnderline(LINESTYLE_SINGLE); - m_pImpl->m_bHyperMode = true; - SetPointer( PointerStyle::RefHand ); - SetControlFont( aFont); - SetTextColor( aColor); - - } - - void HyperLabel::DeactivateHyperMode(vcl::Font aFont, const Color aColor) - { - m_pImpl->m_bHyperMode = false; - aFont.SetUnderline(LINESTYLE_NONE); - SetPointer( PointerStyle::Arrow ); - SetControlFont( aFont); - SetTextColor( aColor); + m_pImpl->m_bHyperMode = bHyperMode; + if (bHyperMode) + { + aFont.SetUnderline(LINESTYLE_SINGLE); + SetPointer(PointerStyle::RefHand); + } + else + { + aFont.SetUnderline(LINESTYLE_NONE); + SetPointer(PointerStyle::Arrow); + } + SetControlFont(aFont); } void HyperLabel::MouseButtonDown( const MouseEvent& ) @@ -193,28 +170,32 @@ namespace svt SetText(_rText); } + void HyperLabel::ApplySettings(vcl::RenderContext& rRenderContext) + { + FixedText::ApplySettings(rRenderContext); + + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + if (GetControlBackground() == COL_TRANSPARENT) + rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor()); + else + rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor()); + } void HyperLabel::DataChanged( const DataChangedEvent& rDCEvt ) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); FixedText::DataChanged( rDCEvt ); + if ((( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) || ( rDCEvt.GetType() == DataChangedEventType::DISPLAY )) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE )) { - const Color& rGBColor = GetControlBackground(); - if (rGBColor == COL_TRANSPARENT) - SetTextColor( rStyleSettings.GetFieldTextColor( ) ); - else - { + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + if (GetControlBackground() != COL_TRANSPARENT) SetControlBackground(rStyleSettings.GetHighlightColor()); - SetTextColor( rStyleSettings.GetHighlightTextColor( ) ); - } Invalidate(); } } - } // namespace svt diff --git a/svtools/source/control/roadmap.cxx b/svtools/source/control/roadmap.cxx index bf1840702f3a..e9c3bf9e302b 100644 --- a/svtools/source/control/roadmap.cxx +++ b/svtools/source/control/roadmap.cxx @@ -41,7 +41,8 @@ class IDLabel : public FixedText { public: IDLabel( vcl::Window* _pParent, WinBits _nWinStyle ); - virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; }; class RoadmapItem : public RoadmapTypes @@ -664,7 +665,6 @@ RoadmapItem::RoadmapItem(ORoadmap& _rParent, const Size& _rItemPlayground) : m_aItemPlayground(_rItemPlayground) { mpID = VclPtr<IDLabel>::Create( &_rParent, WB_WORDBREAK ); - mpID->SetTextColor( mpID->GetSettings().GetStyleSettings().GetFieldTextColor( ) ); mpID->Show(); mpDescription = VclPtr<HyperLabel>::Create( &_rParent, WB_NOTABSTOP | WB_WORDBREAK ); mpDescription->Show(); @@ -760,15 +760,9 @@ bool RoadmapItem::IsEnabled() const void RoadmapItem::ToggleBackgroundColor(const Color& _rGBColor) { if (_rGBColor == COL_TRANSPARENT) - { - mpID->SetTextColor( mpID->GetSettings().GetStyleSettings().GetFieldTextColor( ) ); - mpID->SetControlBackground( COL_TRANSPARENT ); - } + mpID->SetControlBackground(); else - { mpID->SetControlBackground( mpID->GetSettings().GetStyleSettings().GetHighlightColor() ); - mpID->SetTextColor( mpID->GetSettings().GetStyleSettings().GetHighlightTextColor( ) ); - } mpDescription->ToggleBackgroundColor(_rGBColor); } @@ -811,22 +805,28 @@ IDLabel::IDLabel(vcl::Window* _pParent, WinBits _nWinStyle) { } +void IDLabel::ApplySettings(vcl::RenderContext& rRenderContext) +{ + FixedText::ApplySettings(rRenderContext); + + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + if (GetControlBackground() == COL_TRANSPARENT) + rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor()); + else + rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor()); +} + void IDLabel::DataChanged(const DataChangedEvent& rDCEvt) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); FixedText::DataChanged( rDCEvt ); + if ((( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) || ( rDCEvt.GetType() == DataChangedEventType::DISPLAY )) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE )) { - const Color& rGBColor = GetControlBackground(); - if (rGBColor == COL_TRANSPARENT) - SetTextColor( rStyleSettings.GetFieldTextColor( ) ); - else - { + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + if (GetControlBackground() != COL_TRANSPARENT) SetControlBackground(rStyleSettings.GetHighlightColor()); - SetTextColor( rStyleSettings.GetHighlightTextColor( ) ); - } Invalidate(); } } |