Add wx{Pen,Brush}::Is[Non]Transparent() methods and use them.
Using GetStyle() == wx{PEN,BRUSH}STYLE_TRANSPARENT doesn't work for uninitialized pen or brush objects so add convenient helpers which do work for them. Use the new helper functions everywhere instead of explicitly checking for style. This makes the code shorter and more clear and also fixes some bugs (at least those in GTK printing code). Notice that this patch removes the main reason for explicitly initializing m_pen and m_brush in wxGTKDCImpl ctor but this initialization still can't be removed, at least for the latter, as doing this somehow breaks GetPixel(). It would be nice to understand why and do remove this initialization so that a newly created DC doesn't have any non-default pen nor brush. Closes #12522. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65820 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1266,7 +1266,8 @@ bool wxGtkPrinterDCImpl::DoGetPixel(wxCoord WXUNUSED(x1),
|
||||
|
||||
void wxGtkPrinterDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
|
||||
{
|
||||
if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
|
||||
if ( m_pen.IsTransparent() )
|
||||
return;
|
||||
|
||||
SetPen( m_pen );
|
||||
cairo_move_to ( m_cairo, XLOG2DEV(x1), YLOG2DEV(y1) );
|
||||
@@ -1374,7 +1375,8 @@ void wxGtkPrinterDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord
|
||||
|
||||
void wxGtkPrinterDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
|
||||
{
|
||||
if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
|
||||
if ( m_pen.IsTransparent() )
|
||||
return;
|
||||
|
||||
SetPen( m_pen );
|
||||
|
||||
@@ -1387,7 +1389,9 @@ void wxGtkPrinterDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
|
||||
|
||||
void wxGtkPrinterDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
|
||||
{
|
||||
if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
|
||||
if ( m_pen.IsTransparent() )
|
||||
return;
|
||||
|
||||
|
||||
if (n <= 0) return;
|
||||
|
||||
|
Reference in New Issue
Block a user