ScummVM API documentation
qd_interface_button.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#ifndef QDENGINE_QDCORE_QD_INTERFACE_BUTTON_H
24#define QDENGINE_QDCORE_QD_INTERFACE_BUTTON_H
25
26#include "qdengine/qdcore/qd_interface_element.h"
27#include "qdengine/qdcore/qd_interface_element_state.h"
28
29
30namespace QDEngine {
31
34public:
38
39 qdInterfaceButton &operator = (const qdInterfaceButton &bt);
40
44 }
45
47 int num_states() const {
48 return _states.size();
49 }
50
52 bool activate_state(int state_num);
54 bool activate_state(const char *state_name);
55
56 int option_value() const {
57 return _cur_state;
58 }
59 bool set_option_value(int value);
60
62 const qdInterfaceElementState *get_state(int state_num) const {
63 assert(state_num >= 0 && state_num < (int)_states.size());
64#ifndef _QD_INTERFACE_BUTTON_PTR_CONTAINER
65 return &_states[state_num];
66#else
67 return &*_states[state_num];
68#endif
69 }
72 assert(state_num >= 0 && state_num < (int)_states.size());
73#ifndef _QD_INTERFACE_BUTTON_PTR_CONTAINER
74 return &_states[state_num];
75#else
76 return &*_states[state_num];
77#endif
78 }
79
81
85
87
91 bool insert_state(int insert_before, const qdInterfaceElementState &st);
92
94 bool erase_state(int state_num);
95
97
100 bool modify_state(int state_num, const qdInterfaceElementState &st) {
101 assert(state_num >= 0 && state_num < (int)_states.size());
102#ifdef _QD_INTERFACE_BUTTON_PTR_CONTAINER
103 *_states[state_num] = st;
104 _states[state_num]->set_owner(this);
105#else
106 _states[state_num] = st;
107 _states[state_num].set_owner(this);
108#endif
109 return true;
110 }
111
113
116 bool change_state(bool direction = true);
117
121 bool keyboard_handler(Common::KeyCode vkey);
122
124
127 bool init(bool is_game_active = true);
128
130 bool quant(float dt);
131
133 bool hit_test(int x, int y) const;
134
135 const qdInterfaceEvent *find_event(qdInterfaceEvent::event_t type) const;
136 bool has_event(qdInterfaceEvent::event_t type, const char *ev_data = NULL) const;
137
138protected:
139
141 bool save_script_body(Common::WriteStream &fh, int indent = 0) const;
144
145private:
146
147#ifdef _QD_INTERFACE_BUTTON_PTR_CONTAINER
149#else
151#endif
152
154 state_container_t _states;
155
157 int _cur_state;
158
159};
160
161} // namespace QDEngine
162
163#endif // QDENGINE_QDCORE_QD_INTERFACE_BUTTON_H
size_type size() const
Definition: array.h:316
Definition: stream.h:77
mouseEvent
События.
Definition: mouse_input.h:41
Интерфейсный элемент - кнопка.
Definition: qd_interface_button.h:33
bool keyboard_handler(Common::KeyCode vkey)
Обработчик ввода с клавиатуры.
bool load_script_body(const xml::tag *p)
Загрузка данных из скрипта.
bool mouse_handler(int x, int y, mouseDispatcher::mouseEvent ev)
Обработчик событий мыши.
int option_value() const
Возвращает значение настройки игры, связанной с элементом.
Definition: qd_interface_button.h:56
bool save_script_body(Common::WriteStream &fh, int indent=0) const
Запись данных в скрипт.
bool erase_state(int state_num)
Удаляет состояние номер state_num.
qdInterfaceElement::element_type get_element_type() const
Возвращает тип элемента.
Definition: qd_interface_button.h:42
bool modify_state(int state_num, const qdInterfaceElementState &st)
Модифицирует состояние кнопки.
Definition: qd_interface_button.h:100
const qdInterfaceElementState * get_state(int state_num) const
Возвращает указатель на состояние кнопки.
Definition: qd_interface_button.h:62
qdInterfaceElementState * get_state(int state_num)
Возвращает указатель на состояние кнопки.
Definition: qd_interface_button.h:71
int num_states() const
Возвращает количество состояний кнопки.
Definition: qd_interface_button.h:47
bool activate_state(int state_num)
Включает состояние номер state_num.
bool quant(float dt)
Обсчет логики, параметр - время в секундах.
bool insert_state(int insert_before, const qdInterfaceElementState &st)
Добавляет состояние кнопки.
bool add_state(const qdInterfaceElementState &st)
Добавляет состояние кнопки.
bool set_option_value(int value)
Устанавливает значение настройки игры, связанной с элементом.
bool activate_state(const char *state_name)
Включает состояние с именем state_name.
bool hit_test(int x, int y) const
Возвращает true, если точка с экранными координатами (x,у) попадает в элемент.
bool init(bool is_game_active=true)
Инициализация элемента.
bool change_state(bool direction=true)
Переключает состояние кнопки.
Базовый класс для элементов GUI.
Definition: qd_interface_element.h:41
element_type
Типы элементов интерфейса.
Definition: qd_interface_element.h:65
@ EL_BUTTON
кнопка
Definition: qd_interface_element.h:69
Состояние элемента интерфейса.
Definition: qd_interface_element_state.h:156
Интерфейсное событие.
Definition: qd_interface_element_state.h:35
event_t
События, производимые элементами интерфейса.
Definition: qd_interface_element_state.h:38
XML тег.
Definition: xml_tag.h:33
Definition: vector.h:39
Базовый класс для игровых ресурсов.
Definition: console.h:28