tbx  0.7.3
Public Types | Public Member Functions | Protected Attributes | List of all members
tbx::OSGraphics Class Reference

Class to draw to graphics to the screen using standard OS routines with no translation or scaling. More...

#include <osgraphics.h>

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

Public Types

enum  PlotAction {
  ACTION_OVERWRITE, ACTION_OR, ACTION_AND, ACTION_XOR,
  ACTION_INVERT, ACTION_NONE, ACTION_AND_NOT, ACTION_OR_NOT
}
 

Public Member Functions

 OSGraphics ()
 Create the graphics class with the default plot action of overwrite.
 
virtual void plot (int code, int x, int y)
 Execute the OS_Plot swi. More...
 
void plot_action (PlotAction action)
 Sets the plot action. More...
 
virtual int os_x (int logical_x) const
 Convert from logical x value to OS units. More...
 
virtual int os_y (int logical_y) const
 Convert from logical y value to OS units. More...
 
virtual int logical_x (int os_x) const
 Convert from OS units to logical x value. More...
 
virtual int logical_y (int os_y) const
 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)
 Set foreground graphics colour to the nearest match to the given colour for the current screen mode. More...
 
virtual void background (Colour colour)
 Set background graphics colour to the nearest match to the given colour for the current screen mode. More...
 
virtual void wimp_foreground (WimpColour colour)
 Set the graphics foreground colour to the given WIMP colour.
 
virtual void wimp_background (WimpColour colour)
 Set the graphics background colour to the given WIMP colour.
 
virtual void move (int x, int y)
 Move graphics position.
 
virtual void point (int x, int y)
 Draw a single pixel point.
 
virtual void line (int fx, int fy, int tx, int ty)
 Draw a line betweenn the given coordinates.
 
virtual void line (int x, int y)
 Draw a line from the current graphics position to the given coordinates.
 
virtual void rectangle (int xmin, int ymin, int xmax, int ymax)
 Draw outline of a rectangle.
 
virtual void fill_rectangle (int xmin, int ymin, int xmax, int ymax)
 Fill a rectangle the current foreground colour.
 
virtual void circle (int centre_x, int centre_y, int radius)
 Draw outline of a circle. More...
 
virtual void fill_circle (int centre_x, int centre_y, int radius)
 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)
 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)
 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)
 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)
 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)
 Draw a filled ellipse. More...
 
virtual void path (const Point *points, int num)
 Draw a line through the specified points. More...
 
virtual void polygon (const Point *points, int num)
 Draw outline of a polygon. More...
 
virtual void fill_polygon (const Point *points, int num)
 Fill a polygon. More...
 
virtual void text (int x, int y, const std::string &text)
 Draw text in current desktop font.
 
virtual void text (int x, int y, const std::string &text, const Font &font)
 Draw text in given font.
 
virtual void text_colours (Colour foreground, Colour background)
 Set the colours for the desktop font.
 
virtual void text_colours (Font &font, Colour foreground, Colour background)
 Set the colours for the given font.
 
virtual void image (int x, int y, const Image &image)
 Draw an image at given location.
 
virtual void fill (int x, int y, const DrawPath &path, DrawFillStyle fill_style=WINDING_NON_ZERO, int flatness=1)
 Fill an draw path at the given location.
 
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)
 Draw lines of a draw path at the given location.
 
void clear ()
 Clear the current graphics window to the background colour.
 
- Public Member Functions inherited from tbx::Graphics
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 (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 (const Point &pt, const Image &im)
 Draw an image. 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 (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...
 

Protected Attributes

int _plot_action
 Stores the current Plot action.
 

Detailed Description

Class to draw to graphics to the screen using standard OS routines with no translation or scaling.

Member Enumeration Documentation

Enum for how to combine plotted graphics with the screen

Enumerator
ACTION_OVERWRITE 

overwrite the screen

ACTION_OR 

Or the colour with the screen

ACTION_AND 

And the colour with the screen

ACTION_XOR 

Exclusive Or the colour with the screen

ACTION_INVERT 

invert the screen colour

ACTION_NONE 

Do not change the screen

ACTION_AND_NOT 

And Not the colour with the screen

Member Function Documentation

void OSGraphics::arc ( int  centre_x,
int  centre_y,
int  start_x,
int  start_y,
int  end_x,
int  end_y 
)
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

Implements tbx::Graphics.

void OSGraphics::background ( Colour  colour)
virtual

Set background graphics colour to the nearest match to the given colour for the current screen mode.

It will use an ECF pattern to get a better match.

Implements tbx::Graphics.

void OSGraphics::circle ( int  centre_x,
int  centre_y,
int  radius 
)
virtual

Draw outline of a circle.

Parameters
centre_xcentre of circle
centre_ycentre of circle
radiusradius of the circle

Implements tbx::Graphics.

void OSGraphics::ellipse ( int  centre_x,
int  centre_y,
int  intersect_x,
int  intersect_y,
int  high_x,
int  high_y 
)
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

Implements tbx::Graphics.

void OSGraphics::fill_circle ( int  centre_x,
int  centre_y,
int  radius 
)
virtual

Draw a filled circle.

Parameters
centre_xcentre of circle
centre_ycentre of circle
radiusradius of the circle

Implements tbx::Graphics.

void OSGraphics::fill_ellipse ( int  centre_x,
int  centre_y,
int  intersect_x,
int  intersect_y,
int  high_x,
int  high_y 
)
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

Implements tbx::Graphics.

void OSGraphics::fill_polygon ( const Point points,
int  num 
)
virtual

Fill a polygon.

The polygon is filled using triangles swept from the first point so the line from the first point to any vertex should not cross any edges of the polygon.

Parameters
pointsvertices of the polygon
numnumber of vertices (minimum of 3)
Exceptions
std::domain_errorif num is less than three

Implements tbx::Graphics.

void OSGraphics::foreground ( Colour  colour)
virtual

Set foreground graphics colour to the nearest match to the given colour for the current screen mode.

It will use an ECF pattern to get a better match.

Implements tbx::Graphics.

virtual Point tbx::OSGraphics::logical ( const Point pt)
inlinevirtual

Convert from OS units to logical coordinates.

Parameters
ptvalue to convert
Returns
equivalent value in logical units

Reimplemented from tbx::Graphics.

Reimplemented in tbx::OffsetGraphics.

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

Convert from OS units to logical coordinates.

Parameters
bvalue to convert
Returns
equivalent value in logical units

Reimplemented from tbx::Graphics.

Reimplemented in tbx::OffsetGraphics.

virtual int tbx::OSGraphics::logical_x ( int  os_x) const
inlinevirtual

Convert from OS units to logical x value.

Parameters
os_xvalue to convert
Returns
equivalent value in logical units

Implements tbx::Graphics.

Reimplemented in tbx::OffsetGraphics.

virtual int tbx::OSGraphics::logical_y ( int  os_y) const
inlinevirtual

Convert from OS units to logical y value.

Parameters
os_yvalue to convert
Returns
equivalent value in logical units

Implements tbx::Graphics.

Reimplemented in tbx::OffsetGraphics.

virtual Point tbx::OSGraphics::os ( const Point pt)
inlinevirtual

Convert from logical coordinates to OS units.

Parameters
ptvalue to convert
Returns
equivalent value in OS units

Reimplemented from tbx::Graphics.

Reimplemented in tbx::OffsetGraphics.

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

Convert from logical coordinates to OS units.

Parameters
bvalue to convert
Returns
equivalent value in OS units

Reimplemented from tbx::Graphics.

Reimplemented in tbx::OffsetGraphics.

virtual int tbx::OSGraphics::os_x ( int  logical_x) const
inlinevirtual

Convert from logical x value to OS units.

Parameters
logical_xvalue to convert
Returns
equivalent value in OS units

Implements tbx::Graphics.

Reimplemented in tbx::OffsetGraphics.

virtual int tbx::OSGraphics::os_y ( int  logical_y) const
inlinevirtual

Convert from logical y value to OS units.

Parameters
logical_yvalue to convert
Returns
equivalent value in OS units

Implements tbx::Graphics.

Reimplemented in tbx::OffsetGraphics.

void OSGraphics::path ( const Point points,
int  num 
)
virtual

Draw a line through the specified points.

Parameters
pointsarray of points to draw through
numnumber of points

Implements tbx::Graphics.

void OSGraphics::plot ( int  code,
int  x,
int  y 
)
virtual

Execute the OS_Plot swi.

For details of the plot codes see the RISC OS PRM.

For clarity use and protability to other Graphics derived classes use the move, line, etc. codes

Reimplemented in tbx::OffsetGraphics.

void OSGraphics::plot_action ( PlotAction  action)

Sets the plot action.

The plot action. The plot action doesn't take effect until the next colour change.

void OSGraphics::polygon ( const Point points,
int  num 
)
virtual

Draw outline of a polygon.

Parameters
pointsvertices of the polygon
numnumber of vertices (minimum of 3)
Exceptions
std::domain_errorif num is less than three

Implements tbx::Graphics.

void OSGraphics::sector ( int  centre_x,
int  centre_y,
int  start_x,
int  start_y,
int  end_x,
int  end_y 
)
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

Implements tbx::Graphics.

void OSGraphics::segment ( int  centre_x,
int  centre_y,
int  start_x,
int  start_y,
int  end_x,
int  end_y 
)
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

Implements tbx::Graphics.


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