4 // Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 #ifndef SUPERTUX_BUTTON_H
22 #define SUPERTUX_BUTTON_H
25 #include "screen/texture.h"
42 friend class ButtonPanel;
45 Button(Surface* icon_file, const std::string& info, SDLKey shortcut,
46 int x, int y, int mw = -1, int h = -1);
47 Button(const std::string& icon_name, const std::string& info, SDLKey shortcut,
48 int x, int y, int mw = -1, int h = -1);
51 void event(SDL_Event& event);
52 void draw(DrawingContext& context);
54 void set_active(bool active) { active ? state = BUTTON_NONE : state = BUTTON_DEACTIVE; };
55 void add_icon(const std::string& imagefile, int mw, int mh);
56 SDL_Rect get_pos() { return rect; }
57 int get_tag(){return tag; }
58 // void set_drawable(Drawable* newdrawable)
59 // { drawable = newdrawable; }
62 static Timer popup_timer;
63 // Drawable* drawable;
64 std::vector<Surface*> icon;
76 ButtonPanel(int x, int y, int w, int h);
78 void draw(DrawingContext& context);
79 Button* event(SDL_Event &event);
80 void additem(Button* pbutton, int tag);
81 Button* button_panel_event(SDL_Event& event);
82 void set_button_size(int w, int h);
83 Button* manipulate_button(int i);
84 void highlight_last(bool b);
85 void set_last_clicked(unsigned int last)
86 { if(hlast) { if(item.size() >= last) { last_clicked = item.begin() + last; } } };
93 std::vector<Button*> item;
94 std::vector<Button*>::iterator last_clicked;
97 #endif /*SUPERTUX_BUTTON_H*/