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:
@@ -172,12 +172,47 @@ public:
|
||||
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.
|
||||
|
@@ -273,9 +273,43 @@ public:
|
||||
|
||||
/**
|
||||
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.
|
||||
|
Reference in New Issue
Block a user