wx.Brush

Inheritance diagram for wx.Brush:



Description

A brush is a drawing tool for filling in areas. It is used for painting the background of rectangles, ellipses, etc. It has a colour and a style.

Derived From

Remarks

On a monochrome display, wxWidgets shows all brushes as white unless the colour is really black.

An application may wish to create brushes with different string characteristics dynamically, and there is the consequent danger that a large number of duplicate brushes will be created. Therefore an application may wish to get a pointer to a brush by using the global list of brushes wx.TheBrushList, and calling the member function FindOrCreateBrush.

This class uses reference counting and copy-on-write internally so that assignments between two instances of this class are very cheap. You can therefore use actual objects instead of pointers without efficiency problems. If an instance of this class is changed it will create its own data internally so that other instances, which previously shared the data using the reference counting, are not affected.

Properties Summary

Class API

Methods

__init__(colour, style=wx.SOLID)

Constructs a brush from a wx.Colour object and a style.

Parameters:


Returns:

wx.Brush


GetColour()

Returns a reference to the brush colour.


Returns:

wx.Colour

See also

SetColour


GetStipple()

Gets a pointer to the stipple bitmap.

If the brush does not have a wx.STIPPLE style, this bitmap may be not None but uninitialised (wx.Bitmap:IsOk returns False).


Returns:

wx.Bitmap

See also

SetStipple


GetStyle()

Returns the brush style, one of:

wx.TRANSPARENT Transparent (no fill).
wx.SOLID Solid.
wx.BDIAGONAL_HATCH Backward diagonal hatch.
wx.CROSSDIAG_HATCH Cross-diagonal hatch.
wx.FDIAGONAL_HATCH Forward diagonal hatch.
wx.CROSS_HATCH Cross hatch.
wx.HORIZONTAL_HATCH Horizontal hatch.
wx.VERTICAL_HATCH Vertical hatch.
wx.STIPPLE Stippled using a bitmap.
wx.STIPPLE_MASK_OPAQUE Stippled using a bitmap’s mask.

Returns:

int


IsHatch()

Returns True if the style of the brush is any of hatched fills.


Returns:

bool

See also

GetStyle


IsOk()

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 None has been assigned to it).


Returns:

bool


SetColour(colour)

Sets the brush colour using red, green and blue values.

Parameters:

See also

GetColour


SetStipple(stipple)

Sets the stipple bitmap.

Parameters:

Note

The style will be set to wx.STIPPLE, unless the bitmap has a mask associated to it, in which case the style will be set to wx.STIPPLE_MASK_OPAQUE.

If the wx.STIPPLE variant is used, the bitmap will be used to fill out the area to be drawn. If the wx.STIPPLE_MASK_OPAQUE is used, the current text foreground and text background determine what colours are used for displaying and the bits in the mask (which is a mono-bitmap actually) determine where to draw what.

Note

Note that under Windows 95, only 8x8 pixel large stipple bitmaps are supported, Windows 98 and NT as well as GTK support arbitrary bitmaps.

See also

wx.Bitmap


SetStyle(style)

Sets the brush style.

Parameters:

  • style (int): One of:

    wx.TRANSPARENT

    Transparent (no fill).

    wx.SOLID

    Solid.

    wx.BDIAGONAL_HATCH

    Backward diagonal hatch.

    wx.CROSSDIAG_HATCH

    Cross-diagonal hatch.

    wx.FDIAGONAL_HATCH

    Forward diagonal hatch.

    wx.CROSS_HATCH

    Cross hatch.

    wx.HORIZONTAL_HATCH

    Horizontal hatch.

    wx.VERTICAL_HATCH

    Vertical hatch.

    wx.STIPPLE

    Stippled using a bitmap.

    wx.STIPPLE_MASK_OPAQUE

    Stippled using a bitmap’s mask.

See also

GetStyle


Properties

Colour
See GetColour and SetColour
Stipple
See GetStipple and SetStipple
Style
See GetStyle and SetStyle