tbx  0.7.3
Public Member Functions | List of all members
tbx::Graphics Class Referenceabstract

Interface to drawing graphics to the screen. More...

#include <graphics.h>

Inheritance diagram for tbx::Graphics:
tbx::OSGraphics tbx::OffsetGraphics

Public Member Functions

virtual int os_x (int logical_x) const =0
 Convert from logical x value to OS units. More...
 
virtual int os_y (int logical_y) const =0
 Convert from logical y value to OS units. More...
 
virtual int logical_x (int os_x) const =0
 Convert from OS units to logical x value. More...
 
virtual int logical_y (int os_y) const =0
 Convert from OS units to logical y value. More...
 
virtual Point os (const Point &pt)
 Convert from logical coordinates to OS units. More...
 
virtual Point logical (const Point &pt)
 Convert from OS units to logical coordinates. More...
 
virtual BBox os (const BBox &b)
 Convert from logical coordinates to OS units. More...
 
virtual BBox logical (const BBox &b)
 Convert from OS units to logical coordinates. More...
 
virtual void foreground (Colour colour)=0
 Set the foreground colour for graphics. More...
 
virtual void background (Colour colour)=0
 Set the background colour for graphics. More...
 
virtual void wimp_foreground (WimpColour colour)=0
 Set the foreground colour for graphics to one of the standard WIMP colours. More...
 
virtual void wimp_background (WimpColour colour)=0
 Set the background colour for graphics to one of the standard WIMP colours. More...
 
virtual void move (int x, int y)=0
 Move the graphics cursor to the given point. More...
 
virtual void point (int x, int y)=0
 Draw a point at the given location. More...
 
virtual void line (int tx, int ty)=0
 Draw a line from the last point visited to the given location. More...
 
virtual void line (int fx, int fy, int tx, int ty)
 Draw a line between the given two points. More...
 
virtual void rectangle (int xmin, int ymin, int xmax, int ymax)=0
 Draw the outline of a rectangle. More...
 
virtual void fill_rectangle (int xmin, int ymin, int xmax, int ymax)=0
 Draw a filled rectangle. More...
 
virtual void path (const Point *points, int num)=0
 Draw a path of lines connecting the given points. More...
 
virtual void polygon (const Point *points, int num)=0
 Draw the outline of a polygon. More...
 
virtual void fill_polygon (const Point *points, int num)=0
 Draw a filled polygon. More...
 
virtual void circle (int centre_x, int centre_y, int radius)=0
 Draw the outline of a circle. More...
 
virtual void fill_circle (int centre_x, int centre_y, int radius)=0
 Draw a filled circle. More...
 
virtual void arc (int centre_x, int centre_y, int start_x, int start_y, int end_x, int end_y)=0
 Draw arc around a circle. More...
 
virtual void segment (int centre_x, int centre_y, int start_x, int start_y, int end_x, int end_y)=0
 Draw a segment of a circle. More...
 
virtual void sector (int centre_x, int centre_y, int start_x, int start_y, int end_x, int end_y)=0
 Draw a sector of a circle. More...
 
virtual void ellipse (int centre_x, int centre_y, int intersect_x, int intersect_y, int high_x, int high_y)=0
 Draw the outline of an ellipse. More...
 
virtual void fill_ellipse (int centre_x, int centre_y, int intersect_x, int intersect_y, int high_x, int high_y)=0
 Draw a filled ellipse. More...
 
virtual void move (const Point &point)
 Move the graphics cursor to the given location. More...
 
virtual void point (const Point &pt)
 Draw a point at the given location. More...
 
virtual void line (const Point &to_point)
 Draw a line from the last point visited to the given location. More...
 
virtual void line (const Point &from_point, const Point &to_point)
 Draw a line between the given two points. More...
 
virtual void rectangle (const Point &min_point, const Point &max_point)
 Draw the outline of a rectangle. More...
 
virtual void rectangle (const BBox &r)
 Draw the outline of a rectangle. More...
 
virtual void fill_rectangle (const Point &min_point, const Point &max_point)
 Draw the outline of a rectangle. More...
 
virtual void fill_rectangle (const BBox &r)
 Draw a filled rectangle. More...
 
virtual void circle (const Point &centre_point, int radius)
 Draw the outline of a circle. More...
 
virtual void fill_circle (const Point &centre_point, int radius)
 Draw a filled circle. More...
 
virtual void arc (const Point &centre_point, const Point &start_point, const Point &end_point)
 Draw an arc. More...
 
virtual void segment (const Point &centre_point, const Point &start_point, const Point &end_point)
 Draw a segment of a circle. More...
 
virtual void sector (const Point &centre_point, const Point &start_point, const Point &end_point)
 Draw a sector of a circle. More...
 
virtual void ellipse (const Point &centre_point, const Point &intersect_point, const Point &high_point)
 Draw the outline of an ellipse. More...
 
virtual void fill_ellipse (const Point &centre_point, const Point &intersect_point, const Point &high_point)
 Draw a filled ellipse. More...
 
virtual void text (int x, int y, const std::string &text)=0
 Draw text at the given location in the current WIMP font. More...
 
virtual void text (int x, int y, const std::string &text, const Font &font)=0
 Draw text at the given location in the given font. More...
 
virtual void text_colours (Colour foreground, Colour background)=0
 Set the text colours for the current WIMP font. More...
 
virtual void text_colours (Font &font, Colour foreground, Colour background)=0
 Set text colours for the given font. More...
 
virtual void text (const Point &pt, const std::string &str)
 Draw text at the given location in the current WIMP font. More...
 
virtual void text (const Point &pt, const std::string &str, const Font &font)
 Draw text at the given location in the given font. More...
 
virtual void image (int x, int y, const Image &image)=0
 Draw an image. More...
 
virtual void image (const Point &pt, const Image &im)
 Draw an image. More...
 
virtual void fill (int x, int y, const DrawPath &path, DrawFillStyle fill_style=WINDING_NON_ZERO, int flatness=1)=0
 Fill a draw path. More...
 
virtual void fill (const Point &pt, const DrawPath &path, DrawFillStyle fill_style=WINDING_NON_ZERO, int flatness=1)
 Fill a draw path. More...
 
virtual void stroke (int x, int y, const DrawPath &path, DrawFillStyle fill_style=WINDING_NON_ZERO, int flatness=1, int thickness=0, DrawCapAndJoin *cap_and_join=0, DrawDashPattern *dashes=0)=0
 Plot the lines in a path. More...
 
virtual void stroke (const Point &pt, const DrawPath &path, DrawFillStyle fill_style=WINDING_NON_ZERO, int flatness=1, int thickness=0, DrawCapAndJoin *cap_and_join=0, DrawDashPattern *dashes=0)
 Plot the lines in a path. More...
 

Detailed Description

Interface to drawing graphics to the screen.

This provides a standard interface that can be used with all the graphics classes.

Member Function Documentation

virtual void tbx::Graphics::arc ( int  centre_x,
int  centre_y,
int  start_x,
int  start_y,
int  end_x,
int  end_y 
)
pure virtual

Draw arc around a circle.

Parameters
centre_xcentre of circle arc is on
centre_ycentre of circle arc is on
start_xstart of arc
start_ystart of arc
end_xpoint on line from centre to the end of the arc
end_ypoint on line from centre to the end of the arc

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::arc ( const Point centre_point,
const Point start_point,
const Point end_point 
)
inlinevirtual

Draw an arc.

Parameters
centre_pointcentre of circle arc is on
start_pointstart of arc
end_pointpoint on line from centre to the end of the arc
virtual void tbx::Graphics::background ( Colour  colour)
pure virtual

Set the background colour for graphics.

Parameters
colournew colour for the background

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::circle ( int  centre_x,
int  centre_y,
int  radius 
)
pure virtual

Draw the outline of a circle.

Parameters
centre_xx coordinate of centre of the circle
centre_yy coordinate of centre of the circle
radiusradius of the circle

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::circle ( const Point centre_point,
int  radius 
)
inlinevirtual

Draw the outline of a circle.

Parameters
centre_pointcoordinates of centre of the circle
radiusradius of the circle
virtual void tbx::Graphics::ellipse ( int  centre_x,
int  centre_y,
int  intersect_x,
int  intersect_y,
int  high_x,
int  high_y 
)
pure virtual

Draw the outline of an ellipse.

Parameters
centre_xcentre of the ellipse
centre_ycentre of the ellipse
intersect_xintersection of centre_y and edge of ellipse
intersect_yintersection of centre_y and edge of ellipse
high_xhighest (or lowest) point on the ellipse
high_yhighest (or lowest) point on the ellipse

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::ellipse ( const Point centre_point,
const Point intersect_point,
const Point high_point 
)
inlinevirtual

Draw the outline of an ellipse.

Parameters
centre_pointcentre of the ellipse
intersect_pointintersection of centre and edge of ellipse
high_pointhighest (or lowest) point on the ellipse
virtual void tbx::Graphics::fill ( int  x,
int  y,
const DrawPath path,
DrawFillStyle  fill_style = WINDING_NON_ZERO,
int  flatness = 1 
)
pure virtual

Fill a draw path.

The path is drawn by transforming it so the user units used in it are treated as OS coordinates.

Parameters
xcoordinate of bottom left to place the path
ycoordinate of bottom left to place the path
paththe DrawPath to fill
stylestyle flags for filling. Default WINDING_NON_ZERO.
flatnessmaximum distance allowed from beizer curve when flattening it in user units. Defaults to 1 as this gives a good curve with the transform used.

Implemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual void tbx::Graphics::fill ( const Point pt,
const DrawPath path,
DrawFillStyle  fill_style = WINDING_NON_ZERO,
int  flatness = 1 
)
inlinevirtual

Fill a draw path.

The path is drawn by transforming it so the user units used in it are treated as OS coordinates.

Parameters
ptcoordinates of bottom left to place the path
paththe DrawPath to fill
stylestyle flags for filling. Default WINDING_NON_ZERO.
flatnessmaximum distance allowed from beizer curve when flattening it in user units. Defaults to 1 as this gives a good curve with the transform used.

Reimplemented in tbx::OffsetGraphics.

virtual void tbx::Graphics::fill_circle ( int  centre_x,
int  centre_y,
int  radius 
)
pure virtual

Draw a filled circle.

Parameters
centre_xx coordinate of centre of the circle
centre_yy coordinate of centre of the circle
radiusradius of the circle

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::fill_circle ( const Point centre_point,
int  radius 
)
inlinevirtual

Draw a filled circle.

Parameters
centre_pointcoordinates of centre of the circle
radiusradius of the circle
virtual void tbx::Graphics::fill_ellipse ( int  centre_x,
int  centre_y,
int  intersect_x,
int  intersect_y,
int  high_x,
int  high_y 
)
pure virtual

Draw a filled ellipse.

Parameters
centre_xcentre of the ellipse
centre_ycentre of the ellipse
intersect_xintersection of centre_y and edge of ellipse
intersect_yintersection of centre_y and edge of ellipse
high_xhighest (or lowest) point on the ellipse
high_yhighest (or lowest) point on the ellipse

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::fill_ellipse ( const Point centre_point,
const Point intersect_point,
const Point high_point 
)
inlinevirtual

Draw a filled ellipse.

Parameters
centre_pointcentre of the ellipse
intersect_pointintersection of centre and edge of ellipse
high_pointhighest (or lowest) point on the ellipse
virtual void tbx::Graphics::fill_polygon ( const Point points,
int  num 
)
pure virtual

Draw a filled polygon.

The algorithm that fills the polygon is not guaranteed to be accurate unless it can fill it by using triangles swept from the first point.

Parameters
pointsarray of vertices of the polygon
numnumber of vertices

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::fill_rectangle ( int  xmin,
int  ymin,
int  xmax,
int  ymax 
)
pure virtual

Draw a filled rectangle.

Parameters
xminminimum x coordinate of rectangle
yminminimum y coordinate of rectangle
xmaxmaximum x coordinate of rectangle
ymaxmaximum y coordinate of rectangle

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::fill_rectangle ( const Point min_point,
const Point max_point 
)
inlinevirtual

Draw the outline of a rectangle.

Parameters
min_pointminimum coordinates of rectangle
max_pointmaximum coordinates of rectangle
virtual void tbx::Graphics::fill_rectangle ( const BBox r)
inlinevirtual

Draw a filled rectangle.

Parameters
rcoordinates of rectangle
virtual void tbx::Graphics::foreground ( Colour  colour)
pure virtual

Set the foreground colour for graphics.

Parameters
colournew colour for the foreground

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::image ( int  x,
int  y,
const Image image 
)
pure virtual

Draw an image.

Parameters
xx coordinate for bottom left of image
yx coordinate for bottom left of image
imageImage to draw

Implemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual void tbx::Graphics::image ( const Point pt,
const Image im 
)
inlinevirtual

Draw an image.

Parameters
ptcoordinates for bottom left of image
imImage to draw

Reimplemented in tbx::OffsetGraphics.

virtual void tbx::Graphics::line ( int  tx,
int  ty 
)
pure virtual

Draw a line from the last point visited to the given location.

Parameters
txcoordinate of end of line
tycoordinate of end of line

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::line ( int  fx,
int  fy,
int  tx,
int  ty 
)
inlinevirtual

Draw a line between the given two points.

Parameters
fxx coordinate of start of line
fyy coordinate of start of line
txx coordinate of end of line
tyy coordinate of end of line

Reimplemented in tbx::OSGraphics.

virtual void tbx::Graphics::line ( const Point to_point)
inlinevirtual

Draw a line from the last point visited to the given location.

Parameters
to_pointcoordinates to draw line to
virtual void tbx::Graphics::line ( const Point from_point,
const Point to_point 
)
inlinevirtual

Draw a line between the given two points.

Parameters
from_pointcoordinates of start of line
to_pointcoordinates of end of line
virtual Point tbx::Graphics::logical ( const Point pt)
inlinevirtual

Convert from OS units to logical coordinates.

Parameters
ptvalue to convert
Returns
equivalent value in logical units

Reimplemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual BBox tbx::Graphics::logical ( const BBox b)
inlinevirtual

Convert from OS units to logical coordinates.

Parameters
bvalue to convert
Returns
equivalent value in logical units

Reimplemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual int tbx::Graphics::logical_x ( int  os_x) const
pure virtual

Convert from OS units to logical x value.

Parameters
os_xvalue to convert
Returns
equivalent value in logical units

Implemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual int tbx::Graphics::logical_y ( int  os_y) const
pure virtual

Convert from OS units to logical y value.

Parameters
os_yvalue to convert
Returns
equivalent value in logical units

Implemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual void tbx::Graphics::move ( int  x,
int  y 
)
pure virtual

Move the graphics cursor to the given point.

Parameters
xx coordinate
yy coordinate

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::move ( const Point point)
inlinevirtual

Move the graphics cursor to the given location.

Parameters
pointcoordinates to move to
virtual Point tbx::Graphics::os ( const Point pt)
inlinevirtual

Convert from logical coordinates to OS units.

Parameters
ptvalue to convert
Returns
equivalent value in OS units

Reimplemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual BBox tbx::Graphics::os ( const BBox b)
inlinevirtual

Convert from logical coordinates to OS units.

Parameters
bvalue to convert
Returns
equivalent value in OS units

Reimplemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual int tbx::Graphics::os_x ( int  logical_x) const
pure virtual

Convert from logical x value to OS units.

Parameters
logical_xvalue to convert
Returns
equivalent value in OS units

Implemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual int tbx::Graphics::os_y ( int  logical_y) const
pure virtual

Convert from logical y value to OS units.

Parameters
logical_yvalue to convert
Returns
equivalent value in OS units

Implemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual void tbx::Graphics::path ( const Point points,
int  num 
)
pure virtual

Draw a path of lines connecting the given points.

Parameters
pointsarray of points to connect
numnumber of points to connect

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::point ( int  x,
int  y 
)
pure virtual

Draw a point at the given location.

Parameters
xx coordinate
yy coordinate

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::point ( const Point pt)
inlinevirtual

Draw a point at the given location.

Parameters
ptcoordinates to draw point
virtual void tbx::Graphics::polygon ( const Point points,
int  num 
)
pure virtual

Draw the outline of a polygon.

This draws a line connecting all the points and an additional line connecting the last and first points.

Parameters
pointsarray of vertices of the polygon
numnumber of vertices

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::rectangle ( int  xmin,
int  ymin,
int  xmax,
int  ymax 
)
pure virtual

Draw the outline of a rectangle.

Parameters
xminminimum x coordinate of rectangle
yminminimum y coordinate of rectangle
xmaxmaximum x coordinate of rectangle
ymaxmaximum y coordinate of rectangle

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::rectangle ( const Point min_point,
const Point max_point 
)
inlinevirtual

Draw the outline of a rectangle.

Parameters
min_pointminimum coordinates of rectangle
max_pointmaximum coordinates of rectangle
virtual void tbx::Graphics::rectangle ( const BBox r)
inlinevirtual

Draw the outline of a rectangle.

Parameters
rcoordinates of rectangle
virtual void tbx::Graphics::sector ( int  centre_x,
int  centre_y,
int  start_x,
int  start_y,
int  end_x,
int  end_y 
)
pure virtual

Draw a sector of a circle.

Parameters
centre_xcentre of circle arc is on
centre_ycentre of circle arc is on
start_xstart of arc
start_ystart of arc
end_xpoint on line from centre to the end of the arc
end_ypoint on line from centre to the end of the arc

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::sector ( const Point centre_point,
const Point start_point,
const Point end_point 
)
inlinevirtual

Draw a sector of a circle.

Parameters
centre_pointcentre of circle sector is on
start_pointstart of sector
end_pointpoint on line from centre to the end of the sector
virtual void tbx::Graphics::segment ( int  centre_x,
int  centre_y,
int  start_x,
int  start_y,
int  end_x,
int  end_y 
)
pure virtual

Draw a segment of a circle.

Parameters
centre_xcentre of circle arc is on
centre_ycentre of circle arc is on
start_xstart of arc
start_ystart of arc
end_xpoint on line from centre to the end of the arc
end_ypoint on line from centre to the end of the arc

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::segment ( const Point centre_point,
const Point start_point,
const Point end_point 
)
inlinevirtual

Draw a segment of a circle.

Parameters
centre_pointcentre of circle segment is on
start_pointstart of segment
end_pointpoint on line from centre to the end of the segment
virtual void tbx::Graphics::stroke ( int  x,
int  y,
const DrawPath path,
DrawFillStyle  fill_style = WINDING_NON_ZERO,
int  flatness = 1,
int  thickness = 0,
DrawCapAndJoin cap_and_join = 0,
DrawDashPattern dashes = 0 
)
pure virtual

Plot the lines in a path.

The path is drawn by transforming it so the user units used in it are treated as OS coordinates.

Parameters
xcoordinate of bottom left to place the path
ycoordinate of bottom left to place the path
paththe DrawPath to draw
fill_styleDrawFillStyle. Default WINDING_NON_ZERO.
transformpointer to transformation matrix, or 0 for identity matrix
flatnessflatness. Defaults to 1 as this gives a good curve with the transform used.
thicknessline thickness, or 0 for default. If the thickness is zero then the line is drawn with the minimum width that can be used, given the limitations of the pixel size (so lines are a single pixel wide). If the thickness is n, then the line will be drawn with a thickness of n/2 user coordinates translated to pixels on either side of the theoretical line position. If the line thickness is non-zero, then the cap and join parameter must also be passed.
cap_and_joinpointer to line cap and join specification (if required)
pointerto dash pattern, or 0 for no dashes

Implemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual void tbx::Graphics::stroke ( const Point pt,
const DrawPath path,
DrawFillStyle  fill_style = WINDING_NON_ZERO,
int  flatness = 1,
int  thickness = 0,
DrawCapAndJoin cap_and_join = 0,
DrawDashPattern dashes = 0 
)
inlinevirtual

Plot the lines in a path.

The path is drawn by transforming it so the user units used in it are treated as OS coordinates.

Parameters
ptcoordinates of bottom left to place the path
paththe DrawPath to draw
fill_styleDrawFillStyle. Default WINDING_NON_ZERO.
transformpointer to transformation matrix, or 0 for identity matrix
flatnessflatness. Defaults to 1 as this gives a good curve with the transform used.
thicknessline thickness, or 0 for default. If the thickness is zero then the line is drawn with the minimum width that can be used, given the limitations of the pixel size (so lines are a single pixel wide). If the thickness is n, then the line will be drawn with a thickness of n/2 user coordinates translated to pixels on either side of the theoretical line position. If the line thickness is non-zero, then the cap and join parameter must also be passed.
cap_and_joinpointer to line cap and join specification (if required)
pointerto dash pattern, or 0 for no dashes

Reimplemented in tbx::OffsetGraphics.

virtual void tbx::Graphics::text ( int  x,
int  y,
const std::string &  text 
)
pure virtual

Draw text at the given location in the current WIMP font.

Parameters
xx coordinate for base line of text
yy coordinate for left of text
texttext to draw

Implemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual void tbx::Graphics::text ( int  x,
int  y,
const std::string &  text,
const Font font 
)
pure virtual

Draw text at the given location in the given font.

Parameters
xx coordinate for base line of text
yy coordinate for left of text
texttext to draw
fontfont to use to draw the text

Implemented in tbx::OffsetGraphics, and tbx::OSGraphics.

virtual void tbx::Graphics::text ( const Point pt,
const std::string &  str 
)
inlinevirtual

Draw text at the given location in the current WIMP font.

Parameters
ptcoordinates for base line and left of text
strtext to draw
virtual void tbx::Graphics::text ( const Point pt,
const std::string &  str,
const Font font 
)
inlinevirtual

Draw text at the given location in the given font.

Parameters
ptcoordinates for base line and left of text
strtext to draw
fontfont to use to draw the text
virtual void tbx::Graphics::text_colours ( Colour  foreground,
Colour  background 
)
pure virtual

Set the text colours for the current WIMP font.

Parameters
foregroundtext foreground colour
backgroundtext background colour

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::text_colours ( Font font,
Colour  foreground,
Colour  background 
)
pure virtual

Set text colours for the given font.

Parameters
fontto set colours for
foregroundtext foreground colour
backgroundtext background colour

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::wimp_background ( WimpColour  colour)
pure virtual

Set the background colour for graphics to one of the standard WIMP colours.

Parameters
colournew colour for the background

Implemented in tbx::OSGraphics.

virtual void tbx::Graphics::wimp_foreground ( WimpColour  colour)
pure virtual

Set the foreground colour for graphics to one of the standard WIMP colours.

Parameters
colournew colour for the foreground

Implemented in tbx::OSGraphics.


The documentation for this class was generated from the following file: