ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
virtual-keyboard-parser.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 #ifndef COMMON_VIRTUAL_KEYBOARD_PARSER_H
23 #define COMMON_VIRTUAL_KEYBOARD_PARSER_H
24 
25 #include "common/scummsys.h"
26 
27 #ifdef ENABLE_VKEYBD
28 
29 #include "common/formats/xmlparser.h"
30 #include "backends/vkeybd/virtual-keyboard.h"
31 
172 namespace Common {
173 
178 class VirtualKeyboardParser : public XMLParser {
179 
180 public:
181 
185  enum ParseMode {
189  kParseFull,
190 
195  kParseCheckResolutions
196  };
197 
198  VirtualKeyboardParser(VirtualKeyboard *kbd);
199  void setParseMode(ParseMode m) {
200  _parseMode = m;
201  }
202 
203 protected:
204  CUSTOM_XML_PARSER(VirtualKeyboardParser) {
205  XML_KEY(keyboard)
206  XML_PROP(initial_mode, true)
207  XML_PROP(v_align, false)
208  XML_PROP(h_align, false)
209  XML_KEY(mode)
210  XML_PROP(name, true)
211  XML_PROP(resolutions, true)
212  XML_KEY(layout)
213  XML_PROP(resolution, true)
214  XML_PROP(bitmap, true)
215  XML_PROP(transparent_color, false)
216  XML_PROP(display_font_color, false)
217  XML_KEY(map)
218  XML_KEY(area)
219  XML_PROP(shape, true)
220  XML_PROP(coords, true)
221  XML_PROP(target, true)
222  KEY_END()
223  KEY_END()
224  KEY_END()
225  XML_KEY(event)
226  XML_PROP(name, true)
227  XML_PROP(type, true)
228  XML_PROP(code, false)
229  XML_PROP(ascii, false)
230  XML_PROP(modifiers, false)
231  XML_PROP(mode, false)
232  KEY_END()
233  KEY_END()
234  KEY_END()
235  } PARSER_END()
236 
237 protected:
238  VirtualKeyboard *_keyboard;
239 
241  ParseMode _parseMode;
242  VirtualKeyboard::Mode *_mode;
243  String _initialModeName;
244  bool _kbdParsed;
245  bool _layoutParsed;
246 
248  virtual void cleanup();
249 
251  bool parserCallback_keyboard(ParserNode *node);
252  bool parserCallback_mode(ParserNode *node);
253  bool parserCallback_event(ParserNode *node);
254  bool parserCallback_layout(ParserNode *node);
255  bool parserCallback_map(ParserNode *node);
256  bool parserCallback_area(ParserNode *node);
257  virtual bool closedKeyCallback(ParserNode *node);
258 
260  byte parseFlags(const String &flags);
261  bool parseRect(Rect &rect, const String &coords);
262  bool parsePolygon(Polygon &poly, const String &coords);
263  bool parseRectAsPolygon(Polygon &poly, const String &coords);
264 };
265 
266 } // End of namespace GUI
267 
268 #endif // #ifdef ENABLE_VKEYBD
269 
270 #endif // #ifndef COMMON_VIRTUAL_KEYBOARD_PARSER_H
Definition: algorithm.h:29