2008-07-03 10:10:29 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GUI_VIRTUAL_KEYBOARD_H
|
|
|
|
#define GUI_VIRTUAL_KEYBOARD_H
|
|
|
|
|
|
|
|
class OSystem;
|
|
|
|
|
2008-07-07 14:30:11 +00:00
|
|
|
#include "common/events.h"
|
2008-07-03 22:38:19 +00:00
|
|
|
#include "common/hashmap.h"
|
|
|
|
#include "common/hash-str.h"
|
2008-07-03 10:10:29 +00:00
|
|
|
#include "common/imagemap.h"
|
2008-07-04 17:55:19 +00:00
|
|
|
#include "common/keyboard.h"
|
2008-07-03 10:10:29 +00:00
|
|
|
#include "common/str.h"
|
|
|
|
#include "graphics/surface.h"
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
2008-07-03 22:38:19 +00:00
|
|
|
class VirtualKeyboardParser;
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-07-04 11:38:15 +00:00
|
|
|
class VirtualKeyboard {
|
2008-07-07 14:30:11 +00:00
|
|
|
|
2008-07-03 22:38:19 +00:00
|
|
|
/** Type of key event */
|
|
|
|
enum EventType {
|
|
|
|
kEventKey,
|
|
|
|
kEventSwitchMode,
|
2008-07-04 17:55:19 +00:00
|
|
|
kEventClose,
|
2008-07-03 22:38:19 +00:00
|
|
|
|
|
|
|
kEventMax
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Event {
|
|
|
|
Common::String name;
|
|
|
|
EventType type;
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef Common::HashMap<Common::String, Event, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> EventMap;
|
|
|
|
|
|
|
|
struct Mode {
|
|
|
|
Common::String name;
|
|
|
|
Common::String resolution;
|
|
|
|
Common::String bitmapName;
|
|
|
|
Graphics::Surface *image;
|
|
|
|
Common::ImageMap imageMap;
|
|
|
|
EventMap events;
|
2008-07-04 17:55:19 +00:00
|
|
|
Mode() : image(0) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef Common::HashMap<Common::String, Mode, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ModeMap;
|
|
|
|
|
|
|
|
enum HorizontalAlignment {
|
|
|
|
kAlignLeft,
|
|
|
|
kAlignCentre,
|
|
|
|
kAlignRight
|
|
|
|
};
|
|
|
|
|
|
|
|
enum VerticalAlignment {
|
|
|
|
kAlignTop,
|
|
|
|
kAlignMiddle,
|
|
|
|
kAlignBottom
|
2008-07-03 22:38:19 +00:00
|
|
|
};
|
2008-07-03 10:10:29 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
VirtualKeyboard();
|
|
|
|
virtual ~VirtualKeyboard();
|
|
|
|
|
2008-07-03 22:38:19 +00:00
|
|
|
bool loadKeyboardPack(Common::String packName);
|
2008-07-03 10:10:29 +00:00
|
|
|
void show();
|
2008-07-07 14:30:11 +00:00
|
|
|
void hide();
|
|
|
|
bool isDisplaying() {
|
|
|
|
return _displaying;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the next virtual key event in the event queue.
|
|
|
|
* @param event point to an Event struct, which will be filled with the event data.
|
|
|
|
* @return true if an event was retrieved.
|
|
|
|
*/
|
|
|
|
bool pollEvent(Common::Event &event);
|
2008-07-03 10:10:29 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
OSystem *_system;
|
2008-07-03 22:38:19 +00:00
|
|
|
|
|
|
|
friend class VirtualKeyboardParser;
|
|
|
|
VirtualKeyboardParser *_parser;
|
2008-07-03 10:10:29 +00:00
|
|
|
|
2008-07-04 17:55:19 +00:00
|
|
|
// TODO : sort order of all this stuff
|
|
|
|
void reset();
|
|
|
|
void reposition();
|
2008-07-07 14:30:11 +00:00
|
|
|
void switchMode(Mode *newMode);
|
2008-07-04 17:55:19 +00:00
|
|
|
void switchMode(const Common::String& newMode);
|
|
|
|
void processClick(int16 x, int16 y);
|
2008-07-03 10:10:29 +00:00
|
|
|
void runLoop();
|
2008-07-07 14:30:11 +00:00
|
|
|
void redraw();
|
2008-07-03 10:10:29 +00:00
|
|
|
|
2008-07-04 17:55:19 +00:00
|
|
|
bool _displaying;
|
2008-07-07 14:30:11 +00:00
|
|
|
bool _needRedraw;
|
2008-07-04 17:55:19 +00:00
|
|
|
|
|
|
|
ModeMap _modes;
|
|
|
|
Mode *_initialMode;
|
|
|
|
Mode *_currentMode;
|
|
|
|
|
|
|
|
Common::Point _pos;
|
|
|
|
HorizontalAlignment _hAlignment;
|
|
|
|
VerticalAlignment _vAlignment;
|
|
|
|
|
2008-07-07 14:30:11 +00:00
|
|
|
Common::Point _mouseDown;
|
|
|
|
|
2008-07-04 17:55:19 +00:00
|
|
|
Common::Array<Common::KeyState> _keyQueue;
|
2008-07-07 14:30:11 +00:00
|
|
|
Common::KeyState *_keyDown;
|
2008-07-04 17:55:19 +00:00
|
|
|
|
2008-07-03 10:10:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // End of namespace GUI
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|