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

# sdlbutton.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/sdlbutton_h-source.html,v $
    00025     CVS/RCS Revision: $Revision: 1.34 $
    00026     Status:           $State: Exp $
    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