wxPen — wx v2.4.3.1

Search documentation of wx

# wxPen (wx v2.4.3.1)

View Source

A pen is a drawing tool for drawing outlines.

It is used for drawing lines and painting the outline of rectangles, ellipses, etc. It has a colour, a width and a style.

Note: On a monochrome display, wxWidgets shows all non-white pens as black.

Do not initialize objects on the stack before the program commences, since other required structures may not have been set up yet. Instead, define global pointers to objects and create them in `wxApp::OnInit()` (not implemented in wx) or when required.

An application may wish to dynamically create pens with different characteristics, and there is the consequent danger that a large number of duplicate pens will be created. Therefore an application may wish to get a pointer to a pen by using the global list of pens ?wxThePenList, and calling the member function `wxPenList::FindOrCreatePen()` (not implemented in wx). See `wxPenList` (not implemented in wx) for more info.

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.

Predefined objects (include wx.hrl):

- ?wxNullPen

- ?wxBLACK_DASHED_PEN

- ?wxBLACK_PEN

- ?wxBLUE_PEN

- ?wxCYAN_PEN

- ?wxGREEN_PEN

- ?wxYELLOW_PEN

- ?wxGREY_PEN

- ?wxLIGHT_GREY_PEN

- ?wxMEDIUM_GREY_PEN

- ?wxRED_PEN

- ?wxTRANSPARENT_PEN

- ?wxWHITE_PEN

See:

- `wxDC`

- `wxDC:setPen/2`

wxWidgets docs: wxPen

# Summary

## Types

wxPen()

## Functions

destroy(This)

Destroys the object

getCap(This)

Returns the pen cap style, which may be one of `wxCAP\_ROUND`, `wxCAP\_PROJECTING` and `wxCAP\_BUTT`.

getColour(This)

Returns a reference to the pen colour.

getJoin(This)

Returns the pen join style, which may be one of `wxJOIN\_BEVEL`, `wxJOIN\_ROUND` and `wxJOIN\_MITER`.

getStyle(This)

Returns the pen style.

getWidth(This)

Returns the pen width.

isOk(This)

Returns true if the pen is initialised.

new()

Default constructor.

new/1

Copy constructor, uses overview_refcount.

new(Colour, Options)

Constructs a pen from a colour object, pen width and style.

setCap(This, CapStyle)

Sets the pen cap style, which may be one of `wxCAP\_ROUND`, `wxCAP\_PROJECTING` and `wxCAP\_BUTT`.

setColour(This, Colour)

The pen's colour is changed to the given colour.

setColour(This, Red, Green, Blue)
setJoin(This, Join_style)

Sets the pen join style, which may be one of `wxJOIN\_BEVEL`, `wxJOIN\_ROUND` and `wxJOIN\_MITER`.

setStyle(This, Style)

Set the pen style.

setWidth(This, Width)

Sets the pen width.

# Types

# wxPen()

    -type wxPen() :: wx:wx_object().

# Functions

# destroy(This)

    -spec destroy(This :: wxPen()) -> ok.

Destroys the object

# getCap(This)

    -spec getCap(This) -> wx:wx_enum() when This :: wxPen().

Returns the pen cap style, which may be one of `wxCAP\_ROUND`, `wxCAP\_PROJECTING` and `wxCAP\_BUTT`.

The default is `wxCAP_ROUND`.

See: `setCap/2`

# getColour(This)

    -spec getColour(This) -> wx:wx_colour4() when This :: wxPen().

Returns a reference to the pen colour.

See: `setColour/4`

# getJoin(This)

    -spec getJoin(This) -> wx:wx_enum() when This :: wxPen().

Returns the pen join style, which may be one of `wxJOIN\_BEVEL`, `wxJOIN\_ROUND` and `wxJOIN\_MITER`.

The default is `wxJOIN_ROUND`.

See: `setJoin/2`

# getStyle(This)

    -spec getStyle(This) -> wx:wx_enum() when This :: wxPen().

Returns the pen style.

See:

- `new/2`

- `setStyle/2`

# getWidth(This)

    -spec getWidth(This) -> integer() when This :: wxPen().

Returns the pen width.

See: `setWidth/2`

# isOk(This)

    -spec isOk(This) -> boolean() when This :: wxPen().

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.

# new()

    -spec new() -> wxPen().

Default constructor.

The pen will be uninitialised, and `isOk/1` will return false.

# new/1

    -spec new(Colour) -> wxPen() when Colour :: wx:wx_colour();
             (Pen) -> wxPen() when Pen :: wxPen().

Copy constructor, uses overview_refcount.

# new(Colour, Options)

    -spec new(Colour, [Option]) -> wxPen()
                 when Colour :: wx:wx_colour(), Option :: {width, integer()} | {style, wx:wx_enum()}.

Constructs a pen from a colour object, pen width and style.

Remark: Different versions of Windows and different versions of other platforms support very different subsets of the styles above so handle with care.

See:

- `setStyle/2`

- `setColour/4`

- `setWidth/2`

# setCap(This, CapStyle)

    -spec setCap(This, CapStyle) -> ok when This :: wxPen(), CapStyle :: wx:wx_enum().

Sets the pen cap style, which may be one of `wxCAP\_ROUND`, `wxCAP\_PROJECTING` and `wxCAP\_BUTT`.

The default is `wxCAP_ROUND`.

See: `getCap/1`

# setColour(This, Colour)

    -spec setColour(This, Colour) -> ok when This :: wxPen(), Colour :: wx:wx_colour().

The pen's colour is changed to the given colour.

See: `getColour/1`

# setColour(This, Red, Green, Blue)

    -spec setColour(This, Red, Green, Blue) -> ok
                       when This :: wxPen(), Red :: integer(), Green :: integer(), Blue :: integer().

# setJoin(This, Join_style)

    -spec setJoin(This, Join_style) -> ok when This :: wxPen(), Join_style :: wx:wx_enum().

Sets the pen join style, which may be one of `wxJOIN\_BEVEL`, `wxJOIN\_ROUND` and `wxJOIN\_MITER`.

The default is `wxJOIN_ROUND`.

See: `getJoin/1`

# setStyle(This, Style)

    -spec setStyle(This, Style) -> ok when This :: wxPen(), Style :: wx:wx_enum().

Set the pen style.

See: `new/2`

# setWidth(This, Width)

    -spec setWidth(This, Width) -> ok when This :: wxPen(), Width :: integer().

Sets the pen width.

See: `getWidth/1`