gr_basic.cpp: ensure a pen with width = 0 is transparent.

Setting its color to COLOR4D::UNSPECIFIED (i.e. opacity = 0) is not enough
for all  platforms (i.e. Windows)
This commit is contained in:
jean-pierre charras 2023-02-21 20:06:54 +01:00
parent 543a3317b4
commit d07738a06c
1 changed files with 16 additions and 10 deletions

View File

@ -102,18 +102,24 @@ void GRSetColorPen( wxDC* DC, const COLOR4D& Color, int width, wxPenStyle style
if( !curr_pen.IsOk() || curr_pen.GetColour() != color.ToColour() if( !curr_pen.IsOk() || curr_pen.GetColour() != color.ToColour()
|| curr_pen.GetWidth() != width || curr_pen.GetStyle() != style ) || curr_pen.GetWidth() != width || curr_pen.GetStyle() != style )
{ {
wxPen pen; if( width == 0 )
pen.SetColour( color.ToColour() ); // COLOR4D::UNSPECIFIED (i.e. opacity = 0) does not work on all platforms
// So ensure the pen is transparent
if( style == wxPENSTYLE_DOT ) DC->SetPen( *wxTRANSPARENT_PEN );
else
{ {
style = wxPENSTYLE_USER_DASH; wxPen pen;
pen.SetDashes( 2, dots ); pen.SetColour( color.ToColour() );
}
pen.SetWidth( width ); if( style == wxPENSTYLE_DOT )
pen.SetStyle( style ); {
DC->SetPen( pen ); style = wxPENSTYLE_USER_DASH;
pen.SetDashes( 2, dots );
}
pen.SetWidth( width );
pen.SetStyle( style );
}
} }
else else
{ {