virtual bool IsHatch() const
{ return (GetStyle()>=wxBRUSHSTYLE_FIRST_HATCH) && (GetStyle()<=wxBRUSHSTYLE_LAST_HATCH); }
+
+ // Convenient helpers for testing whether the brush is a transparent one:
+ // unlike GetStyle() == wxBRUSHSTYLE_TRANSPARENT, they work correctly even
+ // if the brush is invalid (they both return false in this case).
+ bool IsTransparent() const
+ {
+ return IsOk() && GetStyle() == wxBRUSHSTYLE_TRANSPARENT;
+ }
+
+ bool IsNonTransparent() const
+ {
+ return IsOk() && GetStyle() != wxBRUSHSTYLE_TRANSPARENT;
+ }
};
#if defined(__WXPALMOS__)
virtual wxPenCap GetCap() const = 0;
virtual int GetWidth() const = 0;
virtual int GetDashes(wxDash **ptr) const = 0;
+
+ // Convenient helpers for testing whether the pen is a transparent one:
+ // unlike GetStyle() == wxPENSTYLE_TRANSPARENT, they work correctly even if
+ // the pen is invalid (they both return false in this case).
+ bool IsTransparent() const
+ {
+ return IsOk() && GetStyle() == wxPENSTYLE_TRANSPARENT;
+ }
+
+ bool IsNonTransparent() const
+ {
+ return IsOk() && GetStyle() != wxPENSTYLE_TRANSPARENT;
+ }
};
#if defined(__WXPALMOS__)
virtual bool IsHatch() const;
/**
- Returns @true if the brush is initialised. It will return @false if the default
- constructor has been used (for example, the brush is a member of a class, or
- @NULL has been assigned to it).
+ Returns @true if the brush is initialised.
+
+ Notice that an uninitialized brush object can't be queried for any
+ brush properties and all calls to the accessor methods on it will
+ result in an assert failure.
*/
virtual bool IsOk() const;
+ /**
+ Returns @true if the brush is a valid non-transparent brush.
+
+ This method returns @true if the brush object is initialized and has a
+ non-transparent style. Notice that this should be used instead of
+ simply testing whether GetStyle() returns a style different from
+ wxBRUSHSTYLE_TRANSPARENT if the brush may be invalid as GetStyle()
+ would assert in this case.
+
+ @see IsTransparent()
+
+ @since 2.9.2.
+ */
+ bool IsNonTransparent() const;
+
+ /**
+ Returns @true if the brush is transparent.
+
+ A transparent brush is simply a brush with wxBRUSHSTYLE_TRANSPARENT
+ style.
+
+ Notice that this function works even for non-initialized brushs (for
+ which it returns @false) unlike tests of the form <code>GetStyle() ==
+ wxBRUSHSTYLE_TRANSPARENT</code> which would assert if the brush is
+ invalid.
+
+ @see IsNonTransparent()
+
+ @since 2.9.2.
+ */
+ bool IsTransparent() const;
+
+
//@{
/**
Sets the brush colour using red, green and blue values.
/**
Returns @true if the pen is initialised.
+
+ Notice that an uninitialized pen object can't be queried for any pen
+ properties and all calls to the accessor methods on it will result in
+ an assert failure.
*/
virtual bool IsOk() const;
+ /**
+ Returns @true if the pen is a valid non-transparent pen.
+
+ This method returns @true if the pen object is initialized and has a
+ non-transparent style. Notice that this should be used instead of
+ simply testing whether GetStyle() returns a style different from
+ wxPENSTYLE_TRANSPARENT if the pen may be invalid as GetStyle() would
+ assert in this case.
+
+ @see IsTransparent()
+
+ @since 2.9.2.
+ */
+ bool IsNonTransparent() const;
+
+ /**
+ Returns @true if the pen is transparent.
+
+ A transparent pen is simply a pen with wxPENSTYLE_TRANSPARENT style.
+
+ Notice that this function works even for non-initialized pens (for
+ which it returns @false) unlike tests of the form <code>GetStyle() ==
+ wxPENSTYLE_TRANSPARENT</code> which would assert if the pen is invalid.
+
+ @see IsNonTransparent()
+
+ @since 2.9.2.
+ */
+ bool IsTransparent() const;
+
/**
Sets the pen cap style, which may be one of @c wxCAP_ROUND, @c wxCAP_PROJECTING
and @c wxCAP_BUTT. The default is @c wxCAP_ROUND.
bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y,
const wxColour& col, wxFloodFillStyle style)
{
- if (dc->GetBrush().GetStyle() == wxBRUSHSTYLE_TRANSPARENT)
+ if (dc->GetBrush().IsTransparent())
return true;
int height = 0;
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
- if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
+ if ( m_pen.IsTransparent() )
+ return;
SetPen( m_pen );
int i_radius = wxRound( radius );
- if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush( m_brush );
CalcBoundingBox( xc+i_radius, yc+i_radius );
}
- if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen( m_pen );
return;
}
- if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush( m_brush );
CalcBoundingBox( x+w, y+h );
}
- if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen( m_pen );
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
- if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
+ if ( m_pen.IsTransparent() )
+ return;
SetPen (m_pen);
if (n <= 0) return;
- if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush( m_brush );
PsPrint( (fillStyle == wxODDEVEN_RULE ? "eofill\n" : "fill\n") );
}
- if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen( m_pen );
if (n <= 0) return;
- if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush( m_brush );
PsPrint( (fillStyle == wxODDEVEN_RULE ? "eofill\n" : "fill\n") );
}
- if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen( m_pen );
{
wxCHECK_RET( m_ok, wxT("invalid postscript dc") );
- if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
+ if ( m_pen.IsTransparent() )
+ return;
if (n <= 0) return;
width--;
height--;
- if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush( m_brush );
CalcBoundingBox( x + width, y + height );
}
- if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen (m_pen);
wxCoord rad = (wxCoord) radius;
- if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush( m_brush );
CalcBoundingBox( x + width, y + height );
}
- if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen (m_pen);
width--;
height--;
- if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush (m_brush);
CalcBoundingBox( x + width, y + height );
}
- if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen (m_pen);
{
wxCHECK_RET( IsOk(), wxT("invalid window dc") );
- if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
if (m_gdkwindow)
gdk_draw_line( m_gdkwindow, m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) );
{
wxCHECK_RET( IsOk(), wxT("invalid window dc") );
- if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
int w = 0;
int h = 0;
if (m_gdkwindow)
{
- if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
GdkGC* gc;
bool originChanged;
gdk_gc_set_ts_origin(gc, 0, 0);
}
- if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
gdk_draw_arc( m_gdkwindow, m_penGC, FALSE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 );
- if ((m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) && (alpha2 - alpha1 != 360*64))
+ if ( m_brush.IsNonTransparent() && (alpha2 - alpha1 != 360*64) )
{
gdk_draw_line( m_gdkwindow, m_penGC, xx1, yy1, xxc, yyc );
gdk_draw_line( m_gdkwindow, m_penGC, xxc, yyc, xx2, yy2 );
wxCoord start = wxCoord(sa * 64.0);
wxCoord end = wxCoord((ea-sa) * 64.0);
- if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
GdkGC* gc;
bool originChanged;
gdk_gc_set_ts_origin(gc, 0, 0);
}
- if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
gdk_draw_arc( m_gdkwindow, m_penGC, FALSE, xx, yy, ww, hh, start, end );
}
{
wxCHECK_RET( IsOk(), wxT("invalid window dc") );
- if ((m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) && m_gdkwindow)
+ if ( m_pen.IsNonTransparent() && m_gdkwindow )
gdk_draw_point( m_gdkwindow, m_penGC, XLOG2DEV(x), YLOG2DEV(y) );
CalcBoundingBox (x, y);
{
wxCHECK_RET( IsOk(), wxT("invalid window dc") );
- if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
if (n <= 0) return;
+ if ( m_pen.IsTransparent() )
+ return;
+
//Check, if scaling is necessary
const bool doScale =
xoffset != 0 || yoffset != 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10;
if (m_gdkwindow)
{
- if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
GdkGC* gc;
bool originChanged;
gdk_gc_set_ts_origin(gc, 0, 0);
}
- if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
/*
for (i = 0 ; i < n ; i++)
if (m_gdkwindow)
{
- if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
GdkGC* gc;
bool originChanged;
gdk_gc_set_ts_origin(gc, 0, 0);
}
- if ( m_pen.IsOk() && m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT )
+ if ( m_pen.IsNonTransparent() )
{
if ((m_pen.GetWidth() == 2) && (m_pen.GetCap() == wxCAP_ROUND) &&
(m_pen.GetJoin() == wxJOIN_ROUND) && (m_pen.GetStyle() == wxPENSTYLE_SOLID))
// CMB: adjust size if outline is drawn otherwise the result is
// 1 pixel too wide and high
- if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
ww--;
hh--;
if (dd > hh) dd = hh;
rr = dd / 2;
- if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
GdkGC* gc;
bool originChanged;
gdk_gc_set_ts_origin(gc, 0, 0);
}
- if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
gdk_draw_line( m_gdkwindow, m_penGC, xx+rr+1, yy, xx+ww-rr, yy );
gdk_draw_line( m_gdkwindow, m_penGC, xx+rr+1, yy+hh, xx+ww-rr, yy+hh );
if (m_gdkwindow)
{
- if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
GdkGC* gc;
bool originChanged;
// If the pen is transparent pen we increase the size
// for better compatibility with other platforms.
- if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
++ww;
++hh;
gdk_gc_set_ts_origin(gc, 0, 0);
}
- if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
gdk_draw_arc( m_gdkwindow, m_penGC, false, xx, yy, ww, hh, 0, 360*64 );
}
void wxGnomePrinterDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
{
- if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
+ if ( m_pen.IsTransparent() )
+ return;
SetPen( m_pen );
while (alpha2 > 360) alpha2 -= 360;
}
- if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush( m_brush );
gs_libGnomePrint->gnome_print_moveto ( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc) );
gs_libGnomePrint->gnome_print_fill( m_gpc );
}
- if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen (m_pen);
gs_libGnomePrint->gnome_print_newpath( m_gpc );
xx = 0.0;
yy = 0.0;
- if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush( m_brush );
gs_libGnomePrint->gnome_print_fill( m_gpc );
}
- if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen (m_pen);
void wxGnomePrinterDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
{
- if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
-
if (n <= 0) return;
+ if ( m_pen.IsTransparent() )
+ return;
+
SetPen (m_pen);
int i;
{
if (n==0) return;
- if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush( m_brush );
gs_libGnomePrint->gnome_print_fill( m_gpc );
}
- if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen (m_pen);
width--;
height--;
- if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush( m_brush );
CalcBoundingBox( x + width, y + height );
}
- if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen (m_pen);
wxCoord rad = wxRound( radius );
- if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush(m_brush);
gs_libGnomePrint->gnome_print_newpath(m_gpc);
CalcBoundingBox(x+width,y+height);
}
- if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen(m_pen);
gs_libGnomePrint->gnome_print_newpath(m_gpc);
width--;
height--;
- if (m_brush.GetStyle () != wxBRUSHSTYLE_TRANSPARENT)
+ if ( m_brush.IsNonTransparent() )
{
SetBrush( m_brush );
makeEllipticalPath( x, y, width, height );
CalcBoundingBox( x + width, y + height );
}
- if (m_pen.GetStyle () != wxPENSTYLE_TRANSPARENT)
+ if ( m_pen.IsNonTransparent() )
{
SetPen (m_pen);
makeEllipticalPath( x, y, width, height );
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) );
void wxGtkPrinterDCImpl::DoDrawPoint(wxCoord x, wxCoord y)
{
- if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return;
+ if ( m_pen.IsTransparent() )
+ return;
SetPen( m_pen );
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;
wxCoord xxx2 = (wxCoord) (xxc+ray);
wxCoord yyy2 = (wxCoord) (yyc+ray);
- if ( m_brush.IsOk() && m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT )
+ if ( m_brush.IsNonTransparent() )
{
// Have to add 1 to bottom-right corner of rectangle
// to make semi-circles look right (crooked line otherwise).
// (i.e. drawn with a transparent pen) one pixel smaller in both directions
// and we want them to have the same size regardless of which pen is used
#ifndef __WXWINCE__
- if ( m_pen.IsOk() && m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT )
+ if ( m_pen.IsTransparent() )
{
x2dev++;
y2dev++;
// Windows draws the filled rectangles without outline (i.e. drawn with a
// transparent pen) one pixel smaller in both directions and we want them
// to have the same size regardless of which pen is used - adjust
- if ( m_pen.IsOk() && m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT )
+ if ( m_pen.IsTransparent() )
{
x2++;
y2++;