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.
The following standard pens are available to all applications:
Wx::NULL_PEN
Wx::RED_PEN
Wx::CYAN_PEN
Wx::GREEN_PEN
Wx::BLACK_PEN
Wx::WHITE_PEN
Wx::TRANSPARENT_PEN
Wx::BLACK_DASHED_PEN
Wx::GREY_PEN
Wx::MEDIUM_GREY_PEN
Wx::LIGHT_GREY_PEN
On a monochrome display, wxRUby shows all non-white pens as black.
Do not initialize Pens before the application commences, since other required structures may not have been set up yet. Instead, define methods which return Pens, and initialize them on first call.
PenList, DC, DC#set_pen, Brush
Pen.new(Colour colour,
Integer width = 1,
Integer style = SOLID)
Constructs a pen from a colour object, pen width and style.
Pen.new(String colourName,
Integer width,
Integer style)
Constructs a pen from a colour name, pen width and style.
Pen.new(Bitmap stipple,
Integer width)
Constructs a stippled pen from a stipple bitmap and a width.
| SOLID | Solid style. |
| TRANSPARENT | No pen is used. |
| DOT | Dotted style. |
| LONG_DASH | Long dashed style. |
| SHORT_DASH | Short dashed style. |
| DOT_DASH | Dot and dash style. |
| STIPPLE | Use the stipple bitmap. |
| USER_DASH | Use the user dashes: see Pen#set_dashes. |
| BDIAGONAL_HATCH | Backward diagonal hatch. |
| CROSSDIAG_HATCH | Cross-diagonal hatch. |
| FDIAGONAL_HATCH | Forward diagonal hatch. |
| CROSS_HATCH | Cross hatch. |
| HORIZONTAL_HATCH | Horizontal hatch. |
| VERTICAL_HATCH | Vertical hatch. |
Different versions of Windows and different versions of other platforms support very different subsets of the styles above – there is no similarity even between Windows95 and Windows98 – so handle with care, and test across platforms.
If the named colour form is used, an appropriate Wx::Colour structure is found in the colour database.
Pen#set_style, Pen#set_colour, Pen#set_width, Pen#set_stipple
Integer get_cap()
Returns the pen cap style, which may be one of Wx::CAP_ROUND,
Wx::CAP_PROJECTING and Wx::CAP_BUTT. The default is Wx::CAP_ROUND.
Colour get_colour()
Returns the pen’s colour
wxDashes get_dashes()
Gets an array of dashes (defined as char in X, DWORD under Windows). dashes is a pointer to the internal array. Do not deallocate or store this pointer. The function returns the number of dashes associated with this pen.
Not currently supported in wxRuby.
Integer get_join()
Returns the pen join style, which may be one of Wx::JOIN_BEVEL,
Wx::JOIN_ROUND and Wx::JOIN_MITER. The default is Wx::JOIN_ROUND.
Bitmap get_stipple()
Gets the stipple bitmap.
Integer get_style()
Returns the pen style, for example Wx::SOLID.
Integer get_width()
Returns the pen width.
Boolean is_ok()
Returns true if the pen is initialised.
set_cap(Integer capStyle)
Sets the pen cap style, which may be one of Wx::CAP_ROUND,
Wx::CAP_PROJECTING and Wx::CAP_BUTT. The default is
Wx::CAP_ROUND.
set_colour(Colour colour)
set_colour(String colour_name)
set_colour(Integer red, Integer blue, Integer green)
Specifies the colour of the pen by using a Colour, a colour name (see Colour for more details), or a set of red, green and blue values.
set_dashes(wxDashes)
Sets dashes. Not currently supported in wxRuby.
set_join(Integer join_style)
Returns the pen join style, which may be one of Wx::JOIN_BEVEL,
Wx::JOIN_ROUND and Wx::JOIN_MITER. The default is Wx::JOIN_ROUND.
set_stipple(Bitmap stipple)
Sets the bitmap for stippling.
set_style(Integer style)
Sets the pen style; see Pen.new for valid styles.
set_width(Integer width)
Sets the pen width, in pixels.
[This page automatically generated from the Textile source at Fri Oct 31 16:06:47 +0000 2008]