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 SDLBUTTON_H
00030 #define SDLBUTTON_H
00031
00032 #ifdef SWIG
00033 %include "swigcommon.h"
00034 %module sdlbutton
00035 %{
00036 #include "sdlbutton.h"
00037 %}
00038 #endif
00039
00040 #include "sdlwidget.h"
00041
00051 class DECLSPEC SDLUserButton : public SDLWidget {
00052 public:
00053
00054 SDLUserButton(SDLWidget* parent, int btnid, SDL_Rect& r, char* text = NULL);
00055 virtual ~SDLUserButton();
00056
00058 void DrawBorder(int size=2);
00059
00061 #ifndef SWIG
00062
00063 bool SetIcon(char* filenameup, char* filenamedown = NULL, Uint32 colorkey = 0x000000FF);
00064 #endif
00065
00067 #ifdef SWIG
00068
00069 %name(SetIcon2) bool SetIcon(SDL_Surface* icon_up, SDL_Surface* icon_down = NULL);
00070 #else
00071 bool SetIcon(SDL_Surface* icon_up, SDL_Surface* icon_down = NULL);
00072 #endif
00073
00075 void SetBorderSize(int norm, int pressed, int high);
00076
00078 void SetToggle(bool bToggle);
00079
00081 void SetPressed(bool pressed);
00082
00084 void SetTransparency(int norm, int pressed, int high);
00085
00087 void SetText(char* text);
00088
00090 char* GetText();
00091
00093 bool GetPressed();
00094
00095 protected:
00096
00098 void eventDraw(SDL_Surface* surface, SDL_Rect* rect);
00099
00101 void eventSizeWindow(int w, int h);
00102
00104 void eventMouseLeave();
00105
00107 void eventMouseEnter();
00108
00110 bool eventMouseButtonUp(const SDL_MouseButtonEvent* button);
00111
00113 bool eventMouseButtonDown(const SDL_MouseButtonEvent* button);
00114
00116 virtual void OnButtonSurface(SDL_Surface** surface, int newstate, int w, int h);
00117
00118 int bordersize[3];
00119 int transparency[3];
00120 int state;
00121 int id;
00122 int my_pressShift;
00123
00124 private:
00125 SDLUserButton(const SDLUserButton&);
00126 SDLUserButton& operator=(const SDLUserButton&);
00127
00129 void FreeSurfaces();
00130
00132 void FreeIcons();
00133
00134 SDL_Surface* srf_normal;
00135 SDL_Surface* srf_high;
00136 SDL_Surface* srf_down;
00137 SDL_Surface* srf_icon[2];
00138
00139 char labeltext[255];
00140 bool free_icons;
00141
00142 bool isPressed;
00143 bool togglemode;
00144 };
00145
00155 class DECLSPEC SDLButton : public SDLUserButton {
00156 public:
00157
00159 SDLButton(SDLWidget* parent, int id, SDL_Rect& r, char* text = NULL);
00160
00162 virtual ~SDLButton();
00163
00165 void LoadThemeStyle(const char* widgettype);
00166
00168 void LoadThemeStyle(const char* widgettype, const char* objectname);
00169
00171 void SetGradient(int state, SDL_Gradient& gradient);
00172
00174 void SetBackground(int state, SDL_Surface* background, int mode = BKMODE_TILE);
00175
00176 protected:
00177
00179 void OnButtonSurface(SDL_Surface** surface, int newstate, int w, int h);
00180
00181 private:
00182 SDLButton(const SDLButton&);
00183 SDLButton& operator=(const SDLButton&);
00184
00185 SDL_Gradient my_gradState[3];
00186 SDL_Surface* my_background[3];
00187 int my_backMode[3];
00188 int my_backBlend[3];
00189 };
00190
00191 #endif // SDLBUTTON_H