diff options
Diffstat (limited to 'vcl/win')
-rw-r--r-- | vcl/win/gdi/gdiimpl.cxx | 46 | ||||
-rw-r--r-- | vcl/win/gdi/gdiimpl.hxx | 2 |
2 files changed, 42 insertions, 6 deletions
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx index b3f5b0735bb0..a9406729fa21 100644 --- a/vcl/win/gdi/gdiimpl.cxx +++ b/vcl/win/gdi/gdiimpl.cxx @@ -210,7 +210,9 @@ WinSalGraphicsImpl::WinSalGraphicsImpl(WinSalGraphics& rParent): mbXORMode(false), mbPen(false), mhPen(nullptr), + mbStockPen(false), mbBrush(false), + mbStockBrush(false), mhBrush(nullptr) { } @@ -218,10 +220,16 @@ WinSalGraphicsImpl::WinSalGraphicsImpl(WinSalGraphics& rParent): WinSalGraphicsImpl::~WinSalGraphicsImpl() { if ( mhPen ) - DeletePen( mhPen ); + { + if ( !mbStockPen ) + DeletePen( mhPen ); + } if ( mhBrush ) - DeleteBrush( mhBrush ); + { + if ( !mbStockBrush ) + DeleteBrush( mhBrush ); + } } void WinSalGraphicsImpl::Init() @@ -1278,6 +1286,7 @@ void WinSalGraphicsImpl::SetLineColor() // set new data mbPen = FALSE; + mbStockPen = TRUE; } void WinSalGraphicsImpl::SetLineColor(Color nColor) @@ -1285,8 +1294,12 @@ void WinSalGraphicsImpl::SetLineColor(Color nColor) COLORREF nPenColor = PALETTERGB(nColor.GetRed(), nColor.GetGreen(), nColor.GetBlue()); + bool bStockPen = false; + HPEN hNewPen = SearchStockPen(nPenColor); - if (!hNewPen) + if (hNewPen) + bStockPen = true; + else hNewPen = MakePen(nColor); ResetPen(hNewPen); @@ -1295,6 +1308,7 @@ void WinSalGraphicsImpl::SetLineColor(Color nColor) mnPenColor = nPenColor; maLineColor = nColor; mbPen = TRUE; + mbStockPen = bStockPen; } HPEN WinSalGraphicsImpl::SearchStockPen(COLORREF nPenColor) @@ -1336,9 +1350,16 @@ void WinSalGraphicsImpl::ResetPen(HPEN hNewPen) HPEN hOldPen = SelectPen(mrParent.getHDC(), hNewPen); if (mhPen) - DeletePen(mhPen); + { + if (!mbStockPen) + { + DeletePen(mhPen); + } + } else + { mrParent.mhDefPen = hOldPen; + } mhPen = hNewPen; } @@ -1349,6 +1370,7 @@ void WinSalGraphicsImpl::SetFillColor() // set new data mbBrush = FALSE; + mbStockBrush = TRUE; } void WinSalGraphicsImpl::SetFillColor(Color nColor) @@ -1356,8 +1378,12 @@ void WinSalGraphicsImpl::SetFillColor(Color nColor) COLORREF nBrushColor = PALETTERGB(nColor.GetRed(), nColor.GetGreen(), nColor.GetBlue()); + bool bStockBrush = false; + HBRUSH hNewBrush = SearchStockBrush(nBrushColor); - if (!hNewBrush) + if (hNewBrush) + bStockBrush = true; + else hNewBrush = MakeBrush(nColor); ResetBrush(hNewBrush); @@ -1366,6 +1392,7 @@ void WinSalGraphicsImpl::SetFillColor(Color nColor) mnBrushColor = nBrushColor; maFillColor = nColor; mbBrush = TRUE; + mbStockBrush = bStockBrush; } HBRUSH WinSalGraphicsImpl::SearchStockBrush(COLORREF nBrushColor) @@ -1498,9 +1525,16 @@ void WinSalGraphicsImpl::ResetBrush(HBRUSH hNewBrush) HBRUSH hOldBrush = SelectBrush(mrParent.getHDC(), hNewBrush); if (mhBrush) - DeleteBrush(mhBrush); + { + if (!mbStockBrush) + { + DeleteBrush(mhBrush); + } + } else + { mrParent.mhDefBrush = hOldBrush; + } mhBrush = hNewBrush; } diff --git a/vcl/win/gdi/gdiimpl.hxx b/vcl/win/gdi/gdiimpl.hxx index e96b226457f7..f1cd729daf1b 100644 --- a/vcl/win/gdi/gdiimpl.hxx +++ b/vcl/win/gdi/gdiimpl.hxx @@ -38,7 +38,9 @@ private: bool mbXORMode : 1; // _every_ output with RasterOp XOR bool mbPen : 1; // is Pen (FALSE == NULL_PEN) HPEN mhPen; // Pen + bool mbStockPen : 1; // is Pen a stockpen bool mbBrush : 1; // is Brush (FALSE == NULL_BRUSH) + bool mbStockBrush : 1; // is Brush a stockbrush HBRUSH mhBrush; // Brush COLORREF mnPenColor; // PenColor COLORREF mnBrushColor; // BrushColor |