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

@ -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

@ -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,7 +135,7 @@ 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());
}
@ -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;
@ -372,7 +371,7 @@ void VirtualKeyboardGUI::redraw() {
blit(&surf, &_dispSurface, _dispX - _dirtyRect.left,
_dispY - _dirtyRect.top, _dispBackColor);
}
_system->copyRectToOverlay((OverlayColor*)surf.pixels, surf.w,
_system->copyRectToOverlay((OverlayColor *)surf.pixels, surf.w,
_dirtyRect.left, _dirtyRect.top, surf.w, surf.h);
surf.free();
@ -380,7 +379,7 @@ void VirtualKeyboardGUI::redraw() {
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;

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

@ -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,7 +102,7 @@ protected:
}
};
typedef HashMap<String, VKEvent*> VKEventMap;
typedef HashMap<String, VKEvent *> VKEventMap;
/**
* Mode struct encapsulates all the data for each mode of the keyboard
@ -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);