Main Page Class Hierarchy Compound List File List Compound Members File Members Related Pages Examples

# sdldrawobject.h

Go to the documentation of this file.

    00001 /*
    00002     ParaGUI - crossplatform widgetset
    00003     Copyright (C) 2000  Alexander Pipelka
    00004
    00005     This library is free software; you can redistribute it and/or
    00006     modify it under the terms of the GNU Library General Public
    00007     License as published by the Free Software Foundation; either
    00008     version 2 of the License, or (at your option) any later version.
    00009
    00010     This library is distributed in the hope that it will be useful,
    00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013     Library General Public License for more details.
    00014
    00015     You should have received a copy of the GNU Library General Public
    00016     License along with this library; if not, write to the Free
    00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00018
    00019     Alexander Pipelka
    00020     pipelka@teleweb.at
    00021
    00022     Last Update:      $Author: pipelka $
    00023     Update Date:      $Date: 2001/01/31 17:23:15 $
    00024     Source File:      $Source: /usr/local/CVSROOT/linux/paragui/doc/html/sdldrawobject_h-source.html,v $
    00025     CVS/RCS Revision: $Revision: 1.34 $
    00026     Status:           $State: Exp $
    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     // draw, update, move, ...
    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     // set object props
    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     // Drawing functions
    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     // clipping / intersection
    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: // disable the copy operators
    00297     SDLDrawObject(const SDLDrawObject&);
    00298     SDLDrawObject& operator=(const SDLDrawObject&);
    00299 };
    00300
    00301 #endif // SDLDRAWOBJECT_H