00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __INTERFACE__H__
00016 #define __INTERFACE__H__
00017 #include "mxf.h"
00018
00019
00020
00021 #include "mxsurface.h"
00022 #include "mx_types.h"
00023 #include "mx_exception.h"
00024 #include "mx_font.h"
00025
00026
00027 namespace mx
00028 {
00029
00030 class mxSurfacePainter {
00031
00032 public:
00033
00034 mxSurfacePainter(mxSurface *surface = 0);
00035 void resetSurface(mxSurface *surface);
00036 const bool paintLock();
00037 const bool paintUnlock();
00038 const bool setPixel(int x, int y, Color col);
00039 const bool setPixel(int x, int y, Uint32 color);
00040
00041 const bool getPixel(int x, int y, SDL_Color *col, Color &return_col);
00042 const Uint32 getPixel(int x, int y, SDL_Color *col);
00043
00044 void setFont(SDL_Font *font) { this->font = font; }
00045 void printText(int x, int y, Color col,std::string text);
00046 private:
00047 mxSurface *surface;
00048 void *pbuf;
00049 bool locked;
00050 SDL_Font *font;
00051
00052 };
00053
00054 class mxPainter {
00055
00056 public:
00057
00058 mxPainter() {
00059
00060 this->surface = 0;
00061
00062 }
00063 mxPainter(const mxSurface &surface)
00064 {
00065 this->surface = (mxSurface*)&surface;
00066 }
00067 void setSurface(const mxSurface &surface) {
00068 this->surface = (mxSurface*)&surface;
00069 }
00070 void lock();
00071 void unlock();
00072 inline void setpixel(int x, int y, unsigned int color) { surface->operator[](surface->linepos(x,y)) = color; }
00073 inline void setpixel(int x, int y, Color color) { surface->operator[](surface->linepos(x,y)) = mx::Color::mapRGB(*surface, color); }
00074 inline unsigned int getpixel(int x, int y) { return surface->operator[](surface->linepos(x,y)); }
00075 void GetPixel(int x, int y, mx::Color &color);
00076 void fillRect(SDL_Rect *rc, mx::Color &color);
00077 void fillRect(int x, int y, int w, int h, mx::Color &color);
00078 void fillRect(Rect rc, Color col);
00079 void drawLine(int start_x, int start_y, int stop_x, int stop_y, Color color);
00080 void drawLine( Line line, Color color );
00081 void drawHorizontal(int orig_x, int start_y, int stop_y, Color color);
00082 void drawVertical(int start_x, int stop_x, int orig_y, Color color);
00083 void drawSquare(Rect rc);
00084 mxSurface *getSurface() { return surface; }
00085 protected:
00086 mxSurface *surface;
00087 };
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 #endif
00104