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