f66d8687315f9b99a9269906e90dad2d0b73eb59
[supertux.git] / src / gui / button.hpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #ifndef HEADER_SUPERTUX_GUI_BUTTON_HPP
18 #define HEADER_SUPERTUX_GUI_BUTTON_HPP
19
20 #include <SDL.h>
21 #include <string>
22
23 #include "math/vector.hpp"
24
25 class Surface;
26 class DrawingContext;
27 class Font;
28 class ButtonGroup;
29
30 enum {
31   BT_NONE,
32   BT_HOVER,
33   BT_SELECTED,
34   BT_SHOW_INFO
35 };
36
37 class Button
38 {
39 public:
40   Button(Surface* image_, std::string info_, SDLKey binding_);
41   Button(const Button& rhs);
42   ~Button();
43
44   Button& operator=(const Button& rhs);
45
46   void draw(DrawingContext& context, bool selected);
47   int event(SDL_Event& event, int x_offset = 0, int y_offset = 0);
48
49   static Font* info_font;
50
51 private:
52   friend class ButtonGroup;
53
54 private:
55   Vector pos;
56   Vector size;
57
58   Surface* image;
59   SDLKey binding;
60
61   int id;
62   int state;
63   std::string info;
64 };
65
66 #endif
67
68 /* EOF */