00001 00011 #ifndef MEMORY_DRAWENV_H 00012 #define MEMORY_DRAWENV_H 00013 00014 #include <basic.h> 00015 #include <memory> 00016 00018 00021 class MemoryDrawEnv { 00022 00023 private: 00024 00025 CSPEC cspec; 00026 B bitmap_entity[sizeof(BMP)+sizeof(UB*)*28]; 00027 BMP* bmp; 00028 PAT pat; 00029 mutable GID gid; 00030 00032 void getCSPEC(); 00033 00035 void createBitmap(); 00036 00038 void releaseBitmap() throw(); 00039 00040 public: 00041 00043 MemoryDrawEnv() : gid(-1), bmp(reinterpret_cast<BMP*>(bitmap_entity)) { 00044 bmp->baseaddr[0] = 0; 00045 setrect(bmp->bounds, 0, 0, SCREEN.hpixels, SCREEN.vpixels); 00046 bmp->planes = SCREEN.planes; 00047 bmp->pixbits = SCREEN.pixbits; 00048 pat.spat.kind = 0; 00049 pat.spat.vsize = pat.spat.hsize = 1; 00050 pat.spat.fgcol = 0x10ffffff; 00051 pat.spat.bgcol = 0x10000000; 00052 pat.spat.mask = FILL100; 00053 getCSPEC(); 00054 createBitmap(); 00055 clear(); 00056 } 00057 00059 ~MemoryDrawEnv() { 00060 if (gid > 0){ 00061 gcls_env(gid); 00062 } 00063 releaseBitmap(); 00064 } 00065 00067 00071 void setPos(const PNT& p) { 00072 bmp->bounds.p.lefttop = p; 00073 bmp->bounds.c.right = bmp->bounds.c.left + SCREEN.hpixels; 00074 bmp->bounds.c.bottom = bmp->bounds.c.top + SCREEN.vpixels; 00075 if (gid > 0){ 00076 gcls_env(gid); 00077 } 00078 gid = -1; 00079 } 00080 00082 00086 const PNT& getPos() const { 00087 return bmp->bounds.p.lefttop; 00088 } 00089 00091 00094 void clear() { 00095 gfil_rec(getGID(), bmp->bounds, &pat, 0, G_STORE); 00096 } 00097 00099 00104 GID getGID() const; 00105 00107 00111 const BMP* getBMP() const { 00112 return bmp; 00113 } 00114 00115 }; 00116 00117 #endif // MEMORY_DRAWENV_H