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 /vcl | |
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 'vcl')
-rw-r--r-- | vcl/Library_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/inc/ilstbox.hxx | 11 | ||||
-rw-r--r-- | vcl/inc/window.h | 33 | ||||
-rw-r--r-- | vcl/source/app/help.cxx | 3 | ||||
-rw-r--r-- | vcl/source/control/ctrl.cxx | 20 | ||||
-rw-r--r-- | vcl/source/control/edit.cxx | 58 | ||||
-rw-r--r-- | vcl/source/control/ilstbox.cxx | 126 | ||||
-rw-r--r-- | vcl/source/control/lstbox.cxx | 2 | ||||
-rw-r--r-- | vcl/source/edit/vclmedit.cxx | 89 | ||||
-rw-r--r-- | vcl/source/outdev/outdevstate.cxx | 5 | ||||
-rw-r--r-- | vcl/source/outdev/rendersettings.cxx | 59 | ||||
-rw-r--r-- | vcl/source/window/brdwin.cxx | 17 | ||||
-rw-r--r-- | vcl/source/window/dockingarea.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/menubarwindow.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/menuwindow.cxx | 5 | ||||
-rw-r--r-- | vcl/source/window/paint.cxx | 32 | ||||
-rw-r--r-- | vcl/source/window/printdlg.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/status.cxx | 53 | ||||
-rw-r--r-- | vcl/source/window/toolbox.cxx | 99 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 110 | ||||
-rw-r--r-- | vcl/source/window/window2.cxx | 134 |
21 files changed, 605 insertions, 260 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index a174b0dc2c40..7c99bed96ec3 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -241,6 +241,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/outdev/textline \ vcl/source/outdev/pixel \ vcl/source/outdev/rect \ + vcl/source/outdev/rendersettings \ vcl/source/outdev/line \ vcl/source/outdev/polyline \ vcl/source/outdev/hatch \ diff --git a/vcl/inc/ilstbox.hxx b/vcl/inc/ilstbox.hxx index da69ac82f425..f019b699932e 100644 --- a/vcl/inc/ilstbox.hxx +++ b/vcl/inc/ilstbox.hxx @@ -359,8 +359,6 @@ public: void SetReadOnly( bool bReadOnly ) { mbReadOnly = bReadOnly; } bool IsReadOnly() const { return mbReadOnly; } - using Control::ImplInitSettings; - void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); sal_uInt16 ImplGetTextStyle() const; /// pb: #106948# explicit mirroring for calc @@ -371,6 +369,10 @@ public: void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; } void EnableQuickSelection( const bool& b ); + using Control::ImplInitSettings; + void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); + virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE; + protected: // ISearchableStringList virtual vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const SAL_OVERRIDE; @@ -602,6 +604,11 @@ public: void SetEdgeBlending(bool bNew) { mbEdgeBlending = bNew; } virtual void ShowFocus(const Rectangle& rRect) SAL_OVERRIDE; + + using Control::ImplInitSettings; + void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); + virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE; + }; class ImplBtn : public PushButton diff --git a/vcl/inc/window.h b/vcl/inc/window.h index a2066d4bf5b0..d73f3e10a3bc 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -36,14 +36,19 @@ #include <vcl/idle.hxx> #include <vcl/vclevent.hxx> #include <vcl/vclptr.hxx> +#include <vcl/rendersettings.hxx> #include <vector> struct SalPaintEvent; struct ImplDelData; struct ImplAccessibleInfos; +namespace vcl { + class Window; + struct ControlLayoutData; +} + class FixedText; -namespace vcl { class Window; } class VclSizeGroup; class VirtualDevice; class PhysicalFontCollection; @@ -54,23 +59,16 @@ class SalObject; enum class MouseEventModifiers; enum class MouseNotifyEvent; -namespace com { -namespace sun { -namespace star { +namespace com { namespace sun { namespace star { + namespace accessibility { class XAccessible; -}}}} +} -namespace com { -namespace sun { -namespace star { namespace rendering { class XCanvas; -}}}} +} -namespace com { -namespace sun { -namespace star { namespace awt { class XWindowPeer; class XWindow; @@ -79,8 +77,7 @@ namespace uno { class Any; class XInterface; } -namespace datatransfer { -namespace clipboard { +namespace datatransfer { namespace clipboard { class XClipboard; } @@ -89,11 +86,7 @@ namespace dnd { class XDragGestureRecognizer; class XDragSource; class XDropTarget; -} } } } } - -namespace vcl { - struct ControlLayoutData; -} +}}}}} bool ImplWindowFrameProc( vcl::Window* pInst, SalFrame* pFrame, sal_uInt16 nEvent, const void* pEvent ); @@ -377,6 +370,8 @@ public: mbSecondary:1, mbNonHomogeneous:1; + vcl::RenderSettings maRenderSettings; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > mxDNDListenerContainer; }; diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx index 7c4867310f06..f9d02fc01e43 100644 --- a/vcl/source/app/help.cxx +++ b/vcl/source/app/help.cxx @@ -250,8 +250,9 @@ HelpTextWindow::HelpTextWindow( vcl::Window* pParent, const OUString& rText, sal // EnableAlwaysOnTop(); EnableSaveBackground(); + // FIXME RenderContext const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - SetPointFont( rStyleSettings.GetHelpFont() ); + SetPointFont(*this, rStyleSettings.GetHelpFont()); SetTextColor( rStyleSettings.GetHelpTextColor() ); SetTextAlign( ALIGN_TOP ); if ( IsNativeControlSupported( CTRL_TOOLTIP, PART_ENTIRE_CONTROL ) ) diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx index e74dc8fe6821..04c94554d14c 100644 --- a/vcl/source/control/ctrl.cxx +++ b/vcl/source/control/ctrl.cxx @@ -418,6 +418,18 @@ const Color& Control::GetCanonicalTextColor( const StyleSettings& _rStyle ) cons return _rStyle.GetLabelTextColor(); } +void Control::ApplySettings(vcl::RenderContext& rRenderContext) +{ + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + + vcl::Font rFont(GetCanonicalFont(rStyleSettings)); + ApplyControlFont(rRenderContext, rFont); + + ApplyControlForeground(rRenderContext, GetCanonicalTextColor(rStyleSettings)); + + rRenderContext.SetTextFillColor(); +} + void Control::ImplInitSettings( const bool _bFont, const bool _bForeground ) { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); @@ -427,7 +439,7 @@ void Control::ImplInitSettings( const bool _bFont, const bool _bForeground ) Font aFont(GetCanonicalFont(rStyleSettings)); if (IsControlFont()) aFont.Merge(GetControlFont()); - SetZoomedPointFont( aFont ); + SetZoomedPointFont(*this, aFont); } if (_bForeground || _bFont) @@ -460,9 +472,9 @@ void Control::DrawControlText( OutputDevice& _rTargetDevice, Rectangle& _io_rRec Font Control::GetUnzoomedControlPointFont() const { - Font aFont( GetCanonicalFont( GetSettings().GetStyleSettings() ) ); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); + Font aFont(GetCanonicalFont(GetSettings().GetStyleSettings())); + if (IsControlFont()) + aFont.Merge(GetControlFont()); return aFont; } diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 227c7fe63cb4..9449e49f9c2c 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -394,44 +394,70 @@ void Edit::ImplModified() Modify(); } -void Edit::ImplInitSettings( bool bFont, bool bForeground, bool bBackground ) +void Edit::ApplySettings(vcl::RenderContext& rRenderContext) +{ + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + + vcl::Font aFont = rStyleSettings.GetFieldFont(); + ApplyControlFont(rRenderContext, aFont); + + ImplClearLayoutData(); + + Color aTextColor = rStyleSettings.GetFieldTextColor(); + ApplyControlForeground(rRenderContext, aTextColor); + + if (ImplUseNativeBorder(GetStyle()) || IsPaintTransparent()) + { + // Transparent background + rRenderContext.SetBackground(); + rRenderContext.SetFillColor(); + } + else if (IsControlBackground()) + { + rRenderContext.SetBackground(GetControlBackground()); + rRenderContext.SetFillColor(GetControlBackground()); + } + else + { + rRenderContext.SetBackground(rStyleSettings.GetFieldColor()); + rRenderContext.SetFillColor(rStyleSettings.GetFieldColor()); + } +} + +void Edit::ImplInitSettings(bool bFont, bool bForeground, bool bBackground) { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - if ( bFont ) + if (bFont) { vcl::Font aFont = rStyleSettings.GetFieldFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); + ApplyControlFont(*this, aFont); ImplClearLayoutData(); } - if ( bFont || bForeground ) + if (bFont || bForeground) { Color aTextColor = rStyleSettings.GetFieldTextColor(); - if ( IsControlForeground() ) - aTextColor = GetControlForeground(); - SetTextColor( aTextColor ); + ApplyControlForeground(*this, aTextColor); } - if ( bBackground ) + if (bBackground) { - if ( ImplUseNativeBorder( GetStyle() ) || IsPaintTransparent() ) + if (ImplUseNativeBorder(GetStyle()) || IsPaintTransparent()) { // Transparent background SetBackground(); SetFillColor(); } - else if ( IsControlBackground() ) + else if (IsControlBackground()) { - SetBackground( GetControlBackground() ); - SetFillColor( GetControlBackground() ); + SetBackground(GetControlBackground()); + SetFillColor(GetControlBackground()); } else { - SetBackground( rStyleSettings.GetFieldColor() ); - SetFillColor( rStyleSettings.GetFieldColor() ); + SetBackground(rStyleSettings.GetFieldColor()); + SetFillColor(rStyleSettings.GetFieldColor()); } } } diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx index 296e923671ca..40bba26acc1c 100644 --- a/vcl/source/control/ilstbox.cxx +++ b/vcl/source/control/ilstbox.cxx @@ -47,35 +47,6 @@ using namespace ::com::sun::star; -void ImplInitFieldSettings( vcl::Window* pWin, bool bFont, bool bForeground, bool bBackground ) -{ - 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 || bForeground ) - { - Color aTextColor = rStyleSettings.GetFieldTextColor(); - if ( pWin->IsControlForeground() ) - aTextColor = pWin->GetControlForeground(); - pWin->SetTextColor( aTextColor ); - } - - if ( bBackground ) - { - if( pWin->IsControlBackground() ) - pWin->SetBackground( pWin->GetControlBackground() ); - else - pWin->SetBackground( rStyleSettings.GetFieldColor() ); - } -} - void ImplInitDropDownButton( PushButton* pButton ) { if ( pButton->GetSettings().GetStyleSettings().GetOptions() & STYLE_OPTION_SPINUPDOWN ) @@ -546,9 +517,53 @@ void ImplListBoxWindow::dispose() Control::dispose(); } -void ImplListBoxWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackground ) +void ImplListBoxWindow::ApplySettings(vcl::RenderContext& rRenderContext) { - ImplInitFieldSettings( this, bFont, bForeground, bBackground ); + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + + vcl::Font aFont = rStyleSettings.GetFieldFont(); + if (IsControlFont()) + aFont.Merge(GetControlFont()); + SetZoomedPointFont(rRenderContext, aFont); + + Color aTextColor = rStyleSettings.GetFieldTextColor(); + if (IsControlForeground()) + aTextColor = GetControlForeground(); + rRenderContext.SetTextColor(aTextColor); + + if (IsControlBackground()) + rRenderContext.SetBackground(GetControlBackground()); + else + rRenderContext.SetBackground(rStyleSettings.GetFieldColor()); +} + +void ImplListBoxWindow::ImplInitSettings(bool bFont, bool bForeground, bool bBackground) +{ + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + + if (bFont) + { + vcl::Font aFont = rStyleSettings.GetFieldFont(); + if (IsControlFont()) + aFont.Merge(GetControlFont()); + SetZoomedPointFont(*this, aFont); + } + + if (bFont || bForeground) + { + Color aTextColor = rStyleSettings.GetFieldTextColor(); + if (IsControlForeground()) + aTextColor = GetControlForeground(); + SetTextColor( aTextColor ); + } + + if (bBackground) + { + if (IsControlBackground()) + SetBackground(GetControlBackground()); + else + SetBackground(rStyleSettings.GetFieldColor()); + } } void ImplListBoxWindow::ImplCalcMetrics() @@ -2770,6 +2785,55 @@ void ImplWin::ImplDraw( bool bLayout ) } } +void ImplWin::ApplySettings(vcl::RenderContext& rRenderContext) +{ + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + + vcl::Font aFont = rStyleSettings.GetFieldFont(); + if (IsControlFont()) + aFont.Merge(GetControlFont()); + SetZoomedPointFont(rRenderContext, aFont); + + Color aTextColor = rStyleSettings.GetFieldTextColor(); + if (IsControlForeground()) + aTextColor = GetControlForeground(); + rRenderContext.SetTextColor(aTextColor); + + if (IsControlBackground()) + rRenderContext.SetBackground(GetControlBackground()); + else + rRenderContext.SetBackground(rStyleSettings.GetFieldColor()); +} + +void ImplWin::ImplInitSettings(bool bFont, bool bForeground, bool bBackground) +{ + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + + if (bFont) + { + vcl::Font aFont = rStyleSettings.GetFieldFont(); + if (IsControlFont()) + aFont.Merge(GetControlFont()); + SetZoomedPointFont(*this, aFont); + } + + if (bFont || bForeground) + { + Color aTextColor = rStyleSettings.GetFieldTextColor(); + if (IsControlForeground()) + aTextColor = GetControlForeground(); + SetTextColor( aTextColor ); + } + + if (bBackground) + { + if (IsControlBackground()) + SetBackground(GetControlBackground()); + else + SetBackground(rStyleSettings.GetFieldColor()); + } +} + void ImplWin::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& ) { ImplDraw(); diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx index 2c3566b89ade..9f582144e0c0 100644 --- a/vcl/source/control/lstbox.cxx +++ b/vcl/source/control/lstbox.cxx @@ -551,7 +551,7 @@ void ListBox::DataChanged( const DataChangedEvent& rDCEvt ) if ( mpImplWin ) { mpImplWin->SetSettings( GetSettings() ); // If not yet set... - ImplInitFieldSettings( mpImplWin, true, true, true ); + mpImplWin->ImplInitSettings(true, true, true); mpBtn->SetSettings( GetSettings() ); ImplInitDropDownButton( mpBtn ); 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()); } } } diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx index bc6bd4a8b6c9..155efed74888 100644 --- a/vcl/source/outdev/outdevstate.cxx +++ b/vcl/source/outdev/outdevstate.cxx @@ -39,6 +39,11 @@ #include "salgdi.hxx" #include "sallayout.hxx" +OutDevState::OutDevState() : + mnFlags(PushFlags::NONE) +{ +} + OutDevState::~OutDevState() { if ( mnFlags & PushFlags::LINECOLOR ) diff --git a/vcl/source/outdev/rendersettings.cxx b/vcl/source/outdev/rendersettings.cxx new file mode 100644 index 000000000000..fd2524d8858a --- /dev/null +++ b/vcl/source/outdev/rendersettings.cxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#include <vcl/rendersettings.hxx> + +namespace vcl +{ + +void RenderSettings::SetLineColor(const Color& rColor) +{ + maOutDevState.mpLineColor = new Color(rColor); + maOutDevState.mnFlags |= PushFlags::LINECOLOR; +} + +void RenderSettings::SetFillColor(const Color& rColor) +{ + maOutDevState.mpFillColor = new Color(rColor); + maOutDevState.mnFlags |= PushFlags::FILLCOLOR; +} + +void RenderSettings::SetFont(const vcl::Font& rNewFont) +{ + maOutDevState.mpFont = new vcl::Font(rNewFont); + maOutDevState.mnFlags |= PushFlags::FONT; +} + +void RenderSettings::SetBackground(const Wallpaper& rBackground) +{ + mpBackground.reset(new Wallpaper(rBackground)); +} + +void RenderSettings::PushAndApply(vcl::RenderContext& rRenderContext) +{ + rRenderContext.Push(maOutDevState.mnFlags); + Apply(rRenderContext); +} + +void RenderSettings::Apply(vcl::RenderContext& rRenderContext) +{ + if (maOutDevState.mnFlags & PushFlags::LINECOLOR) + rRenderContext.SetLineColor(*maOutDevState.mpLineColor); + if (maOutDevState.mnFlags & PushFlags::FILLCOLOR) + rRenderContext.SetFillColor(*maOutDevState.mpFillColor); + if (maOutDevState.mnFlags & PushFlags::FONT) + rRenderContext.SetFont(*maOutDevState.mpFont); + if (mpBackground) + rRenderContext.SetBackground(Wallpaper(*mpBackground.get())); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx index 06a28c0bccbc..d68c2e1e9aa8 100644 --- a/vcl/source/window/brdwin.cxx +++ b/vcl/source/window/brdwin.cxx @@ -175,7 +175,7 @@ Rectangle ImplBorderWindowView::GetMenuRect() const return Rectangle(); } -void ImplBorderWindowView::ImplInitTitle( ImplBorderFrameData* pData ) +void ImplBorderWindowView::ImplInitTitle(ImplBorderFrameData* pData) { ImplBorderWindow* pBorderWindow = pData->mpBorderWindow; @@ -188,22 +188,23 @@ void ImplBorderWindowView::ImplInitTitle( ImplBorderFrameData* pData ) else { const StyleSettings& rStyleSettings = pData->mpOutDev->GetSettings().GetStyleSettings(); - if ( pData->mnTitleType == BORDERWINDOW_TITLE_TEAROFF ) + if (pData->mnTitleType == BORDERWINDOW_TITLE_TEAROFF) pData->mnTitleHeight = rStyleSettings.GetTearOffTitleHeight(); else { - if ( pData->mnTitleType == BORDERWINDOW_TITLE_SMALL ) + if (pData->mnTitleType == BORDERWINDOW_TITLE_SMALL) { - pBorderWindow->SetPointFont( rStyleSettings.GetFloatTitleFont() ); + pBorderWindow->SetPointFont(*pBorderWindow, rStyleSettings.GetFloatTitleFont() ); pData->mnTitleHeight = rStyleSettings.GetFloatTitleHeight(); } else // pData->mnTitleType == BORDERWINDOW_TITLE_NORMAL { - pBorderWindow->SetPointFont( rStyleSettings.GetTitleFont() ); + // FIXME RenderContext + pBorderWindow->SetPointFont(*pBorderWindow, rStyleSettings.GetTitleFont()); pData->mnTitleHeight = rStyleSettings.GetTitleHeight(); } long nTextHeight = pBorderWindow->GetTextHeight(); - if ( nTextHeight > pData->mnTitleHeight ) + if (nTextHeight > pData->mnTitleHeight) pData->mnTitleHeight = nTextHeight; } } @@ -1426,8 +1427,8 @@ void ImplStdBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHeigh pData->mnBottomBorder += pData->mnBorderSize; pData->mnNoTitleTop = pData->mnTopBorder; - ImplInitTitle( &maFrameData ); - if ( pData->mnTitleHeight ) + ImplInitTitle(&maFrameData); + if (pData->mnTitleHeight) { // to improve symbol display force a minum title height if( pData->mnTitleHeight < MIN_CAPTION_HEIGHT ) diff --git a/vcl/source/window/dockingarea.cxx b/vcl/source/window/dockingarea.cxx index 786c84bbad31..793ae09430fd 100644 --- a/vcl/source/window/dockingarea.cxx +++ b/vcl/source/window/dockingarea.cxx @@ -178,7 +178,7 @@ void DockingAreaWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangl const bool isFooter = GetAlign() == WINDOWALIGN_BOTTOM && !rSetting.GetPersonaFooter().IsEmpty(); if ((GetAlign() == WINDOWALIGN_TOP && !rSetting.GetPersonaHeader().IsEmpty() ) || isFooter) - rRenderContext.Erase(); + Erase(rRenderContext); else if (!ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB) { // draw a single toolbar background covering the whole docking area diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx index 407e0c86ff36..a98948144421 100644 --- a/vcl/source/window/menubarwindow.cxx +++ b/vcl/source/window/menubarwindow.cxx @@ -610,7 +610,7 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 aControlValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this ); if (!Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() ) - rRenderContext.Erase(); + Erase(rRenderContext); else { Rectangle aBgRegion(Point(), rRenderContext.GetOutputSizePixel()); @@ -886,7 +886,7 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&) aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight(this); if (!rStyleSettings.GetPersonaHeader().IsEmpty()) - rRenderContext.Erase(); + Erase(rRenderContext); else { Point aPt; diff --git a/vcl/source/window/menuwindow.cxx b/vcl/source/window/menuwindow.cxx index b7680e5abb8a..2e8df7a104f8 100644 --- a/vcl/source/window/menuwindow.cxx +++ b/vcl/source/window/menuwindow.cxx @@ -30,8 +30,9 @@ void MenuWindow::ImplInitMenuWindow(vcl::Window* pWin, bool bFont, bool bMenuBar { const StyleSettings& rStyleSettings = pWin->GetSettings().GetStyleSettings(); - if ( bFont ) - pWin->SetPointFont( rStyleSettings.GetMenuFont() ); + // FIXME RenderContext + if (bFont) + pWin->SetPointFont(*pWin, rStyleSettings.GetMenuFont()); if( bMenuBar ) { const BitmapEx& rPersonaBitmap = Application::GetSettings().GetStyleSettings().GetPersonaHeader(); diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx index f888d116868d..07851b21ff4f 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -147,6 +147,8 @@ void PaintHelper::DoPaint(const vcl::Region* pRegion) // copy the underlying content to be able to handle trasparency pDevice->DrawOutDev(m_aPaintRect.TopLeft(), m_aPaintRect.GetSize(), m_aPaintRect.TopLeft(), m_aPaintRect.GetSize(), *m_pWindow); + m_pWindow->ApplySettings(*pDevice.get()); + // paint to the VirtualDevice first m_pWindow->Paint(*pDevice.get(), m_aPaintRect); @@ -1384,37 +1386,37 @@ void Window::PaintToDevice( OutputDevice* pDev, const Point& rPos, const Size& / SetParent( pRealParent ); } -void Window::Erase() +void Window::Erase(vcl::RenderContext& rRenderContext) { - if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() ) + if (!IsDeviceOutputNecessary() || ImplIsRecordLayout()) return; bool bNativeOK = false; ControlPart aCtrlPart = ImplGetWindowImpl()->mnNativeBackground; - if( aCtrlPart != 0 && ! IsControlBackground() ) + if (aCtrlPart != 0 && ! IsControlBackground()) { - Rectangle aCtrlRegion( Point(), GetOutputSizePixel() ); - ControlState nState = ControlState::NONE; + Rectangle aCtrlRegion(Point(), rRenderContext.GetOutputSizePixel()); + ControlState nState = ControlState::NONE; - if( IsEnabled() ) + if (IsEnabled()) nState |= ControlState::ENABLED; - bNativeOK = DrawNativeControl( CTRL_WINDOW_BACKGROUND, aCtrlPart, aCtrlRegion, - nState, ImplControlValue(), OUString() ); + bNativeOK = rRenderContext.DrawNativeControl(CTRL_WINDOW_BACKGROUND, aCtrlPart, aCtrlRegion, + nState, ImplControlValue(), OUString()); } - if ( mbBackground && ! bNativeOK ) + if (mbBackground && !bNativeOK) { RasterOp eRasterOp = GetRasterOp(); - if ( eRasterOp != ROP_OVERPAINT ) - SetRasterOp( ROP_OVERPAINT ); - DrawWallpaper( 0, 0, mnOutWidth, mnOutHeight, maBackground ); - if ( eRasterOp != ROP_OVERPAINT ) - SetRasterOp( eRasterOp ); + if (eRasterOp != ROP_OVERPAINT) + SetRasterOp(ROP_OVERPAINT); + rRenderContext.DrawWallpaper(0, 0, mnOutWidth, mnOutHeight, maBackground); + if (eRasterOp != ROP_OVERPAINT) + rRenderContext.SetRasterOp(eRasterOp); } - if( mpAlphaVDev ) + if (mpAlphaVDev) mpAlphaVDev->Erase(); } diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index b778e0811d19..2b13051b3a37 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -176,7 +176,7 @@ void PrintDialog::PrintPreviewWindow::Paint(vcl::RenderContext& rRenderContext, // replacement is active rRenderContext.Push(); Font aFont(rRenderContext.GetSettings().GetStyleSettings().GetLabelFont()); - SetZoomedPointFont(aFont); + SetZoomedPointFont(rRenderContext, aFont); Rectangle aTextRect(aOffset + Point(2, 2), Size(maPreviewSize.Width() - 4, maPreviewSize.Height() - 4)); rRenderContext.DrawText(aTextRect, maReplacementString, TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER | diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx index bfbe30b5f29a..a997130af601 100644 --- a/vcl/source/window/status.cxx +++ b/vcl/source/window/status.cxx @@ -173,29 +173,64 @@ void StatusBar::AdjustItemWidthsForHiDPI(bool bAdjustHiDPI) mbAdjustHiDPI = bAdjustHiDPI; } -void StatusBar::ImplInitSettings( bool bFont, - bool bForeground, bool bBackground ) +void StatusBar::ApplySettings(vcl::RenderContext& rRenderContext) +{ + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + vcl::Font aFont = rStyleSettings.GetToolFont(); + if (IsControlFont()) + aFont.Merge(GetControlFont()); + SetZoomedPointFont(rRenderContext, aFont); + + Color aColor; + if (IsControlForeground()) + aColor = GetControlForeground(); + else if (GetStyle() & WB_3DLOOK) + aColor = rStyleSettings.GetButtonTextColor(); + else + aColor = rStyleSettings.GetWindowTextColor(); + + rRenderContext.SetTextColor(aColor); + rRenderContext.SetTextFillColor(); + + if (IsControlBackground()) + aColor = GetControlBackground(); + else if (GetStyle() & WB_3DLOOK) + aColor = rStyleSettings.GetFaceColor(); + else + aColor = rStyleSettings.GetWindowColor(); + rRenderContext.SetBackground(aColor); + + // NWF background + if (!IsControlBackground() && + rRenderContext.IsNativeControlSupported(CTRL_WINDOW_BACKGROUND, PART_BACKGROUND_WINDOW)) + { + ImplGetWindowImpl()->mnNativeBackground = PART_BACKGROUND_WINDOW; + EnableChildTransparentMode(true); + } +} + +void StatusBar::ImplInitSettings(bool bFont, bool bForeground, bool bBackground) { const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - if ( bFont ) + if (bFont) { vcl::Font aFont = rStyleSettings.GetToolFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); + if (IsControlFont()) + aFont.Merge(GetControlFont()); + SetZoomedPointFont(*this, aFont); } - if ( bForeground || bFont ) + if (bForeground || bFont) { Color aColor; - if ( IsControlForeground() ) + if (IsControlForeground()) aColor = GetControlForeground(); else if ( GetStyle() & WB_3DLOOK ) aColor = rStyleSettings.GetButtonTextColor(); else aColor = rStyleSettings.GetWindowTextColor(); - SetTextColor( aColor ); + SetTextColor(aColor); SetTextFillColor(); mpImplData->mpVirDev->SetFont( GetFont() ); diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 4fc1750bed63..00370ff74cdd 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -1420,52 +1420,107 @@ void ToolBox::ImplInit( vcl::Window* pParent, WinBits nStyle ) ImplGetWindowImpl()->mnStyle &= ~WB_DIALOGCONTROL; } - ImplInitSettings( true, true, true ); + ImplInitSettings(true, true, true); } -void ToolBox::ImplInitSettings( bool bFont, - bool bForeground, bool bBackground ) +void ToolBox::ApplySettings(vcl::RenderContext& rRenderContext) +{ + mpData->mbNativeButtons = rRenderContext.IsNativeControlSupported(CTRL_TOOLBAR, PART_BUTTON); + + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + + // Font + vcl::Font aFont = rStyleSettings.GetToolFont(); + if (IsControlFont()) + aFont.Merge(GetControlFont()); + SetZoomedPointFont(rRenderContext, aFont); + + // ControlForeground + Color aColor; + if (IsControlForeground()) + aColor = GetControlForeground(); + else if (Window::GetStyle() & WB_3DLOOK) + aColor = rStyleSettings.GetButtonTextColor(); + else + aColor = rStyleSettings.GetWindowTextColor(); + rRenderContext.SetTextColor(aColor); + rRenderContext.SetTextFillColor(); + + if (IsControlBackground()) + { + aColor = GetControlBackground(); + SetBackground( aColor ); + SetPaintTransparent(false); + SetParentClipMode( 0 ); + } + else + { + if (rRenderContext.IsNativeControlSupported(CTRL_TOOLBAR, PART_ENTIRE_CONTROL) + || (GetAlign() == WINDOWALIGN_TOP && !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty()) + || (GetAlign() == WINDOWALIGN_BOTTOM && !Application::GetSettings().GetStyleSettings().GetPersonaFooter().IsEmpty())) + { + rRenderContext.SetBackground(); + rRenderContext.SetTextColor(rStyleSettings.GetMenuBarTextColor()); + SetPaintTransparent(true); + SetParentClipMode(PARENTCLIPMODE_NOCLIP); + mpData->maDisplayBackground = Wallpaper(rStyleSettings.GetFaceColor()); + } + else + { + if (Window::GetStyle() & WB_3DLOOK) + aColor = rStyleSettings.GetFaceColor(); + else + aColor = rStyleSettings.GetWindowColor(); + + rRenderContext.SetBackground(aColor); + SetPaintTransparent(false); + SetParentClipMode(0); + } + } +} + +void ToolBox::ImplInitSettings(bool bFont, bool bForeground, bool bBackground) { mpData->mbNativeButtons = IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ); const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - if ( bFont ) + if (bFont) { vcl::Font aFont = rStyleSettings.GetToolFont(); - if ( IsControlFont() ) - aFont.Merge( GetControlFont() ); - SetZoomedPointFont( aFont ); + if (IsControlFont()) + aFont.Merge(GetControlFont()); + SetZoomedPointFont(*this, aFont); } - if ( bForeground || bFont ) + if (bForeground || bFont) { Color aColor; - if ( IsControlForeground() ) + if (IsControlForeground()) aColor = GetControlForeground(); - else if ( Window::GetStyle() & WB_3DLOOK ) + else if (Window::GetStyle() & WB_3DLOOK) aColor = rStyleSettings.GetButtonTextColor(); else aColor = rStyleSettings.GetWindowTextColor(); - SetTextColor( aColor ); + SetTextColor(aColor); SetTextFillColor(); } - if ( bBackground ) + if (bBackground) { Color aColor; - if ( IsControlBackground() ) + if (IsControlBackground()) { aColor = GetControlBackground(); SetBackground( aColor ); - SetPaintTransparent( false ); + SetPaintTransparent(false); SetParentClipMode( 0 ); } else { - if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) || - ( GetAlign() == WINDOWALIGN_TOP && !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )|| - ( GetAlign() == WINDOWALIGN_BOTTOM && !Application::GetSettings().GetStyleSettings().GetPersonaFooter().IsEmpty()) ) + if (IsNativeControlSupported(CTRL_TOOLBAR, PART_ENTIRE_CONTROL) + || (GetAlign() == WINDOWALIGN_TOP && !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty()) + || (GetAlign() == WINDOWALIGN_BOTTOM && !Application::GetSettings().GetStyleSettings().GetPersonaFooter().IsEmpty())) { SetBackground(); SetTextColor(rStyleSettings.GetMenuBarTextColor()); @@ -1475,14 +1530,14 @@ void ToolBox::ImplInitSettings( bool bFont, } else { - if ( Window::GetStyle() & WB_3DLOOK ) + if (Window::GetStyle() & WB_3DLOOK) aColor = rStyleSettings.GetFaceColor(); else aColor = rStyleSettings.GetWindowColor(); - SetBackground( aColor ); - SetPaintTransparent( false ); - SetParentClipMode( 0 ); + SetBackground(aColor); + SetPaintTransparent(false); + SetParentClipMode(0); } } } @@ -3014,7 +3069,7 @@ void ToolBox::ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, vcl::Font aOldFont = rRenderContext.GetFont(); Color aOldTextColor = rRenderContext.GetTextColor(); - SetZoomedPointFont( rStyleSettings.GetAppFont() ); + SetZoomedPointFont(rRenderContext, rStyleSettings.GetAppFont()); rRenderContext.SetLineColor(Color(COL_BLACK)); rRenderContext.SetFillColor(rStyleSettings.GetFieldColor()); rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor()); diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index eddde5ccacec..730cb0309cfb 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -1143,7 +1143,8 @@ void Window::ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* p mnDPIX = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100; mnDPIY = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100; maFont = rStyleSettings.GetAppFont(); - ImplPointToLogic( maFont ); + + ImplPointToLogic(*this, maFont); if ( nStyle & WB_3DLOOK ) { @@ -1412,7 +1413,7 @@ void Window::ImplRemoveDel( ImplDelData* pDel ) // TODO: make "const" when incom void Window::ImplInitResolutionSettings() { // recalculate AppFont-resolution and DPI-resolution - if ( mpWindowImpl->mbFrame ) + if (mpWindowImpl->mbFrame) { const StyleSettings& rStyleSettings = mxSettings->GetStyleSettings(); sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom(); @@ -1421,7 +1422,7 @@ void Window::ImplInitResolutionSettings() // setup the scale factor for Hi-DPI displays mnDPIScaleFactor = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY); - SetPointFont( rStyleSettings.GetAppFont() ); + SetPointFont(*this, rStyleSettings.GetAppFont()); } else if ( mpWindowImpl->mpParent ) { @@ -1440,15 +1441,15 @@ void Window::ImplInitResolutionSettings() } } -void Window::ImplPointToLogic( vcl::Font& rFont ) const +void Window::ImplPointToLogic(vcl::RenderContext& rRenderContext, vcl::Font& rFont) const { - Size aSize = rFont.GetSize(); - sal_uInt16 nScreenFontZoom = mxSettings->GetStyleSettings().GetScreenFontZoom(); + Size aSize = rFont.GetSize(); + sal_uInt16 nScreenFontZoom = rRenderContext.GetSettings().GetStyleSettings().GetScreenFontZoom(); - if ( aSize.Width() ) + if (aSize.Width()) { aSize.Width() *= mpWindowImpl->mpFrameData->mnDPIX; - aSize.Width() += 72/2; + aSize.Width() += 72 / 2; aSize.Width() /= 72; aSize.Width() *= nScreenFontZoom; aSize.Width() /= 100; @@ -1459,35 +1460,35 @@ void Window::ImplPointToLogic( vcl::Font& rFont ) const aSize.Height() *= nScreenFontZoom; aSize.Height() /= 100; - if ( IsMapModeEnabled() ) - aSize = PixelToLogic( aSize ); + if (rRenderContext.IsMapModeEnabled()) + aSize = rRenderContext.PixelToLogic(aSize); - rFont.SetSize( aSize ); + rFont.SetSize(aSize); } -void Window::ImplLogicToPoint( vcl::Font& rFont ) const +void Window::ImplLogicToPoint(vcl::RenderContext& rRenderContext, vcl::Font& rFont) const { - Size aSize = rFont.GetSize(); - sal_uInt16 nScreenFontZoom = mxSettings->GetStyleSettings().GetScreenFontZoom(); + Size aSize = rFont.GetSize(); + sal_uInt16 nScreenFontZoom = rRenderContext.GetSettings().GetStyleSettings().GetScreenFontZoom(); - if ( IsMapModeEnabled() ) - aSize = LogicToPixel( aSize ); + if (rRenderContext.IsMapModeEnabled()) + aSize = rRenderContext.LogicToPixel(aSize); - if ( aSize.Width() ) + if (aSize.Width()) { aSize.Width() *= 100; aSize.Width() /= nScreenFontZoom; aSize.Width() *= 72; - aSize.Width() += mpWindowImpl->mpFrameData->mnDPIX/2; + aSize.Width() += mpWindowImpl->mpFrameData->mnDPIX / 2; aSize.Width() /= mpWindowImpl->mpFrameData->mnDPIX; } aSize.Height() *= 100; aSize.Height() /= nScreenFontZoom; aSize.Height() *= 72; - aSize.Height() += mpWindowImpl->mpFrameData->mnDPIY/2; + aSize.Height() += mpWindowImpl->mpFrameData->mnDPIY / 2; aSize.Height() /= mpWindowImpl->mpFrameData->mnDPIY; - rFont.SetSize( aSize ); + rFont.SetSize(aSize); } bool Window::ImplUpdatePos() @@ -2165,7 +2166,7 @@ long Window::CalcTitleWidth() const // border of external dialogs const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); vcl::Font aFont = GetFont(); - const_cast<vcl::Window*>(this)->SetPointFont( rStyleSettings.GetTitleFont() ); + const_cast<vcl::Window*>(this)->SetPointFont(*const_cast<Window*>(this), rStyleSettings.GetTitleFont()); long nTitleWidth = GetTextWidth( GetText() ); const_cast<vcl::Window*>(this)->SetFont( aFont ); nTitleWidth += rStyleSettings.GetTitleHeight() * 3; @@ -2257,23 +2258,21 @@ void Window::CollectChildren(::std::vector<vcl::Window *>& rAllChildren ) } } -void Window::SetPointFont( const vcl::Font& rFont ) +void Window::SetPointFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont) { - vcl::Font aFont = rFont; - ImplPointToLogic( aFont ); - SetFont( aFont ); + ImplPointToLogic(rRenderContext, aFont); + rRenderContext.SetFont(aFont); } -vcl::Font Window::GetPointFont() const +vcl::Font Window::GetPointFont(vcl::RenderContext& rRenderContext) const { - - vcl::Font aFont = GetFont(); - ImplLogicToPoint( aFont ); + vcl::Font aFont = rRenderContext.GetFont(); + ImplLogicToPoint(rRenderContext, aFont); return aFont; } -void Window::Show( bool bVisible, sal_uInt16 nFlags ) +void Window::Show(bool bVisible, sal_uInt16 nFlags) { if ( IsDisposed() || mpWindowImpl->mbVisible == bVisible ) return; @@ -3870,42 +3869,46 @@ bool Window::UsePolyPolygonForComplexGradient() return false; } -void Window::DrawGradientWallpaper( long nX, long nY, - long nWidth, long nHeight, - const Wallpaper& rWallpaper ) +void Window::ApplySettings(vcl::RenderContext& /*rRenderContext*/) { - Rectangle aBound; - GDIMetaFile* pOldMetaFile = mpMetaFile; - const bool bOldMap = mbMap; - bool bNeedGradient = true; +} - aBound = Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) ); +void Window::DrawGradientWallpaper(vcl::RenderContext& rRenderContext, + long nX, long nY, long nWidth, long nHeight, + const Wallpaper& rWallpaper) +{ + Rectangle aBound; + GDIMetaFile* pOldMetaFile = mpMetaFile; + const bool bOldMap = mbMap; + bool bNeedGradient = true; + + aBound = Rectangle(Point(nX, nY), Size(nWidth, nHeight)); mpMetaFile = NULL; - EnableMapMode( false ); - Push( PushFlags::CLIPREGION ); - IntersectClipRegion( Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) ) ); + rRenderContext.EnableMapMode(false); + rRenderContext.Push(PushFlags::CLIPREGION); + rRenderContext.IntersectClipRegion(Rectangle(Point(nX, nY), Size(nWidth, nHeight))); - if( rWallpaper.GetStyle() == WALLPAPER_APPLICATIONGRADIENT ) + if (rWallpaper.GetStyle() == WALLPAPER_APPLICATIONGRADIENT) { // limit gradient to useful size, so that it still can be noticed // in maximized windows long gradientWidth = GetDesktopRectPixel().GetSize().Width(); - if( gradientWidth > 1024 ) + if (gradientWidth > 1024) gradientWidth = 1024; - if( mnOutOffX+nWidth > gradientWidth ) - DrawColorWallpaper( nX, nY, nWidth, nHeight, rWallpaper.GetGradient().GetEndColor() ); - if( mnOutOffX > gradientWidth ) + if (mnOutOffX + nWidth > gradientWidth) + rRenderContext.DrawColorWallpaper(nX, nY, nWidth, nHeight, rWallpaper.GetGradient().GetEndColor()); + if (mnOutOffX > gradientWidth) bNeedGradient = false; else - aBound = Rectangle( Point( -mnOutOffX, nY ), Size( gradientWidth, nHeight ) ); + aBound = Rectangle(Point(-mnOutOffX, nY), Size(gradientWidth, nHeight)); } - if( bNeedGradient ) - DrawGradient( aBound, rWallpaper.GetGradient() ); + if (bNeedGradient) + rRenderContext.DrawGradient(aBound, rWallpaper.GetGradient()); - Pop(); - EnableMapMode( bOldMap ); + rRenderContext.Pop(); + rRenderContext.EnableMapMode(bOldMap); mpMetaFile = pOldMetaFile; } @@ -3927,6 +3930,11 @@ Any Window::GetSystemDataAny() const return aRet; } +vcl::RenderSettings& Window::GetRenderSettings() +{ + return mpWindowImpl->maRenderSettings; +} + } /* namespace vcl */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 43d3ecda4ef5..e15c8b4fa7be 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -521,42 +521,44 @@ inline long WinFloatRound( double fVal ) return( fVal > 0.0 ? (long) ( fVal + 0.5 ) : -(long) ( -fVal + 0.5 ) ); } -void Window::SetZoomedPointFont( const vcl::Font& rFont ) +void Window::SetZoomedPointFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont) { const Fraction& rZoom = GetZoom(); - if ( rZoom.GetNumerator() != rZoom.GetDenominator() ) + if (rZoom.GetNumerator() != rZoom.GetDenominator()) { - vcl::Font aFont( rFont ); + vcl::Font aFont(rFont); Size aSize = aFont.GetSize(); - double n = (double)aSize.Width(); - n *= (double)rZoom.GetNumerator(); - n /= (double)rZoom.GetDenominator(); - aSize.Width() = WinFloatRound( n ); - n = (double)aSize.Height(); - n *= (double)rZoom.GetNumerator(); - n /= (double)rZoom.GetDenominator(); - aSize.Height() = WinFloatRound( n ); - aFont.SetSize( aSize ); - SetPointFont( aFont ); + double n = double(aSize.Width()); + n *= double(rZoom.GetNumerator()); + n /= double(rZoom.GetDenominator()); + aSize.Width() = WinFloatRound(n); + n = double(aSize.Height()); + n *= double(rZoom.GetNumerator()); + n /= double(rZoom.GetDenominator()); + aSize.Height() = WinFloatRound(n); + aFont.SetSize(aSize); + SetPointFont(rRenderContext, aFont); // Use another font if the representation is to be scaled, // and the actual font is not scalable - FontMetric aMetric = GetFontMetric(); - long nFontDiff = std::abs( GetFont().GetSize().Height()-aMetric.GetSize().Height() ); - if ( (aMetric.GetType() == TYPE_RASTER) && (nFontDiff >= 2) ) + FontMetric aMetric = rRenderContext.GetFontMetric(); + long nFontDiff = std::abs(rRenderContext.GetFont().GetSize().Height() - aMetric.GetSize().Height()); + if ((aMetric.GetType() == TYPE_RASTER) && (nFontDiff >= 2)) { DefaultFontType nType; - if ( aMetric.GetPitch() == PITCH_FIXED ) + if (aMetric.GetPitch() == PITCH_FIXED) nType = DefaultFontType::FIXED; else nType = DefaultFontType::UI_SANS; - vcl::Font aTempFont = GetDefaultFont( nType, GetSettings().GetLanguageTag().getLanguageType(), 0 ); - aFont.SetName( aTempFont.GetName() ); - SetPointFont( aFont ); + vcl::Font aTempFont = OutputDevice::GetDefaultFont(nType, rRenderContext.GetSettings().GetLanguageTag().getLanguageType(), 0); + aFont.SetName(aTempFont.GetName()); + SetPointFont(rRenderContext, aFont); } } else - SetPointFont( rFont ); + { + SetPointFont(rRenderContext, rFont); + } } long Window::CalcZoom( long nCalc ) const @@ -575,37 +577,37 @@ long Window::CalcZoom( long nCalc ) const void Window::SetControlFont() { - if ( mpWindowImpl->mpControlFont ) + if (mpWindowImpl->mpControlFont) { delete mpWindowImpl->mpControlFont; mpWindowImpl->mpControlFont = NULL; - StateChanged( StateChangedType::ControlFont ); + StateChanged(StateChangedType::ControlFont); } } -void Window::SetControlFont( const vcl::Font& rFont ) +void Window::SetControlFont(const vcl::Font& rFont) { - if ( rFont == vcl::Font() ) + if (rFont == vcl::Font()) { SetControlFont(); return; } - if ( mpWindowImpl->mpControlFont ) + if (mpWindowImpl->mpControlFont) { - if ( *mpWindowImpl->mpControlFont == rFont ) + if (*mpWindowImpl->mpControlFont == rFont) return; *mpWindowImpl->mpControlFont = rFont; } else - mpWindowImpl->mpControlFont = new vcl::Font( rFont ); + mpWindowImpl->mpControlFont = new vcl::Font(rFont); - StateChanged( StateChangedType::ControlFont ); + StateChanged(StateChangedType::ControlFont); } vcl::Font Window::GetControlFont() const { - if ( mpWindowImpl->mpControlFont ) + if (mpWindowImpl->mpControlFont) return *mpWindowImpl->mpControlFont; else { @@ -614,70 +616,94 @@ vcl::Font Window::GetControlFont() const } } +void Window::ApplyControlFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont) +{ + vcl::Font aFont(rFont); + if (IsControlFont()) + aFont.Merge(GetControlFont()); + SetZoomedPointFont(rRenderContext, aFont); +} + void Window::SetControlForeground() { - if ( mpWindowImpl->mbControlForeground ) + if (mpWindowImpl->mbControlForeground) { - mpWindowImpl->maControlForeground = Color( COL_TRANSPARENT ); + mpWindowImpl->maControlForeground = Color(COL_TRANSPARENT); mpWindowImpl->mbControlForeground = false; - StateChanged( StateChangedType::ControlForeground ); + StateChanged(StateChangedType::ControlForeground); } } -void Window::SetControlForeground( const Color& rColor ) +void Window::SetControlForeground(const Color& rColor) { - if ( rColor.GetTransparency() ) + if (rColor.GetTransparency()) { - if ( mpWindowImpl->mbControlForeground ) + if (mpWindowImpl->mbControlForeground) { - mpWindowImpl->maControlForeground = Color( COL_TRANSPARENT ); + mpWindowImpl->maControlForeground = Color(COL_TRANSPARENT); mpWindowImpl->mbControlForeground = false; - StateChanged( StateChangedType::ControlForeground ); + StateChanged(StateChangedType::ControlForeground); } } else { - if ( mpWindowImpl->maControlForeground != rColor ) + if (mpWindowImpl->maControlForeground != rColor) { mpWindowImpl->maControlForeground = rColor; mpWindowImpl->mbControlForeground = true; - StateChanged( StateChangedType::ControlForeground ); + StateChanged(StateChangedType::ControlForeground); } } } +void Window::ApplyControlForeground(vcl::RenderContext& rRenderContext, const Color& rDefaultColor) +{ + Color aTextColor(rDefaultColor); + if (IsControlForeground()) + aTextColor = GetControlForeground(); + rRenderContext.SetTextColor(aTextColor); +} + void Window::SetControlBackground() { - if ( mpWindowImpl->mbControlBackground ) + if (mpWindowImpl->mbControlBackground) { - mpWindowImpl->maControlBackground = Color( COL_TRANSPARENT ); + mpWindowImpl->maControlBackground = Color(COL_TRANSPARENT); mpWindowImpl->mbControlBackground = false; - StateChanged( StateChangedType::ControlBackground ); + StateChanged(StateChangedType::ControlBackground); } } -void Window::SetControlBackground( const Color& rColor ) +void Window::SetControlBackground(const Color& rColor) { - if ( rColor.GetTransparency() ) + if (rColor.GetTransparency()) { - if ( mpWindowImpl->mbControlBackground ) + if (mpWindowImpl->mbControlBackground) { - mpWindowImpl->maControlBackground = Color( COL_TRANSPARENT ); + mpWindowImpl->maControlBackground = Color(COL_TRANSPARENT); mpWindowImpl->mbControlBackground = false; - StateChanged( StateChangedType::ControlBackground ); + StateChanged(StateChangedType::ControlBackground); } } else { - if ( mpWindowImpl->maControlBackground != rColor ) + if (mpWindowImpl->maControlBackground != rColor) { mpWindowImpl->maControlBackground = rColor; mpWindowImpl->mbControlBackground = true; - StateChanged( StateChangedType::ControlBackground ); + StateChanged(StateChangedType::ControlBackground); } } } +void Window::ApplyControlBackground(vcl::RenderContext& rRenderContext, const Color& rDefaultColor) +{ + Color aColor(rDefaultColor); + if (IsControlBackground()) + aColor = GetControlBackground(); + rRenderContext.SetBackground(aColor); +} + Size Window::CalcWindowSize( const Size& rOutSz ) const { Size aSz = rOutSz; @@ -694,11 +720,11 @@ Size Window::CalcOutputSize( const Size& rWinSz ) const return aSz; } -vcl::Font Window::GetDrawPixelFont( OutputDevice* pDev ) const +vcl::Font Window::GetDrawPixelFont(OutputDevice* pDev) const { - vcl::Font aFont = GetPointFont(); - Size aFontSize = aFont.GetSize(); - MapMode aPtMapMode( MAP_POINT ); + vcl::Font aFont = GetPointFont(*const_cast<Window*>(this)); + Size aFontSize = aFont.GetSize(); + MapMode aPtMapMode(MAP_POINT); aFontSize = pDev->LogicToPixel( aFontSize, aPtMapMode ); aFont.SetSize( aFontSize ); return aFont; |