diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-05-16 01:25:19 +0000 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-05-22 23:00:45 +0200 |
commit | cc223fa12a61ba0e580b884386a7f5d7efd0541f (patch) | |
tree | 62184f16ce568b083fae06dd0585f0a193c95e10 /vcl/source/edit | |
parent | 9b6a9a1f50a6d7326e97b02618e9bd5e44fb5832 (diff) |
VCL keep / return the original set TextEngine font
TextEngine::SetFont copies the font parameter and then modifies
its color, transparency, fill color and alignment, so passing the
same font again will not be detected as the same font.
Therefore this patch stores the original font in addition to the
modified one and also returns that one on the GetFont call.
This allows us to merge the font setup in VclMultiLineEdit's
ImplInitSettings and ApplySettings into a common function.
Change-Id: I618d283ecd0ae14faf9b87a3aceec6ca1c37b526
Reviewed-on: https://gerrit.libreoffice.org/72788
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/source/edit')
-rw-r--r-- | vcl/source/edit/texteng.cxx | 7 | ||||
-rw-r--r-- | vcl/source/edit/vclmedit.cxx | 74 |
2 files changed, 25 insertions, 56 deletions
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 097305df51c7..b6835dbc07a2 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -170,8 +170,9 @@ void TextEngine::SetActiveView( TextView* pTextView ) void TextEngine::SetFont( const vcl::Font& rFont ) { - if ( rFont == maFont ) + if (rFont == maOrigFont) return; + maOrigFont = rFont; maFont = rFont; // #i40221# As the font's color now defaults to transparent (since i35764) @@ -206,9 +207,9 @@ void TextEngine::SetFont( const vcl::Font& rFont ) for ( auto nView = mpViews->size(); nView; ) { TextView* pView = (*mpViews)[ --nView ]; - pView->GetWindow()->SetInputContext( InputContext( GetFont(), !pView->IsReadOnly() ? InputContextFlags::Text|InputContextFlags::ExtText : InputContextFlags::NONE ) ); + pView->GetWindow()->SetInputContext(InputContext(maFont, !pView->IsReadOnly() + ? InputContextFlags::Text|InputContextFlags::ExtText : InputContextFlags::NONE)); } - } void TextEngine::SetMaxTextLen( sal_Int32 nLen ) diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx index 9a6d6d018ea9..1419602fa34b 100644 --- a/vcl/source/edit/vclmedit.cxx +++ b/vcl/source/edit/vclmedit.cxx @@ -913,36 +913,8 @@ WinBits VclMultiLineEdit::ImplInitStyle( WinBits nStyle ) return nStyle; } -void VclMultiLineEdit::ApplySettings(vcl::RenderContext& rRenderContext) +void VclMultiLineEdit::ApplyBackgroundSettings(vcl::RenderContext& rRenderContext, const StyleSettings& rStyleSettings) { - const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); - - // The Font has to be adjusted, as the TextEngine does not take care of - // TextColor/Background - - Color aTextColor = rStyleSettings.GetFieldTextColor(); - if (IsControlForeground()) - aTextColor = GetControlForeground(); - - if (!IsEnabled()) - aTextColor = rStyleSettings.GetDisableColor(); - - vcl::Font aFont = rStyleSettings.GetFieldFont(); - aFont.SetTransparent(IsPaintTransparent()); - ApplyControlFont(rRenderContext, aFont); - - vcl::Font theFont = rRenderContext.GetFont(); - theFont.SetColor(aTextColor); - if (IsPaintTransparent()) - theFont.SetFillColor(COL_TRANSPARENT); - else - theFont.SetFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor()); - - pImpVclMEdit->GetTextWindow()->SetFont(theFont); - // FIXME: next call causes infinite invalidation loop, rethink how to properly fix this situation - // pImpVclMEdit->GetTextWindow()->GetTextEngine()->SetFont(theFont); - pImpVclMEdit->GetTextWindow()->SetTextColor(aTextColor); - if (IsPaintTransparent()) { pImpVclMEdit->GetTextWindow()->SetPaintTransparent(true); @@ -962,10 +934,8 @@ void VclMultiLineEdit::ApplySettings(vcl::RenderContext& rRenderContext) } } -void VclMultiLineEdit::ImplInitSettings(bool bBackground) +void VclMultiLineEdit::ApplyFontSettings(vcl::RenderContext& rRenderContext, const StyleSettings& rStyleSettings) { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - // The Font has to be adjusted, as the TextEngine does not take care of // TextColor/Background @@ -977,38 +947,36 @@ void VclMultiLineEdit::ImplInitSettings(bool bBackground) vcl::Font aFont = rStyleSettings.GetFieldFont(); aFont.SetTransparent(IsPaintTransparent()); - ApplyControlFont(*this, aFont); + ApplyControlFont(rRenderContext, aFont); - vcl::Font TheFont = GetFont(); + vcl::Font TheFont = rRenderContext.GetFont(); TheFont.SetColor(aTextColor); if (IsPaintTransparent()) TheFont.SetFillColor(COL_TRANSPARENT); else TheFont.SetFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor()); + pImpVclMEdit->GetTextWindow()->SetFont(TheFont); pImpVclMEdit->GetTextWindow()->GetTextEngine()->SetFont(TheFont); pImpVclMEdit->GetTextWindow()->SetTextColor(aTextColor); +} + +void VclMultiLineEdit::ApplySettings(vcl::RenderContext& rRenderContext) +{ + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + + ApplyFontSettings(rRenderContext, rStyleSettings); + ApplyBackgroundSettings(rRenderContext, rStyleSettings); +} + +void VclMultiLineEdit::ImplInitSettings(bool bBackground) +{ + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + + ApplyFontSettings(*this, rStyleSettings); if (bBackground) - { - if (IsPaintTransparent()) - { - pImpVclMEdit->GetTextWindow()->SetPaintTransparent(true); - pImpVclMEdit->GetTextWindow()->SetBackground(); - pImpVclMEdit->GetTextWindow()->SetControlBackground(); - SetBackground(); - SetControlBackground(); - } - else - { - if (IsControlBackground()) - pImpVclMEdit->GetTextWindow()->SetBackground(GetControlBackground()); - else - pImpVclMEdit->GetTextWindow()->SetBackground(rStyleSettings.GetFieldColor()); - // also adjust for VclMultiLineEdit as the TextComponent might hide Scrollbars - SetBackground(pImpVclMEdit->GetTextWindow()->GetBackground()); - } - } + ApplyBackgroundSettings(*this, rStyleSettings); } void VclMultiLineEdit::Modify() |