tbx  0.7.6
Public Member Functions | List of all members
tbx::OffsetGraphics Class Reference

Class to draw to graphics to the screen using standard OS routines off setting the coordinates given. More...

#include <offsetgraphics.h>

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

Public Member Functions

 OffsetGraphics ()
 Construct with no offset.
 
 OffsetGraphics (int offset_x, int offset_y)
 Construct with given offsets. More...
 
 OffsetGraphics (const VisibleArea &area)
 Construct from a visible area. More...
 
void offset_x (int new_x)
 Set the horizontal offset. More...
 
int offset_x () const
 Get the horizontal offset. More...
 
void offset_y (int new_y)
 Set the vertical offset. More...
 
int offset_y () const
 Get the vertical offset. More...
 
Point offset () const
 Get the offsets as a point. More...
 
void offset (const Point &new_offset)
 Set both offsets from a point. More...
 
virtual void plot (int code, int x, int y)
 Execute the OS_Plot swi. 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) const
 Convert from logical coordinates to OS units. More...
 
virtual Point logical (const Point &pt) const
 Convert from OS units to logical coordinates. More...
 
virtual BBox os (const BBox &b) const
 Convert from logical coordinates to OS units. More...
 
virtual BBox logical (const BBox &b) const
 Convert from OS units to logical coordinates. 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 image (int x, int y, const Image &image)
 Draw an image at given location.
 
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)
 Fill an draw path at the given location.
 
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)
 Draw lines of a draw path at the given location.
 
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...
 
- Public Member Functions inherited from tbx::OSGraphics
 OSGraphics ()
 Create the graphics class with the default plot action of overwrite.
 
void plot_action (PlotAction action)
 Sets the plot action. 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_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.
 
void clear ()
 Clear the current graphics window to the background colour.
 
BBox clip () const
 Get the current Graphics clipping region. More...
 
void clip (const BBox &clip_to)
 Set the clipping region. More...
 
- 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...
 

Additional Inherited Members

- Public Types inherited from tbx::OSGraphics
enum  PlotAction {
  ACTION_OVERWRITE, ACTION_OR, ACTION_AND, ACTION_XOR,
  ACTION_INVERT, ACTION_NONE, ACTION_AND_NOT, ACTION_OR_NOT
}
 
- Protected Attributes inherited from tbx::OSGraphics
int _plot_action
 Stores the current Plot action.
 

Detailed Description

Class to draw to graphics to the screen using standard OS routines off setting the coordinates given.

Constructor & Destructor Documentation

◆ OffsetGraphics() [1/2]

tbx::OffsetGraphics::OffsetGraphics ( int  offset_x,
int  offset_y 
)
inline

Construct with given offsets.

Parameters
offset_xx offset in OS units
offset_yy offset in OS units

◆ OffsetGraphics() [2/2]

tbx::OffsetGraphics::OffsetGraphics ( const VisibleArea area)
inline

Construct from a visible area.

This constructor calculates its offsets required to plot in a visible area.

Parameters
areavisible area to retrieve offsets from

Member Function Documentation

◆ fill()

virtual void tbx::OffsetGraphics::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 from tbx::Graphics.

◆ image()

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

Draw an image.

Parameters
ptcoordinates for bottom left of image
imImage to draw

Reimplemented from tbx::Graphics.

◆ logical() [1/2]

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

Convert from OS units to logical coordinates.

Parameters
bvalue to convert
Returns
equivalent value in logical units

Reimplemented from tbx::OSGraphics.

◆ logical() [2/2]

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

Convert from OS units to logical coordinates.

Parameters
ptvalue to convert
Returns
equivalent value in logical units

Reimplemented from tbx::OSGraphics.

◆ logical_x()

virtual int tbx::OffsetGraphics::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

Reimplemented from tbx::OSGraphics.

◆ logical_y()

virtual int tbx::OffsetGraphics::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

Reimplemented from tbx::OSGraphics.

◆ offset() [1/2]

Point tbx::OffsetGraphics::offset ( ) const
inline

Get the offsets as a point.

Returns
current offsets in a Point

◆ offset() [2/2]

void tbx::OffsetGraphics::offset ( const Point new_offset)
inline

Set both offsets from a point.

Parameters
new_offsetPoint containing the new horizontal and vertical offset in OS units

◆ offset_x() [1/2]

int tbx::OffsetGraphics::offset_x ( ) const
inline

Get the horizontal offset.

Returns
horizontal offset in OS units

◆ offset_x() [2/2]

void tbx::OffsetGraphics::offset_x ( int  new_x)
inline

Set the horizontal offset.

Parameters
new_xnew value for horizontal offset in OS units

◆ offset_y() [1/2]

int tbx::OffsetGraphics::offset_y ( ) const
inline

Get the vertical offset.

Returns
vertical offset in OS units

◆ offset_y() [2/2]

void tbx::OffsetGraphics::offset_y ( int  new_y)
inline

Set the vertical offset.

Parameters
new_ynew value for vertical offset in OS units

◆ os() [1/2]

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

Convert from logical coordinates to OS units.

Parameters
bvalue to convert
Returns
equivalent value in OS units

Reimplemented from tbx::OSGraphics.

◆ os() [2/2]

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

Convert from logical coordinates to OS units.

Parameters
ptvalue to convert
Returns
equivalent value in OS units

Reimplemented from tbx::OSGraphics.

◆ os_x()

virtual int tbx::OffsetGraphics::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

Reimplemented from tbx::OSGraphics.

◆ os_y()

virtual int tbx::OffsetGraphics::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

Reimplemented from tbx::OSGraphics.

◆ plot()

virtual void tbx::OffsetGraphics::plot ( int  code,
int  x,
int  y 
)
inlinevirtual

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 from tbx::OSGraphics.

◆ stroke()

virtual void tbx::OffsetGraphics::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 from tbx::Graphics.


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