Woopsi 1.0 GUI Framework for Nintendo DS Homebrew

- 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
    00020 #define woopsiRGB(r, g, b) (((b) << 10) | ((g) << 5) | (r) | (1 << 15))
    00021
    00022 namespace WoopsiUI {
    00023
    00024         class FontBase;
    00025
    00030         class Graphics {
    00031         public:
    00032
    00038                 Graphics(MutableBitmapBase* bitmap, const Rect& clipRect);
    00039
    00043                 virtual inline ~Graphics() { };
    00044
    00050                 void setClipRect(const Rect& clipRect);
    00051
    00057                 void getClipRect(Rect& rect) const;
    00058
    00065                 const u16 getPixel(s16 x, s16 y) const;
    00066
    00073                 virtual void drawPixel(s16 x, s16 y, u16 colour);
    00074
    00083                 virtual void drawFilledRect(s16 x, s16 y, u16 width, u16 height, u16 colour);
    00084
    00093                 virtual void drawRect(s16 x, s16 y, u16 width, u16 height, u16 colour);
    00094
    00102                 virtual void drawXORPixel(s16 x, s16 y, u16 colour);
    00103
    00112                 virtual void drawXORHorizLine(s16 x, s16 y, u16 width, u16 colour);
    00113
    00122                 virtual void drawXORVertLine(s16 x, s16 y, u16 height, u16 colour);
    00123
    00133                 virtual void drawFilledXORRect(s16 x, s16 y, u16 width, u16 height, u16 colour);
    00134
    00144                 virtual void drawXORRect(s16 x, s16 y, u16 width, u16 height, u16 colour);
    00145
    00151                 virtual void drawXORPixel(s16 x, s16 y);
    00152
    00159                 virtual void drawXORHorizLine(s16 x, s16 y, u16 width);
    00160
    00167                 virtual void drawXORVertLine(s16 x, s16 y, u16 height);
    00168
    00176                 virtual void drawXORRect(s16 x, s16 y, u16 width, u16 height);
    00177
    00185                 virtual void drawFilledXORRect(s16 x, s16 y, u16 width, u16 height);
    00186
    00199                 virtual void drawBitmap(s16 x, s16 y, u16 width, u16 height, const BitmapBase* bitmap, s16 bitmapX, s16  bitmapY);
    00200
    00217                 virtual void drawBitmap(s16 x, s16 y, u16 width, u16 height, const BitmapBase* bitmap, s16 bitmapX, s16 bitmapY, u16 transparentColour);
    00218
    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 drawEllipse(s16 xCentre, s16 yCentre, s16 horizRadius, s16 vertRadius, u16 colour);
    00287
    00296                 virtual void drawFilledEllipse(s16 xCentre, s16 yCentre, s16 horizRadius, s16 vertRadius, u16 colour);
    00297
    00305                 void greyScale(s16 x, s16 y, u16 width, u16 height);
    00306
    00314                 virtual void drawText(s16 x, s16 y, FontBase* font, const WoopsiString& string);
    00315
    00328                 virtual void drawText(s16 x, s16 y, FontBase* font, const WoopsiString& string, s32 startIndex, s32 length, u16 colour);
    00329
    00340                 virtual void drawText(s16 x, s16 y, FontBase* font, const WoopsiString& string, s32 startIndex, s32 length);
    00341
    00353         void drawBaselineText(s16 x, s16 y, FontBase* font, const WoopsiString& string, s32 startIndex, s32 length);
    00354
    00368                 virtual void scroll(s16 x, s16 y, s16 xDistance, s16 yDistance, u16 width, u16 height, WoopsiArray<Rect>* revealedRects);
    00369
    00379                 virtual void drawBevelledRect(s16 x, s16 y, u16 width, u16 height, u16 shineColour, u16 shadowColour);
    00380
    00381         protected:
    00382                 MutableBitmapBase* _bitmap;
    00383                 u16 _width;
    00384                 u16 _height;
    00385                 Rect _clipRect;
    00394                 virtual void drawHorizLine(s16 x, s16 y, u16 width, u16 colour);
    00395
    00403                 virtual void drawVertLine(s16 x, s16 y, u16 height, u16 colour);
    00404
    00413                 virtual void drawCircle(s16 x0, s16 y0, u16 radius, u16 colour);
    00414
    00423                 virtual void drawFilledCircle(s16 x0, s16 y0, u16 radius, u16 colour);
    00424
    00437                 bool clipBitmapCoordinates(s16* x, s16* y, u16* width, u16* height);
    00438
    00449                 bool popStack(s16* x, s16* y, WoopsiArray<s32>* stack);
    00450
    00457                 void pushStack(s16 x, s16 y, WoopsiArray<s32>* stack);
    00458
    00469                 u8 getClipLineOutCode(s16 x, s16 y, s16 xMin, s16 yMin, s16 xMax, s16 yMax);
    00470
    00480                 void drawClippedLine(s16 x1, s16 y1, s16 x2, s16 y2, u16 colour);
    00481
    00495                 void drawClippedBitmapGreyScale(s16 x, s16 y, u16 width, u16 height, const BitmapBase* bitmap, s16 bitmapX, s16 bitmapY);
    00496
    00507                 bool clipCoordinates(s16* x1, s16* y1, s16* x2, s16* y2, const Rect& clipRect);
    00508
    00512                 inline Graphics(const Graphics& graphics) { };
    00513         };
    00514 }
    00515
    00516 #endif