From b4bbb5e5d7b31caad2fbcc00382ad27df3c81001 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sun, 17 May 2015 22:56:46 +0900 Subject: 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 --- svtools/source/brwbox/datwin.cxx | 38 +++++------------ svtools/source/brwbox/editbrowsebox.cxx | 31 +++----------- svtools/source/contnr/imivctl1.cxx | 29 +++++++------ svtools/source/contnr/ivctrl.cxx | 13 +++--- svtools/source/contnr/treelistbox.cxx | 36 ++++++++++++---- svtools/source/control/calendar.cxx | 15 +++++-- svtools/source/control/headbar.cxx | 45 +++++++++---------- svtools/source/control/ruler.cxx | 64 +++++++++++++++------------- svtools/source/control/tabbar.cxx | 27 +++++------- svtools/source/control/toolbarmenu.cxx | 7 +-- svtools/source/control/valueset.cxx | 46 +++++++++++--------- svtools/source/toolpanel/toolpaneldrawer.cxx | 24 ++++------- svtools/source/toolpanel/toolpaneldrawer.hxx | 4 +- 13 files changed, 184 insertions(+), 195 deletions(-) (limited to 'svtools') diff --git a/svtools/source/brwbox/datwin.cxx b/svtools/source/brwbox/datwin.cxx index e3dfa380cd21..74f2f25c4ac7 100644 --- a/svtools/source/brwbox/datwin.cxx +++ b/svtools/source/brwbox/datwin.cxx @@ -257,36 +257,18 @@ void BrowserDataWin::LeaveUpdateLock() } } - -void InitSettings_Impl( vcl::Window *pWin, - bool bFont, bool bForeground, bool bBackground ) +void InitSettings_Impl(vcl::Window* pWin, bool bFont, bool bForeground, bool bBackground) { - const StyleSettings& rStyleSettings = - pWin->GetSettings().GetStyleSettings(); + const StyleSettings& rStyleSettings = pWin->GetSettings().GetStyleSettings(); - if ( bFont ) - { - vcl::Font aFont = rStyleSettings.GetFieldFont(); - if ( pWin->IsControlFont() ) - aFont.Merge( pWin->GetControlFont() ); - pWin->SetZoomedPointFont( aFont ); - } + if (bFont) + pWin->ApplyControlFont(*pWin, rStyleSettings.GetFieldFont()); - if ( bFont || bForeground ) - { - Color aTextColor = rStyleSettings.GetWindowTextColor(); - if ( pWin->IsControlForeground() ) - aTextColor = pWin->GetControlForeground(); - pWin->SetTextColor( aTextColor ); - } + if (bFont || bForeground) + pWin->ApplyControlForeground(*pWin, rStyleSettings.GetWindowTextColor()); - if ( bBackground ) - { - if( pWin->IsControlBackground() ) - pWin->SetBackground( pWin->GetControlBackground() ); - else - pWin->SetBackground( rStyleSettings.GetWindowColor() ); - } + if (bBackground) + pWin->ApplyControlBackground(*pWin, rStyleSettings.GetWindowColor()); } @@ -306,9 +288,9 @@ void BrowserDataWin::DataChanged( const DataChangedEvent& rDCEvt ) { if( !bOwnDataChangedHdl ) { - InitSettings_Impl( this, true, true, true ); + InitSettings_Impl(this, true, true, true); Invalidate(); - InitSettings_Impl( GetParent(), true, true, true ); + InitSettings_Impl(GetParent(), true, true, true); GetParent()->Invalidate(); GetParent()->Resize(); } diff --git a/svtools/source/brwbox/editbrowsebox.cxx b/svtools/source/brwbox/editbrowsebox.cxx index 31424b38570b..0c07e7c7d665 100644 --- a/svtools/source/brwbox/editbrowsebox.cxx +++ b/svtools/source/brwbox/editbrowsebox.cxx @@ -818,40 +818,21 @@ namespace svt } } - void EditBrowseBox::ImplInitSettings( bool bFont, bool bForeground, bool bBackground ) { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); if (bFont) { - vcl::Font aFont = rStyleSettings.GetFieldFont(); - if (IsControlFont()) - { - GetDataWindow().SetControlFont(GetControlFont()); - aFont.Merge(GetControlFont()); - } - else - GetDataWindow().SetControlFont(); - - GetDataWindow().SetZoomedPointFont(aFont); + GetDataWindow().ApplyControlFont(GetDataWindow(), rStyleSettings.GetFieldFont()); } - if ( bFont || bForeground ) + if (bFont || bForeground) { - Color aTextColor = rStyleSettings.GetFieldTextColor(); - if (IsControlForeground()) - { - aTextColor = GetControlForeground(); - GetDataWindow().SetControlForeground(aTextColor); - } - else - GetDataWindow().SetControlForeground(); - - GetDataWindow().SetTextColor( aTextColor ); + GetDataWindow().ApplyControlForeground(GetDataWindow(), rStyleSettings.GetFieldTextColor()); } - if ( bBackground ) + if (bBackground) // FIXME: Outside of Paint Hierarchy { if (GetDataWindow().IsControlBackground()) { @@ -862,8 +843,8 @@ namespace svt else { GetDataWindow().SetControlBackground(); - GetDataWindow().SetBackground( rStyleSettings.GetFieldColor() ); - GetDataWindow().SetFillColor( rStyleSettings.GetFieldColor() ); + GetDataWindow().SetBackground(rStyleSettings.GetFieldColor()); + GetDataWindow().SetFillColor(rStyleSettings.GetFieldColor()); } } } diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx index 0db2da34085e..64dbe4d3bf50 100644 --- a/svtools/source/contnr/imivctl1.cxx +++ b/svtools/source/contnr/imivctl1.cxx @@ -2483,20 +2483,20 @@ void SvxIconChoiceCtrl_Impl::SetDefaultTextSize() long nDY = nGridDY; nDY -= aImageSize.Height(); nDY -= VER_DIST_BMP_STRING; - nDY -= 2*TBOFFS_BOUND; - if( nDY <= 0 ) + nDY -= 2 * TBOFFS_BOUND; + if (nDY <= 0) nDY = 2; long nDX = nGridDX; - nDX -= 2*LROFFS_BOUND; + nDX -= 2 * LROFFS_BOUND; nDX -= 2; - if( nDX <= 0 ) + if (nDX <= 0) nDX = 2; long nHeight = pView->GetTextHeight(); - if( nDY < nHeight ) + if (nDY < nHeight) nDY = nHeight; - aDefaultTextSize = Size( nDX, nDY ); + aDefaultTextSize = Size(nDX, nDY); } @@ -2535,7 +2535,7 @@ void SvxIconChoiceCtrl_Impl::Scroll( long nDeltaX, long nDeltaY, bool bScrollBar const Size& SvxIconChoiceCtrl_Impl::GetItemSize( SvxIconChoiceCtrlEntry*, IcnViewFieldType eItem ) const { - if( eItem == IcnViewFieldTypeText ) + if (eItem == IcnViewFieldTypeText) return aDefaultTextSize; return aImageSize; } @@ -3153,14 +3153,15 @@ IcnViewEdit_Impl::IcnViewEdit_Impl( SvtIconChoiceCtrl* pParent, const Point& rPo bAlreadyInCallback( false ), bGrabFocus( false ) { - vcl::Font aFont( pParent->GetPointFont() ); + // FIXME: Outside of Paint Hierarchy + vcl::Font aFont(pParent->GetPointFont(*this)); aFont.SetTransparent( false ); - SetControlFont( aFont ); - SetControlBackground( aFont.GetFillColor() ); - SetControlForeground( aFont.GetColor() ); - SetPosPixel( rPos ); - SetSizePixel( CalcAdjustedSize(rSize) ); - SetText( rData ); + SetControlFont(aFont); + SetControlBackground(aFont.GetFillColor()); + SetControlForeground(aFont.GetColor()); + SetPosPixel(rPos); + SetSizePixel(CalcAdjustedSize(rSize)); + SetText(rData); SaveValue(); aAccReturn.InsertItem( IMPICNVIEW_ACC_RETURN, vcl::KeyCode(KEY_RETURN) ); diff --git a/svtools/source/contnr/ivctrl.cxx b/svtools/source/contnr/ivctrl.cxx index fe721c4f939f..56fff117da27 100644 --- a/svtools/source/contnr/ivctrl.cxx +++ b/svtools/source/contnr/ivctrl.cxx @@ -221,23 +221,24 @@ void SvtIconChoiceCtrl::LoseFocus() Control::LoseFocus(); } -void SvtIconChoiceCtrl::SetFont( const vcl::Font& rFont ) +void SvtIconChoiceCtrl::SetFont(const vcl::Font& rFont) { - if( rFont != GetFont() ) + if (rFont != GetFont()) { - Control::SetFont( rFont ); + Control::SetFont(rFont); _pImp->FontModified(); } } -void SvtIconChoiceCtrl::SetPointFont( const vcl::Font& rFont ) +void SvtIconChoiceCtrl::SetPointFont(const vcl::Font& rFont) { - if( rFont != GetPointFont() ) + if (rFont != GetPointFont(*this)) //FIXME { - Control::SetPointFont( rFont ); + Control::SetPointFont(*this, rFont); //FIXME _pImp->FontModified(); } } + SvxIconChoiceCtrlEntry* SvtIconChoiceCtrl::GetEntry( const Point& rPixPos, bool bHit ) const { Point aPos( rPixPos ); diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx index aba60a71bf5d..b6d18de66122 100644 --- a/svtools/source/contnr/treelistbox.cxx +++ b/svtools/source/contnr/treelistbox.cxx @@ -3779,30 +3779,48 @@ void SvTreeListBox::StateChanged( StateChangedType eType ) ImplInitStyle(); } +void SvTreeListBox::ApplySettings(vcl::RenderContext& rRenderContext) +{ + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + vcl::Font aFont; + aFont = rStyleSettings.GetFieldFont(); + aFont.SetColor(rStyleSettings.GetWindowTextColor()); + SetPointFont(rRenderContext, aFont); + AdjustEntryHeightAndRecalc(aFont); + + rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor()); + rRenderContext.SetTextFillColor(); + rRenderContext.SetBackground(rStyleSettings.GetFieldColor()); + + // always try to re-create default-SvLBoxButtonData + if (pCheckButtonData && pCheckButtonData->HasDefaultImages()) + pCheckButtonData->SetDefaultImages(this); +} + void SvTreeListBox::InitSettings(bool bFont, bool bForeground, bool bBackground) { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - if( bFont ) + if (bFont) { vcl::Font aFont; aFont = rStyleSettings.GetFieldFont(); - aFont.SetColor( rStyleSettings.GetWindowTextColor() ); - SetPointFont( aFont ); - AdjustEntryHeightAndRecalc( aFont ); + aFont.SetColor(rStyleSettings.GetWindowTextColor()); + SetPointFont(*this, aFont); + AdjustEntryHeightAndRecalc(aFont); } - if( bForeground || bFont ) + if (bForeground || bFont) { - SetTextColor( rStyleSettings.GetFieldTextColor() ); + SetTextColor(rStyleSettings.GetFieldTextColor()); SetTextFillColor(); } - if( bBackground ) - SetBackground( rStyleSettings.GetFieldColor() ); + if (bBackground) + SetBackground(rStyleSettings.GetFieldColor()); // always try to re-create default-SvLBoxButtonData if( pCheckButtonData && pCheckButtonData->HasDefaultImages() ) - pCheckButtonData->SetDefaultImages( this ); + pCheckButtonData->SetDefaultImages(this); } bool SvTreeListBox::IsCellFocusEnabled() const 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); } } diff --git a/svtools/source/toolpanel/toolpaneldrawer.cxx b/svtools/source/toolpanel/toolpaneldrawer.cxx index 4b986a635aa5..0ce9851ea5e7 100644 --- a/svtools/source/toolpanel/toolpaneldrawer.cxx +++ b/svtools/source/toolpanel/toolpaneldrawer.cxx @@ -246,6 +246,13 @@ namespace svt (void)i_rMouseEvent; } + void ToolPanelDrawer::ApplySettings(vcl::RenderContext& rRenderContext) + { + const StyleSettings& rStyleSettings(rRenderContext.GetSettings().GetStyleSettings()); + ApplyControlFont(rRenderContext, rStyleSettings.GetAppFont()); + ApplyControlForeground(rRenderContext, rStyleSettings.GetButtonTextColor()); + rRenderContext.SetTextFillColor(); + } void ToolPanelDrawer::DataChanged( const DataChangedEvent& i_rEvent ) { @@ -265,22 +272,9 @@ namespace svt case DataChangedEventType::FONTSUBSTITUTION: { const StyleSettings& rStyleSettings( GetSettings().GetStyleSettings() ); - - // Font. - vcl::Font aFont = rStyleSettings.GetAppFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); - - // Color. - Color aColor; - if ( IsControlForeground() ) - aColor = GetControlForeground(); - else - aColor = rStyleSettings.GetButtonTextColor(); - SetTextColor( aColor ); + ApplyControlFont(*this, rStyleSettings.GetAppFont()); + ApplyControlForeground(*this, rStyleSettings.GetButtonTextColor()); SetTextFillColor(); - Invalidate(); } break; diff --git a/svtools/source/toolpanel/toolpaneldrawer.hxx b/svtools/source/toolpanel/toolpaneldrawer.hxx index 6fd17cf2a448..403b296c9957 100644 --- a/svtools/source/toolpanel/toolpaneldrawer.hxx +++ b/svtools/source/toolpanel/toolpaneldrawer.hxx @@ -64,7 +64,7 @@ namespace svt return m_bExpanded; } - void Paint(vcl::RenderContext& rRenderContext); + void Paint(vcl::RenderContext& rRenderContext); protected: // Window overridables @@ -77,6 +77,8 @@ namespace svt virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > GetComponentInterface( bool i_bCreate ) SAL_OVERRIDE; + virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE; + private: Rectangle impl_calcTextBoundingBox() const; Rectangle impl_calcTitleBarBox( const Rectangle& i_rTextBox ) const; -- cgit v1.2.3