90285687cb40b3b6c273bc8a32df4efb48d9f712
[supertux.git] / src / button.h
1 //
2 // C Interface: button
3 //
4 // Description:
5 //
6 //
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12
13 #ifndef SUPERTUX_BUTTON_H
14 #define SUPERTUX_BUTTON_H
15
16 #include "texture.h"
17
18 enum ButtonState {
19   BUTTON_NONE = -1,
20   BUTTON_CLICKED,
21   BUTTON_PRESSED,
22   BUTTON_HOVER
23 };
24
25 typedef struct button_type
26   {
27     texture_type icon;
28     texture_type* bkgd;
29     char *info;
30     SDLKey shortcut;
31     int x;
32     int y;
33     int w;
34     int h;
35     int show_info;
36     ButtonState state;
37     int tag;
38   }
39 button_type;
40
41 void button_load(button_type* pbutton,char* icon_file, char* info, SDLKey shortcut, int x, int y);
42 button_type* button_create(char* icon_file, char* info, SDLKey shortcut, int x, int y);
43 void button_change_icon(button_type* pbutton,char* icon_file);
44 void button_draw(button_type* pbutton);
45 void button_free(button_type* pbutton);
46 void button_event(button_type* pbutton, SDL_Event* event);
47 int  button_get_state(button_type* pbutton);
48
49 typedef struct button_panel_type
50   {
51     int num_items;
52     int hidden;
53     int x,y;
54     int w,h;
55     button_type* item;
56   }
57 button_panel_type;
58
59 void button_panel_init(button_panel_type* pbutton_panel, int x, int y, int w, int h);
60 void button_panel_free(button_panel_type* pbutton_panel);
61 void button_panel_draw(button_panel_type* pbutton_panel);
62 void button_panel_additem(button_panel_type* pbutton_panel, button_type* pbutton, int tag);
63 button_type* button_panel_event(button_panel_type* pbutton_panel, SDL_Event* event);
64
65 #endif /*SUPERTUX_BUTTON_H*/