Woopsi 1.3
Nintendo DS Gui Framework
libwoopsi/include/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 
00329         virtual void drawText(s16 x, s16 y, FontBase* font, const WoopsiString& string, s32 startIndex, s32 length, u16 colour = 0);
00330 
00344         void drawBaselineText(s16 x, s16 y, FontBase* font, const WoopsiString& string, s32 startIndex, s32 length, u16 colour = 0);        
00345         
00359         virtual void scroll(s16 x, s16 y, s16 xDistance, s16 yDistance, u16 width, u16 height, WoopsiArray<Rect>* revealedRects);
00360 
00370         virtual void drawBevelledRect(s16 x, s16 y, u16 width, u16 height, u16 shineColour, u16 shadowColour);
00371 
00372     protected:
00373         MutableBitmapBase* _bitmap;     
00374         u16 _width;                     
00375         u16 _height;                    
00376         Rect _clipRect;                 
00385         virtual void drawHorizLine(s16 x, s16 y, u16 width, u16 colour);
00386         
00394         virtual void drawVertLine(s16 x, s16 y, u16 height, u16 colour);
00395 
00404         virtual void drawCircle(s16 x0, s16 y0, u16 radius, u16 colour);
00405         
00414         virtual void drawFilledCircle(s16 x0, s16 y0, u16 radius, u16 colour);
00415 
00428         bool clipBitmapCoordinates(s16* x, s16* y, u16* width, u16* height);
00429 
00440         bool popStack(s16* x, s16* y, WoopsiArray<s32>& stack);
00441         
00448         void pushStack(s16 x, s16 y, WoopsiArray<s32>& stack);
00449 
00460         u8 getClipLineOutCode(s16 x, s16 y, s16 xMin, s16 yMin, s16 xMax, s16 yMax);
00461 
00471         void drawClippedLine(s16 x1, s16 y1, s16 x2, s16 y2, u16 colour);
00472 
00486         void drawClippedBitmapGreyScale(s16 x, s16 y, u16 width, u16 height, const BitmapBase* bitmap, s16 bitmapX, s16 bitmapY);
00487 
00498         bool clipCoordinates(s16* x1, s16* y1, s16* x2, s16* y2, const Rect& clipRect);
00499 
00503         inline Graphics(const Graphics& graphics) { };
00504     };
00505 }
00506 
00507 #endif
 All Classes Functions Variables Enumerations Enumerator