WoopsiUI::Graphics Class Reference

#include <graphics.h>

List of all members.

Public Member Functions

 Graphics (MutableBitmapBase *bitmap, const Rect &clipRect)
virtual ~Graphics ()
void setClipRect (const Rect &clipRect)
void getClipRect (Rect &rect) const
const u16 getPixel (s16 x, s16 y) const
virtual void drawPixel (s16 x, s16 y, u16 colour)
virtual void drawFilledRect (s16 x, s16 y, u16 width, u16 height, u16 colour)
virtual void drawHorizLine (s16 x, s16 y, u16 width, u16 colour)
virtual void drawVertLine (s16 x, s16 y, u16 height, u16 colour)
virtual void drawRect (s16 x, s16 y, u16 width, u16 height, u16 colour)
virtual void drawXORPixel (s16 x, s16 y, u16 colour)
virtual void drawXORHorizLine (s16 x, s16 y, u16 width, u16 colour)
virtual void drawXORVertLine (s16 x, s16 y, u16 height, u16 colour)
virtual void drawFilledXORRect (s16 x, s16 y, u16 width, u16 height, u16 colour)
virtual void drawXORRect (s16 x, s16 y, u16 width, u16 height, u16 colour)
virtual void drawXORPixel (s16 x, s16 y)
virtual void drawXORHorizLine (s16 x, s16 y, u16 width)
virtual void drawXORVertLine (s16 x, s16 y, u16 height)
virtual void drawXORRect (s16 x, s16 y, u16 width, u16 height)
virtual void drawFilledXORRect (s16 x, s16 y, u16 width, u16 height)
virtual void drawBitmap (s16 x, s16 y, u16 width, u16 height, const BitmapBase *bitmap, s16 bitmapX, s16 bitmapY)
virtual void drawBitmap (s16 x, s16 y, u16 width, u16 height, const BitmapBase *bitmap, s16 bitmapX, s16 bitmapY, u16 transparentColour)
virtual void drawBitmapGreyScale (s16 x, s16 y, u16 width, u16 height, const BitmapBase *bitmap, s16 bitmapX, s16 bitmapY)
virtual void floodFill (s16 x, s16 y, u16 newColour)
void copy (s16 sourceX, s16 sourceY, s16 destX, s16 destY, u16 width, u16 height)
void dim (s16 x, s16 y, u16 width, u16 height)
virtual void drawLine (s16 x1, s16 y1, s16 x2, s16 y2, u16 colour)
virtual void drawCircle (s16 x0, s16 y0, u16 radius, u16 colour)
virtual void drawFilledCircle (s16 x0, s16 y0, u16 radius, u16 colour)
virtual void drawEllipse (s16 xCentre, s16 yCentre, s16 horizRadius, s16 vertRadius, u16 colour)
virtual void drawFilledEllipse (s16 xCentre, s16 yCentre, s16 horizRadius, s16 vertRadius, u16 colour)
void greyScale (s16 x, s16 y, u16 width, u16 height)
virtual void drawText (s16 x, s16 y, FontBase *font, const WoopsiString &string)
virtual void drawText (s16 x, s16 y, FontBase *font, const WoopsiString &string, s32 startIndex, s32 length, u16 colour)
virtual void drawText (s16 x, s16 y, FontBase *font, const WoopsiString &string, s32 startIndex, s32 length)
virtual void scroll (s16 x, s16 y, s16 xDistance, s16 yDistance, u16 width, u16 height, WoopsiArray< Rect > *revealedRects)
virtual void drawBevelledRect (s16 x, s16 y, u16 width, u16 height, u16 shineColour, u16 shadowColour)

Protected Member Functions

bool clipBitmapCoordinates (s16 *x, s16 *y, u16 *width, u16 *height)
bool popStack (s16 *x, s16 *y, WoopsiArray< s32 > *stack)
void pushStack (s16 x, s16 y, WoopsiArray< s32 > *stack)
u8 getClipLineOutCode (s16 x, s16 y, s16 xMin, s16 yMin, s16 xMax, s16 yMax)
void drawClippedLine (s16 x1, s16 y1, s16 x2, s16 y2, u16 colour)
void drawClippedBitmapGreyScale (s16 x, s16 y, u16 width, u16 height, const BitmapBase *bitmap, s16 bitmapX, s16 bitmapY)
bool clipCoordinates (s16 *x1, s16 *y1, s16 *x2, s16 *y2, const Rect &clipRect)
 Graphics (const Graphics &graphics)

Protected Attributes

MutableBitmapBase_bitmap
u16 _width
u16 _height
Rect _clipRect

Detailed Description

Class providing bitmap manipulation (drawing, etc) functions. Functions are all clipped to the size of the bitmap being drawn to.


Constructor & Destructor Documentation

WoopsiUI::Graphics::Graphics ( MutableBitmapBase bitmap,
const Rect clipRect 
)

Constructor.

Parameters:
bitmap The bitmap that the port will draw to.
clipRect The clipping region within which the class must draw.
virtual WoopsiUI::Graphics::~Graphics (  )  [inline, virtual]

Destructor.

WoopsiUI::Graphics::Graphics ( const Graphics graphics  )  [inline, protected]

Copy constructor is protected to prevent usage.


Member Function Documentation

bool WoopsiUI::Graphics::clipBitmapCoordinates ( s16 *  x,
s16 *  y,
u16 *  width,
u16 *  height 
) [protected]

Clip the supplied rectangular dimensions to the size of the internal bitmap.

Parameters:
x The x co-ordinate of the rectangle to clip (modified by the function).
y The y co-ordinate of the rectangle to clip (modified by the function).
width The width of the rectangle to clip (modified by the function).
height The height of the rectangle to clip (modified by the function).
bool WoopsiUI::Graphics::clipCoordinates ( s16 *  x1,
s16 *  y1,
s16 *  x2,
s16 *  y2,
const Rect clipRect 
) [protected]

Clips the supplied co-ordinates so that they fit within the supplied clipping rectangle. If the clipped area is empty, the method returns false to indicate this. Otherwise, it returns true.

Parameters:
x1 The top-left x co-ordinate.
y1 The top-left y co-ordinate.
x2 The bottom-right x co-ordinate.
y2 The bottom-right y co-ordinate.
clipRect A rect to clip to.
void WoopsiUI::Graphics::copy ( s16  sourceX,
s16  sourceY,
s16  destX,
s16  destY,
u16  width,
u16  height 
)

Copy a rectangular region from the source co-ordinates to the destination co-ordinates. Uses the DMA for speed. Worst-case scenario uses an off-screen buffer for situations wherein there is no vertical movement and the source and destination overlap, in which case two copies are performed for each row (source to buffer and buffer to destination). Does not clip.

Parameters:
sourceX Source x co-ord.
sourceY Source y co-ord.
destX Destination x co-ord.
destY Destination y co-ord.
width Width of the rectangle to copy.
height Height of the rectangle to copy.
void WoopsiUI::Graphics::dim ( s16  x,
s16  y,
u16  width,
u16  height 
)

Halve the brightness of a specified region.

Parameters:
x X co-ord of the region to dim.
y Y co-ord of the region to dim.
width Width of the region to dim.
height Height of the region to dim.
virtual void WoopsiUI::Graphics::drawBevelledRect ( s16  x,
s16  y,
u16  width,
u16  height,
u16  shineColour,
u16  shadowColour 
) [virtual]

Draw a bevelled rectangle to the bitmap.

Parameters:
x The x co-ordinate of the rectangle.
y The y co-ordinate of the rectangle.
width The width of the rectangle.
height The height of the rectangle.
shineColour The colour of the top/left sides.
shadowColour The colour of the bottom/right sides.
virtual void WoopsiUI::Graphics::drawBitmap ( s16  x,
s16  y,
u16  width,
u16  height,
const BitmapBase bitmap,
s16  bitmapX,
s16  bitmapY,
u16  transparentColour 
) [virtual]

Draw a bitmap to the port's bitmap, using the supplied transparent colour as an invisible colour. This is considerably slower than the standard bitmap drawing routine as it plots pixel-by-pixel instead of using a scanline DMA copy.

Parameters:
x The x co-ordinate to draw the bitmap to.
y The y co-ordinate to draw the bitmap to.
width The width of the bitmap to draw.
height The height of the bitmap to draw.
bitmap Pointer to the bitmap to draw.
bitmapX The x co-ordinate within the supplied bitmap to use as the origin.
bitmapY The y co-ordinate within the supplied bitmap to use as the origin.
transparentColour The transparent colour used in the bitmap.
virtual void WoopsiUI::Graphics::drawBitmap ( s16  x,
s16  y,
u16  width,
u16  height,
const BitmapBase bitmap,
s16  bitmapX,
s16  bitmapY 
) [virtual]

Draw an external bitmap to the internal bitmap.

Parameters:
x The x co-ordinate to draw the bitmap to.
y The y co-ordinate to draw the bitmap to.
width The width of the bitmap to draw.
height The height of the bitmap to draw.
bitmap Pointer to the bitmap to draw.
bitmapX The x co-ordinate within the supplied bitmap to use as the origin.
bitmapY The y co-ordinate within the supplied bitmap to use as the origin.
virtual void WoopsiUI::Graphics::drawBitmapGreyScale ( s16  x,
s16  y,
u16  width,
u16  height,
const BitmapBase bitmap,
s16  bitmapX,
s16  bitmapY 
) [virtual]

Draw a bitmap to the port's bitmap in greyscale. This is considerably slower than the standard bitmap drawing routine as it plots pixel-by-pixel instead of using a scanline DMA copy.

Parameters:
x The x co-ordinate to draw the bitmap to.
y The y co-ordinate to draw the bitmap to.
width The width of the bitmap to draw.
height The height of the bitmap to draw.
bitmap Pointer to the bitmap to draw.
bitmapX The x co-ordinate within the supplied bitmap to use as the origin.
bitmapY The y co-ordinate within the supplied bitmap to use as the origin.
virtual void WoopsiUI::Graphics::drawCircle ( s16  x0,
s16  y0,
u16  radius,
u16  colour 
) [virtual]

Draw an unfilled circle to the internal bitmap. Faster than drawEllipse() but limited to circles only.

Parameters:
x0 The x co-ordinate of the circle.
y0 The y co-ordinate of the circle.
radius The radius of the circle.
colour The colour of the circle.
void WoopsiUI::Graphics::drawClippedBitmapGreyScale ( s16  x,
s16  y,
u16  width,
u16  height,
const BitmapBase bitmap,
s16  bitmapX,
s16  bitmapY 
) [protected]

Draws a bitmap in greyscale. The parameters must be pre-clipped by the drawBitmapGreyScale method.

Parameters:
x The x co-ordinate to draw the bitmap to.
y The y co-ordinate to draw the bitmap to.
width The width of the bitmap to draw.
height The height of the bitmap to draw.
bitmap Pointer to the bitmap to draw.
bitmapX The x co-ordinate within the supplied bitmap to use as the origin.
bitmapY The y co-ordinate within the supplied bitmap to use as the origin.
void WoopsiUI::Graphics::drawClippedLine ( s16  x1,
s16  y1,
s16  x2,
s16  y2,
u16  colour 
) [protected]

Draws a line. The parameters must be pre-clipped by the drawLine() method.

Parameters:
x1 The x co-ord of the start of the line.
y1 The y co-ord of the start of the line.
x2 The x co-ord of the end of the line.
y2 The y co-ord of the end of the line.
colour The colour of the line.
virtual void WoopsiUI::Graphics::drawEllipse ( s16  xCentre,
s16  yCentre,
s16  horizRadius,
s16  vertRadius,
u16  colour 
) [virtual]

Draw an unfilled ellipse to the bitmap.

Parameters:
xCentre The x co-ordinate of the ellipse's centre.
yCentre The y co-ordinate of the ellipse's centre.
horizRadius The size of the ellipse's horizontal radius.
vertRadius The size of the ellipse's vertical radius.
colour The colour of the ellipse.
virtual void WoopsiUI::Graphics::drawFilledCircle ( s16  x0,
s16  y0,
u16  radius,
u16  colour 
) [virtual]

Draw a filled circle to the internal bitmap. Faster than drawFilledEllipse() but limited to circles only.

Parameters:
x0 The x co-ordinate of the circle.
y0 The y co-ordinate of the circle.
radius The radius of the circle.
colour The colour of the circle.
virtual void WoopsiUI::Graphics::drawFilledEllipse ( s16  xCentre,
s16  yCentre,
s16  horizRadius,
s16  vertRadius,
u16  colour 
) [virtual]

Draw a filled ellipse to the bitmap.

Parameters:
xCentre The x co-ordinate of the ellipse's centre.
yCentre The y co-ordinate of the ellipse's centre.
horizRadius The size of the ellipse's horizontal radius.
vertRadius The size of the ellipse's vertical radius.
colour The colour of the ellipse.
virtual void WoopsiUI::Graphics::drawFilledRect ( s16  x,
s16  y,
u16  width,
u16  height,
u16  colour 
) [virtual]

Draw a filled rectangle to the internal bitmap.

Parameters:
x The x co-ordinate of the rectangle.
y The y co-ordinate of the rectangle.
width The width of the rectangle.
height The height of the rectangle.
colour The colour of the rectangle.
virtual void WoopsiUI::Graphics::drawFilledXORRect ( s16  x,
s16  y,
u16  width,
u16  height 
) [virtual]

Invert the colour of a filled rectangle of pixels.

Parameters:
x The x co-ordinate of the rectangle.
y The y co-ordinate of the rectangle.
width The width of the rectangle.
height The height of the rectangle.
virtual void WoopsiUI::Graphics::drawFilledXORRect ( s16  x,
s16  y,
u16  width,
u16  height,
u16  colour 
) [virtual]

XOR the colour of a filled rectangle of pixels against the supplied colour.

Parameters:
x The x co-ordinate of the rectangle.
y The y co-ordinate of the rectangle.
width The width of the rectangle.
height The height of the rectangle.
colour The colour to XOR against.
virtual void WoopsiUI::Graphics::drawHorizLine ( s16  x,
s16  y,
u16  width,
u16  colour 
) [virtual]

Draw a horizontal line to the internal bitmap.

Parameters:
x The x co-ordinate of the line.
y The y co-ordinate of the line.
width The width of the line.
colour The colour of the line.
virtual void WoopsiUI::Graphics::drawLine ( s16  x1,
s16  y1,
s16  x2,
s16  y2,
u16  colour 
) [virtual]

Draw a line to the internal bitmap.

Parameters:
x1 The x co-ordinate of the start point of the line.
y1 The y co-ordinate of the start point of the line.
x2 The x co-ordinate of the end point of the line.
y2 The y co-ordinate of the end point of the line.
colour The colour of the line.
virtual void WoopsiUI::Graphics::drawPixel ( s16  x,
s16  y,
u16  colour 
) [virtual]

Draw a pixel to the internal bitmap.

Parameters:
x The x co-ordinate of the pixel.
y The y co-ordinate of the pixel.
colour The colour of the pixel.
virtual void WoopsiUI::Graphics::drawRect ( s16  x,
s16  y,
u16  width,
u16  height,
u16  colour 
) [virtual]

Draw an unfilled rectangle to the internal bitmap.

Parameters:
x The x co-ordinate of the rectangle.
y The y co-ordinate of the rectangle.
width The width of the rectangle.
height The height of the rectangle.
colour The colour of the rectangle.
virtual void WoopsiUI::Graphics::drawText ( s16  x,
s16  y,
FontBase font,
const WoopsiString string,
s32  startIndex,
s32  length 
) [virtual]

Draw a string to the internal bitmap in a specific colour.

Parameters:
x The x co-ordinate of the string.
y The y co-ordinate of the string.
font The font to draw with.
string The string to output.
startIndex The start index within the string from which drawing will commence.
length The number of characters to draw.
virtual void WoopsiUI::Graphics::drawText ( s16  x,
s16  y,
FontBase font,
const WoopsiString string,
s32  startIndex,
s32  length,
u16  colour 
) [virtual]

Draw a particular length of a string to the bitmap in a specific colour.

Parameters:
x The x co-ordinate of the string.
y The y co-ordinate of the string.
font The font to draw with.
string The string to output.
startIndex The start index within the string from which drawing will commence.
length The number of characters to draw.
colour The colour of the string.
virtual void WoopsiUI::Graphics::drawText ( s16  x,
s16  y,
FontBase font,
const WoopsiString string 
) [virtual]

Draw a string to the internal bitmap.

Parameters:
x The x co-ordinate of the string.
y The y co-ordinate of the string.
font The font to draw with.
string The string to output.
virtual void WoopsiUI::Graphics::drawVertLine ( s16  x,
s16  y,
u16  height,
u16  colour 
) [virtual]

Draw a vertical line to the internal bitmap.

Parameters:
x The x co-ordinate of the line.
y The y co-ordinate of the line.
height The height of the line.
colour The colour of the line.
virtual void WoopsiUI::Graphics::drawXORHorizLine ( s16  x,
s16  y,
u16  width 
) [virtual]

Invert the colour of a horizontal line of pixels.

Parameters:
x The x co-ordinate of the line.
y The y co-ordinate of the line.
width The width of the line.
virtual void WoopsiUI::Graphics::drawXORHorizLine ( s16  x,
s16  y,
u16  width,
u16  colour 
) [virtual]

XOR the colour of a horizontal line of pixels against the supplied colour.

Parameters:
x The x co-ordinate of the line.
y The y co-ordinate of the line.
width The width of the line.
colour The colour to XOR against.
virtual void WoopsiUI::Graphics::drawXORPixel ( s16  x,
s16  y 
) [virtual]

Invert the colour of the pixel at the specified co-ordinates.

Parameters:
x The x co-ordinate of the pixel.
y The y co-ordinate of the pixel.
virtual void WoopsiUI::Graphics::drawXORPixel ( s16  x,
s16  y,
u16  colour 
) [virtual]

XOR the colour of the pixel at the specified co-ordinates against the supplied colour.

Parameters:
x The x co-ordinate of the pixel.
y The y co-ordinate of the pixel.
colour The colour to XOR against.
virtual void WoopsiUI::Graphics::drawXORRect ( s16  x,
s16  y,
u16  width,
u16  height 
) [virtual]

Invert the colour of an unfilled rectangle of pixels.

Parameters:
x The x co-ordinate of the rectangle.
y The y co-ordinate of the rectangle.
width The width of the rectangle.
height The height of the rectangle.
virtual void WoopsiUI::Graphics::drawXORRect ( s16  x,
s16  y,
u16  width,
u16  height,
u16  colour 
) [virtual]

XOR the colour of an unfilled rectangle of pixels against the supplied colour.

Parameters:
x The x co-ordinate of the rectangle.
y The y co-ordinate of the rectangle.
width The width of the rectangle.
height The height of the rectangle.
colour The colour to XOR against.
virtual void WoopsiUI::Graphics::drawXORVertLine ( s16  x,
s16  y,
u16  height 
) [virtual]

Invert the colour of a vertical line of pixels.

Parameters:
x The x co-ordinate of the line.
y The y co-ordinate of the line.
height The height of the line.
virtual void WoopsiUI::Graphics::drawXORVertLine ( s16  x,
s16  y,
u16  height,
u16  colour 
) [virtual]

XOR the colour of a vertical line of pixels against the supplied colour.

Parameters:
x The x co-ordinate of the line.
y The y co-ordinate of the line.
height The height of the line.
colour The colour to XOR against.
virtual void WoopsiUI::Graphics::floodFill ( s16  x,
s16  y,
u16  newColour 
) [virtual]

Fill a region of the internal bitmap with the specified colour.

Parameters:
x The x co-ordinate to use as the starting point of the fill.
y The y co-ordinate to use as the starting point of the fill.
newColour The colour to fill with.
u8 WoopsiUI::Graphics::getClipLineOutCode ( s16  x,
s16  y,
s16  xMin,
s16  yMin,
s16  xMax,
s16  yMax 
) [protected]

Get the clipping code for the given co-ordinates based on the given clipping region.

Parameters:
x X co-ordinate to clip.
y Y co-ordinate to clip.
xMin Minimum x value.
yMin Minimum y value.
xMax Maximum x value.
yMax Maximum y value.
void WoopsiUI::Graphics::getClipRect ( Rect rect  )  const

Get the current clipping region.

Parameters:
rect A rect that will be populated with the current clipping region.
const u16 WoopsiUI::Graphics::getPixel ( s16  x,
s16  y 
) const

Get the colour of the pixel at the specified co-ordinates

Parameters:
x The x co-ordinate of the pixel.
y The y co-ordinate of the pixel.
Returns:
The colour of the pixel.
void WoopsiUI::Graphics::greyScale ( s16  x,
s16  y,
u16  width,
u16  height 
)

Convert the region to greyscale.

Parameters:
x X co-ord of the region to change.
y Y co-ord of the region to change.
width Width of the region to change.
height Height of the region to change.
bool WoopsiUI::Graphics::popStack ( s16 *  x,
s16 *  y,
WoopsiArray< s32 > *  stack 
) [protected]

Remove the last item from the flood fill stack and insert its properties into the supplied x and y variables.

Parameters:
x The x co-ordinate of the pixel from the stack (output by the function).
y The y co-ordinate of the pixel from the stack (output by the function).
stack Pointer to the stack to pop from.
void WoopsiUI::Graphics::pushStack ( s16  x,
s16  y,
WoopsiArray< s32 > *  stack 
) [protected]

Push new co-ordinates onto the stack.

Parameters:
x The x co-ordinate of the pixel to add to the stack.
y The y co-ordinate of the pixel to add to the stack.
stack The stack to add a new value to.
virtual void WoopsiUI::Graphics::scroll ( s16  x,
s16  y,
s16  xDistance,
s16  yDistance,
u16  width,
u16  height,
WoopsiArray< Rect > *  revealedRects 
) [virtual]

Scroll a region by a specified distance in two dimensions. Performs a clipped copy to achieve scroll effect.

Parameters:
x X co-ord of the area to scroll.
y Y co-ord of the area to scroll.
xDistance Horizontal distance to scroll.
yDistance Vertical distance to scroll.
width Width of the area to scroll.
height Height of the area to scroll.
revealedRects Populated with rects representing the region uncovered by the scroll method. This should be empty when passed, and the regions should be drawn to once the scroll has finished.
void WoopsiUI::Graphics::setClipRect ( const Rect clipRect  ) 

Sets the clip rect. Attempts to draw outside of this region will be clipped out.

Parameters:
clipRect The new clipping region.

Member Data Documentation

Clipping rect that the object must draw within.

u16 WoopsiUI::Graphics::_height [protected]

Bitmap height

u16 WoopsiUI::Graphics::_width [protected]

Bitmap width


The documentation for this class was generated from the following file:
Generated by  doxygen 1.6.3