1// SuperTux
2// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3// 2015 Hume2 <teratux.mail@gmail.com>
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18#ifndef HEADER_SUPERTUX_GUI_MENU_ITEM_HPP
19#define HEADER_SUPERTUX_GUI_MENU_ITEM_HPP
20
21#include "gui/menu.hpp"
22
23class MenuItem
24{
25public:
26 MenuItem(const std::string& text, int id = -1);
27 virtual ~MenuItem();
28
29 int get_id() const { return m_id; }
30
31 void set_help(const std::string& help_text);
32 const std::string& get_help() const { return m_help; }
33
34 void set_text(const std::string& text) { m_text = text; }
35 const std::string& get_text() const { return m_text; }
36
37 /** Draws the menu item. */
38 virtual void draw(DrawingContext&, const Vector& pos, int menu_width, bool active);
39
40 /** Returns true when the menu item has no action and therefore can be skipped.
41 Useful for labels and horizontal lines.*/
42 virtual bool skippable() const {
43 return false;
44 }
45
46 /** Returns the minimum width of the menu item. */
47 virtual int get_width() const;
48
49 /** Processes the menu action. */
50 virtual void process_action(const MenuAction& action) { }
51
52 /** Processes the given event. */
53 virtual void event(const SDL_Event& ev) { }
54
55 virtual Color get_color() const;
56
57 /** Returns true when the MenuManager shouldn't do anything else. */
58 virtual bool no_other_action() const {
59 return false;
60 }
61
62 /** Returns true when the width must be recalculated when an action is
63 processed */
64 virtual bool changes_width() const {
65 return false;
66 }
67
68private:
69 int m_id;
70 std::string m_text;
71 std::string m_help;
72
73private:
74 MenuItem(const MenuItem&) = delete;
75 MenuItem& operator=(const MenuItem&) = delete;
76};
77
78#endif
79
80/* EOF */
81