supertux
src
gui
menu_item.hpp
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
23
class
MenuItem
24
{
25
public
:
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
void
set_font(
const
FontPtr font) { m_font = font; }
38
const
FontPtr& get_font()
const
{
return
m_font; }
39
41
virtual
void
draw
(
DrawingContext
&,
const
Vector& pos,
int
menu_width,
bool
active);
42
43
virtual
void
on_window_resize() {}
44
47
virtual
bool
skippable
()
const
{
48
return
false
;
49
}
50
53
virtual
float
get_distance
()
const
{
return
0.f; }
54
56
virtual
int
get_width
()
const
;
57
59
virtual
int
get_height
()
const
{
return
24; }
60
62
virtual
void
process_action
(
const
MenuAction& action) { }
63
65
virtual
void
event
(
const
SDL_Event& ev) { }
66
67
virtual
Color
get_color()
const
;
68
70
virtual
bool
no_other_action
()
const
{
71
return
false
;
72
}
73
76
virtual
bool
changes_width
()
const
{
77
return
false
;
78
}
79
82
virtual
bool
select_blink
()
const
{
return
true
; }
83
84
private
:
85
int
m_id;
86
std::string m_text;
87
std::string m_help;
88
FontPtr m_font;
89
90
private
:
91
MenuItem
(
const
MenuItem
&) =
delete
;
92
MenuItem
& operator=(
const
MenuItem
&) =
delete
;
93
};
94
95
#endif
96
97
/* EOF */
MenuItem::event
virtual void event(const SDL_Event &ev)
Processes the given event.
Definition:
menu_item.hpp:65
MenuItem::get_width
virtual int get_width() const
Returns the minimum width of the menu item.
Definition:
menu_item.cpp:67
MenuItem::select_blink
virtual bool select_blink() const
Returns true when the item should have a blink effect, provided by the menu, when active...
Definition:
menu_item.hpp:82
MenuItem::process_action
virtual void process_action(const MenuAction &action)
Processes the menu action.
Definition:
menu_item.hpp:62
MenuItem
Definition:
menu_item.hpp:23
MenuItem::get_height
virtual int get_height() const
Returns height of menu item.
Definition:
menu_item.hpp:59
MenuItem::skippable
virtual bool skippable() const
Returns true when the menu item has no action and therefore can be skipped.
Definition:
menu_item.hpp:47
MenuItem::draw
virtual void draw(DrawingContext &, const Vector &pos, int menu_width, bool active)
Draws the menu item.
Definition:
menu_item.cpp:53
MenuItem::get_distance
virtual float get_distance() const
Returns the distance between the items above and below the current menu item.
Definition:
menu_item.hpp:53
Color
Definition:
color.hpp:26
MenuItem::no_other_action
virtual bool no_other_action() const
Returns true when the MenuManager shouldn't do anything else.
Definition:
menu_item.hpp:70
MenuItem::changes_width
virtual bool changes_width() const
Returns true when the width must be recalculated when an action is processed.
Definition:
menu_item.hpp:76
DrawingContext
This class provides functions for drawing things on screen.
Definition:
drawing_context.hpp:42
Generated by
1.8.13