summaryrefslogtreecommitdiff
path: root/vcl/source/edit
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-17 22:56:46 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-05-18 11:22:49 +0900
commitb4bbb5e5d7b31caad2fbcc00382ad27df3c81001 (patch)
tree8ac345712ff92a9b33a7d54651ed27ad88f1ec67 /vcl/source/edit
parent2ca7795a6a723c701f295323fcc3f6c52ad37976 (diff)
refactor how font, fg. and bg. are applied in widgets/controls
- Move vcl::RenderContext to outdev. - Change some methods on vcl::Window to accept RenderContext as parameter. - Add ApplySettings to vcl::Window - This method is called before painting. Refactor existing classes that use InitSettings to have ApplySettings or mark the classes to be refactored later. - Add RenderSettings for adding defered settings to rendering. This is similar to ApplySettings but for more ad-hoc calls. Change-Id: I4ea58461f3b6b08ccfa3e0ddd1a4a3e04f8c4f45
Diffstat (limited to 'vcl/source/edit')
-rw-r--r--vcl/source/edit/vclmedit.cxx89
1 files changed, 68 insertions, 21 deletions
diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx
index c34fc22baeb4..66ae92933be6 100644
--- a/vcl/source/edit/vclmedit.cxx
+++ b/vcl/source/edit/vclmedit.cxx
@@ -976,7 +976,55 @@ WinBits VclMultiLineEdit::ImplInitStyle( WinBits nStyle )
return nStyle;
}
-void VclMultiLineEdit::ImplInitSettings( bool /*bFont*/, bool /*bForeground*/, bool bBackground )
+void VclMultiLineEdit::ApplySettings(vcl::RenderContext& rRenderContext)
+{
+ 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(Color(COL_TRANSPARENT));
+ else
+ theFont.SetFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());
+
+ pImpVclMEdit->GetTextWindow()->SetFont(theFont);
+ pImpVclMEdit->GetTextWindow()->GetTextEngine()->SetFont(theFont);
+ pImpVclMEdit->GetTextWindow()->SetTextColor(aTextColor);
+
+ if (IsPaintTransparent())
+ {
+ pImpVclMEdit->GetTextWindow()->SetPaintTransparent(true);
+ pImpVclMEdit->GetTextWindow()->SetBackground();
+ pImpVclMEdit->GetTextWindow()->SetControlBackground();
+ rRenderContext.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
+ rRenderContext.SetBackground(pImpVclMEdit->GetTextWindow()->GetBackground());
+ }
+}
+
+void VclMultiLineEdit::ImplInitSettings(bool /*bFont*/, bool /*bForeground*/, bool bBackground)
{
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
@@ -984,31 +1032,30 @@ void VclMultiLineEdit::ImplInitSettings( bool /*bFont*/, bool /*bForeground*/, b
// TextColor/Background
Color aTextColor = rStyleSettings.GetFieldTextColor();
- if ( IsControlForeground() )
+ if (IsControlForeground())
aTextColor = GetControlForeground();
- if ( !IsEnabled() )
+ if (!IsEnabled())
aTextColor = rStyleSettings.GetDisableColor();
vcl::Font aFont = rStyleSettings.GetFieldFont();
- if ( IsControlFont() )
- aFont.Merge( GetControlFont() );
- aFont.SetTransparent( IsPaintTransparent() );
- SetZoomedPointFont( aFont );
+ aFont.SetTransparent(IsPaintTransparent());
+ ApplyControlFont(*this, aFont);
+
vcl::Font TheFont = GetFont();
- TheFont.SetColor( aTextColor );
- if( IsPaintTransparent() )
- TheFont.SetFillColor( Color( COL_TRANSPARENT ) );
+ TheFont.SetColor(aTextColor);
+ if (IsPaintTransparent())
+ TheFont.SetFillColor(Color(COL_TRANSPARENT));
else
- TheFont.SetFillColor( IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor() );
- pImpVclMEdit->GetTextWindow()->SetFont( TheFont );
- pImpVclMEdit->GetTextWindow()->GetTextEngine()->SetFont( TheFont );
- pImpVclMEdit->GetTextWindow()->SetTextColor( aTextColor );
+ TheFont.SetFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());
+ pImpVclMEdit->GetTextWindow()->SetFont(TheFont);
+ pImpVclMEdit->GetTextWindow()->GetTextEngine()->SetFont(TheFont);
+ pImpVclMEdit->GetTextWindow()->SetTextColor(aTextColor);
- if ( bBackground )
+ if (bBackground)
{
- if( IsPaintTransparent() )
+ if (IsPaintTransparent())
{
- pImpVclMEdit->GetTextWindow()->SetPaintTransparent( true );
+ pImpVclMEdit->GetTextWindow()->SetPaintTransparent(true);
pImpVclMEdit->GetTextWindow()->SetBackground();
pImpVclMEdit->GetTextWindow()->SetControlBackground();
SetBackground();
@@ -1016,12 +1063,12 @@ void VclMultiLineEdit::ImplInitSettings( bool /*bFont*/, bool /*bForeground*/, b
}
else
{
- if( IsControlBackground() )
- pImpVclMEdit->GetTextWindow()->SetBackground( GetControlBackground() );
+ if (IsControlBackground())
+ pImpVclMEdit->GetTextWindow()->SetBackground(GetControlBackground());
else
- pImpVclMEdit->GetTextWindow()->SetBackground( rStyleSettings.GetFieldColor() );
+ pImpVclMEdit->GetTextWindow()->SetBackground(rStyleSettings.GetFieldColor());
// also adjust for VclMultiLineEdit as the TextComponent might hide Scrollbars
- SetBackground( pImpVclMEdit->GetTextWindow()->GetBackground() );
+ SetBackground(pImpVclMEdit->GetTextWindow()->GetBackground());
}
}
}