Version: 3.3.0
wxGraphicsPenInfo Class Reference

#include <wx/graphics.h>

Detailed Description

This class is a helper used for wxGraphicsPen creation using the named parameter idiom: it allows specifying various wxGraphicsPen attributes using the chained calls to its clearly named methods instead of passing them in the fixed order to wxGraphicsPen constructors.

Typically, you would use wxGraphicsPenInfo with a wxGraphicsContext. For example, to start drawing with a dotted blue pen slightly wider than normal you could, write the following:

ctx.SetPen(wxGraphicsPenInfo(*wxBLUE).Width(1.25).Style(wxPENSTYLE_DOT));
A wxGraphicsContext instance is the object that is drawn upon.
Definition: graphics.h:505
static wxGraphicsContext * Create()
Create a lightweight context that can be used only for measuring text.
void SetPen(const wxPen &pen)
Sets the pen used for stroking.
wxGraphicsPenInfo(const wxColour &colour=wxColour(), wxDouble width=1.0, wxPenStyle style=wxPENSTYLE_SOLID)
Constructor, which can set the colour, width and style for the pen.
@ wxPENSTYLE_DOT
Dotted style.
Definition: pen.h:21
Since
3.1.1

Public Member Functions

 wxGraphicsPenInfo (const wxColour &colour=wxColour(), wxDouble width=1.0, wxPenStyle style=wxPENSTYLE_SOLID)
 Constructor, which can set the colour, width and style for the pen. More...
 
wxGraphicsPenInfoColour (const wxColour &col)
 Sets the colour for the pen. More...
 
wxGraphicsPenInfoWidth (wxDouble width)
 Sets the line width for the pen. More...
 
wxGraphicsPenInfoStyle (wxPenStyle style)
 Sets the style for the pen. More...
 
wxGraphicsPenInfoStipple (const wxBitmap &stipple)
 Sets the bitmap used for stippling. More...
 
wxGraphicsPenInfoDashes (int nb_dashes, const wxDash *dash)
 Sets the dash pattern used to draw the pen's line. More...
 
wxGraphicsPenInfoJoin (wxPenJoin join)
 Sets the join for the pen, which is the appearance of where two lines meet or overlap. More...
 
wxGraphicsPenInfoCap (wxPenCap cap)
 Sets the cap (i.e., the end point) for the pen. More...
 
wxGraphicsPenInfoLinearGradient (wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, const wxColour &c1, const wxColour &c2, const wxGraphicsMatrix &matrix=wxNullGraphicsMatrix)
 Applies a linear gradient to the pen. More...
 
wxGraphicsPenInfoLinearGradient (wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2, const wxGraphicsGradientStops &stops, const wxGraphicsMatrix &matrix=wxNullGraphicsMatrix)
 Applies a linear gradient to the pen, including discontinuous stops in the pattern. More...
 
wxGraphicsPenInfoRadialGradient (wxDouble startX, wxDouble startY, wxDouble endX, wxDouble endY, wxDouble radius, const wxColour &oColor, const wxColour &cColor, const wxGraphicsMatrix &matrix=wxNullGraphicsMatrix)
 Applies a radial (i.e., circular) gradient to the pen. More...
 
wxGraphicsPenInfoRadialGradient (wxDouble startX, wxDouble startY, wxDouble endX, wxDouble endY, wxDouble radius, const wxGraphicsGradientStops &stops, const wxGraphicsMatrix &matrix=wxNullGraphicsMatrix)
 Applies a radial (i.e., circular) gradient to the pen, including discontinuous stops in the pattern. More...
 
wxColour GetColour () const
 Returns the pen's colour. More...
 
wxBitmap GetStipple () const
 Returns the pen's stipple bitmap. More...
 
wxPenStyle GetStyle () const
 Returns the pen's style. More...
 
wxPenJoin GetJoin () const
 Returns the pen's joining method. More...
 
wxPenCap GetCap () const
 Returns the pen's cap (i.e., end-point style). More...
 
int GetDashes (wxDash **ptr)
 Returns the pen's dash pattern and number of dashes in the pattern. More...
 
int GetDashCount () const
 Returns the number of dashes in the pen's dash pattern. More...
 
wxDash * GetDash () const
 Returns the pen's dash pattern. More...
 
bool IsTransparent () const
 Returns whether the pen is transparent. More...
 
wxDouble GetWidth () const
 Returns the pen's line width. More...
 
wxGradientType GetGradientType () const
 Returns the pen's gradient type. More...
 
wxDouble GetX1 () const
 Returns the x coordinate of the starting point (if using a gradient). More...
 
wxDouble GetY1 () const
 Returns the y coordinate of the starting point (if using a gradient). More...
 
wxDouble GetX2 () const
 Returns the x coordinate of the ending point (if using a gradient). More...
 
wxDouble GetY2 () const
 Returns the y coordinate of the ending point (if using a gradient). More...
 
wxDouble GetStartX () const
 Returns the x coordinate of the starting point (if using a gradient). More...
 
wxDouble GetStartY () const
 Returns the y coordinate of the starting point (if using a gradient). More...
 
wxDouble GetEndX () const
 Returns the x coordinate of the ending point (if using a gradient). More...
 
wxDouble GetEndY () const
 Returns the y coordinate of the ending point (if using a gradient). More...
 
wxDouble GetRadius () const
 Returns the radius of the radial gradient. More...
 
const wxGraphicsGradientStopsGetStops () const
 Returns the stops of the gradient. More...
 

Constructor & Destructor Documentation

◆ wxGraphicsPenInfo()

wxGraphicsPenInfo::wxGraphicsPenInfo ( const wxColour colour = wxColour(),
wxDouble  width = 1.0,
wxPenStyle  style = wxPENSTYLE_SOLID 
)
explicit

Constructor, which can set the colour, width and style for the pen.

Member Function Documentation

◆ Cap()

wxGraphicsPenInfo& wxGraphicsPenInfo::Cap ( wxPenCap  cap)

Sets the cap (i.e., the end point) for the pen.

◆ Colour()

wxGraphicsPenInfo& wxGraphicsPenInfo::Colour ( const wxColour col)

Sets the colour for the pen.

◆ Dashes()

wxGraphicsPenInfo& wxGraphicsPenInfo::Dashes ( int  nb_dashes,
const wxDash *  dash 
)

Sets the dash pattern used to draw the pen's line.

◆ GetCap()

wxPenCap wxGraphicsPenInfo::GetCap ( ) const

Returns the pen's cap (i.e., end-point style).

◆ GetColour()

wxColour wxGraphicsPenInfo::GetColour ( ) const

Returns the pen's colour.

◆ GetDash()

wxDash* wxGraphicsPenInfo::GetDash ( ) const

Returns the pen's dash pattern.

◆ GetDashCount()

int wxGraphicsPenInfo::GetDashCount ( ) const

Returns the number of dashes in the pen's dash pattern.

◆ GetDashes()

int wxGraphicsPenInfo::GetDashes ( wxDash **  ptr)

Returns the pen's dash pattern and number of dashes in the pattern.

◆ GetEndX()

wxDouble wxGraphicsPenInfo::GetEndX ( ) const

Returns the x coordinate of the ending point (if using a gradient).

◆ GetEndY()

wxDouble wxGraphicsPenInfo::GetEndY ( ) const

Returns the y coordinate of the ending point (if using a gradient).

◆ GetGradientType()

wxGradientType wxGraphicsPenInfo::GetGradientType ( ) const

Returns the pen's gradient type.

◆ GetJoin()

wxPenJoin wxGraphicsPenInfo::GetJoin ( ) const

Returns the pen's joining method.

◆ GetRadius()

wxDouble wxGraphicsPenInfo::GetRadius ( ) const

Returns the radius of the radial gradient.

◆ GetStartX()

wxDouble wxGraphicsPenInfo::GetStartX ( ) const

Returns the x coordinate of the starting point (if using a gradient).

◆ GetStartY()

wxDouble wxGraphicsPenInfo::GetStartY ( ) const

Returns the y coordinate of the starting point (if using a gradient).

◆ GetStipple()

wxBitmap wxGraphicsPenInfo::GetStipple ( ) const

Returns the pen's stipple bitmap.

◆ GetStops()

const wxGraphicsGradientStops& wxGraphicsPenInfo::GetStops ( ) const

Returns the stops of the gradient.

◆ GetStyle()

wxPenStyle wxGraphicsPenInfo::GetStyle ( ) const

Returns the pen's style.

◆ GetWidth()

wxDouble wxGraphicsPenInfo::GetWidth ( ) const

Returns the pen's line width.

◆ GetX1()

wxDouble wxGraphicsPenInfo::GetX1 ( ) const

Returns the x coordinate of the starting point (if using a gradient).

◆ GetX2()

wxDouble wxGraphicsPenInfo::GetX2 ( ) const

Returns the x coordinate of the ending point (if using a gradient).

◆ GetY1()

wxDouble wxGraphicsPenInfo::GetY1 ( ) const

Returns the y coordinate of the starting point (if using a gradient).

◆ GetY2()

wxDouble wxGraphicsPenInfo::GetY2 ( ) const

Returns the y coordinate of the ending point (if using a gradient).

◆ IsTransparent()

bool wxGraphicsPenInfo::IsTransparent ( ) const

Returns whether the pen is transparent.

◆ Join()

wxGraphicsPenInfo& wxGraphicsPenInfo::Join ( wxPenJoin  join)

Sets the join for the pen, which is the appearance of where two lines meet or overlap.

◆ LinearGradient() [1/2]

wxGraphicsPenInfo& wxGraphicsPenInfo::LinearGradient ( wxDouble  x1,
wxDouble  y1,
wxDouble  x2,
wxDouble  y2,
const wxColour c1,
const wxColour c2,
const wxGraphicsMatrix matrix = wxNullGraphicsMatrix 
)

Applies a linear gradient to the pen.

Parameters
x1The x coordinate of the starting point of the gradient.
y1The y coordinate of the starting point of the gradient.
x2The x coordinate of the ending point of the gradient.
y2The y coordinate of the ending point of the gradient.
c1The starting colour.
c2The ending colour.
matrixAn optional transformation to apply to the gradient.
Remarks
The starting and ending coordinates define the direction of the gradient. Along with north, south, east and west, diagonal directions can also be used.

◆ LinearGradient() [2/2]

wxGraphicsPenInfo& wxGraphicsPenInfo::LinearGradient ( wxDouble  x1,
wxDouble  y1,
wxDouble  x2,
wxDouble  y2,
const wxGraphicsGradientStops stops,
const wxGraphicsMatrix matrix = wxNullGraphicsMatrix 
)

Applies a linear gradient to the pen, including discontinuous stops in the pattern.

Parameters
x1The x coordinate of the starting point of the gradient.
y1The y coordinate of the starting point of the gradient.
x2The x coordinate of the ending point of the gradient.
y2The y coordinate of the ending point of the gradient.
stopsA series of stops to include in the pattern.
matrixAn optional transformation to apply to the gradient.
Remarks
The starting and ending coordinates define the direction of the gradient. Along with north, south, east and west, diagonal directions can also be used.

◆ RadialGradient() [1/2]

wxGraphicsPenInfo& wxGraphicsPenInfo::RadialGradient ( wxDouble  startX,
wxDouble  startY,
wxDouble  endX,
wxDouble  endY,
wxDouble  radius,
const wxColour oColor,
const wxColour cColor,
const wxGraphicsMatrix matrix = wxNullGraphicsMatrix 
)

Applies a radial (i.e., circular) gradient to the pen.

Parameters
startXThe x coordinate of the starting point of the gradient.
startYThe startY coordinate of the starting point of the gradient.
endXThe endX coordinate of the end of the circle.
endYThe endY coordinate of the end of the circle.
radiusThe radius of the circle of the gradient (around endX and endY).
oColorThe outer colour.
cColorThe center colour.
matrixAn optional transformation to apply to the gradient.
Remarks
The starting and ending coordinates define the direction of the gradient. Along with north, south, east and west, diagonal directions can also be used.

◆ RadialGradient() [2/2]

wxGraphicsPenInfo& wxGraphicsPenInfo::RadialGradient ( wxDouble  startX,
wxDouble  startY,
wxDouble  endX,
wxDouble  endY,
wxDouble  radius,
const wxGraphicsGradientStops stops,
const wxGraphicsMatrix matrix = wxNullGraphicsMatrix 
)

Applies a radial (i.e., circular) gradient to the pen, including discontinuous stops in the pattern.

Parameters
startXThe x coordinate of the starting point of the gradient.
startYThe startY coordinate of the starting point of the gradient.
endXThe endX coordinate of the end of the circle.
endYThe endY coordinate of the end of the circle.
radiusThe radius of the circle of the gradient (around endX and endY).
stopsA series of stops to include in the pattern.
matrixAn optional transformation to apply to the gradient.
Remarks
The starting and ending coordinates define the direction of the gradient. Along with north, south, east and west, diagonal directions can also be used.

◆ Stipple()

wxGraphicsPenInfo& wxGraphicsPenInfo::Stipple ( const wxBitmap stipple)

Sets the bitmap used for stippling.

When the pen is used, a repeating pattern of this bitmap will be drawn.

◆ Style()

wxGraphicsPenInfo& wxGraphicsPenInfo::Style ( wxPenStyle  style)

Sets the style for the pen.

◆ Width()

wxGraphicsPenInfo& wxGraphicsPenInfo::Width ( wxDouble  width)

Sets the line width for the pen.