class PCanvasState

A class representing the state of a PCanvas.

Inheritance:


Public Classes

[more]enum PenStyles
This enum describes the types of styles that the pen uses.
[more]enum DrawingModes
This enum describes the set of transfer modes for pixels as they are drawn.
[more]enum PolyFillMode
This enum describes the ways in which a complex, overlapping polygon may be filled.

Public Methods

[more] PCanvasState ()
Create a new canvas state with default values.
[more] PCanvasState ( const PCanvasState & s )
Create a copy of the canvas state.
[more]virtual BOOL SetPenStyle ( PenStyles style )
Set the pen style to be used by future drawing operations.
[more]PenStyles GetPenStyle () const
Get the pen style to be used by future drawing operations.
[more]virtual BOOL SetPenWidth ( int width )
Set the pen width to be used by future drawing operations.
[more]int GetPenWidth () const
Get the pen width to be used by future drawing operations.
[more]virtual BOOL SetPenMode ( DrawingModes mode )
Set the pen mode to be used by future drawing operations.
[more]DrawingModes GetPenMode () const
Get the pen mode to be used by future drawing operations.
[more]virtual BOOL SetPenFgColour ( const PColour & colour )
Set the pen foreground colour to be used by future drawing operations.
[more]const PColour& GetPenFgColour () const
Get the pen foreground colour to be used by future drawing operations.
[more]virtual BOOL SetPenBkColour ( const PColour & colour )
Set the pen background colour to be used by future drawing operations.
[more]const PColour& GetPenBkColour () const
Get the pen background colour to be used by future drawing operations.
[more]virtual BOOL SetFillPattern ( const PPattern & pattern )
Set the fill pattern to be used by future drawing operations.
[more]PPattern GetFillPattern () const
Get the fill pattern to be used by future drawing operations.
[more]virtual BOOL SetPatternOrigin ( const PPoint & pt )
Set the origin for the pattern.
[more]PPoint GetPatternOrigin () const
Get the origin for the pattern.
[more]virtual BOOL SetFillMode (DrawingModes style)
Set the fill mode to be used by future drawing operations.
[more]DrawingModes GetFillMode () const
Get the fill mode to be used by future drawing operations.
[more]virtual BOOL SetFillFgColour ( const PColour & colour )
Set the fill foreground colour to be used by future drawing operations.
[more]const PColour& GetFillFgColour () const
Get the fill foreground colour to be used by future drawing operations.
[more]virtual BOOL SetFillBkColour ( const PColour & colour )
Set the fill background colour to be used by future drawing operations.
[more]const PColour& GetFillBkColour () const
Get the fill background colour to be used by future drawing operations.
[more]virtual BOOL SetFont (const PFont & newFont)
Set the font drawing tool to be used by future drawing operations.
[more]PFont GetFont () const
Get the font drawing tool that is used by drawing operations.
[more]virtual BOOL SetTextFgColour ( const PColour & colour )
Set the text foreground colour to be used by future drawing operations.
[more]const PColour& GetTextFgColour () const
Get the text foreground colour to be used by future drawing operations.
[more]virtual BOOL SetTextBkColour ( const PColour & colour )
Set the text background colour to be used by future drawing operations.
[more]const PColour& GetTextBkColour () const
Get the text background colour to be used by future drawing operations.
[more]virtual BOOL SetPolyFillMode ( PolyFillMode newMode )
Set the polygon fill mode to be used by future drawing operations.
[more]PolyFillMode GetPolyFillMode () const
Get the polygon fill mode to be used by future drawing operations.
[more]virtual BOOL SetPalette ( const PPalette & newPal )
Set the colour palette to be used by future drawing operations.
[more]PPalette GetPalette () const
Get the colour palette to be used by future drawing operations.
[more]virtual BOOL SetMappingRect ( const PRect & rect )
Set the source rectangle to be used in the coordinate transform in future drawing operations.
[more]PRect GetMappingRect () const
Get the source rectangle that is used in the coordinate transform of drawing operations.
[more]virtual BOOL SetViewportRect ( const PRect & rect )
Set the destination rectangle to be used in the coordinate transform in future drawing operations.
[more]PRect GetViewportRect () const
Get the destination rectangle that is used in the coordinate transform of drawing operations.
[more]void SetOrigin (const PPoint & pt)
Set the origin of the user coordinate system.
[more]PPoint GetOrigin () const
Set the origin of the user coordinate system.

Public

[more] New functions for class


Documentation

A class representing the state of a PCanvas. The state of a canvas is the current font, colours, line & fill modes etc that describes the way in which drawing operations are performed. Note that this class is not descended from the standard PObject class as multiple inheritance is used and common ancestors should be avoided at all costs.
o PCanvasState()
Create a new canvas state with default values. These values are:
penStyle
Solid
penWidth
0 Hairline
penMode
SrcCopy
penFgColour
Black
penBkColour
White
fillFgColour
Clear
fillBkColour
Clear
fillPattern
Solid
fillMode
SrcCopy
font
System, 10 point
textFgColour
Black
textBkColour
White
palette
Empty palette
polyFillMode
Winding
viewport
(0, 0, 100, 100) Scaling to pixels, no offset
map
(0, 0, 100, 100)

o PCanvasState( const PCanvasState & s )
Create a copy of the canvas state.
Parameters:
s - Source canvas state

o New functions for class

oenum PenStyles
This enum describes the types of styles that the pen uses. The pen is used to draw lines as well as border about other shapes eg rectangles, ellipses etc.

o Solid
Drawn with all pixels connected

o Dotted
Drawn with short line segments with equal sized gaps

o Dashed
Drawn with long line segments with short gaps

o DotDashed
Drawn with alternating dots and dashes

ovirtual BOOL SetPenStyle( PenStyles style )
Set the pen style to be used by future drawing operations. The pen is used to draw lines as well as border about other shapes eg rectangles, ellipses etc.

Returns:
TRUE if the pen style was changed, FALSE if the new pen style was identical to the current setting.
Parameters:
style - New pen style to set in the canvas state

oPenStyles GetPenStyle() const
Get the pen style to be used by future drawing operations. The pen is used to draw lines as well as border about other shapes eg rectangles, ellipses etc.

Returns:
the current pen style used in the canvas state.

ovirtual BOOL SetPenWidth( int width )
Set the pen width to be used by future drawing operations. The pen is used to draw lines as well as border about other shapes eg rectangles, ellipses etc.

Returns:
TRUE if the pen width was changed, FALSE if the new pen width was identical to the current setting.
Parameters:
width - Width of lines drawn by the pen in the current coordinate system used by the canvas state. A value of 0 indicates "hairline" or, by definition, one pixel wide regardless of the current coordinate transform.

oint GetPenWidth() const
Get the pen width to be used by future drawing operations. The pen is used to draw lines as well as border about other shapes eg rectangles, ellipses etc.

Returns:
the current pen width used in the canvas state.

oenum DrawingModes
This enum describes the set of transfer modes for pixels as they are drawn. As a drawing operation is performed (pen or fill) pixels are placed on the canvas as a combination of the drawing colour eg pen foreground colour, and the current colour of the canvas pixel. Many of these modes may have odd behaviour on colour canvases and are really only useful if the combination is made between black and white (1 bit) pixels.

If the logical modes, eg SrcAndDst, are used on a colour canvas then the boolean states for source and destination are derived by comparing the colour to the current drawing foreground colour.

o SrcCopy
Pixels are drawn in the requested colour

o SrcInvert
Pixels are drawn in the inverse of the colour

o SrcAndDst
The result is the AND of the requested colour and the current colour of the canvas pixel

o NotSrcAndDst
The result is the AND of the inverse of the requested colour and the current colour of the canvas pixel

o SrcAndNotDst
The result is the AND of the requested colour and the inverse of the current colour of the canvas pixel

o InvertSrcAndDst
The result is the inverse of the AND of the requested colour and the current colour of the canvas pixel

o SrcOrDst
The result is the OR of the requested colour and the current colour of the canvas pixel

o NotSrcOrDst
The result is the OR of the inverse of the requested colour and the current colour of the canvas pixel

o SrcOrNotDst
The result is the OR of the requested colour and the inverse of the current colour of the canvas pixel

o InvertSrcOrDst
The result is the inverse of the OR of the requested colour and the current colour of the canvas pixel

o SrcXorDst
The result is the eXclusive OR of the requested colour and the current colour of the canvas pixel

o InvertSrcXorDst
The result is the inverse of the eXclusive OR of the requested colour and the current colour of the canvas pixel

o InvertDst
Pixels on the canvas are inverted

o CopyDst
No change is made to the canvas pixels

ovirtual BOOL SetPenMode( DrawingModes mode )
Set the pen mode to be used by future drawing operations. The pen is used to draw lines as well as border about other shapes eg rectangles, ellipses etc.

Returns:
TRUE if the pen mode was changed, FALSE if the new pen mode was identical to the current setting.
Parameters:
mode - New mode to be used for pen drawing operations.

oDrawingModes GetPenMode() const
Get the pen mode to be used by future drawing operations. The pen is used to draw lines as well as border about other shapes eg rectangles, ellipses etc.

Returns:
the current pen mode used in the canvas state.

ovirtual BOOL SetPenFgColour( const PColour & colour )
Set the pen foreground colour to be used by future drawing operations. The pen is used to draw lines as well as border about other shapes eg rectangles, ellipses etc.

Returns:
TRUE if the pen foreground colour was changed, FALSE if the new pen foreground colour was identical to the current setting.
Parameters:
colour - New colour for the pen foreground

oconst PColour& GetPenFgColour() const
Get the pen foreground colour to be used by future drawing operations. The pen is used to draw lines as well as border about other shapes eg rectangles, ellipses etc.

Returns:
the current pen foreground colour used in the canvas state.

ovirtual BOOL SetPenBkColour( const PColour & colour )
Set the pen background colour to be used by future drawing operations. The pen background colour is used to draw the gaps in the drawn line when pen styles Dotted, Dashed or DotDashed are used. The pen is used to draw lines as well as border about other shapes eg rectangles, ellipses etc.

Returns:
TRUE if the pen background colour was changed, FALSE if the new pen background colour was identical to the current setting.
Parameters:
colour - New colour for the pen background

oconst PColour& GetPenBkColour() const
Get the pen background colour to be used by future drawing operations. The pen background colour is used to draw the gaps in the drawn line when pen styles Dotted, Dashed or DotDashed are used. The pen is used to draw lines as well as border about other shapes eg rectangles, ellipses etc.

Returns:
the current pen background colour used in the canvas state.

ovirtual BOOL SetFillPattern( const PPattern & pattern )
Set the fill pattern to be used by future drawing operations. The fill pattern is a (usually) small bitmap which is tiled into the interior of solid shapes eg rectangles, ellipses etc.

Returns:
TRUE if the fill pattern was changed, FALSE if the new fill pattern was identical to the current setting.
Parameters:
pattern - New pattern to be used for drawing fills

oPPattern GetFillPattern() const
Get the fill pattern to be used by future drawing operations. The fill pattern is a (usually) small bitmap which is tiled into the interior of solid shapes eg rectangles, ellipses etc.

Returns:
the current fill pattern used in the canvas state.

ovirtual BOOL SetPatternOrigin( const PPoint & pt )
Set the origin for the pattern. This sets the offset from 0 to 7 for origin for a pattern.
Parameters:
pt - New origin for pattern.

oPPoint GetPatternOrigin() const
Get the origin for the pattern. This sets the offset from 0 to 7 for origin for a pattern.

Returns:
point origin for patterns.

ovirtual BOOL SetFillMode(DrawingModes style)
Set the fill mode to be used by future drawing operations. The fill is used for the internal parts of solid shapes eg rectangles, ellipses etc.

Returns:
TRUE if the fill mode was changed, FALSE if the new fill mode was identical to the current setting.

oDrawingModes GetFillMode() const
Get the fill mode to be used by future drawing operations. The fill is used for the internal parts of solid shapes eg rectangles, ellipses etc.

Returns:
the current fill mode used in the canvas state.

ovirtual BOOL SetFillFgColour( const PColour & colour )
Set the fill foreground colour to be used by future drawing operations. The fill is used for the internal parts of solid shapes eg rectangles, ellipses etc.

Returns:
TRUE if the fill foreground colour was changed, FALSE if the new fill foreground colour was identical to the current setting.
Parameters:
colour - New colour for the fill foreground

oconst PColour& GetFillFgColour() const
Get the fill foreground colour to be used by future drawing operations. The fill is used for the internal parts of solid shapes eg rectangles, ellipses etc.

Returns:
the current fill foreground colour used in the canvas state.

ovirtual BOOL SetFillBkColour( const PColour & colour )
Set the fill background colour to be used by future drawing operations. The fill is used for the internal parts of solid shapes eg rectangles, ellipses etc.

Returns:
TRUE if the fill background colour was changed, FALSE if the new fill background colour was identical to the current setting.
Parameters:
colour - New colour for the fill background

oconst PColour& GetFillBkColour() const
Get the fill background colour to be used by future drawing operations. The fill is used for the internal parts of solid shapes eg rectangles, ellipses etc.

Returns:
the current fill background colour used in the canvas state.

ovirtual BOOL SetFont(const PFont & newFont)
Set the font drawing tool to be used by future drawing operations.

oPFont GetFont() const
Get the font drawing tool that is used by drawing operations.

ovirtual BOOL SetTextFgColour( const PColour & colour )
Set the text foreground colour to be used by future drawing operations.

Returns:
TRUE if the text foreground colour was changed, FALSE if the new text foreground colour was identical to the current setting.
Parameters:
colour - New colour for the text foreground

oconst PColour& GetTextFgColour() const
Get the text foreground colour to be used by future drawing operations.

Returns:
the current text foreground colour used in the canvas state.

ovirtual BOOL SetTextBkColour( const PColour & colour )
Set the text background colour to be used by future drawing operations. The background colour is for the "surrounds" of the characters drawn up to the size of the rectangular character cell.

Returns:
TRUE if the fill background colour was changed, FALSE if the new fill background colour was identical to the current setting.
Parameters:
colour - New colour for the text background

oconst PColour& GetTextBkColour() const
Get the text background colour to be used by future drawing operations. The background colour is for the "surrounds" of the characters drawn up to the size of the rectangular character cell.

Returns:
the current text background colour used in the canvas state.

oenum PolyFillMode
This enum describes the ways in which a complex, overlapping polygon may be filled.

When the fill mode is Alternating, the area between odd-numbered and even-numbered polygon sides on each scan line is filled. That is, the area between the first and second side, between the third and fourth side, and so on is filled.

When the fill mode is Winding, any region that has a nonzero winding value is filled. This value is defined as the number of times a pen used to draw the polygon would go around the region. The direction of each edge of the polygon is important.

o Winding
Selects alternate mode (fills area between odd-numbered and even-numbered polygon sides on each scan line)

o Alternating
Selects winding mode (fills any region with a nonzero winding value)

ovirtual BOOL SetPolyFillMode( PolyFillMode newMode )
Set the polygon fill mode to be used by future drawing operations.

Returns:
TRUE if the polygon fill mode was changed, FALSE if the new polygon fill mode was identical to the current setting.
Parameters:
newMode - New polygon fill mode

oPolyFillMode GetPolyFillMode() const
Get the polygon fill mode to be used by future drawing operations.

Returns:
the current polygon fill mode used in the canvas state.

ovirtual BOOL SetPalette( const PPalette & newPal )
Set the colour palette to be used by future drawing operations.

Returns:
TRUE if the colour palette was changed, FALSE if the new colour palette was identical to the current setting.
Parameters:
newPal - New palette to use

oPPalette GetPalette() const
Get the colour palette to be used by future drawing operations.

Returns:
the current colour palette used in the canvas state.

ovirtual BOOL SetMappingRect( const PRect & rect )
Set the source rectangle to be used in the coordinate transform in future drawing operations. This is a rectangle in the world coordinates of the application.

The mapping rectangle (in user coordinates) is transformed into the viewport rectangle (in device coordinates). This provides a scaling factor as well as origin shifting.

Returns:
TRUE if the mapping rectangle was changed, FALSE if the new mapping rectangle was identical to the current setting.
Parameters:
rect - New mapping rectangle

oPRect GetMappingRect() const
Get the source rectangle that is used in the coordinate transform of drawing operations.

The mapping rectangle (in user coordinates) is transformed into the viewport rectangle (in device coordinates). This provides a scaling factor as well as origin shifting.

Returns:
the current mapping rectangle used in the canvas state.

ovirtual BOOL SetViewportRect( const PRect & rect )
Set the destination rectangle to be used in the coordinate transform in future drawing operations. This is a rectangle in the device coordinates (pixels) of the screen, printer etc.

The mapping rectangle (in user coordinates) is transformed into the viewport rectangle (in device coordinates). This provides a scaling factor as well as origin shifting.

Returns:
TRUE if the mapping rectangle was changed, FALSE if the new mapping rectangle was identical to the current setting.
Parameters:
rect - New viewport rectangle

oPRect GetViewportRect() const
Get the destination rectangle that is used in the coordinate transform of drawing operations.

The mapping rectangle (in user coordinates) is transformed into the viewport rectangle (in device coordinates). This provides a scaling factor as well as origin shifting.

Returns:
the current mapping rectangle used in the canvas state.

ovoid SetOrigin(const PPoint & pt)
Set the origin of the user coordinate system. This is a shorthand way of adjusting the map and viewport rectangles.

oPPoint GetOrigin() const
Set the origin of the user coordinate system. This is a shorthand way of adjusting the map and viewport rectangles.

Returns:
point in user coordinates at origin of the canvas.


Direct child classes:
PShape
State
PCanvas

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.