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
00033 #ifndef PG_THEMEWIDGET_H
00034 #define PG_THEMEWIDGET_H
00035
00036 #include "pgwidget.h"
00037 #include "pgdraw.h"
00038
00039 class PG_ThemeWidgetDataInternal;
00040
00084 class DECLSPEC PG_ThemeWidget : public PG_Widget {
00085 public:
00086
00095 PG_ThemeWidget(PG_Widget* parent, const PG_Rect& r = PG_Rect::null, const std::string& style="ThemeWidget");
00096
00108 PG_ThemeWidget(PG_Widget* parent, const PG_Rect& r, bool bCreateSurface, const std::string& style="ThemeWidget");
00109
00112 ~PG_ThemeWidget();
00113
00118 void LoadThemeStyle(const std::string& widgettype);
00119
00120 void LoadThemeStyle(const std::string& widgettype, const std::string& objectname);
00121
00128 bool SetBackground(const std::string& filename, PG_Draw::BkMode mode=PG_Draw::TILE);
00129
00137 bool SetBackground(const std::string& filename, PG_Draw::BkMode mode, const PG_Color& colorkey);
00138
00145 bool SetBackground(SDL_Surface* surface, PG_Draw::BkMode mode=PG_Draw::TILE);
00146
00151 void SetBackgroundBlend(Uint8 backblend);
00152
00157 void SetGradient(const PG_Gradient& grad);
00158
00163 PG_Gradient GetGradient();
00164
00173 bool LoadImage(const std::string& filename);
00174
00184 bool LoadImage(const std::string& filename, const PG_Color& key);
00185
00194 bool SetImage(SDL_Surface* image, bool bFreeImage = true);
00195
00201 void SetTransparency(Uint8 t, bool bRecursive = false);
00202
00215 static SDL_Surface* CreateThemedSurface(const PG_Rect& r, PG_Gradient* gradient, SDL_Surface* background, PG_Draw::BkMode bkmode, Uint8 blend);
00216
00221 static void DeleteThemedSurface(SDL_Surface* surface);
00222
00223 void SetSimpleBackground(bool simple);
00224
00225 void SetBackgroundColor(const PG_Color& c);
00226
00227 protected:
00228
00230 void eventSizeWidget(Uint16 w, Uint16 h);
00231
00233 void eventDraw(SDL_Surface* surface, const PG_Rect& rect);
00234
00236 void eventBlit(SDL_Surface* surface, const PG_Rect& src, const PG_Rect& dst);
00237
00238
00239 bool my_has_gradient;
00240
00241 PG_Gradient my_gradient;
00242
00243 SDL_Surface* my_background;
00244
00245 SDL_Surface* my_image;
00246
00247 Uint8 my_blendLevel;
00248
00249 bool my_backgroundFree;
00250
00251 PG_Draw::BkMode my_backgroundMode;
00252
00253 private:
00254
00255 PG_ThemeWidget(const PG_ThemeWidget&);
00256
00257 PG_ThemeWidget& operator=(const PG_ThemeWidget&);
00258
00259 DLLLOCAL void Init(const std::string& style);
00260
00261 DLLLOCAL void CreateSurface(Uint16 w = 0, Uint16 h = 0);
00262
00266 DLLLOCAL void FreeSurface();
00267
00268 DLLLOCAL void FreeImage();
00269
00270
00271
00272
00273 PG_ThemeWidgetDataInternal* _mid;
00274 };
00275
00276 #endif // PG_THEMEWIDGET_H