diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/KeysDialog.cpp | 14 | ||||
-rw-r--r-- | gui/KeysDialog.h | 4 | ||||
-rw-r--r-- | gui/ListWidget.cpp | 18 | ||||
-rw-r--r-- | gui/ListWidget.h | 4 | ||||
-rw-r--r-- | gui/PopUpWidget.cpp | 10 | ||||
-rw-r--r-- | gui/TabWidget.cpp | 4 | ||||
-rw-r--r-- | gui/TabWidget.h | 2 | ||||
-rw-r--r-- | gui/about.cpp | 8 | ||||
-rw-r--r-- | gui/about.h | 4 | ||||
-rw-r--r-- | gui/console.cpp | 22 | ||||
-rw-r--r-- | gui/console.h | 2 | ||||
-rw-r--r-- | gui/dialog.cpp | 16 | ||||
-rw-r--r-- | gui/dialog.h | 4 | ||||
-rw-r--r-- | gui/editable.cpp | 6 | ||||
-rw-r--r-- | gui/editable.h | 2 | ||||
-rw-r--r-- | gui/launcher.cpp | 8 | ||||
-rw-r--r-- | gui/launcher.h | 4 | ||||
-rw-r--r-- | gui/newgui.cpp | 4 | ||||
-rw-r--r-- | gui/widget.h | 5 |
19 files changed, 72 insertions, 69 deletions
diff --git a/gui/KeysDialog.cpp b/gui/KeysDialog.cpp index 33d09e4e69..9586950669 100644 --- a/gui/KeysDialog.cpp +++ b/gui/KeysDialog.cpp @@ -126,23 +126,23 @@ void KeysDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { } } -void KeysDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers){ +void KeysDialog::handleKeyDown(Common::KeyState state){ if (!Actions::Instance()->mappingActive()) - Dialog::handleKeyDown(ascii,keycode,modifiers); + Dialog::handleKeyDown(state); } -void KeysDialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) { +void KeysDialog::handleKeyUp(Common::KeyState state) { #ifdef __SYMBIAN32__ if (Actions::Instance()->mappingActive()) { #else - if (modifiers == 0xff && Actions::Instance()->mappingActive()) { // GAPI key was selected + if (state.flags == 0xff && Actions::Instance()->mappingActive()) { // GAPI key was selected #endif char selection[100]; - Actions::Instance()->setMapping((ActionType)_actionSelected, ascii); + Actions::Instance()->setMapping((ActionType)_actionSelected, state.ascii); if (ascii != 0) - sprintf(selection, "Associated key : %s", SDL_GetKeyName((SDLKey) keycode)); + sprintf(selection, "Associated key : %s", SDL_GetKeyName((SDLKey) state.keycode)); else sprintf(selection, "Associated key : none"); @@ -154,7 +154,7 @@ void KeysDialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) { _actionsList->setEnabled(true); Actions::Instance()->beginMapping(false); } else - Dialog::handleKeyUp(ascii,keycode,modifiers); + Dialog::handleKeyUp(state); } } // namespace GUI diff --git a/gui/KeysDialog.h b/gui/KeysDialog.h index f4fa4d9419..6d780e665a 100644 --- a/gui/KeysDialog.h +++ b/gui/KeysDialog.h @@ -38,8 +38,8 @@ public: KeysDialog(const Common::String &title = "Choose an action to map"); virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); - virtual void handleKeyUp(uint16 ascii, int keycode, int modifiers); - virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers); + virtual void handleKeyUp(Common::KeyState state); + virtual void handleKeyDown(Common::KeyState state); protected: diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 271cbccd94..3d5c3dee62 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -186,12 +186,12 @@ static int matchingCharsIgnoringCase(const char *x, const char *y, bool &stop) { return match; } -bool ListWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { +bool ListWidget::handleKeyDown(Common::KeyState state) { bool handled = true; bool dirty = false; int oldSelectedItem = _selectedItem; - if (!_editMode && isprint((char)ascii)) { + if (!_editMode && isprint((char)state.ascii)) { // Quick selection mode: Go to first list item starting with this key // (or a substring accumulated from the last couple key presses). // Only works in a useful fashion if the list entries are sorted. @@ -199,9 +199,9 @@ bool ListWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { // method "enableQuickSelect()" or so ? uint32 time = getMillis(); if (_quickSelectTime < time) { - _quickSelectStr = (char)ascii; + _quickSelectStr = (char)state.ascii; } else { - _quickSelectStr += (char)ascii; + _quickSelectStr += (char)state.ascii; } _quickSelectTime = time + 300; // TODO: Turn this into a proper constant (kQuickSelectDelay ?) @@ -227,11 +227,11 @@ bool ListWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { scrollToCurrent(); } else if (_editMode) { // Class EditableWidget handles all text editing related key presses for us - handled = EditableWidget::handleKeyDown(ascii, keycode, modifiers); + handled = EditableWidget::handleKeyDown(state); } else { // not editmode - switch (keycode) { + switch (state.keycode) { case Common::KEYCODE_RETURN: case Common::KEYCODE_KP_ENTER: if (_selectedItem >= 0) { @@ -285,14 +285,14 @@ bool ListWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { #if !defined(PALMOS_MODE) // not done on PalmOS because keyboard is emulated and keyup is not generated - _currentKeyDown = keycode; + _currentKeyDown = state.keycode; #endif return handled; } -bool ListWidget::handleKeyUp(uint16 ascii, int keycode, int modifiers) { - if (keycode == _currentKeyDown) +bool ListWidget::handleKeyUp(Common::KeyState state) { + if (state.keycode == _currentKeyDown) _currentKeyDown = 0; return true; } diff --git a/gui/ListWidget.h b/gui/ListWidget.h index a8656061d3..fe3dd4cd7e 100644 --- a/gui/ListWidget.h +++ b/gui/ListWidget.h @@ -92,8 +92,8 @@ public: virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleMouseUp(int x, int y, int button, int clickCount); virtual void handleMouseWheel(int x, int y, int direction); - virtual bool handleKeyDown(uint16 ascii, int keycode, int modifiers); - virtual bool handleKeyUp(uint16 ascii, int keycode, int modifiers); + virtual bool handleKeyDown(Common::KeyState state); + virtual bool handleKeyUp(Common::KeyState state); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual void reflowLayout(); diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp index d40a01c981..ac91376269 100644 --- a/gui/PopUpWidget.cpp +++ b/gui/PopUpWidget.cpp @@ -58,7 +58,7 @@ public: void handleMouseUp(int x, int y, int button, int clickCount); void handleMouseWheel(int x, int y, int direction); // Scroll through entries with scroll wheel void handleMouseMoved(int x, int y, int button); // Redraw selections depending on mouse position - void handleKeyDown(uint16 ascii, int keycode, int modifiers); // Scroll through entries with arrow keys etc. + void handleKeyDown(Common::KeyState state); // Scroll through entries with arrow keys etc. protected: void drawMenuEntry(int entry, bool hilite); @@ -210,8 +210,8 @@ void PopUpDialog::handleMouseMoved(int x, int y, int button) { setSelection(item); } -void PopUpDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { - if (keycode == Common::KEYCODE_ESCAPE) { +void PopUpDialog::handleKeyDown(Common::KeyState state) { + if (state.keycode == Common::KEYCODE_ESCAPE) { // Don't change the previous selection setResult(-1); close(); @@ -221,7 +221,7 @@ void PopUpDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { if (isMouseDown()) return; - switch (keycode) { + switch (state.keycode) { case Common::KEYCODE_RETURN: case Common::KEYCODE_KP_ENTER: setResult(_selection); @@ -239,6 +239,8 @@ void PopUpDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { case Common::KEYCODE_END: setSelection(_popUpBoss->_entries.size()-1); break; + default: + break; } } diff --git a/gui/TabWidget.cpp b/gui/TabWidget.cpp index 38ea6229ec..c414f6bf3b 100644 --- a/gui/TabWidget.cpp +++ b/gui/TabWidget.cpp @@ -198,11 +198,11 @@ void TabWidget::handleMouseDown(int x, int y, int button, int clickCount) { } } -bool TabWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { +bool TabWidget::handleKeyDown(Common::KeyState state) { // TODO: maybe there should be a way to switch between tabs // using the keyboard? E.g. Alt-Shift-Left/Right-Arrow or something // like that. - return Widget::handleKeyDown(ascii, keycode, modifiers); + return Widget::handleKeyDown(state); } void TabWidget::reflowLayout() { diff --git a/gui/TabWidget.h b/gui/TabWidget.h index 928f7916b6..a8c5e07525 100644 --- a/gui/TabWidget.h +++ b/gui/TabWidget.h @@ -87,7 +87,7 @@ public: void setActiveTab(int tabID); virtual void handleMouseDown(int x, int y, int button, int clickCount); - virtual bool handleKeyDown(uint16 ascii, int keycode, int modifiers); + virtual bool handleKeyDown(Common::KeyState state); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual void reflowLayout(); diff --git a/gui/about.cpp b/gui/about.cpp index 31381cadd5..780091f35d 100644 --- a/gui/about.cpp +++ b/gui/about.cpp @@ -302,13 +302,13 @@ void AboutDialog::handleMouseUp(int x, int y, int button, int clickCount) { close(); } -void AboutDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { - if (ascii) +void AboutDialog::handleKeyDown(Common::KeyState state) { + if (state.ascii) _willClose = true; } -void AboutDialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) { - if (ascii && _willClose) +void AboutDialog::handleKeyUp(Common::KeyState state) { + if (state.ascii && _willClose) close(); } diff --git a/gui/about.h b/gui/about.h index a1ee96b090..d62510b1a6 100644 --- a/gui/about.h +++ b/gui/about.h @@ -52,8 +52,8 @@ public: void drawDialog(); void handleTickle(); void handleMouseUp(int x, int y, int button, int clickCount); - void handleKeyDown(uint16 ascii, int keycode, int modifiers); - void handleKeyUp(uint16 ascii, int keycode, int modifiers); + void handleKeyDown(Common::KeyState state); + void handleKeyUp(Common::KeyState state); void reflowLayout(); }; diff --git a/gui/console.cpp b/gui/console.cpp index b7c257d3ce..04a1103628 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -258,13 +258,13 @@ void ConsoleDialog::handleMouseWheel(int x, int y, int direction) { _scrollBar->handleMouseWheel(x, y, direction); } -void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { +void ConsoleDialog::handleKeyDown(Common::KeyState state) { int i; if (_slideMode != kNoSlideMode) return; - switch (keycode) { + switch (state.keycode) { case Common::KEYCODE_RETURN: case Common::KEYCODE_KP_ENTER: { if (_caretVisible) @@ -351,7 +351,7 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { drawLine(pos2line(_currentPos)); break; case Common::KEYCODE_PAGEUP: - if (modifiers == Common::KBD_SHIFT) { + if (state.flags == Common::KBD_SHIFT) { _scrollLine -= _linesPerPage - 1; if (_scrollLine < _firstLineInBuffer + _linesPerPage - 1) _scrollLine = _firstLineInBuffer + _linesPerPage - 1; @@ -360,7 +360,7 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { } break; case Common::KEYCODE_PAGEDOWN: - if (modifiers == Common::KBD_SHIFT) { + if (state.flags == Common::KBD_SHIFT) { _scrollLine += _linesPerPage - 1; if (_scrollLine > _promptEndPos / kCharsPerLine) { _scrollLine = _promptEndPos / kCharsPerLine; @@ -372,7 +372,7 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { } break; case Common::KEYCODE_HOME: - if (modifiers == Common::KBD_SHIFT) { + if (state.flags == Common::KBD_SHIFT) { _scrollLine = _firstLineInBuffer + _linesPerPage - 1; updateScrollBuffer(); } else { @@ -381,7 +381,7 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { draw(); break; case Common::KEYCODE_END: - if (modifiers == Common::KBD_SHIFT) { + if (state.flags == Common::KBD_SHIFT) { _scrollLine = _promptEndPos / kCharsPerLine; if (_scrollLine < _linesPerPage - 1) _scrollLine = _linesPerPage - 1; @@ -408,15 +408,15 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { drawLine(pos2line(_currentPos)); break; default: - if (ascii == '~' || ascii == '#') { + if (state.ascii == '~' || state.ascii == '#') { slideUpAndClose(); - } else if (modifiers == Common::KBD_CTRL) { - specialKeys(keycode); - } else if ((ascii >= 32 && ascii <= 127) || (ascii >= 160 && ascii <= 255)) { + } else if (state.flags == Common::KBD_CTRL) { + specialKeys(state.keycode); + } else if ((state.ascii >= 32 && state.ascii <= 127) || (state.ascii >= 160 && state.ascii <= 255)) { for (i = _promptEndPos - 1; i >= _currentPos; i--) buffer(i + 1) = buffer(i); _promptEndPos++; - putchar((byte)ascii); + putchar((byte)state.ascii); scrollToCurrent(); } } diff --git a/gui/console.h b/gui/console.h index ea28e5b449..c683a1f619 100644 --- a/gui/console.h +++ b/gui/console.h @@ -140,7 +140,7 @@ public: void handleTickle(); void reflowLayout(); void handleMouseWheel(int x, int y, int direction); - void handleKeyDown(uint16 ascii, int keycode, int modifiers); + void handleKeyDown(Common::KeyState state); void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); int printf(const char *format, ...); diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 1afd18ec52..f643e6f988 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -211,18 +211,18 @@ void Dialog::handleMouseWheel(int x, int y, int direction) { w->handleMouseWheel(x, y, direction); } -void Dialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { +void Dialog::handleKeyDown(Common::KeyState state) { if (_focusedWidget) { - if (_focusedWidget->handleKeyDown(ascii, keycode, modifiers)) + if (_focusedWidget->handleKeyDown(state)) return; } // Hotkey handling - if (ascii != 0) { + if (state.ascii != 0) { Widget *w = _firstWidget; - ascii = toupper(ascii); + state.ascii = toupper(state.ascii); while (w) { - if (w->_type == kButtonWidget && ascii == toupper(((ButtonWidget *)w)->_hotkey)) { + if (w->_type == kButtonWidget && state.ascii == toupper(((ButtonWidget *)w)->_hotkey)) { // The hotkey for widget w was pressed. We fake a mouse click into the // button by invoking the appropriate methods. w->handleMouseDown(0, 0, 1, 1); @@ -234,7 +234,7 @@ void Dialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { } // ESC closes all dialogs by default - if (keycode == Common::KEYCODE_ESCAPE) { + if (state.keycode == Common::KEYCODE_ESCAPE) { setResult(-1); close(); } @@ -242,10 +242,10 @@ void Dialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { // TODO: tab/shift-tab should focus the next/previous focusable widget } -void Dialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) { +void Dialog::handleKeyUp(Common::KeyState state) { // Focused widget receives keyup events if (_focusedWidget) - _focusedWidget->handleKeyUp(ascii, keycode, modifiers); + _focusedWidget->handleKeyUp(state); } void Dialog::handleMouseMoved(int x, int y, int button) { diff --git a/gui/dialog.h b/gui/dialog.h index 1c97b4b185..418e3b8e63 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -77,8 +77,8 @@ protected: virtual void handleMouseDown(int x, int y, int button, int clickCount); virtual void handleMouseUp(int x, int y, int button, int clickCount); virtual void handleMouseWheel(int x, int y, int direction); - virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers); - virtual void handleKeyUp(uint16 ascii, int keycode, int modifiers); + virtual void handleKeyDown(Common::KeyState state); + virtual void handleKeyUp(Common::KeyState state); virtual void handleMouseMoved(int x, int y, int button); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); diff --git a/gui/editable.cpp b/gui/editable.cpp index a8638b8b48..1333bf0a9d 100644 --- a/gui/editable.cpp +++ b/gui/editable.cpp @@ -85,7 +85,7 @@ void EditableWidget::handleTickle() { } } -bool EditableWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { +bool EditableWidget::handleKeyDown(Common::KeyState state) { bool handled = true; bool dirty = false; bool forcecaret = false; @@ -94,7 +94,7 @@ bool EditableWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { if (_caretVisible) drawCaret(true); - switch (keycode) { + switch (state.keycode) { case Common::KEYCODE_RETURN: case Common::KEYCODE_KP_ENTER: // confirm edit and exit editmode @@ -143,7 +143,7 @@ bool EditableWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { forcecaret = true; break; default: - if (tryInsertChar((byte)ascii, _caretPos)) { + if (tryInsertChar((byte)state.ascii, _caretPos)) { _caretPos++; dirty = true; forcecaret = true; diff --git a/gui/editable.h b/gui/editable.h index a56b079662..c8ef8a80cb 100644 --- a/gui/editable.h +++ b/gui/editable.h @@ -63,7 +63,7 @@ public: virtual const String &getEditString() const { return _editString; } virtual void handleTickle(); - virtual bool handleKeyDown(uint16 ascii, int keycode, int modifiers); + virtual bool handleKeyDown(Common::KeyState state); virtual void reflowLayout(); diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 1b36ccff76..af35fb46b0 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -789,13 +789,13 @@ void LauncherDialog::editGame(int item) { } } -void LauncherDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { - Dialog::handleKeyDown(ascii, keycode, modifiers); +void LauncherDialog::handleKeyDown(Common::KeyState state) { + Dialog::handleKeyDown(state); updateButtons(); } -void LauncherDialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) { - Dialog::handleKeyUp(ascii, keycode, modifiers); +void LauncherDialog::handleKeyUp(Common::KeyState state) { + Dialog::handleKeyUp(state); updateButtons(); } diff --git a/gui/launcher.h b/gui/launcher.h index 5ccf9cb422..164a7e0707 100644 --- a/gui/launcher.h +++ b/gui/launcher.h @@ -47,8 +47,8 @@ public: virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); - virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers); - virtual void handleKeyUp(uint16 ascii, int keycode, int modifiers); + virtual void handleKeyDown(Common::KeyState state); + virtual void handleKeyUp(Common::KeyState state); protected: ListWidget *_list; diff --git a/gui/newgui.cpp b/gui/newgui.cpp index ad1933863a..51d67b8769 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -272,10 +272,10 @@ void NewGui::runLoop() { switch (event.type) { case Common::EVENT_KEYDOWN: - activeDialog->handleKeyDown(event.kbd.ascii, event.kbd.keycode, event.kbd.flags); + activeDialog->handleKeyDown(event.kbd); break; case Common::EVENT_KEYUP: - activeDialog->handleKeyUp(event.kbd.ascii, event.kbd.keycode, event.kbd.flags); + activeDialog->handleKeyUp(event.kbd); break; case Common::EVENT_MOUSEMOVE: activeDialog->handleMouseMoved(mouse.x, mouse.y, 0); diff --git a/gui/widget.h b/gui/widget.h index bf15081f79..c19059d32c 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -27,6 +27,7 @@ #include "common/scummsys.h" #include "common/str.h" +#include "common/keyboard.h" #include "graphics/font.h" #include "graphics/surface.h" #include "gui/object.h" @@ -127,8 +128,8 @@ public: virtual void handleMouseLeft(int button) {} virtual void handleMouseMoved(int x, int y, int button) {} virtual void handleMouseWheel(int x, int y, int direction) {} - virtual bool handleKeyDown(uint16 ascii, int keycode, int modifiers) { return false; } // Return true if the event was handled - virtual bool handleKeyUp(uint16 ascii, int keycode, int modifiers) { return false; } // Return true if the event was handled + virtual bool handleKeyDown(Common::KeyState state) { return false; } // Return true if the event was handled + virtual bool handleKeyUp(Common::KeyState state) { return false; } // Return true if the event was handled virtual void handleTickle() {} virtual void reflowLayout() { GuiObject::reflowLayout(); } |