00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef BUTTON_H
00018 # define BUTTON_H
00019
00020 # include "Global.hh"
00021 # include "Colors.hh"
00022 # include "Widget.hh"
00023
00024 # include <SDL_gfxPrimitives.h>
00025
00026 # define BUTTON_ALPHA 200
00027
00037 class ImageButton: public Widget
00038 {
00039 ushort action;
00040 public:
00041 ImageButton(const uint x, const uint y, const uint w, const uint h,
00042 SDL_Surface* screen, Widget* father, const string filename, const ushort action = CLOSE);
00043 ImageButton(const uint w, const uint h,
00044 SDL_Surface* screen, Widget* father, const string filename, const ushort action = CLOSE);
00045 ImageButton(SDL_Surface* screen, Widget* father, const string filename, const ushort action = CLOSE);
00046 virtual ~ImageButton(){};
00047
00051 void draw();
00052
00053 void refresh(){};
00054
00063 void mousemotion(const uint mousex, const uint mousey);
00064
00067 ushort mousebuttondown(const uint mousex = 0, const uint mousey = 0);
00068 };
00069
00079 class TextButton : public Widget
00080 {
00081 string txt;
00082 TTF_Font* font;
00083 SDL_Color textColor, textColorMotion;
00084 SDL_Color bgColor, bgColorMotion;
00085 ushort action;
00086
00087 public:
00088 TextButton(const uint x, const uint y, const uint w, const uint h,
00089 SDL_Surface* screen, Widget* father, const string txt, const ushort action = CLOSE);
00090 TextButton(const uint w, const uint h,
00091 SDL_Surface* screen, Widget* father, const string txt, const ushort action = CLOSE);
00092 TextButton(SDL_Surface* screen, Widget* father, const string txt, const ushort action = CLOSE);
00093 virtual ~TextButton();
00094
00101 void drawmotion(SDL_Color textColor, SDL_Color bgColor);
00102
00106 void draw();
00107
00108 void refresh(){};
00109
00118 void mousemotion(const uint mousex, const uint mousey);
00119
00125 ushort mousebuttondown(const uint mousex = 0, const uint mousey = 0);
00126 };
00127
00137 class BClose:public ImageButton
00138 {
00139 public:
00140 BClose(SDL_Surface* screen, Widget* father)
00141 : ImageButton(62,136,114,30,screen,father,"image/dialog/close.jpg")
00142 {}
00143 };
00144
00154 class BYes:public ImageButton
00155 {
00156 public:
00157 BYes(SDL_Surface* screen, Widget* father)
00158 : ImageButton(62,135,50,31,screen,father,"image/dialog/yes.jpg")
00159 {}
00160 };
00161
00171 class BNo:public ImageButton
00172 {
00173 public:
00174 BNo(SDL_Surface* screen, Widget* father)
00175 : ImageButton(130,135,50,31,screen,father, "image/dialog/no.jpg")
00176 {};
00177 };
00178
00179 #endif