Button.hh

00001 /*
00002 ** TowBowlTactics, an adaptation of the tabletop game Blood Bowl.
00003 ** 
00004 ** Copyright (C) 2006 The TBT Team.
00005 ** 
00006 ** This program is free software; you can redistribute it and/or
00007 ** modify it under the terms of the GNU General Public License
00008 ** as published by the Free Software Foundation; either version 2
00009 ** of the License, or (at your option) any later version.
00010 ** 
00011 ** The complete GNU General Public Licence Notice can be found as the
00012 ** `NOTICE' file in the root directory.
00013 ** 
00014 ** The TBT Team consists of people listed in the `AUTHORS' file.
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; // Action associate to the button
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; // text of the button
00082   TTF_Font* font;
00083   SDL_Color textColor, textColorMotion; // Color of the button in default or motion mode
00084   SDL_Color bgColor, bgColorMotion;  // Color of the background of the button in default or motion mode
00085   ushort action; // Action associate to the button
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

Generated on Sat Jun 23 16:07:22 2007 for Stechec/TBT by  doxygen 1.4.7