00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef SDLDRAWOBJECT_H
00030 #define SDLDRAWOBJECT_H
00031
00032 #ifdef SWIG
00033 %include "swigcommon.h"
00034 %module sdldrawobject
00035 %{
00036 #include "sdldrawobject.h"
00037 %}
00038 #endif
00039
00040 #include "paragui.h"
00041
00050 class DECLSPEC SDLDrawObject {
00051 public:
00052
00054 SDLDrawObject(int id, SDL_Rect& rect, bool visible, bool storeBackground, SDLDrawObject* objParent = NULL);
00055
00057 virtual ~SDLDrawObject();
00058
00059
00060
00067 virtual bool Redraw(bool update = true);
00068
00074 virtual void Update(bool doBlit = true);
00075
00079 virtual void Blit();
00080
00088 virtual bool MoveWindow(int x, int y);
00089
00097 virtual bool SizeWindow(int w, int h);
00098
00099
00100
00107 bool SetVisible(bool visible);
00108
00113 bool IsVisible();
00114
00116 void SetTransparency(Uint8 t);
00117
00119 Uint8 GetTransparency();
00120
00122 bool RestoreBackground();
00123
00125 bool StoreBackground();
00126
00128 void SetStoreBackground(bool store);
00129
00131 bool GetStoreBackground();
00132
00134 virtual void SetScreenUpdate(bool update);
00135
00137 bool GetScreenUpdate();
00138
00140 void FadeOut();
00141
00143 void FadeIn();
00144
00145
00146
00148 static void SetPixel(int x, int y, Uint8 r, Uint8 g, Uint8 b, SDL_Surface* surface);
00149
00151 void DrawHLine(int x, int y, int w, Uint8 r, Uint8 g, Uint8 b, SDL_Surface* surface);
00152
00154 void DrawVLine(int x, int y, int h, Uint8 r, Uint8 g, Uint8 b, SDL_Surface* surface);
00155
00157 void DrawRectWH(int x, int y, int w, int h, Uint8 r, Uint8 g, Uint8 b, SDL_Surface* surface);
00158
00160 void DrawBorder(SDL_Surface* surface, SDL_Rect* r, int size, bool up = true);
00161
00171 static SDL_Surface* CreateGradient(SDL_Rect& r, SDL_Gradient& gradient);
00172
00185 #ifdef SWIG
00186 %name(CreateGradient2) static SDL_Surface* CreateGradient(SDL_Rect& r, SDL_Color& ul, SDL_Color& ur, SDL_Color& dl, SDL_Color& dr);
00187 #else
00188 static SDL_Surface* CreateGradient(SDL_Rect& r, SDL_Color& ul, SDL_Color& ur, SDL_Color& dl, SDL_Color& dr);
00189 #endif
00190
00192 #ifdef SWIG
00193 %name(DrawGradient2) static void DrawGradient(SDL_Surface* surface, SDL_Rect& r, SDL_Color& ul, SDL_Color& ur, SDL_Color& dl, SDL_Color& dr);
00194 #else
00195 static void DrawGradient(SDL_Surface* surface, SDL_Rect& r, SDL_Color& ul, SDL_Color& ur, SDL_Color& dl, SDL_Color& dr);
00196 #endif
00197
00199 static void DrawGradient(SDL_Surface* surface, SDL_Rect& r, SDL_Gradient& gradient);
00200
00211 static void DrawThemedSurface(SDL_Surface* surface, SDL_Rect* r, SDL_Gradient* gradient, SDL_Surface* background, int bkmode, Uint8 blend);
00212
00223 static SDL_Surface* CreateThemedSurface(SDL_Rect& r, SDL_Gradient* gradient, SDL_Surface* background, int bkmode, Uint8 blend);
00224
00226 void DrawText(int x, int y, char* text, SDL_Color c, TTF_Font* textfont = NULL);
00227
00229 #ifdef SWIG
00230 %name(DrawText2) void DrawText(SDL_Rect* r, char* text, SDL_Color c, int align = SDL_TA_LEFT, TTF_Font* textfont = NULL);
00231 #else
00232 void DrawText(SDL_Rect* r, char* text, SDL_Color c, int align = SDL_TA_LEFT, TTF_Font* textfont = NULL);
00233 #endif
00234
00235
00236
00238 static SDL_Rect IntersectRect(SDL_Rect p, SDL_Rect c);
00239
00241 void SetClipRect(int x, int y, int w, int h);
00242
00244 bool IsClippingEnabled();
00245
00247 void GetClipRects(SDL_Rect& src, SDL_Rect& dst, SDL_Rect* displayrect = NULL);
00248
00250 SDL_Rect GetClipRect();
00251
00253 virtual bool IsDisplayRectValid();
00254
00256 void SetParent(SDLDrawObject* objParent);
00257
00258 protected:
00259
00261 SDL_Surface* CreateSubSurface(SDL_Surface* surface, SDL_Rect* r);
00262
00264 virtual void eventDraw(SDL_Surface* surface, SDL_Rect* rect);
00265
00267 virtual void eventBlit(SDL_Surface* srf, SDL_Rect* src, SDL_Rect* dst);
00268
00270 virtual void eventSizeWindow(int w, int h);
00271
00273 virtual void eventMoveWindow(int x, int y);
00274
00275 int my_id;
00276
00277 SDL_Rect my_rectDisplay;
00278 SDL_Rect my_rectClip;
00279
00280 bool my_visible;
00281 bool my_storeBackground;
00282
00283 Uint8 my_transparency;
00284
00285 SDL_Surface* my_srfBackground;
00286 SDL_Surface* my_srfObject;
00287 SDL_Surface* my_srfScreen;
00288 SDL_Surface* my_srfDrag;
00289
00290 SDLDrawObject* my_objParent;
00291 SDL_Point my_ptDragStart;
00292
00293 private:
00294 bool my_screenUpdate;
00295
00296 private:
00297 SDLDrawObject(const SDLDrawObject&);
00298 SDLDrawObject& operator=(const SDLDrawObject&);
00299 };
00300
00301 #endif // SDLDRAWOBJECT_H