wxRuby Documentation Home

# Wx::Brush

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

## Derived from

GDIObject

Object

## Predefined objects

The following predefined brushes are available everywhere once the
application has started.

Wx::NULL_BRUSH Wx::BLUE_BRUSH Wx::GREEN_BRUSH Wx::WHITE_BRUSH Wx::BLACK_BRUSH Wx::GREY_BRUSH Wx::MEDIUM_GREY_BRUSH Wx::LIGHT_GREY_BRUSH Wx::TRANSPARENT_BRUSH Wx::CYAN_BRUSH Wx::RED_BRUSH

## Remarks

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

Do not initialize brushes before the program commences, since other
required structures may not have been set up yet. Instead, reference them
using methods which create them if necessary.

## See also

DC, DC#set_brush, Pen

## Methods

- Brush.new
- Brush#get_colour
- Brush#get_stipple
- Brush#get_style
- Brush#is_hatch
- Brush#is_ok
- Brush#set_colour
- Brush#set_stipple
- Brush#set_style

### Brush.new

Brush.new()

Default constructor. The brush will be uninitialised, and “is_ok” will
return false.

Brush.new(%(arg-type)Colour% colour, Integer style = Wx::SOLID)

Constructs a brush from a colour object and a fill style.

Brush.new(%(arg-type)String% colour_name, Integer style)

Constructs a brush from a colour name and a fill style.

Brush.new(%(arg-type)Bitmap% stipple_bitmap)

Constructs a stippled brush using a bitmap. The brush style will
automatically be set to `Wx::STIPPLE`

The style for a brush may be one of the following constants:

- `Wx::TRANSPARENT` : Transparent (no fill).
- `Wx::SOLID` : Solid.
- `Wx::STIPPLE` : Uses a bitmap as a stipple.
- `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.

### Brush#get_colour

Colour get_colour()

Returns this brush’s colour.

### Brush#get_stipple

Bitmap get_stipple()

Returns the stipple bitmap used by this brush

### Brush#get_style

Integer get_style()

Returns the integer fill-style constant for this brush.

### Brush#is_hatch

Boolean is_hatch()

Returns `true` if this brush has any of the hatched fill styles.

### Brush#is_ok

Boolean is_ok()

Returns `true` if this brush is properly initialized and ready for use.

### #Brush_set_colour

set_colour(%(arg-type)Colour% colour) set_colour(%(arg-type)String% colour_name) set_colour(%(arg-type)Integer% red, Integer green, Integer blue)

Sets the fill colour used by this brush, by using a Colour
object, a colour name, or a set of red/green/blue components.

### Brush#set_stipple

set_bitmap(%(arg-type)Bitmap% stipple_bitmap)

Sets the stipple bitmap to be used by this brush.

### Brush#set_style

set_style(%(arg-type)Integer% style)

Sets the fill style to be used by this brush. See Brush.new
for a list of the available styles.

[This page automatically generated from the Textile source at 2023-06-09 00:45:36 +0000]