diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-05-17 22:56:46 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-05-18 11:22:49 +0900 |
commit | b4bbb5e5d7b31caad2fbcc00382ad27df3c81001 (patch) | |
tree | 8ac345712ff92a9b33a7d54651ed27ad88f1ec67 /svtools/source/control | |
parent | 2ca7795a6a723c701f295323fcc3f6c52ad37976 (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 'svtools/source/control')
-rw-r--r-- | svtools/source/control/calendar.cxx | 15 | ||||
-rw-r--r-- | svtools/source/control/headbar.cxx | 45 | ||||
-rw-r--r-- | svtools/source/control/ruler.cxx | 64 | ||||
-rw-r--r-- | svtools/source/control/tabbar.cxx | 27 | ||||
-rw-r--r-- | svtools/source/control/toolbarmenu.cxx | 7 | ||||
-rw-r--r-- | svtools/source/control/valueset.cxx | 46 |
6 files changed, 107 insertions, 97 deletions
diff --git a/svtools/source/control/calendar.cxx b/svtools/source/control/calendar.cxx index 24f5e6af169f..ffd68d62ff7f 100644 --- a/svtools/source/control/calendar.cxx +++ b/svtools/source/control/calendar.cxx @@ -213,13 +213,22 @@ void Calendar::ImplInit( WinBits nWinStyle ) ImplInitSettings(); } +void Calendar::ApplySettings(vcl::RenderContext& rRenderContext) +{ + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + maSelColor = rStyleSettings.GetHighlightTextColor(); + SetPointFont(rRenderContext, rStyleSettings.GetToolFont()); + rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor()); + rRenderContext.SetBackground(Wallpaper(rStyleSettings.GetFieldColor())); +} + void Calendar::ImplInitSettings() { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); maSelColor = rStyleSettings.GetHighlightTextColor(); - SetPointFont( rStyleSettings.GetToolFont() ); - SetTextColor( rStyleSettings.GetFieldTextColor() ); - SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) ); + SetPointFont(*this, rStyleSettings.GetToolFont()); + SetTextColor(rStyleSettings.GetFieldTextColor()); + SetBackground(Wallpaper(rStyleSettings.GetFieldColor())); } Calendar::Calendar( vcl::Window* pParent, WinBits nWinStyle ) : diff --git a/svtools/source/control/headbar.cxx b/svtools/source/control/headbar.cxx index 6d4be8b36188..f34884213e71 100644 --- a/svtools/source/control/headbar.cxx +++ b/svtools/source/control/headbar.cxx @@ -121,40 +121,33 @@ void HeaderBar::dispose() Window::dispose(); } -void HeaderBar::ImplInitSettings( bool bFont, - bool bForeground, bool bBackground ) +void HeaderBar::ApplySettings(vcl::RenderContext& rRenderContext) { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - if ( bFont ) - { - vcl::Font aFont; - aFont = rStyleSettings.GetToolFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); - } + ApplyControlFont(rRenderContext, rStyleSettings.GetToolFont()); - if ( bForeground || bFont ) + ApplyControlForeground(rRenderContext, rStyleSettings.GetButtonTextColor()); + SetTextFillColor(); + + ApplyControlBackground(rRenderContext, rStyleSettings.GetFaceColor()); +} + +void HeaderBar::ImplInitSettings(bool bFont, bool bForeground, bool bBackground) +{ + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + + if (bFont) + ApplyControlFont(*this, rStyleSettings.GetToolFont()); + + if (bForeground || bFont) { - Color aColor; - if ( IsControlForeground() ) - aColor = GetControlForeground(); - else - aColor = rStyleSettings.GetButtonTextColor(); - SetTextColor( aColor ); + ApplyControlForeground(*this, rStyleSettings.GetButtonTextColor()); SetTextFillColor(); } - if ( bBackground ) - { - Color aColor; - if ( IsControlBackground() ) - aColor = GetControlBackground(); - else - aColor = rStyleSettings.GetFaceColor(); - SetBackground( aColor ); - } + if (bBackground) + ApplyControlBackground(*this, rStyleSettings.GetFaceColor()); } long HeaderBar::ImplGetItemPos( sal_uInt16 nPos ) const diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx index 35d5be2ca6aa..b6ff5aaf9ae4 100644 --- a/svtools/source/control/ruler.cxx +++ b/svtools/source/control/ruler.cxx @@ -1045,58 +1045,64 @@ static int adjustSize(int nOrig) return ( (3*nOrig) / 8) * 2 + 1; } -void Ruler::ImplInitSettings( bool bFont, bool bForeground, bool bBackground ) +void Ruler::ApplySettings(vcl::RenderContext& rRenderContext) +{ + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + + vcl::Font aFont = rStyleSettings.GetToolFont(); + // make the font a bit smaller than default + Size aSize(adjustSize(aFont.GetSize().Width()), adjustSize(aFont.GetSize().Height())); + aFont.SetSize(aSize); + + ApplyControlFont(rRenderContext, aFont); + + ApplyControlForeground(*this, rStyleSettings.GetDarkShadowColor()); + SetTextFillColor(); + + Color aColor; + svtools::ColorConfig aColorConfig; + aColor = Color(aColorConfig.GetColorValue(svtools::APPBACKGROUND).nColor); + ApplyControlBackground(rRenderContext, aColor); +} + +void Ruler::ImplInitSettings(bool bFont, bool bForeground, bool bBackground) { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - if ( bFont ) + if (bFont) { - vcl::Font aFont; - aFont = rStyleSettings.GetToolFont(); - + vcl::Font aFont = rStyleSettings.GetToolFont(); // make the font a bit smaller than default Size aSize(adjustSize(aFont.GetSize().Width()), adjustSize(aFont.GetSize().Height())); aFont.SetSize(aSize); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); + ApplyControlFont(*this, aFont); } - if ( bForeground || bFont ) + if (bForeground || bFont) { - Color aColor; - if ( IsControlForeground() ) - aColor = GetControlForeground(); - else - aColor = rStyleSettings.GetDarkShadowColor(); - SetTextColor( aColor ); + ApplyControlForeground(*this, rStyleSettings.GetDarkShadowColor()); SetTextFillColor(); } - if ( bBackground ) + if (bBackground) { Color aColor; - if ( IsControlBackground() ) - aColor = GetControlBackground(); - else - { - svtools::ColorConfig aColorConfig; - aColor = Color( aColorConfig.GetColorValue( svtools::APPBACKGROUND ).nColor ); - } - SetBackground( aColor ); + svtools::ColorConfig aColorConfig; + aColor = Color(aColorConfig.GetColorValue(svtools::APPBACKGROUND).nColor); + ApplyControlBackground(*this, aColor); } maVirDev->SetSettings( GetSettings() ); maVirDev->SetBackground( GetBackground() ); vcl::Font aFont = GetFont(); - if ( mnWinStyle & WB_VERT ) - aFont.SetOrientation( 900 ); + if (mnWinStyle & WB_VERT) + aFont.SetOrientation(900); - maVirDev->SetFont( aFont ); - maVirDev->SetTextColor( GetTextColor() ); - maVirDev->SetTextFillColor( GetTextFillColor() ); + maVirDev->SetFont(aFont); + maVirDev->SetTextColor(GetTextColor()); + maVirDev->SetTextFillColor(GetTextFillColor()); } void Ruler::ImplCalc() diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index 0b8ca9eaf132..291786f43ca8 100644 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -625,36 +625,31 @@ ImplTabBarItem* TabBar::next() void TabBar::ImplInitSettings( bool bFont, bool bBackground ) { + // FIXME RenderContext + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - if ( bFont ) + if (bFont) { vcl::Font aToolFont; aToolFont = rStyleSettings.GetToolFont(); - if ( IsControlFont() ) - aToolFont.Merge( GetControlFont() ); aToolFont.SetWeight( WEIGHT_BOLD ); - SetZoomedPointFont( aToolFont ); + ApplyControlFont(*this, aToolFont); // Adapt font size if window too small? - while ( GetTextHeight() > (GetOutputSizePixel().Height()-1) ) + while (GetTextHeight() > (GetOutputSizePixel().Height() - 1)) { vcl::Font aFont = GetFont(); - if ( aFont.GetHeight() <= 6 ) + if (aFont.GetHeight() <= 6) break; - aFont.SetHeight( aFont.GetHeight()-1 ); - SetFont( aFont ); + aFont.SetHeight(aFont.GetHeight() - 1); + SetFont(aFont); } } - if ( bBackground ) + if (bBackground) { - Color aColor; - if ( IsControlBackground() ) - aColor = GetControlBackground(); - else - aColor = rStyleSettings.GetFaceColor(); - SetBackground( aColor ); + ApplyControlBackground(*this, rStyleSettings.GetFaceColor()); } } @@ -2173,7 +2168,7 @@ bool TabBar::StartEditMode(sal_uInt16 nPageId) } mpImpl->mpEdit->SetText(GetPageText(mnEditId)); mpImpl->mpEdit->setPosSizePixel(nX, aRect.Top() + mnOffY + 1, nWidth, aRect.GetHeight() - 3); - vcl::Font aFont = GetPointFont(); + vcl::Font aFont = GetPointFont(*this); // FIXME RenderContext Color aForegroundColor; Color aBackgroundColor; diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx index ab7da47123be..bb9d1a3325ee 100644 --- a/svtools/source/control/toolbarmenu.cxx +++ b/svtools/source/control/toolbarmenu.cxx @@ -567,9 +567,10 @@ void ToolbarMenu::initWindow() { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - SetPointFont( rStyleSettings.GetMenuFont() ); - SetBackground( Wallpaper( GetControlBackground() ) ); - SetTextColor( rStyleSettings.GetMenuTextColor() ); + // FIXME RenderContext + SetPointFont(*this, rStyleSettings.GetMenuFont()); + SetBackground(Wallpaper(GetControlBackground())); + SetTextColor(rStyleSettings.GetMenuTextColor()); SetTextFillColor(); SetLineColor(); diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index b2c84dde2f39..a3398c9d9689 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -161,42 +161,48 @@ void ValueSet::ImplDeleteItems() mItemList.clear(); } -void ValueSet::ImplInitSettings( bool bFont, bool bForeground, bool bBackground ) +void ValueSet::ApplySettings(vcl::RenderContext& rRenderContext) +{ + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + + ApplyControlFont(rRenderContext, rStyleSettings.GetAppFont()); + ApplyControlForeground(rRenderContext, rStyleSettings.GetButtonTextColor()); + SetTextFillColor(); + Color aColor; + if (GetStyle() & WB_MENUSTYLEVALUESET) + aColor = rStyleSettings.GetMenuColor(); + else if (IsEnabled() && (GetStyle() & WB_FLATVALUESET)) + aColor = rStyleSettings.GetWindowColor(); + else + aColor = rStyleSettings.GetFaceColor(); + ApplyControlBackground(rRenderContext, aColor); +} + +void ValueSet::ImplInitSettings(bool bFont, bool bForeground, bool bBackground) { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - if ( bFont ) + if (bFont) { - vcl::Font aFont; - aFont = rStyleSettings.GetAppFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); + ApplyControlFont(*this, rStyleSettings.GetAppFont()); } - if ( bForeground || bFont ) + if (bForeground || bFont) { - Color aColor; - if ( IsControlForeground() ) - aColor = GetControlForeground(); - else - aColor = rStyleSettings.GetButtonTextColor(); - SetTextColor( aColor ); + ApplyControlForeground(*this, rStyleSettings.GetButtonTextColor()); SetTextFillColor(); } - if ( bBackground ) + if (bBackground) { Color aColor; - if ( IsControlBackground() ) - aColor = GetControlBackground(); - else if ( GetStyle() & WB_MENUSTYLEVALUESET ) + if (GetStyle() & WB_MENUSTYLEVALUESET) aColor = rStyleSettings.GetMenuColor(); - else if ( IsEnabled() && (GetStyle() & WB_FLATVALUESET) ) + else if (IsEnabled() && (GetStyle() & WB_FLATVALUESET)) aColor = rStyleSettings.GetWindowColor(); else aColor = rStyleSettings.GetFaceColor(); - SetBackground( aColor ); + ApplyControlBackground(*this, aColor); } } |