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:
@@ -427,7 +427,8 @@ void wxPostScriptDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord
|
||||
{
|
||||
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
|
||||
|
||||
if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
|
||||
if ( m_pen.IsTransparent() )
|
||||
return;
|
||||
|
||||
SetPen( m_pen );
|
||||
|
||||
@@ -480,7 +481,7 @@ void wxPostScriptDCImpl::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord
|
||||
|
||||
int i_radius = wxRound( radius );
|
||||
|
||||
if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT)
|
||||
if ( m_brush.IsNonTransparent() )
|
||||
{
|
||||
SetBrush( m_brush );
|
||||
|
||||
@@ -501,7 +502,7 @@ void wxPostScriptDCImpl::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord
|
||||
CalcBoundingBox( xc+i_radius, yc+i_radius );
|
||||
}
|
||||
|
||||
if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
|
||||
if ( m_pen.IsNonTransparent() )
|
||||
{
|
||||
SetPen( m_pen );
|
||||
|
||||
@@ -542,7 +543,7 @@ void wxPostScriptDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
|
||||
if ( m_brush.IsNonTransparent() )
|
||||
{
|
||||
SetBrush( m_brush );
|
||||
|
||||
@@ -559,7 +560,7 @@ void wxPostScriptDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord
|
||||
CalcBoundingBox( x+w, y+h );
|
||||
}
|
||||
|
||||
if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
|
||||
if ( m_pen.IsNonTransparent() )
|
||||
{
|
||||
SetPen( m_pen );
|
||||
|
||||
@@ -581,7 +582,8 @@ void wxPostScriptDCImpl::DoDrawPoint (wxCoord x, wxCoord y)
|
||||
{
|
||||
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
|
||||
|
||||
if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
|
||||
if ( m_pen.IsTransparent() )
|
||||
return;
|
||||
|
||||
SetPen (m_pen);
|
||||
|
||||
@@ -604,7 +606,7 @@ void wxPostScriptDCImpl::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset
|
||||
|
||||
if (n <= 0) return;
|
||||
|
||||
if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
|
||||
if ( m_brush.IsNonTransparent() )
|
||||
{
|
||||
SetBrush( m_brush );
|
||||
|
||||
@@ -635,7 +637,7 @@ void wxPostScriptDCImpl::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset
|
||||
PsPrint( (fillStyle == wxODDEVEN_RULE ? "eofill\n" : "fill\n") );
|
||||
}
|
||||
|
||||
if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
|
||||
if ( m_pen.IsNonTransparent() )
|
||||
{
|
||||
SetPen( m_pen );
|
||||
|
||||
@@ -674,7 +676,7 @@ void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, int count[], wxPoint points[]
|
||||
|
||||
if (n <= 0) return;
|
||||
|
||||
if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
|
||||
if ( m_brush.IsNonTransparent() )
|
||||
{
|
||||
SetBrush( m_brush );
|
||||
|
||||
@@ -708,7 +710,7 @@ void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, int count[], wxPoint points[]
|
||||
PsPrint( (fillStyle == wxODDEVEN_RULE ? "eofill\n" : "fill\n") );
|
||||
}
|
||||
|
||||
if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
|
||||
if ( m_pen.IsNonTransparent() )
|
||||
{
|
||||
SetPen( m_pen );
|
||||
|
||||
@@ -748,7 +750,8 @@ void wxPostScriptDCImpl::DoDrawLines (int n, wxPoint points[], wxCoord xoffset,
|
||||
{
|
||||
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
|
||||
|
||||
if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
|
||||
if ( m_pen.IsTransparent() )
|
||||
return;
|
||||
|
||||
if (n <= 0) return;
|
||||
|
||||
@@ -785,7 +788,7 @@ void wxPostScriptDCImpl::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, w
|
||||
width--;
|
||||
height--;
|
||||
|
||||
if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
|
||||
if ( m_brush.IsNonTransparent() )
|
||||
{
|
||||
SetBrush( m_brush );
|
||||
|
||||
@@ -808,7 +811,7 @@ void wxPostScriptDCImpl::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, w
|
||||
CalcBoundingBox( x + width, y + height );
|
||||
}
|
||||
|
||||
if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
|
||||
if ( m_pen.IsNonTransparent() )
|
||||
{
|
||||
SetPen (m_pen);
|
||||
|
||||
@@ -849,7 +852,7 @@ void wxPostScriptDCImpl::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord w
|
||||
|
||||
wxCoord rad = (wxCoord) radius;
|
||||
|
||||
if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
|
||||
if ( m_brush.IsNonTransparent() )
|
||||
{
|
||||
SetBrush( m_brush );
|
||||
|
||||
@@ -881,7 +884,7 @@ void wxPostScriptDCImpl::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord w
|
||||
CalcBoundingBox( x + width, y + height );
|
||||
}
|
||||
|
||||
if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
|
||||
if ( m_pen.IsNonTransparent() )
|
||||
{
|
||||
SetPen (m_pen);
|
||||
|
||||
@@ -921,7 +924,7 @@ void wxPostScriptDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxC
|
||||
width--;
|
||||
height--;
|
||||
|
||||
if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
|
||||
if ( m_brush.IsNonTransparent() )
|
||||
{
|
||||
SetBrush (m_brush);
|
||||
|
||||
@@ -938,7 +941,7 @@ void wxPostScriptDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxC
|
||||
CalcBoundingBox( x + width, y + height );
|
||||
}
|
||||
|
||||
if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
|
||||
if ( m_pen.IsNonTransparent() )
|
||||
{
|
||||
SetPen (m_pen);
|
||||
|
||||
|
Reference in New Issue
Block a user