00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef SDLSURFACE_H
00023 #define SDLSURFACE_H
00024
00025 #include "SDL/SDL.h"
00026 #include <list>
00027
00028 using namespace std;
00029
00044 class DECLSPEC SdlSurface
00045 {
00046 public:
00053 DECLSPEC SdlSurface( const char *name );
00062 DECLSPEC SdlSurface( SDL_Surface *surf, const char *name );
00074 DECLSPEC SdlSurface( Uint32 w, Uint32 h, const char *name = (char*)-1, Uint32 flags = SDL_HWSURFACE );
00075 virtual DECLSPEC ~SdlSurface();
00076
00082 void DECLSPEC rename( const char *newname );
00084 const char *getName() const { return chName; }
00085
00098 DECLSPEC bool fastBlit( SdlSurface *src_surf, Sint16 xDst, Sint16 yDst, SDL_Rect *src );
00107 DECLSPEC bool fill( SDL_Rect *r, Uint32 color );
00118 DECLSPEC bool zoomBlit( SdlSurface *src_surf, Sint16 xDst, Sint16 yDst, double xZoom, double yZoom, bool smooth = false );
00126 DECLSPEC bool stretchBlit( SdlSurface *src_surf, SDL_Rect *dst, bool smooth = false );
00137 DECLSPEC bool rotozoomBlit( SdlSurface *src_surf, Sint16 xDst, Sint16 yDst, double angle, double zoom, bool smooth = false );
00138
00140 SDL_Surface *surf() { return surface; }
00145 void getSize( int &w, int &h ) { w = surface->w; h = surface->h; }
00150 void getSize( Uint16 &w, Uint16 &h ) { w = surface->w; h = surface->h; }
00151
00153 Uint32 getWidth() const { return surface->w; }
00155 Uint32 getHeight() const { return surface->h; }
00156
00162 void setClip( const SDL_Rect &r ) { SDL_SetClipRect( surface, &r ); }
00166 void setNoClip() { SDL_SetClipRect( surface, NULL ); }
00170 const SDL_Rect &getClip() const { return surface->clip_rect; }
00175 DECLSPEC void setColorKey( Uint32 color );
00181 DECLSPEC void setAlphaValue( int a );
00182
00188 bool lock() { return SDL_LockSurface( surface ) >= 0; }
00192 void unlock() { SDL_UnlockSurface( surface ); }
00193
00197 virtual DECLSPEC bool saveToFile( const char *fn );
00198
00199 protected:
00204 virtual DECLSPEC void onRefresh() {}
00206 DECLSPEC void failed();
00207
00209 SDL_Surface *surface;
00210
00211 private:
00212 void initName( const char *name );
00213 char *chName;
00214 bool bFailed;
00215 };
00216
00217 #endif