summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2025-01-30 09:55:02 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2025-01-31 09:34:34 +0100
commit7cd00ca413da8d29f54749c04493e85937a2fa38 (patch)
tree1af931500f55d653df2acb37f0fc96666a9becfa
parent94eb08183ac2be67f11d45e6ad8e703d39115246 (diff)
use more OutputDevice::Push/Pop (tdf#164799 related)
So we save/restore the fill colors properly Change-Id: I9613587d76785905346b341e24b5491188d095d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180929 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--vcl/source/control/imgctrl.cxx7
-rw-r--r--vcl/source/control/imivctl1.cxx4
-rw-r--r--vcl/source/edit/texteng.cxx4
-rw-r--r--vcl/source/filter/wmf/emfwr.cxx6
-rw-r--r--vcl/source/outdev/font.cxx8
-rw-r--r--vcl/source/treelist/iconview.cxx12
-rw-r--r--vcl/source/window/decoview.cxx20
-rw-r--r--vcl/source/window/toolbox.cxx14
-rw-r--r--vcl/source/window/window.cxx6
9 files changed, 24 insertions, 57 deletions
diff --git a/vcl/source/control/imgctrl.cxx b/vcl/source/control/imgctrl.cxx
index 5e7c95dab374..132e10ca820b 100644
--- a/vcl/source/control/imgctrl.cxx
+++ b/vcl/source/control/imgctrl.cxx
@@ -133,8 +133,7 @@ void ImageControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
bool bFlat = (GetBorderStyle() == WindowBorderStyle::MONO);
tools::Rectangle aRect(Point(0,0), pBorderWindow->GetOutputSizePixel());
- Color oldLineCol = pBorderWindow->GetOutDev()->GetLineColor();
- Color oldFillCol = pBorderWindow->GetOutDev()->GetFillColor();
+ pBorderWindow->GetOutDev()->Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
pBorderWindow->GetOutDev()->SetFillColor();
pBorderWindow->GetOutDev()->SetLineColor(bFlat ? COL_WHITE : COL_BLACK);
pBorderWindow->GetOutDev()->DrawRect(aRect);
@@ -144,9 +143,7 @@ void ImageControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan
aRect.AdjustBottom( -1 );
pBorderWindow->GetOutDev()->SetLineColor(bFlat ? COL_BLACK : COL_WHITE);
pBorderWindow->GetOutDev()->DrawRect(aRect);
- pBorderWindow->GetOutDev()->SetLineColor(oldLineCol);
- pBorderWindow->GetOutDev()->SetFillColor(oldFillCol);
-
+ pBorderWindow->GetOutDev()->Pop();
}
void ImageControl::Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags )
diff --git a/vcl/source/control/imivctl1.cxx b/vcl/source/control/imivctl1.cxx
index 55ac31cc0bbb..36e3bacc9c88 100644
--- a/vcl/source/control/imivctl1.cxx
+++ b/vcl/source/control/imivctl1.cxx
@@ -938,14 +938,14 @@ void SvxIconChoiceCtrl_Impl::LoseFocus()
void SvxIconChoiceCtrl_Impl::PaintEmphasis(const tools::Rectangle& rTextRect,
vcl::RenderContext& rRenderContext)
{
- Color aOldFillColor(rRenderContext.GetFillColor());
+ rRenderContext.Push(vcl::PushFlags::FILLCOLOR);
const Color& rFillColor = rRenderContext.GetFont().GetFillColor();
rRenderContext.SetFillColor(rFillColor);
// draw text rectangle
if (rFillColor != COL_TRANSPARENT)
rRenderContext.DrawRect(rTextRect);
- rRenderContext.SetFillColor(aOldFillColor);
+ rRenderContext.Pop();
}
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index 6ddbce0f6bdd..ab18263c8817 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -2007,11 +2007,11 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, tools:
const TextPaM aTextEnd(nPara, nIndex + 1);
if ((aTextStart < *pSelEnd) && (aTextEnd > *pSelStart))
{
- const Color aOldColor = pOutDev->GetFillColor();
+ pOutDev->Push(vcl::PushFlags::FILLCOLOR);
pOutDev->SetFillColor(
rStyleSettings.GetHighlightColor());
pOutDev->DrawRect(aTabArea);
- pOutDev->SetFillColor(aOldColor);
+ pOutDev->Pop();
}
else
{
diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx
index 891457153103..7e1dd5d7c51d 100644
--- a/vcl/source/filter/wmf/emfwr.cxx
+++ b/vcl/source/filter/wmf/emfwr.cxx
@@ -954,8 +954,9 @@ void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const bas
if(!aFillPolyPolygon.count())
return;
+ maVDev->Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
+
const Color aOldLineColor(maVDev->GetLineColor());
- const Color aOldFillColor(maVDev->GetFillColor());
maVDev->SetLineColor();
maVDev->SetFillColor(aOldLineColor);
@@ -965,8 +966,7 @@ void EMFWriter::Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const bas
ImplWritePolyPolygonRecord(tools::PolyPolygon( tools::Polygon(rB2DPolygon) ));
}
- maVDev->SetLineColor(aOldLineColor);
- maVDev->SetFillColor(aOldFillColor);
+ maVDev->Pop();
}
void EMFWriter::ImplWrite( const GDIMetaFile& rMtf )
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index e0b986f2d20b..b75a7863bcb2 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -895,9 +895,7 @@ void OutputDevice::ImplDrawEmphasisMark( tools::Long nBaseX, tools::Long nX, too
void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout )
{
- Color aOldLineColor = GetLineColor();
- Color aOldFillColor = GetFillColor();
- bool bOldMap = mbMap;
+ Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR | vcl::PushFlags::MAPMODE);
GDIMetaFile* pOldMetaFile = mpMetaFile;
mpMetaFile = nullptr;
EnableMapMode( false );
@@ -981,9 +979,7 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout )
}
}
- SetLineColor( aOldLineColor );
- SetFillColor( aOldFillColor );
- EnableMapMode( bOldMap );
+ Pop();
mpMetaFile = pOldMetaFile;
}
diff --git a/vcl/source/treelist/iconview.cxx b/vcl/source/treelist/iconview.cxx
index 927ad5decb4e..fde2a1a244f6 100644
--- a/vcl/source/treelist/iconview.cxx
+++ b/vcl/source/treelist/iconview.cxx
@@ -107,8 +107,8 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, tools::Long nX, tools::Long n
Point aEntryPos(nX, nY);
- const Color aBackupTextColor(rRenderContext.GetTextColor());
- const vcl::Font aBackupFont(rRenderContext.GetFont());
+ rRenderContext.Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR
+ | vcl::PushFlags::FONT);
const Color aBackupColor = rRenderContext.GetFillColor();
const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
@@ -119,7 +119,6 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, tools::Long nX, tools::Long n
const SvViewDataEntry* pViewDataEntry = GetViewDataEntry(&rEntry);
- bool bCurFontIsSel = false;
if (pViewDataEntry->IsHighlighted())
{
vcl::Font aHighlightFont(rRenderContext.GetFont());
@@ -129,7 +128,6 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, tools::Long nX, tools::Long n
// set font color to highlight
rRenderContext.SetTextColor(aHighlightTextColor);
rRenderContext.SetFont(aHighlightFont);
- bCurFontIsSel = true;
}
bool bFillColorSet = false;
@@ -223,11 +221,7 @@ void IconView::PaintEntry(SvTreeListEntry& rEntry, tools::Long nX, tools::Long n
rItem.Paint(aEntryPos, *this, rRenderContext, pViewDataEntry, rEntry);
}
- if (bCurFontIsSel)
- {
- rRenderContext.SetTextColor(aBackupTextColor);
- rRenderContext.SetFont(aBackupFont);
- }
+ rRenderContext.Pop();
}
css::uno::Reference<css::accessibility::XAccessible> IconView::CreateAccessible()
diff --git a/vcl/source/window/decoview.cxx b/vcl/source/window/decoview.cxx
index 4b793b4610ef..9a336372beb1 100644
--- a/vcl/source/window/decoview.cxx
+++ b/vcl/source/window/decoview.cxx
@@ -770,9 +770,7 @@ void DecorationView::DrawSymbol( const tools::Rectangle& rRect, SymbolType eType
{
const StyleSettings& rStyleSettings = mpOutDev->GetSettings().GetStyleSettings();
const tools::Rectangle aRect = mpOutDev->LogicToPixel( rRect );
- const Color aOldLineColor = mpOutDev->GetLineColor();
- const Color aOldFillColor = mpOutDev->GetFillColor();
- const bool bOldMapMode = mpOutDev->IsMapModeEnabled();
+ mpOutDev->Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR | vcl::PushFlags::MAPMODE);
Color nColor(rColor);
mpOutDev->EnableMapMode( false );
@@ -803,9 +801,7 @@ void DecorationView::DrawSymbol( const tools::Rectangle& rRect, SymbolType eType
ImplDrawSymbol( mpOutDev, aRect, eType );
// Restore previous settings
- mpOutDev->SetLineColor( aOldLineColor );
- mpOutDev->SetFillColor( aOldFillColor );
- mpOutDev->EnableMapMode( bOldMapMode );
+ mpOutDev->Pop();
}
void DecorationView::DrawFrame( const tools::Rectangle& rRect,
@@ -873,11 +869,9 @@ tools::Rectangle DecorationView::DrawFrame( const tools::Rectangle& rRect, DrawF
ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle, nFlags );
else
{
- Color aOldLineColor = mpOutDev->GetLineColor();
- Color aOldFillColor = mpOutDev->GetFillColor();
+ mpOutDev->Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
ImplDrawFrame( mpOutDev, aRect, mpOutDev->GetSettings().GetStyleSettings(), nStyle, nFlags );
- mpOutDev->SetLineColor( aOldLineColor );
- mpOutDev->SetFillColor( aOldFillColor );
+ mpOutDev->Pop();
}
}
@@ -898,11 +892,9 @@ tools::Rectangle DecorationView::DrawButton( const tools::Rectangle& rRect, Draw
const bool bOldMap = mpOutDev->IsMapModeEnabled();
mpOutDev->EnableMapMode( false );
- const Color aOldLineColor = mpOutDev->GetLineColor();
- const Color aOldFillColor = mpOutDev->GetFillColor();
+ mpOutDev->Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
ImplDrawButton( mpOutDev, aRect, nStyle );
- mpOutDev->SetLineColor( aOldLineColor );
- mpOutDev->SetFillColor( aOldFillColor );
+ mpOutDev->Pop();
// keep border free, although it is used at default representation
aRect.AdjustLeft( 1 );
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 338d817cf25d..3cbd2db0c3f2 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -2368,10 +2368,7 @@ static void ImplDrawMoreIndicator(vcl::RenderContext& rRenderContext, const tool
static void ImplDrawDropdownArrow(vcl::RenderContext& rRenderContext, const tools::Rectangle& rDropDownRect, bool bSetColor, bool bRotate )
{
- bool bLineColor = rRenderContext.IsLineColor();
- bool bFillColor = rRenderContext.IsFillColor();
- Color aOldFillColor = rRenderContext.GetFillColor();
- Color aOldLineColor = rRenderContext.GetLineColor();
+ rRenderContext.Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
rRenderContext.SetLineColor();
if ( bSetColor )
@@ -2409,14 +2406,7 @@ static void ImplDrawDropdownArrow(vcl::RenderContext& rRenderContext, const tool
rRenderContext.DrawPolygon( aPoly );
rRenderContext.SetAntialiasing(aaflags);
- if( bFillColor )
- rRenderContext.SetFillColor(aOldFillColor);
- else
- rRenderContext.SetFillColor();
- if( bLineColor )
- rRenderContext.SetLineColor(aOldLineColor);
- else
- rRenderContext.SetLineColor();
+ rRenderContext.Pop();
}
void ToolBox::ImplDrawMenuButton(vcl::RenderContext& rRenderContext, bool bHighlight)
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 23df41fa50ce..a91c4812b8f6 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3511,8 +3511,7 @@ void Window::DrawSelectionBackground( const tools::Rectangle& rRect,
}
tools::Rectangle aRect( rRect );
- Color oldFillCol = GetOutDev()->GetFillColor();
- Color oldLineCol = GetOutDev()->GetLineColor();
+ GetOutDev()->Push(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR);
if( bDrawBorder )
GetOutDev()->SetLineColor( bDark ? COL_WHITE : ( bBright ? COL_BLACK : aSelectionBorderCol ) );
@@ -3586,8 +3585,7 @@ void Window::DrawSelectionBackground( const tools::Rectangle& rRect,
GetOutDev()->DrawTransparent( aPolyPoly, nPercent );
}
- GetOutDev()->SetFillColor( oldFillCol );
- GetOutDev()->SetLineColor( oldLineCol );
+ GetOutDev()->Pop();
}
bool Window::IsScrollable() const