Include optimizations
[supertux.git] / src / gui / menu_item.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_MENU_ITEM_HPP
18 #define HEADER_SUPERTUX_GUI_MENU_ITEM_HPP
19
20 #include <list>
21 #include <memory>
22 #include <SDL.h>
23
24 #include "gui/menu.hpp"
25
26 /* Kinds of menu items */
27 enum MenuItemKind {
28   MN_ACTION,
29   MN_GOTO,
30   MN_TOGGLE,
31   MN_BACK,
32   MN_INACTIVE,
33   MN_TEXTFIELD,
34   MN_NUMFIELD,
35   MN_CONTROLFIELD,
36   MN_STRINGSELECT,
37   MN_LABEL,
38   MN_HL /* horizontal line */
39 };
40
41 class MenuItem
42 {
43 public:
44   MenuItem(MenuItemKind kind, int id = -1);
45
46   void set_help(const std::string& help_text);
47
48   void change_text (const std::string& text);
49   void change_input(const std::string& text);
50
51   static MenuItem* create(MenuItemKind kind, const std::string& text,
52                           int init_toggle, Menu* target_menu, int id, int key);
53
54   std::string get_input_with_symbol(bool active_item);   // returns the text with an input symbol
55
56 public:
57   MenuItemKind kind;
58   int id;   // item id
59   bool toggled;
60   std::string text;
61   std::string input;
62   std::string help;
63
64   std::vector<std::string> list; // list of values for a STRINGSELECT item
65   size_t selected; // currently selected item
66
67   Menu* target_menu;
68
69 private:
70   /// keyboard key or joystick button
71   bool input_flickering;
72
73 private:
74   MenuItem(const MenuItem&);
75   MenuItem& operator=(const MenuItem&);
76 };
77
78 #endif
79
80 /* EOF */