The Graphics
class is the abstract base class for all graphics contexts that allow an application to draw onto components that are realized on various devices, as well as onto off-screen images.
More...
#include <CGraphics.h>
Public Member Functions | |
CGraphics (INT16 width, INT16 height) | |
Initiate internal data. | |
void | DrawString (const CString *str, INT16 x, INT16 y, INT8 anchor) |
Draws the specified String using the current font and color. | |
virtual void | DrawImage (CImage *img, INT16 x, INT16 y, INT8 anchor) |
Draws the specified image by using the anchor point. | |
virtual void | DrawLine (INT16 x1, INT16 y1, INT16 x2, INT16 y2) |
Draws a line, using the current color, between the points (x1, y1) and (x2, y2) in this graphics context's coordinate system. | |
virtual void | DrawRectangle (INT16 x, INT16 y, INT16 width, INT16 height) |
Draws the outline of the specified rectangle. | |
virtual void | FillRectangle (INT16 x, INT16 y, INT16 width, INT16 height)=0 |
Fills the specified rectangle. | |
void | ClipRect (INT16 x, INT16 y, INT16 width, INT16 height) |
Intersects the current clip with the specified rectangle. | |
void | SetClip (INT16 x, INT16 y, INT16 width, INT16 height) |
Sets the current clip to the rectangle specified by the given coordinates. | |
void | SetColor (INT32 rgb) |
Sets RGB color for next operation. | |
CFont * | SetFont (CFont *font) |
Sets this graphics context's font to the specified font All subsequent text operations using this graphics context use this font. | |
void | SetPaintMode (BOOL b) |
This sets the pixel operation function to the set or xor mode. | |
const UINT8 * | GetBuffer () |
INT32 | GetBufferLength () |
Protected Member Functions | |
virtual INT16 | DrawChar (CHAR ch, INT16 x, INT16 y) |
Draws the specified character using the current font and color. | |
virtual INT32 | GetPixel (INT16 x, INT16 y)=0 |
Gets the RGB pixel color by the given coordinates. | |
Protected Attributes | |
CFont * | m_font |
The current font. | |
UINT8 * | m_buffer |
The internal pixel buffer. | |
INT32 | m_bufferLength |
The length of the internal pixel buffer. | |
INT16 | m_width |
The width of the current graphics object in pixels. | |
INT16 | m_height |
The height of the current graphics object in pixels. | |
INT16 | m_Xmin |
Left X offset of the current clipping area. | |
INT16 | m_Xmax |
Right X offset of the current clipping area. | |
INT16 | m_Ymin |
Left Y offset of the current clipping area. | |
INT16 | m_Ymax |
Right Y offset of the current clipping area. | |
INT32 | m_color |
RGB color for next drawing operations. | |
BOOL | m_xor |
Painting mode. |
The Graphics
class is the abstract base class for all graphics contexts that allow an application to draw onto components that are realized on various devices, as well as onto off-screen images.
A Graphics
object encapsulates state information needed for the basic rendering operations. This state information includes the following properties:
All drawing is done in the current color, using the current font.
CGraphics::CGraphics | ( | INT16 | width, | |
INT16 | height | |||
) |
Initiate internal data.
width | - width of Graphics | |
height | - height of Graphics |
void CGraphics::ClipRect | ( | INT16 | x, | |
INT16 | y, | |||
INT16 | width, | |||
INT16 | height | |||
) |
Intersects the current clip with the specified rectangle.
The resulting clipping area is the intersection of the current clipping area and the specified rectangle. This method can only be used to make the current clip smaller. To set the current clip larger, use the setClip method. Rendering operations have no effect outside of the clipping area.
x | - the X coordinate of the rectangle to intersect the clip with. | |
y | - the Y coordinate of the rectangle to intersect the clip with. | |
width | - the width of the rectangle to intersect the clip with. | |
height | - the height of the rectangle to intersect the clip with. |
INT16 CGraphics::DrawChar | ( | CHAR | ch, | |
INT16 | x, | |||
INT16 | y | |||
) | [protected, virtual] |
Draws the specified character using the current font and color.
ch | - the character to be drawn | |
x | - the x coordinate of the anchor point | |
y | - the y coordinate of the anchor point |
void CGraphics::DrawImage | ( | CImage * | img, | |
INT16 | x, | |||
INT16 | y, | |||
INT8 | anchor | |||
) | [virtual] |
Draws the specified image by using the anchor point.
The image can be drawn in different positions relative to the anchor point by passing the appropriate position constants. See anchor points.
If the source image contains transparent pixels, the corresponding pixels in the destination image must be left untouched. If the source image contains partially transparent pixels, a compositing operation must be performed with the destination pixels, leaving all pixels of the destination image fully opaque.
img | - the specified image to be drawn | |
x | - the x coordinate of the anchor point | |
y | - the y coordinate of the anchor point | |
anchor | - the anchor point for positioning the image |
Reimplemented in CGraphicsMono.
void CGraphics::DrawLine | ( | INT16 | x1, | |
INT16 | y1, | |||
INT16 | x2, | |||
INT16 | y2 | |||
) | [virtual] |
Draws a line, using the current color, between the points (x1, y1)
and (x2, y2)
in this graphics context's coordinate system.
x1 | - the first point's X coordinate. | |
y1 | - the first point's Y coordinate. | |
x2 | - the second point's X coordinate. | |
y2 | - the second point's Y coordinate. |
void CGraphics::DrawRectangle | ( | INT16 | x, | |
INT16 | y, | |||
INT16 | width, | |||
INT16 | height | |||
) | [virtual] |
Draws the outline of the specified rectangle.
The left and right edges of the rectangle are at x
and x + width
. The top and bottom edges are at y
and y + height
. The rectangle is drawn using the graphics context's current color.
x | - the X coordinate of the rectangle to be drawn. | |
y | - the Y coordinate of the rectangle to be drawn. | |
width | - the width of the rectangle to be drawn. | |
height | - the height of the rectangle to be drawn. |
void CGraphics::DrawString | ( | const CString * | str, | |
INT16 | x, | |||
INT16 | y, | |||
INT8 | anchor | |||
) |
Draws the specified String using the current font and color.
The x,y position is the position of the anchor point.
str | - the String to be draw | |
x | - the x coordinate of the anchor point | |
y | - the y coordinate of the anchor point | |
anchor | - the anchor point for positioning the text |
virtual void CGraphics::FillRectangle | ( | INT16 | x, | |
INT16 | y, | |||
INT16 | width, | |||
INT16 | height | |||
) | [pure virtual] |
Fills the specified rectangle.
The left and right edges of the rectangle are at x
and x + width - 1
. The top and bottom edges are at y
and y + height - 1
. The resulting rectangle covers an area width
pixels wide by height
pixels tall. The rectangle is filled using the graphics context's current color.
x | - the X coordinate of the rectangle to be filled. | |
y | - the Y coordinate of the rectangle to be filled. | |
width | - the width of the rectangle to be filled. | |
height | - the height of the rectangle to be filled. |
Implemented in CGraphicsMono.
const UINT8 * CGraphics::GetBuffer | ( | ) |
INT32 CGraphics::GetBufferLength | ( | ) |
virtual INT32 CGraphics::GetPixel | ( | INT16 | x, | |
INT16 | y | |||
) | [protected, pure virtual] |
Gets the RGB pixel color by the given coordinates.
x | - the x coordinate | |
y | - the y coordinate |
Implemented in CGraphicsMono.
void CGraphics::SetClip | ( | INT16 | x, | |
INT16 | y, | |||
INT16 | width, | |||
INT16 | height | |||
) |
Sets the current clip to the rectangle specified by the given coordinates.
Rendering operations have no effect outside of the clipping area.
x | the X coordinate of the new clip rectangle. | |
y | the Y coordinate of the new clip rectangle. | |
width | the WIDTH of the new clip rectangle. | |
height | the HEIGHT of the new clip rectangle. |
void CGraphics::SetColor | ( | INT32 | rgb | ) |
Sets RGB color for next operation.
rgb | - color in the format: 0x00RRGGBB |
Sets this graphics context's font to the specified font All subsequent text operations using this graphics context use this font.
font | - the font |
void CGraphics::SetPaintMode | ( | BOOL | b | ) |
This sets the pixel operation function to the set or xor mode.
b | - true for xor mode |
INT32 CGraphics::m_color [protected] |
RGB color for next drawing operations.
Color component is specified in the form of 0x00RRGGBB. The high order byte of this value is ignored.