00001 #ifndef _GRAPHICS_PORT_H_
00002 #define _GRAPHICS_PORT_H_
00003
00004 #include <nds.h>
00005 #include "gadget.h"
00006 #include "woopsiarray.h"
00007
00008 namespace WoopsiUI {
00009
00010 class FontBase;
00011
00019 class GraphicsPort {
00020 public:
00021
00035 GraphicsPort(Gadget* const gadget, const s16 x, const s16 y, const u16 width, const u16 height, u16* const bitmap, const u16 bitmapWidth, const u16 bitmapHeight, const WoopsiArray<Gadget::Rect>* clipRectList, const Gadget::Rect* clipRect);
00036
00040 inline ~GraphicsPort() {
00041 delete _clipRect;
00042 };
00043
00048 inline const s16 getX() const { return _rect.x + _gadget->getX(); };
00049
00054 const s16 getY() const { return _rect.y + _gadget->getY(); };
00055
00062 void drawPixel(s16 x, s16 y, u16 colour);
00063
00072 void drawFilledRect(s16 x, s16 y, u16 width, u16 height, u16 colour);
00073
00081 void drawHorizLine(s16 x, s16 y, s16 width, u16 colour);
00082
00090 void drawVertLine(s16 x, s16 y, s16 height, u16 colour);
00091
00100 void drawRect(s16 x, s16 y, u16 width, u16 height, u16 colour);
00101
00111 void drawBevelledRect(s16 x, s16 y, u16 width, u16 height, u16 shineColour, u16 shadowColour);
00112
00121 void drawBevelledRect(s16 x, s16 y, u16 width, u16 height);
00122
00130 void drawFilledCircle(s16 x0, s16 y0, u16 radius, u16 colour);
00131
00137 void drawXORPixel(s16 x, s16 y);
00138
00145 void drawXORHorizLine(s16 x, s16 y, s16 width);
00146
00153 void drawXORVertLine(s16 x, s16 y, s16 height);
00154
00162 void drawXORRect(s16 x, s16 y, u16 width, u16 height);
00163
00171 void drawFilledXORRect(s16 x, s16 y, u16 width, u16 height);
00172
00180 void drawText(s16 x, s16 y, FontBase* font, const char* string);
00181
00190 void drawText(s16 x, s16 y, FontBase* font, u16 length, const char* string);
00191
00199 void drawText(s16 x, s16 y, FontBase* font, char letter);
00200
00209 void drawText(s16 x, s16 y, FontBase* font, const char* string, u16 colour);
00210
00219 void drawText(s16 x, s16 y, FontBase* font, char letter, u16 colour);
00220
00233 void drawBitmap(s16 x, s16 y, u16 width, u16 height, const u16* bitmap, s16 bitmapX, s16 bitmapY, u16 bitmapWidth, u16 bitmapHeight);
00234
00250 void drawBitmap(s16 x, s16 y, u16 width, u16 height, const u16* bitmap, s16 bitmapX, s16 bitmapY, u16 bitmapWidth, u16 bitmapHeight, u16 transparentColour);
00251
00260 void drawLine(s16 x1, s16 y1, s16 x2, s16 y2, u16 colour);
00261
00265 void clear();
00266
00281 void copy(s16 sourceX, s16 sourceY, s16 destX, s16 destY, u16 width, u16 height);
00282
00296 void scroll(s16 x, s16 y, s16 xDistance, s16 yDistance, u16 width, u16 height, WoopsiArray<Gadget::Rect>* revealedRects);
00297
00305 void dim(s16 x, s16 y, u16 width, u16 height);
00306
00307 private:
00308 Gadget* _gadget;
00309 Gadget::Rect* _clipRect;
00310 const WoopsiArray<Gadget::Rect>* _clipRectList;
00311 Gadget::Rect _rect;
00312 u16* _bitmap;
00313 u16 _bitmapWidth;
00314 u16 _bitmapHeight;
00316
00317 void clipPixel(s16 x, s16 y, u16 colour, const Gadget::Rect& clipRect);
00318 void clipFilledRect(s16 x, s16 y, u16 width, u16 height, u16 colour, const Gadget::Rect& clipRect);
00319 void clipHorizLine(s16 x, s16 y, s16 width, u16 colour, const Gadget::Rect& clipRect);
00320 void clipVertLine(s16 x, s16 y, s16 height, u16 colour, const Gadget::Rect& clipRect);
00321 void clipBitmap(s16 x, s16 y, u16 width, u16 height, const u16* bitmap, s16 bitmapX, s16 bitmapY, u16 bitmapWidth, u16 bitmapHeight, const Gadget::Rect& clipRect);
00322 void clipBitmap(s16 x, s16 y, u16 width, u16 height, const u16* bitmap, s16 bitmapX, s16 bitmapY, u16 bitmapWidth, u16 bitmapHeight, u16 transparentColour, const Gadget::Rect& clipRect);
00323 void clipText(s16 x, s16 y, FontBase* font, u16 length, const char* string, const Gadget::Rect& clipRect);
00324 void clipFilledCircle(s16 x0, s16 y0, u16 radius, u16 colour, const Gadget::Rect& clipRect);
00325 void clipXORPixel(s16 x, s16 y, const Gadget::Rect& clipRect);
00326 void clipXORHorizLine(s16 x, s16 y, s16 width, const Gadget::Rect& clipRect);
00327 void clipXORVertLine(s16 x, s16 y, s16 height, const Gadget::Rect& clipRect);
00328 void clipLine(s16 x1, s16 y1, s16 x2, s16 y2, u16 colour, const Gadget::Rect& clipRect);
00329 void clipScroll(s16 x, s16 y, s16 xDistance, s16 yDistance, u16 width, u16 height, const Gadget::Rect& clipRect, WoopsiArray<Gadget::Rect>* revealedRects);
00330 void clipDim(s16 x, s16 y, u16 width, u16 height, const Gadget::Rect& clipRect);
00331
00332
00333 void drawClippedPixel(s16 x, s16 y, u16 colour);
00334 void drawClippedFilledRect(s16 x, s16 y, u16 width, u16 height, u16 colour);
00335 void drawClippedHorizLine(s16 x, s16 y, s16 width, u16 colour);
00336 void drawClippedVertLine(s16 x, s16 y, s16 height, u16 colour);
00337 void drawClippedBitmap(s16 x, s16 y, u16 width, u16 height, const u16* bitmap, s16 bitmapX, s16 bitmapY, u16 bitmapWidth, u16 bitmapHeight);
00338 void drawClippedBitmap(s16 x, s16 y, u16 width, u16 height, const u16* bitmap, s16 bitmapX, s16 bitmapY, u16 bitmapWidth, u16 bitmapHeight, u16 transparentColour);
00339 void drawClippedXORPixel(s16 x, s16 y);
00340 void drawClippedXORHorizLine(s16 x, s16 y, u16 width);
00341 void drawClippedXORVertLine(s16 x, s16 y, u16 height);
00342 void drawClippedXORRect(s16 x, s16 y, u16 width, u16 height);
00343 void drawClippedLine(s16 x1, s16 y1, s16 x2, s16 y2, u16 colour);
00344
00345 void convertPortToScreenSpace(s16* x, s16* y);
00346 bool clipCoordinates(s16* x1, s16* y1, s16* x2, s16* y2, const Gadget::Rect& clipRect);
00347 u8 getClipLineOutCode(s16 x, s16 y, s16 xMin, s16 yMin, s16 xMax, s16 yMax);
00348 };
00349 }
00350
00351 #endif