ScummVM API documentation
RadioButtonMenu.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/*
23 * This code is based on the CRAB engine
24 *
25 * Copyright (c) Arvind Raja Yadav
26 *
27 * Licensed under MIT
28 *
29 */
30
31#ifndef CRAB_RADIOBUTTONMENU_H
32#define CRAB_RADIOBUTTONMENU_H
33
34#include "crab/ui/menu.h"
35#include "crab/ui/RadioButton.h"
36
37namespace Crab {
38
39namespace pyrodactyl {
40namespace ui {
41class RadioButtonMenu : public Menu<RadioButton> {
42 // The description of the menu
43 HoverInfo _desc;
44
45 // The selected radio button
46 int _select;
47
48public:
50 _select = 0;
51 }
52
54
55 void load(rapidxml::xml_node<char> *node) {
56 if (nodeValid("desc", node))
57 _desc.load(node->first_node("desc"));
58
59 if (nodeValid("menu", node))
60 Menu::load(node->first_node("menu"));
61 }
62
63 void draw(const int &xOffset = 0, const int &yOffset = 0) {
64 _desc.draw(xOffset, yOffset);
65 Menu::draw(xOffset, yOffset);
66 }
67
68 int handleEvents(const Common::Event &event, const int &xOffset = 0, const int &yOffset = 0) {
69 int result = Menu::handleEvents(event, xOffset, yOffset);
70
71 if (result >= 0) {
72 _select = result;
73
74 for (int i = 0; i < (int)_element.size(); ++i)
75 _element[i]._state = (i == result);
76 }
77
78 return result;
79 }
80
81 void setUI() {
82 Menu::setUI();
83 _desc.setUI();
84 }
85};
86} // End of namespace ui
87} // End of namespace pyrodactyl
88
89} // End of namespace Crab
90
91#endif // CRAB_RADIOBUTTONMENU_H
size_type size() const
Definition: array.h:316
Definition: HoverInfo.h:41
Definition: menu.h:47
Definition: RadioButtonMenu.h:41
Definition: events.h:218