Preserve wxDC attributes in wxMac wxRenderer too

This is similar to the grand-parent commit which did the same thing for
MSW and generic renderer implementations.
This commit is contained in:
Vadim Zeitlin
2021-07-06 13:48:40 +02:00
parent 46c8b608b6
commit 4bab6fe64f

View File

@@ -178,7 +178,7 @@ int wxRendererMac::DrawHeaderButton( wxWindow *win,
const wxCoord w = rect.width; const wxCoord w = rect.width;
const wxCoord h = rect.height; const wxCoord h = rect.height;
dc.SetBrush( *wxTRANSPARENT_BRUSH ); wxDCBrushChanger setBrush(dc, *wxTRANSPARENT_BRUSH);
HIRect headerRect = CGRectMake( x, y, w, h ); HIRect headerRect = CGRectMake( x, y, w, h );
if ( !wxHasCGContext(win, dc) ) if ( !wxHasCGContext(win, dc) )
@@ -267,7 +267,7 @@ void wxRendererMac::DrawTreeItemButton( wxWindow *win,
const wxCoord w = rect.width; const wxCoord w = rect.width;
const wxCoord h = rect.height; const wxCoord h = rect.height;
dc.SetBrush( *wxTRANSPARENT_BRUSH ); wxDCBrushChanger setBrush(dc, *wxTRANSPARENT_BRUSH);
HIRect headerRect = CGRectMake( x, y, w, h ); HIRect headerRect = CGRectMake( x, y, w, h );
if ( !wxHasCGContext(win, dc) ) if ( !wxHasCGContext(win, dc) )
@@ -415,8 +415,8 @@ wxRendererMac::DrawItemSelectionRect(wxWindow * WXUNUSED(win),
: kThemeBrushSecondaryHighlightColor ) ); : kThemeBrushSecondaryHighlightColor ) );
wxBrush selBrush( col ); wxBrush selBrush( col );
dc.SetPen( *wxTRANSPARENT_PEN ); wxDCPenChanger setPen(dc, *wxTRANSPARENT_PEN);
dc.SetBrush( selBrush ); wxDCBrushChanger setBrush(dc, selBrush);
dc.DrawRectangle( rect ); dc.DrawRectangle( rect );
} }
@@ -435,7 +435,7 @@ wxRendererMac::DrawMacThemeButton(wxWindow *win,
const wxCoord w = rect.width; const wxCoord w = rect.width;
const wxCoord h = rect.height; const wxCoord h = rect.height;
dc.SetBrush( *wxTRANSPARENT_BRUSH ); wxDCBrushChanger setBrush(dc, *wxTRANSPARENT_BRUSH);
HIRect headerRect = CGRectMake( x, y, w, h ); HIRect headerRect = CGRectMake( x, y, w, h );
if ( !wxHasCGContext(win, dc) ) if ( !wxHasCGContext(win, dc) )
@@ -681,10 +681,12 @@ void wxRendererMac::DrawTextCtrl(wxWindow* win, wxDC& dc,
const wxCoord w = rect.width; const wxCoord w = rect.width;
const wxCoord h = rect.height; const wxCoord h = rect.height;
dc.SetBrush( *wxWHITE_BRUSH ); wxDCBrushChanger setBrush(dc, *wxWHITE_BRUSH);
dc.SetPen( *wxTRANSPARENT_PEN ); wxDCPenChanger setPen(dc, *wxTRANSPARENT_PEN);
dc.DrawRectangle(rect); dc.DrawRectangle(rect);
// Note that calling SetBrush() here is fine as we already have
// wxDCBrushChanger above, so the original brush will get restored.
dc.SetBrush( *wxTRANSPARENT_BRUSH ); dc.SetBrush( *wxTRANSPARENT_BRUSH );
HIRect hiRect = CGRectMake( x, y, w, h ); HIRect hiRect = CGRectMake( x, y, w, h );
@@ -733,19 +735,20 @@ void wxRendererMac::DrawTitleBarBitmap(wxWindow *win,
// The following hard coded RGB values are based the close button in // The following hard coded RGB values are based the close button in
// XCode 6+ welcome screen // XCode 6+ welcome screen
bool drawCircle; bool drawCircle;
wxColour circleBorderCol, circleInteriorCol;
if ( flags & wxCONTROL_PRESSED ) if ( flags & wxCONTROL_PRESSED )
{ {
drawCircle = true; drawCircle = true;
glyphColor = wxColour(104, 104, 104); glyphColor = wxColour(104, 104, 104);
dc.SetPen(wxPen(wxColour(70, 70, 71), 1)); circleBorderCol = wxColour(70, 70, 71);
dc.SetBrush(wxColour(78, 78, 78)); circleInteriorCol = wxColour(78, 78, 78);
} }
else if ( flags & wxCONTROL_CURRENT ) else if ( flags & wxCONTROL_CURRENT )
{ {
drawCircle = true; drawCircle = true;
glyphColor = *wxWHITE; glyphColor = *wxWHITE;
dc.SetPen(wxPen(wxColour(163, 165, 166), 1)); circleBorderCol = wxColour(163, 165, 166);
dc.SetBrush(wxColour(182, 184, 187)); circleInteriorCol = wxColour(182, 184, 187);
} }
else else
{ {
@@ -755,13 +758,16 @@ void wxRendererMac::DrawTitleBarBitmap(wxWindow *win,
if ( drawCircle ) if ( drawCircle )
{ {
wxDCPenChanger setPen(dc, circleBorderCol);
wxDCBrushChanger setBrush(dc, circleInteriorCol);
wxRect circleRect(rect); wxRect circleRect(rect);
circleRect.Deflate(2); circleRect.Deflate(2);
dc.DrawEllipse(circleRect); dc.DrawEllipse(circleRect);
} }
dc.SetPen(wxPen(glyphColor, 1)); wxDCPenChanger setPen(dc, glyphColor);
wxRect centerRect(rect); wxRect centerRect(rect);
centerRect.Deflate(5); centerRect.Deflate(5);