- Main Page
- Classes
- Files

- File List

# graphics.h

    00001 #ifndef _GRAPHICS_H_
    00002 #define _GRAPHICS_H_
    00003
    00004 #include <nds.h>
    00005 #include "woopsiarray.h"
    00006 #include "bitmapbase.h"
    00007 #include "mutablebitmapbase.h"
    00008 #include "rect.h"
    00009 #include "woopsistring.h"
    00010
    00011 namespace WoopsiUI {
    00012
    00013         class FontBase;
    00014
    00019         class Graphics {
    00020         public:
    00021
    00027                 Graphics(MutableBitmapBase* bitmap, const Rect& clipRect);
    00028
    00032                 virtual inline ~Graphics() { };
    00033
    00039                 void setClipRect(const Rect& clipRect);
    00040
    00046                 void getClipRect(Rect& rect) const;
    00047
    00054                 const u16 getPixel(s16 x, s16 y) const;
    00055
    00062                 virtual void drawPixel(s16 x, s16 y, u16 colour);
    00063
    00072                 virtual void drawFilledRect(s16 x, s16 y, u16 width, u16 height, u16 colour);
    00073
    00081                 virtual void drawHorizLine(s16 x, s16 y, u16 width, u16 colour);
    00082
    00090                 virtual void drawVertLine(s16 x, s16 y, u16 height, u16 colour);
    00091
    00100                 virtual void drawRect(s16 x, s16 y, u16 width, u16 height, u16 colour);
    00101
    00109                 virtual void drawXORPixel(s16 x, s16 y, u16 colour);
    00110
    00119                 virtual void drawXORHorizLine(s16 x, s16 y, u16 width, u16 colour);
    00120
    00129                 virtual void drawXORVertLine(s16 x, s16 y, u16 height, u16 colour);
    00130
    00140                 virtual void drawFilledXORRect(s16 x, s16 y, u16 width, u16 height, u16 colour);
    00141
    00151                 virtual void drawXORRect(s16 x, s16 y, u16 width, u16 height, u16 colour);
    00152
    00158                 virtual void drawXORPixel(s16 x, s16 y);
    00159
    00166                 virtual void drawXORHorizLine(s16 x, s16 y, u16 width);
    00167
    00174                 virtual void drawXORVertLine(s16 x, s16 y, u16 height);
    00175
    00183                 virtual void drawXORRect(s16 x, s16 y, u16 width, u16 height);
    00184
    00192                 virtual void drawFilledXORRect(s16 x, s16 y, u16 width, u16 height);
    00193
    00204                 virtual void drawBitmap(s16 x, s16 y, u16 width, u16 height, const BitmapBase* bitmap, s16 bitmapX, s16  bitmapY);
    00205
    00219                 virtual void drawBitmap(s16 x, s16 y, u16 width, u16 height, const BitmapBase* bitmap, s16 bitmapX, s16 bitmapY, u16 transparentColour);
    00220
    00233                 virtual void drawBitmapGreyScale(s16 x, s16 y, u16 width, u16 height, const BitmapBase* bitmap, s16 bitmapX, s16  bitmapY);
    00234
    00241                 virtual void floodFill(s16 x, s16 y, u16 newColour);
    00242
    00257                 void copy(s16 sourceX, s16 sourceY, s16 destX, s16 destY, u16 width, u16 height);
    00258
    00266                 void dim(s16 x, s16 y, u16 width, u16 height);
    00267
    00276                 virtual void drawLine(s16 x1, s16 y1, s16 x2, s16 y2, u16 colour);
    00277
    00286                 virtual void drawCircle(s16 x0, s16 y0, u16 radius, u16 colour);
    00287
    00296                 virtual void drawFilledCircle(s16 x0, s16 y0, u16 radius, u16 colour);
    00297
    00306                 virtual void drawEllipse(s16 xCentre, s16 yCentre, s16 horizRadius, s16 vertRadius, u16 colour);
    00307
    00316                 virtual void drawFilledEllipse(s16 xCentre, s16 yCentre, s16 horizRadius, s16 vertRadius, u16 colour);
    00317
    00325                 void greyScale(s16 x, s16 y, u16 width, u16 height);
    00326
    00334                 virtual void drawText(s16 x, s16 y, FontBase* font, const WoopsiString& string);
    00335
    00348                 virtual void drawText(s16 x, s16 y, FontBase* font, const WoopsiString& string, s32 startIndex, s32 length, u16 colour);
    00349
    00360                 virtual void drawText(s16 x, s16 y, FontBase* font, const WoopsiString& string, s32 startIndex, s32 length);
    00361
    00375                 virtual void scroll(s16 x, s16 y, s16 xDistance, s16 yDistance, u16 width, u16 height, WoopsiArray<Rect>* revealedRects);
    00376
    00386                 virtual void drawBevelledRect(s16 x, s16 y, u16 width, u16 height, u16 shineColour, u16 shadowColour);
    00387
    00388         protected:
    00389                 MutableBitmapBase* _bitmap;
    00390                 u16 _width;
    00391                 u16 _height;
    00392                 Rect _clipRect;
    00401                 bool clipBitmapCoordinates(s16* x, s16* y, u16* width, u16* height);
    00402
    00410                 bool popStack(s16* x, s16* y, WoopsiArray<s32>* stack);
    00411
    00418                 void pushStack(s16 x, s16 y, WoopsiArray<s32>* stack);
    00419
    00430                 u8 getClipLineOutCode(s16 x, s16 y, s16 xMin, s16 yMin, s16 xMax, s16 yMax);
    00431
    00440                 void drawClippedLine(s16 x1, s16 y1, s16 x2, s16 y2, u16 colour);
    00441
    00453                 void drawClippedBitmapGreyScale(s16 x, s16 y, u16 width, u16 height, const BitmapBase* bitmap, s16 bitmapX, s16 bitmapY);
    00454
    00465                 bool clipCoordinates(s16* x1, s16* y1, s16* x2, s16* y2, const Rect& clipRect);
    00466
    00470                 inline Graphics(const Graphics& graphics) { };
    00471         };
    00472 }
    00473
    00474 #endif