VKEYBD: Some formatting fixes.

This commit is contained in:
Johannes Schickel 2012-01-03 01:25:16 +01:00
parent b3e44e05a3
commit c98a123f4c
10 changed files with 76 additions and 76 deletions

View File

@ -35,7 +35,7 @@ ImageMap::~ImageMap() {
removeAllAreas();
}
Polygon *ImageMap::createArea(const String& id) {
Polygon *ImageMap::createArea(const String &id) {
if (_areas.contains(id)) {
warning("Image map already contains an area with target of '%s'", id.c_str());
return 0;
@ -45,7 +45,7 @@ Polygon *ImageMap::createArea(const String& id) {
return p;
}
void ImageMap::removeArea(const String& id) {
void ImageMap::removeArea(const String &id) {
if (!_areas.contains(id))
return;
delete _areas[id];
@ -53,7 +53,7 @@ void ImageMap::removeArea(const String& id) {
}
void ImageMap::removeAllAreas() {
HashMap<String, Polygon*>::iterator it;
HashMap<String, Polygon *>::iterator it;
for (it = _areas.begin(); it != _areas.end(); ++it) {
delete it->_value;
}
@ -61,7 +61,7 @@ void ImageMap::removeAllAreas() {
}
String ImageMap::findMapArea(int16 x, int16 y) {
HashMap<String, Polygon*>::iterator it;
HashMap<String, Polygon *>::iterator it;
for (it = _areas.begin(); it != _areas.end(); ++it) {
if (it->_value->contains(x, y))
return it->_key;

View File

@ -40,8 +40,8 @@ public:
~ImageMap();
Polygon *createArea(const String& id);
void removeArea(const String& id);
Polygon *createArea(const String &id);
void removeArea(const String &id);
void removeAllAreas();
String findMapArea(int16 x, int16 y);

View File

@ -42,7 +42,7 @@ bool Polygon::contains(int16 x, int16 y) const {
yflag1 = (vtx1->y >= y);
if (yflag0 != yflag1) {
if (((vtx1->y - y) * (vtx0->x - vtx1->x) >=
(vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
(vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) {
inside_flag = !inside_flag;
}
}

View File

@ -46,13 +46,13 @@ struct Polygon {
}
}
void addPoint(const Point& p) {
void addPoint(const Point &p) {
_points.push_back(p);
_bound.extend(Rect(p.x, p.y, p.x, p.y));
}
void addPoint(int16 x, int16 y) {
addPoint(Point(x,y));
addPoint(Point(x, y));
}
uint getPointCount() {

View File

@ -75,8 +75,8 @@ static void blit(Graphics::Surface *surf_dst, Graphics::Surface *surf_src, int16
VirtualKeyboardGUI::VirtualKeyboardGUI(VirtualKeyboard *kbd)
: _kbd(kbd), _displaying(false), _drag(false),
_drawCaret(false), _displayEnabled(false), _firstRun(true),
_cursorAnimateTimer(0), _cursorAnimateCounter(0) {
_drawCaret(false), _displayEnabled(false), _firstRun(true),
_cursorAnimateTimer(0), _cursorAnimateCounter(0) {
assert(_kbd);
assert(g_system);
@ -111,7 +111,7 @@ void VirtualKeyboardGUI::initMode(VirtualKeyboard::Mode *mode) {
}
}
void VirtualKeyboardGUI::setupDisplayArea(Rect& r, OverlayColor forecolor) {
void VirtualKeyboardGUI::setupDisplayArea(Rect &r, OverlayColor forecolor) {
_dispFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
if (!fontIsSuitable(_dispFont, r)) {
@ -135,9 +135,9 @@ void VirtualKeyboardGUI::setupDisplayArea(Rect& r, OverlayColor forecolor) {
_displayEnabled = true;
}
bool VirtualKeyboardGUI::fontIsSuitable(const Graphics::Font *font, const Rect& rect) {
bool VirtualKeyboardGUI::fontIsSuitable(const Graphics::Font *font, const Rect &rect) {
return (font->getMaxCharWidth() < rect.width() &&
font->getFontHeight() < rect.height());
font->getFontHeight() < rect.height());
}
void VirtualKeyboardGUI::checkScreenChanged() {
@ -161,7 +161,7 @@ void VirtualKeyboardGUI::run() {
_system->clearOverlay();
}
_overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat());
_system->grabOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w);
_system->grabOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w);
setupCursor();
@ -171,7 +171,7 @@ void VirtualKeyboardGUI::run() {
removeCursor();
_system->copyRectToOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w, 0, 0, _overlayBackup.w, _overlayBackup.h);
_system->copyRectToOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w, 0, 0, _overlayBackup.w, _overlayBackup.h);
if (!g_gui.isActive()) _system->hideOverlay();
_overlayBackup.free();
@ -183,16 +183,15 @@ void VirtualKeyboardGUI::close() {
}
void VirtualKeyboardGUI::reset() {
_kbdBound.left = _kbdBound.top
= _kbdBound.right = _kbdBound.bottom = 0;
_kbdBound.left = _kbdBound.top = 0;
_kbdBound.right = _kbdBound.bottom = 0;
_displaying = _drag = false;
_firstRun = true;
_lastScreenChanged = _system->getScreenChangeID();
_kbdSurface = 0;
}
void VirtualKeyboardGUI::moveToDefaultPosition()
{
void VirtualKeyboardGUI::moveToDefaultPosition() {
int16 kbdW = _kbdBound.width(), kbdH = _kbdBound.height();
int16 x = 0, y = 0;
if (_screenW != kbdW) {
@ -263,7 +262,7 @@ void VirtualKeyboardGUI::screenChanged() {
_screenH = newScreenH;
_overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat());
_system->grabOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w);
_system->grabOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w);
if (!_kbd->checkModeResolutions()) {
_displaying = false;
@ -290,19 +289,19 @@ void VirtualKeyboardGUI::mainLoop() {
case Common::EVENT_LBUTTONDOWN:
if (_kbdBound.contains(event.mouse)) {
_kbd->handleMouseDown(event.mouse.x - _kbdBound.left,
event.mouse.y - _kbdBound.top);
event.mouse.y - _kbdBound.top);
}
break;
case Common::EVENT_LBUTTONUP:
if (_kbdBound.contains(event.mouse)) {
_kbd->handleMouseUp(event.mouse.x - _kbdBound.left,
event.mouse.y - _kbdBound.top);
event.mouse.y - _kbdBound.top);
}
break;
case Common::EVENT_MOUSEMOVE:
if (_drag)
move(event.mouse.x - _dragPoint.x,
event.mouse.y - _dragPoint.y);
event.mouse.y - _dragPoint.y);
break;
case Common::EVENT_SCREEN_CHANGED:
screenChanged();
@ -367,20 +366,20 @@ void VirtualKeyboardGUI::redraw() {
}
blit(&surf, _kbdSurface, _kbdBound.left - _dirtyRect.left,
_kbdBound.top - _dirtyRect.top, _kbdTransparentColor);
_kbdBound.top - _dirtyRect.top, _kbdTransparentColor);
if (_displayEnabled) {
blit(&surf, &_dispSurface, _dispX - _dirtyRect.left,
_dispY - _dirtyRect.top, _dispBackColor);
_dispY - _dirtyRect.top, _dispBackColor);
}
_system->copyRectToOverlay((OverlayColor*)surf.pixels, surf.w,
_dirtyRect.left, _dirtyRect.top, surf.w, surf.h);
_system->copyRectToOverlay((OverlayColor *)surf.pixels, surf.w,
_dirtyRect.left, _dirtyRect.top, surf.w, surf.h);
surf.free();
resetDirtyRect();
}
uint VirtualKeyboardGUI::calculateEndIndex(const String& str, uint startIndex) {
uint VirtualKeyboardGUI::calculateEndIndex(const String &str, uint startIndex) {
int16 w = 0;
while (w <= _dispSurface.w && startIndex < str.size()) {
w += _dispFont->getCharWidth(str[startIndex++]);

View File

@ -121,7 +121,7 @@ private:
bool _displaying;
bool _firstRun;
void setupDisplayArea(Rect& r, OverlayColor forecolor);
void setupDisplayArea(Rect &r, OverlayColor forecolor);
void move(int16 x, int16 y);
void moveToDefaultPosition();
void screenChanged();
@ -131,8 +131,8 @@ private:
void redraw();
void forceRedraw();
void updateDisplay();
bool fontIsSuitable(const Graphics::Font *font, const Rect& rect);
uint calculateEndIndex(const String& str, uint startIndex);
bool fontIsSuitable(const Graphics::Font *font, const Rect &rect);
uint calculateEndIndex(const String &str, uint startIndex);
bool _drawCaret;
int16 _caretX;
@ -141,7 +141,7 @@ private:
static const int kCursorAnimateDelay = 250;
int _cursorAnimateCounter;
int _cursorAnimateTimer;
int _cursorAnimateTimer;
byte _cursor[2048];
void setupCursor();
void removeCursor();

View File

@ -116,7 +116,7 @@ bool VirtualKeyboardParser::parserCallback_mode(ParserNode *node) {
_keyboard->_initialMode = _mode;
String resolutions = node->values["resolutions"];
StringTokenizer tok (resolutions, " ,");
StringTokenizer tok(resolutions, " ,");
// select best resolution simply by minimising the difference between the
// overlay size and the resolution dimensions.
@ -189,7 +189,7 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) {
}
evt->type = VirtualKeyboard::kVKEventKey;
KeyState *ks = (KeyState*) malloc(sizeof(KeyState));
KeyState *ks = (KeyState *)malloc(sizeof(KeyState));
ks->keycode = (KeyCode)atoi(node->values["code"].c_str());
ks->ascii = atoi(node->values["ascii"].c_str());
ks->flags = 0;
@ -204,7 +204,7 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) {
}
evt->type = VirtualKeyboard::kVKEventModifier;
byte *flags = (byte*) malloc(sizeof(byte));
byte *flags = (byte *)malloc(sizeof(byte));
if (!flags)
error("[VirtualKeyboardParser::parserCallback_event] Cannot allocate memory");
@ -218,8 +218,8 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) {
}
evt->type = VirtualKeyboard::kVKEventSwitchMode;
String& mode = node->values["mode"];
char *str = (char*) malloc(sizeof(char) * mode.size() + 1);
String &mode = node->values["mode"];
char *str = (char *)malloc(sizeof(char) * mode.size() + 1);
if (!str)
error("[VirtualKeyboardParser::parserCallback_event] Cannot allocate memory");
@ -302,9 +302,9 @@ bool VirtualKeyboardParser::parserCallback_map(ParserNode *node) {
}
bool VirtualKeyboardParser::parserCallback_area(ParserNode *node) {
String& shape = node->values["shape"];
String& target = node->values["target"];
String& coords = node->values["coords"];
String &shape = node->values["shape"];
String &target = node->values["target"];
String &coords = node->values["coords"];
if (target.equalsIgnoreCase("display_area")) {
if (!shape.equalsIgnoreCase("rect"))
@ -321,7 +321,7 @@ bool VirtualKeyboardParser::parserCallback_area(ParserNode *node) {
return parserError("Area shape '" + shape + "' not known");
}
byte VirtualKeyboardParser::parseFlags(const String& flags) {
byte VirtualKeyboardParser::parseFlags(const String &flags) {
if (flags.empty())
return 0;
@ -338,7 +338,7 @@ byte VirtualKeyboardParser::parseFlags(const String& flags) {
return val;
}
bool VirtualKeyboardParser::parseRect(Rect &rect, const String& coords) {
bool VirtualKeyboardParser::parseRect(Rect &rect, const String &coords) {
int x1, y1, x2, y2;
if (!parseIntegerKey(coords, 4, &x1, &y1, &x2, &y2))
return parserError("Invalid coords for rect area");
@ -351,7 +351,7 @@ bool VirtualKeyboardParser::parseRect(Rect &rect, const String& coords) {
return true;
}
bool VirtualKeyboardParser::parsePolygon(Polygon &poly, const String& coords) {
bool VirtualKeyboardParser::parsePolygon(Polygon &poly, const String &coords) {
StringTokenizer tok(coords, ", ");
for (String st = tok.nextToken(); !st.empty(); st = tok.nextToken()) {
int x, y;
@ -368,7 +368,7 @@ bool VirtualKeyboardParser::parsePolygon(Polygon &poly, const String& coords) {
return true;
}
bool VirtualKeyboardParser::parseRectAsPolygon(Polygon &poly, const String& coords) {
bool VirtualKeyboardParser::parseRectAsPolygon(Polygon &poly, const String &coords) {
Rect rect;
if (!parseRect(rect, coords))
return false;

View File

@ -56,31 +56,31 @@ keyboard layouts for different screen resolutions.
<area shape="poly" coords="65,50,67,48,94,48,96,50,96,77,94,79,67,79,65,77" target="q" />
<area shape="poly" coords="105,50,107,48,134,48,136,50,136,77,134,79,107,79,105,77" target="w" />
<area shape="poly" coords="146,50,148,48,174,48,176,50,176,77,174,79,148,79,146,77" target="e" />
...
...
<area shape="poly" coords="11,89,12,88,69,88,70,89,70,116,69,117,12,117,11,116" target="caps" />
</map>
</layout>
<layout resolution="320x200" bitmap="normal_320x200.bmp" transparent_color="255,0,255">
...
</layout>
</layout>
<layout resolution="320x200" bitmap="normal_320x200.bmp" transparent_color="255,0,255">
...
</layout>
<event name="a" type="key" code="97" ascii="97" modifiers="" />
<event name="b" type="key" code="98" ascii="98" modifiers="" />
<event name="c" type="key" code="99" ascii="99" modifiers="" />
...
<event name="caps" type="switch_mode" mode="caps" />
...
<event name="caps" type="switch_mode" mode="caps" />
</mode>
<mode name="caps" resolutions="640x400">
<layout resolution="640x400" bitmap="caps_640x480.bmp" transparent_color="255,0,255">
<map>
<area shape="poly" coords="65,50,67,48,94,48,96,50,96,77,94,79,67,79,65,77" target="Q" />
...
...
</map>
</layout>
<event name="A" type="key" code="97" ascii="65" modifiers="shift" />
<event name="B" type="key" code="98" ascii="66" modifiers="shift" />
<event name="C" type="key" code="99" ascii="67" modifiers="shift" />
...
...
</mode>
</keyboard>
@ -188,6 +188,7 @@ public:
* Full parse - when loading keyboard pack for first time
*/
kParseFull,
/**
* Just check resolutions and reload layouts if needed - following a
* change in screen size
@ -257,10 +258,10 @@ protected:
virtual bool closedKeyCallback(ParserNode *node);
/** Parse helper functions */
byte parseFlags(const String& flags);
bool parseRect(Rect &rect, const String& coords);
bool parsePolygon(Polygon &poly, const String& coords);
bool parseRectAsPolygon(Polygon &poly, const String& coords);
byte parseFlags(const String &flags);
bool parseRect(Rect &rect, const String &coords);
bool parsePolygon(Polygon &poly, const String &coords);
bool parseRectAsPolygon(Polygon &poly, const String &coords);
};
} // End of namespace GUI

View File

@ -160,7 +160,7 @@ String VirtualKeyboard::findArea(int16 x, int16 y) {
return _currentMode->imageMap.findMapArea(x, y);
}
void VirtualKeyboard::processAreaClick(const String& area) {
void VirtualKeyboard::processAreaClick(const String &area) {
if (!_currentMode->events.contains(area))
return;
@ -169,10 +169,10 @@ void VirtualKeyboard::processAreaClick(const String& area) {
switch (evt->type) {
case kVKEventKey:
// add virtual keypress to queue
_keyQueue.insertKey(*(KeyState*)evt->data);
_keyQueue.insertKey(*(KeyState *)evt->data);
break;
case kVKEventModifier:
_keyQueue.toggleFlags(*(byte*)(evt->data));
_keyQueue.toggleFlags(*(byte *)(evt->data));
break;
case kVKEventSwitchMode:
// switch to new mode

View File

@ -102,21 +102,21 @@ protected:
}
};
typedef HashMap<String, VKEvent*> VKEventMap;
typedef HashMap<String, VKEvent *> VKEventMap;
/**
* Mode struct encapsulates all the data for each mode of the keyboard
*/
struct Mode {
String name;
String resolution;
String bitmapName;
Graphics::Surface *image;
OverlayColor transparentColor;
ImageMap imageMap;
VKEventMap events;
Rect displayArea;
OverlayColor displayFontColor;
String name;
String resolution;
String bitmapName;
Graphics::Surface *image;
OverlayColor transparentColor;
ImageMap imageMap;
VKEventMap events;
Rect displayArea;
OverlayColor displayFontColor;
Mode() : image(0) {}
~Mode() {
@ -193,7 +193,7 @@ public:
* The system first looks for an uncompressed keyboard pack by searching
* for packName.xml in the filesystem, if this does not exist then it
* searches for a compressed keyboard pack by looking for packName.zip.
* @param packName name of the keyboard pack
* @param packName name of the keyboard pack
*/
bool loadKeyboardPack(const String &packName);
@ -206,8 +206,8 @@ public:
/**
* Hides the keyboard, ending the event loop.
* @param submit if true all accumulated key presses are submitted to
* the event manager
* @param submit if true all accumulated key presses are submitted to
* the event manager
*/
void close(bool submit);
@ -229,7 +229,7 @@ protected:
Archive *_fileArchive;
friend class VirtualKeyboardGUI;
VirtualKeyboardGUI *_kbdGUI;
VirtualKeyboardGUI *_kbdGUI;
KeyPressQueue _keyQueue;
@ -241,7 +241,7 @@ protected:
void deleteEvents();
bool checkModeResolutions();
void switchMode(Mode *newMode);
void switchMode(const String& newMode);
void switchMode(const String &newMode);
void handleMouseDown(int16 x, int16 y);
void handleMouseUp(int16 x, int16 y);
String findArea(int16 x, int16 y);