Woopsi 1.3
Nintendo DS Gui Framework
Public Member Functions
WoopsiUI::GraphicsPort Class Reference

#include <libwoopsi/include/graphicsport.h>

List of all members.

Public Member Functions

 GraphicsPort (const s16 x, const s16 y, const u16 width, const u16 height, const bool isEnabled, FrameBuffer *bitmap, const WoopsiArray< Rect > *clipRectList, const Rect *clipRect)
virtual ~GraphicsPort ()
void setClipRect (const Rect &clipRect)
void getClipRect (Rect &rect) const
const s16 getX () const
const s16 getY () const
void drawPixel (s16 x, s16 y, u16 colour)
void drawFilledRect (s16 x, s16 y, u16 width, u16 height, u16 colour)
void drawRect (s16 x, s16 y, u16 width, u16 height, u16 colour)
void drawBevelledRect (s16 x, s16 y, u16 width, u16 height, u16 shineColour, u16 shadowColour)
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 drawXORRect (s16 x, s16 y, u16 width, u16 height, u16 colour)
virtual void drawFilledXORRect (s16 x, s16 y, u16 width, u16 height, u16 colour)
virtual void drawXORPixel (s16 x, s16 y)
void drawXORHorizLine (s16 x, s16 y, u16 width)
void drawXORVertLine (s16 x, s16 y, u16 height)
void drawXORRect (s16 x, s16 y, u16 width, u16 height)
void drawFilledXORRect (s16 x, s16 y, u16 width, u16 height)
void drawText (s16 x, s16 y, FontBase *font, const WoopsiString &string)
void drawText (s16 x, s16 y, FontBase *font, const WoopsiString &string, s32 startIndex, s32 length, u16 colour=0)
void drawBaselineText (s16 x, s16 y, FontBase *font, const WoopsiString &string, s32 startIndex, s32 length, u16 colour=0)
void drawBitmap (s16 x, s16 y, u16 width, u16 height, const BitmapBase *bitmap, s16 bitmapX, s16 bitmapY)
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)
void drawLine (s16 x1, s16 y1, s16 x2, s16 y2, u16 colour)
void copy (s16 sourceX, s16 sourceY, s16 destX, s16 destY, u16 width, u16 height)
void scroll (s16 x, s16 y, s16 xDistance, s16 yDistance, u16 width, u16 height, WoopsiArray< Rect > *revealedRects)
void dim (s16 x, s16 y, u16 width, u16 height)
void greyScale (s16 x, s16 y, u16 width, u16 height)
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)

Detailed Description

GraphicsPort is the interface between a gadget and the framebuffer. It provides drawing tools that are clipped to the visible regions of a gadget.

All drawing co-ordinates should be submitted in GraphicsPort space. GraphicsPort space is relative to the x and y co-ordinates given to an instance of the GraphicsPort class via its constructor. The width and height parameters define the size of that space. The x and y co-ordinates submitted to the constructor should be relative to the gadget. The getClipRect() method returns the rect in GraphicsPort space.

Internally, all co-ordinates are converted to Woopsi-space for manipulation. However, when drawing all co-ordinates are converted from Woopsi-space to framebuffer-space.

This class can only draw to one of the DS' framebuffers. This means that a gadget cannot span both of the DS' screens. If a gadget attempts to span both screens (as in the case of the Woopsi gadget), any drawing will be done to the bottom display only. Drawing commands that should take effect on the top display will simply be clipped out. This is why the Woopsi class creates two blank screens as backgrounds in its constructor and does not include any drawing commands.

A workaround for this limitation is to manually create a new graphicsport in your gadget's draw methods and force it to use the top display's framebuffer. You can then direct drawing commands to the upper display.


Constructor & Destructor Documentation

WoopsiUI::GraphicsPort::GraphicsPort ( const s16  x,
const s16  y,
const u16  width,
const u16  height,
const bool  isEnabled,
FrameBuffer bitmap,
const WoopsiArray< Rect > *  clipRectList,
const Rect clipRect 
)

Constructor.

The x, y, width and height parameters define the area within which the GraphicsPort can draw. These should represent the co-ordinates of the gadget, or an area within the gadget, expressed in Woopsi-space co-ordinates. A gadget's co-ordinates in Woopsi-space are given by its getX() and getY() methods. The width and height parameters are given by the getWidth() and getHeight() methods of the gadget.

To limit drawing to an area within a gadget, add the co-ordinates of the area to the values returned by getX() and getY(). For example, to create a GraphicsPort that will not draw within any of the pixels from co-ordinates (0,0) to (0,12), the x parameter should be:

getX() + 12

When the co-ordinates are increased, the width must decrease. The appropriate width for the above situation is:

getWidth() - 12

In most circumstances, x/y/width/height should reflect either the dimensions and co-ordinates of the gadget or the area inside its border.

Parameters:
xThe x co-ordinate of the region into which the graphics port can draw.
yThe y co-ordinate of the region into which the graphics port can draw.
widthThe width of the region into which the graphics port can draw.
heightThe height of the region into which the graphics port can draw.
isEnabledSet this to false to disable all drawing commands.
bitmapThe bitmap that the port will draw to.
clipRectListAn array of clipping regions within which the class must draw. If set, clipRect must be NULL.
clipRectThe clipping region within which the class must draw. If set, clipRectList must be NULL.
virtual WoopsiUI::GraphicsPort::~GraphicsPort ( ) [inline, virtual]

Destructor.


Member Function Documentation

void WoopsiUI::GraphicsPort::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:
sourceXSource x co-ord.
sourceYSource y co-ord.
destXDestination x co-ord.
destYDestination y co-ord.
widthWidth of the rectangle to copy.
heightHeight of the rectangle to copy.
void WoopsiUI::GraphicsPort::dim ( s16  x,
s16  y,
u16  width,
u16  height 
)

Halve the brightness of a specified region.

Parameters:
xX co-ord of the region to dim.
yY co-ord of the region to dim.
widthWidth of the region to dim.
heightHeight of the region to dim.
void WoopsiUI::GraphicsPort::drawBaselineText ( s16  x,
s16  y,
FontBase font,
const WoopsiString string,
s32  startIndex,
s32  length,
u16  colour = 0 
)

Draw a portion of a string on a baseline (chars may have different tops/heights/depths) to the bitmap.

Parameters:
xThe x co-ordinate of the string.
yThe y co-ordinate of the string.
fontThe font to draw with.
stringThe string to output.
startIndexThe start index within the string from which drawing will commence.
lengthThe number of characters to draw.
colourThe colour of the string. If this is not specified the font's default colour will be used.
void WoopsiUI::GraphicsPort::drawBevelledRect ( s16  x,
s16  y,
u16  width,
u16  height,
u16  shineColour,
u16  shadowColour 
)

Draw a bevelled rectangle to the bitmap.

Parameters:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
shineColourThe colour of the top/left sides.
shadowColourThe colour of the bottom/right sides.
void WoopsiUI::GraphicsPort::drawBitmap ( s16  x,
s16  y,
u16  width,
u16  height,
const BitmapBase bitmap,
s16  bitmapX,
s16  bitmapY 
)

Draw a bitmap to the port's bitmap.

Parameters:
xThe x co-ordinate to draw the bitmap to.
yThe y co-ordinate to draw the bitmap to.
widthThe width of the bitmap to draw.
heightThe height of the bitmap to draw.
bitmapPointer to the bitmap to draw.
bitmapXThe x co-ordinate within the supplied bitmap to use as the origin.
bitmapYThe y co-ordinate within the supplied bitmap to use as the origin.
void WoopsiUI::GraphicsPort::drawBitmap ( s16  x,
s16  y,
u16  width,
u16  height,
const BitmapBase bitmap,
s16  bitmapX,
s16  bitmapY,
u16  transparentColour 
)

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:
xThe x co-ordinate to draw the bitmap to.
yThe y co-ordinate to draw the bitmap to.
widthThe width of the bitmap to draw.
heightThe height of the bitmap to draw.
bitmapPointer to the bitmap to draw.
bitmapXThe x co-ordinate within the supplied bitmap to use as the origin.
bitmapYThe y co-ordinate within the supplied bitmap to use as the origin.
transparentColourThe transparent colour used in the bitmap.
virtual void WoopsiUI::GraphicsPort::drawBitmapGreyScale ( s16  x,
s16  y,
u16  width,
u16  height,
const BitmapBase bitmap,
s16  bitmapX,
s16  bitmapY 
) [virtual]

Draw a bitmap to the port 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:
xThe x co-ordinate to draw the bitmap to.
yThe y co-ordinate to draw the bitmap to.
widthThe width of the bitmap to draw.
heightThe height of the bitmap to draw.
bitmapPointer to the bitmap to draw.
bitmapXThe x co-ordinate within the supplied bitmap to use as the origin.
bitmapYThe y co-ordinate within the supplied bitmap to use as the origin.
virtual void WoopsiUI::GraphicsPort::drawEllipse ( s16  xCentre,
s16  yCentre,
s16  horizRadius,
s16  vertRadius,
u16  colour 
) [virtual]

Draw an unfilled ellipse to the bitmap.

Parameters:
xCentreThe x co-ordinate of the ellipse's centre.
yCentreThe y co-ordinate of the ellipse's centre.
horizRadiusThe size of the ellipse's horizontal radius.
vertRadiusThe size of the ellipse's vertical radius.
colourThe colour of the ellipse.
virtual void WoopsiUI::GraphicsPort::drawFilledEllipse ( s16  xCentre,
s16  yCentre,
s16  horizRadius,
s16  vertRadius,
u16  colour 
) [virtual]

Draw a filled ellipse to the bitmap.

Parameters:
xCentreThe x co-ordinate of the ellipse's centre.
yCentreThe y co-ordinate of the ellipse's centre.
horizRadiusThe size of the ellipse's horizontal radius.
vertRadiusThe size of the ellipse's vertical radius.
colourThe colour of the ellipse.
void WoopsiUI::GraphicsPort::drawFilledRect ( s16  x,
s16  y,
u16  width,
u16  height,
u16  colour 
)

Draw a filled rectangle to the bitmap.

Parameters:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
colourThe colour of the rectangle.
void WoopsiUI::GraphicsPort::drawFilledXORRect ( s16  x,
s16  y,
u16  width,
u16  height 
)

Invert the colour of a filled rectangle of pixels.

Parameters:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
virtual void WoopsiUI::GraphicsPort::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:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
colourThe colour to XOR against.
void WoopsiUI::GraphicsPort::drawLine ( s16  x1,
s16  y1,
s16  x2,
s16  y2,
u16  colour 
)

Draw a line to the port's bitmap.

Parameters:
x1The x co-ordinate of the start point of the line.
y1The y co-ordinate of the start point of the line.
x2The x co-ordinate of the end point of the line.
y2The y co-ordinate of the end point of the line.
colourThe colour of the line.
void WoopsiUI::GraphicsPort::drawPixel ( s16  x,
s16  y,
u16  colour 
)

Draw a pixel to the bitmap.

Parameters:
xThe x co-ordinate of the pixel.
yThe y co-ordinate of the pixel.
colourThe colour of the pixel.
void WoopsiUI::GraphicsPort::drawRect ( s16  x,
s16  y,
u16  width,
u16  height,
u16  colour 
)

Draw an unfilled rectangle to the bitmap

Parameters:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
colourThe colour of the rectangle.
void WoopsiUI::GraphicsPort::drawText ( s16  x,
s16  y,
FontBase font,
const WoopsiString string 
)

Draw a string to the bitmap.

Parameters:
xThe x co-ordinate of the string.
yThe y co-ordinate of the string.
fontThe font to draw with.
stringThe string to output.
void WoopsiUI::GraphicsPort::drawText ( s16  x,
s16  y,
FontBase font,
const WoopsiString string,
s32  startIndex,
s32  length,
u16  colour = 0 
)

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

Parameters:
xThe x co-ordinate of the string.
yThe y co-ordinate of the string.
fontThe font to draw with.
stringThe string to output.
startIndexThe start index within the string from which drawing will commence.
lengthThe number of characters to draw.
colourThe colour of the string. If this is not specified the font's default colour will be used.
virtual void WoopsiUI::GraphicsPort::drawXORHorizLine ( s16  x,
s16  y,
u16  width,
u16  colour 
) [virtual]

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

Parameters:
xThe x co-ordinate of the line.
yThe y co-ordinate of the line.
widthThe width of the line.
colourThe colour to XOR against.
void WoopsiUI::GraphicsPort::drawXORHorizLine ( s16  x,
s16  y,
u16  width 
)

Invert the colour of a horizontal line of pixels.

Parameters:
xThe x co-ordinate of the line.
yThe y co-ordinate of the line.
widthThe width of the line.
virtual void WoopsiUI::GraphicsPort::drawXORPixel ( s16  x,
s16  y,
u16  colour 
) [virtual]

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

Parameters:
xThe x co-ordinate of the pixel.
yThe y co-ordinate of the pixel.
colourThe colour to XOR against.
virtual void WoopsiUI::GraphicsPort::drawXORPixel ( s16  x,
s16  y 
) [virtual]

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

Parameters:
xThe x co-ordinate of the pixel.
yThe y co-ordinate of the pixel.
void WoopsiUI::GraphicsPort::drawXORRect ( s16  x,
s16  y,
u16  width,
u16  height 
)

Invert the colour of an unfilled rectangle of pixels.

Parameters:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
virtual void WoopsiUI::GraphicsPort::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:
xThe x co-ordinate of the rectangle.
yThe y co-ordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
colourThe colour to XOR against.
virtual void WoopsiUI::GraphicsPort::drawXORVertLine ( s16  x,
s16  y,
u16  height,
u16  colour 
) [virtual]

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

Parameters:
xThe x co-ordinate of the line.
yThe y co-ordinate of the line.
heightThe height of the line.
colourThe colour to XOR against.
void WoopsiUI::GraphicsPort::drawXORVertLine ( s16  x,
s16  y,
u16  height 
)

Invert the colour of a vertical line of pixels.

Parameters:
xThe x co-ordinate of the line.
yThe y co-ordinate of the line.
heightThe height of the line.
void WoopsiUI::GraphicsPort::getClipRect ( Rect rect) const

Get the current clipping region. The rect is automatically converted to GraphicsPort-space so that it can be retrieved in gadget drawing code in order to optmise the drawing routines.

Parameters:
rectA rect that will be populated with the current clipping region.
const s16 WoopsiUI::GraphicsPort::getX ( ) const [inline]

Return the x co-ordinate of the graphics port.

Returns:
The x co-ordinate of the graphics port.
const s16 WoopsiUI::GraphicsPort::getY ( ) const [inline]

Return the y co-ordinate of the graphics port.

Returns:
The y co-ordinate of the graphics port.
void WoopsiUI::GraphicsPort::greyScale ( s16  x,
s16  y,
u16  width,
u16  height 
)

Convert the region to greyscale.

Parameters:
xX co-ord of the region to change.
yY co-ord of the region to change.
widthWidth of the region to change.
heightHeight of the region to change.
void WoopsiUI::GraphicsPort::scroll ( s16  x,
s16  y,
s16  xDistance,
s16  yDistance,
u16  width,
u16  height,
WoopsiArray< Rect > *  revealedRects 
)

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

Parameters:
xX co-ord of the area to scroll.
yY co-ord of the area to scroll.
xDistanceHorizontal distance to scroll.
yDistanceVertical distance to scroll.
widthWidth of the area to scroll.
heightHeight of the area to scroll.
revealedRectsPopulated 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. The rects in the revealedRects array are returned in GadgetPort co-ordinates, and should be converted to Gadget co-ordinates before redrawing is attempted.
void WoopsiUI::GraphicsPort::setClipRect ( const Rect clipRect)

Sets the clip rect. Attempts to draw outside of this region will be clipped out. The rect's co-ordinates must be in Woopsi-space relative to the entire Woopsi system.

User code should not interfere with the clipping rects inside the GraphicsPort. Doing so will result in graphical glitches.

Parameters:
clipRectThe new clipping region.

The documentation for this class was generated from the following file:
 All Classes Functions Variables Enumerations Enumerator