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/source/window | |
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/source/window')
-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 |
10 files changed, 293 insertions, 165 deletions
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; |