diff options
author | Torbjörn Andersson | 2003-09-24 06:33:59 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2003-09-24 06:33:59 +0000 |
commit | 570e60a48797efa08ae5a6c7102f16678704bae8 (patch) | |
tree | f7fe3554f78b9c5e70ba4391eeedb69a5f0911ea /gui | |
parent | 3854ce8f3d060f5bb4c1e248d846f73a7fe2942c (diff) | |
download | scummvm-rg350-570e60a48797efa08ae5a6c7102f16678704bae8.tar.gz scummvm-rg350-570e60a48797efa08ae5a6c7102f16678704bae8.tar.bz2 scummvm-rg350-570e60a48797efa08ae5a6c7102f16678704bae8.zip |
Whitespace changes
svn-id: r10390
Diffstat (limited to 'gui')
-rw-r--r-- | gui/EditTextWidget.cpp | 100 | ||||
-rw-r--r-- | gui/PopUpWidget.cpp | 34 | ||||
-rw-r--r-- | gui/console.cpp | 285 | ||||
-rw-r--r-- | gui/newgui.cpp | 104 |
4 files changed, 260 insertions, 263 deletions
diff --git a/gui/EditTextWidget.cpp b/gui/EditTextWidget.cpp index 17a4abc3f6..82eb2b4c22 100644 --- a/gui/EditTextWidget.cpp +++ b/gui/EditTextWidget.cpp @@ -82,59 +82,59 @@ bool EditTextWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { drawCaret(true); switch (keycode) { - case '\n': // enter/return - case '\r': - _boss->releaseFocus(); - dirty = true; - break; - case 27: // escape - _label = _backupString; - _pos = _label.size() - 1; - _labelOffset = (_boss->getGui()->getStringWidth(_label) - (_w-6)); - if (_labelOffset < 0) - _labelOffset = 0; - _boss->releaseFocus(); - dirty = true; - break; - case 8: // backspace - if (_pos > 0) { - _pos--; - _label.deleteChar(_pos); - } - dirty = true; - break; - case 127: // delete + case '\n': // enter/return + case '\r': + _boss->releaseFocus(); + dirty = true; + break; + case 27: // escape + _label = _backupString; + _pos = _label.size() - 1; + _labelOffset = (_boss->getGui()->getStringWidth(_label) - (_w-6)); + if (_labelOffset < 0) + _labelOffset = 0; + _boss->releaseFocus(); + dirty = true; + break; + case 8: // backspace + if (_pos > 0) { + _pos--; _label.deleteChar(_pos); - dirty = true; - break; - case 256 + 20: // left arrow - if (_pos > 0) { - _pos--; - dirty = adjustOffset(); - } - break; - case 256 + 19: // right arrow - if (_pos < _label.size()) { - _pos++; - dirty = adjustOffset(); - } - break; - case 256 + 22: // home - _pos = 0; + } + dirty = true; + break; + case 127: // delete + _label.deleteChar(_pos); + dirty = true; + break; + case 256 + 20: // left arrow + if (_pos > 0) { + _pos--; dirty = adjustOffset(); - break; - case 256 + 23: // end - _pos = _label.size(); + } + break; + case 256 + 19: // right arrow + if (_pos < _label.size()) { + _pos++; dirty = adjustOffset(); - break; - default: - if (isprint((char)ascii)) { - _label.insertChar((char)ascii, _pos++); - //_label += (char)ascii; - dirty = true; - } else { - handled = false; - } + } + break; + case 256 + 22: // home + _pos = 0; + dirty = adjustOffset(); + break; + case 256 + 23: // end + _pos = _label.size(); + dirty = adjustOffset(); + break; + default: + if (isprint((char)ascii)) { + _label.insertChar((char)ascii, _pos++); + //_label += (char)ascii; + dirty = true; + } else { + handled = false; + } } if (dirty) diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp index 06c0b7fdb0..ab08fc551c 100644 --- a/gui/PopUpWidget.cpp +++ b/gui/PopUpWidget.cpp @@ -167,23 +167,23 @@ void PopUpDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { return; switch (keycode) { - case '\n': // enter/return - case '\r': - setResult(_selection); - close(); - break; - case 256+17: // up arrow - moveUp(); - break; - case 256+18: // down arrow - moveDown(); - break; - case 256+22: // home - setSelection(0); - break; - case 256+23: // end - setSelection(_popUpBoss->_entries.size()-1); - break; + case '\n': // enter/return + case '\r': + setResult(_selection); + close(); + break; + case 256+17: // up arrow + moveUp(); + break; + case 256+18: // down arrow + moveDown(); + break; + case 256+22: // home + setSelection(0); + break; + case 256+23: // end + setSelection(_popUpBoss->_entries.size()-1); + break; } } diff --git a/gui/console.cpp b/gui/console.cpp index a35903a189..815f6f5c1c 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -141,146 +141,143 @@ void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { int i; switch (keycode) { - case '\n': // enter/return - case '\r': { - if (_caretVisible) - drawCaret(true); + case '\n': // enter/return + case '\r': { + if (_caretVisible) + drawCaret(true); - nextLine(); + nextLine(); - int len = _promptEndPos - _promptStartPos; - bool keepRunning = true; + int len = _promptEndPos - _promptStartPos; + bool keepRunning = true; - // FIXME - len should NEVER be negative. If anything makes it negative, - // then the code doing that is buggy and needs to be fixed. - assert(len >= 0); + // FIXME - len should NEVER be negative. If anything makes it negative, + // then the code doing that is buggy and needs to be fixed. + assert(len >= 0); - if (len > 0) { + if (len > 0) { - // We have to allocate the string buffer with new, since VC++ sadly does not - // comply to the C++ standard, so we can't use a dynamic sized stack array. - char *str = new char[len + 1]; + // We have to allocate the string buffer with new, since VC++ sadly does not + // comply to the C++ standard, so we can't use a dynamic sized stack array. + char *str = new char[len + 1]; - // Copy the user input to str - for (i = 0; i < len; i++) - str[i] = _buffer[(_promptStartPos + i) % kBufferSize]; - str[len] = '\0'; + // Copy the user input to str + for (i = 0; i < len; i++) + str[i] = _buffer[(_promptStartPos + i) % kBufferSize]; + str[len] = '\0'; - // Add the input to the history - addToHistory(str); + // Add the input to the history + addToHistory(str); - // Pass it to the input callback, if any - if (_callbackProc) - keepRunning = (*_callbackProc)(this, str, _callbackRefCon); + // Pass it to the input callback, if any + if (_callbackProc) + keepRunning = (*_callbackProc)(this, str, _callbackRefCon); - // Get rid of the string buffer - delete [] str; - } + // Get rid of the string buffer + delete [] str; + } - print(PROMPT); - _promptStartPos = _promptEndPos = _currentPos; + print(PROMPT); + _promptStartPos = _promptEndPos = _currentPos; - draw(); - if (!keepRunning) - close(); - break; - } - case 27: // escape + draw(); + if (!keepRunning) close(); - break; - case 8: // backspace - if (_caretVisible) - drawCaret(true); - - if (_currentPos > _promptStartPos) { - _currentPos--; - killChar(); - } - scrollToCurrent(); - draw(); // FIXME - not nice to redraw the full console just for one char! - break; - case 9: // tab - { - if (_completionCallbackProc) { - int len = _currentPos - _promptStartPos; - assert(len >= 0); - char *str = new char[len + 1]; + break; + } + case 27: // escape + close(); + break; + case 8: // backspace + if (_caretVisible) + drawCaret(true); + + if (_currentPos > _promptStartPos) { + _currentPos--; + killChar(); + } + scrollToCurrent(); + draw(); // FIXME - not nice to redraw the full console just for one char! + break; + case 9: // tab + { + if (_completionCallbackProc) { + int len = _currentPos - _promptStartPos; + assert(len >= 0); + char *str = new char[len + 1]; - // Copy the user input to str - for (i = 0; i < len; i++) - str[i] = _buffer[(_promptStartPos + i) % kBufferSize]; - str[len] = '\0'; - - char *completion = 0; - if ((*_completionCallbackProc)(this, str, completion, - _callbackRefCon)) - { - if (_caretVisible) - drawCaret(true); - insertIntoPrompt(completion); - scrollToCurrent(); - draw(); - delete[] completion; - } - delete[] str; + // Copy the user input to str + for (i = 0; i < len; i++) + str[i] = _buffer[(_promptStartPos + i) % kBufferSize]; + str[len] = '\0'; + + char *completion = 0; + if ((*_completionCallbackProc)(this, str, completion, _callbackRefCon)) { + if (_caretVisible) + drawCaret(true); + insertIntoPrompt(completion); + scrollToCurrent(); + draw(); + delete[] completion; } - break; + delete[] str; } - case 127: - killChar(); - draw(); - break; + break; + } + case 127: + killChar(); + draw(); + break; /* - case 256 + 24: // pageup - _selectedItem -= _entriesPerPage - 1; - if (_selectedItem < 0) - _selectedItem = 0; - break; - case 256 + 25: // pagedown - _selectedItem += _entriesPerPage - 1; - if (_selectedItem >= _list.size() ) - _selectedItem = _list.size() - 1; - break; + case 256 + 24: // pageup + _selectedItem -= _entriesPerPage - 1; + if (_selectedItem < 0) + _selectedItem = 0; + break; + case 256 + 25: // pagedown + _selectedItem += _entriesPerPage - 1; + if (_selectedItem >= _list.size() ) + _selectedItem = _list.size() - 1; + break; */ - case 256 + 22: // home - _scrollLine = _linesPerPage - 1; // FIXME - this is not correct after a wrap around - updateScrollBar(); - draw(); - break; - case 256 + 23: // end - _scrollLine = _currentPos / _lineWidth; - updateScrollBar(); - draw(); - break; - case 273: // cursor up - historyScroll(+1); - break; - case 274: // cursor down - historyScroll(-1); - break; - case 275: // cursor right - if (_currentPos < _promptEndPos) - _currentPos++; - draw(); - break; - case 276: // cursor left - if (_currentPos > _promptStartPos) - _currentPos--; - draw(); - break; - - default: - if (ascii == '~' || ascii == '#') { - close(); - } else if (modifiers == OSystem::KBD_CTRL) { - specialKeys(keycode); - } else if (isprint((char)ascii)) { - for (i = _promptEndPos-1; i >= _currentPos; i--) - _buffer[(i + 1) % kBufferSize] = _buffer[i % kBufferSize]; - _promptEndPos++; - putchar((char)ascii); - scrollToCurrent(); - } + case 256 + 22: // home + _scrollLine = _linesPerPage - 1; // FIXME - this is not correct after a wrap around + updateScrollBar(); + draw(); + break; + case 256 + 23: // end + _scrollLine = _currentPos / _lineWidth; + updateScrollBar(); + draw(); + break; + case 273: // cursor up + historyScroll(+1); + break; + case 274: // cursor down + historyScroll(-1); + break; + case 275: // cursor right + if (_currentPos < _promptEndPos) + _currentPos++; + draw(); + break; + case 276: // cursor left + if (_currentPos > _promptStartPos) + _currentPos--; + draw(); + break; + default: + if (ascii == '~' || ascii == '#') { + close(); + } else if (modifiers == OSystem::KBD_CTRL) { + specialKeys(keycode); + } else if (isprint((char)ascii)) { + for (i = _promptEndPos-1; i >= _currentPos; i--) + _buffer[(i + 1) % kBufferSize] = _buffer[i % kBufferSize]; + _promptEndPos++; + putchar((char)ascii); + scrollToCurrent(); + } } } @@ -310,28 +307,28 @@ void ConsoleDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data void ConsoleDialog::specialKeys(int keycode) { switch (keycode) { - case 'a': - _currentPos = _promptStartPos; - draw(); - break; - case 'd': - if (_currentPos < _promptEndPos) { - killChar(); - draw(); - } - break; - case 'e': - _currentPos = _promptEndPos; - draw(); - break; - case 'k': - killLine(); - draw(); - break; - case 'w': - killLastWord(); + case 'a': + _currentPos = _promptStartPos; + draw(); + break; + case 'd': + if (_currentPos < _promptEndPos) { + killChar(); draw(); - break; + } + break; + case 'e': + _currentPos = _promptEndPos; + draw(); + break; + case 'k': + killLine(); + draw(); + break; + case 'w': + killLastWord(); + draw(); + break; } } diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 736be2d8c8..2bc9aacac0 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -147,60 +147,60 @@ void NewGui::runLoop() { uint32 time = get_time(); while (_system->poll_event(&event)) { - switch(event.event_code) { - case OSystem::EVENT_KEYDOWN: + switch (event.event_code) { + case OSystem::EVENT_KEYDOWN: #if !defined(_WIN32_WCE) && !defined(__PALM_OS__) - // init continuous event stream - // not done on WinCE because keyboard is emulated and - // keyup is not generated - _currentKeyDown.ascii = event.kbd.ascii; - _currentKeyDown.keycode = event.kbd.keycode; - _currentKeyDown.flags = event.kbd.flags; - _keyRepeatTime = time + kKeyRepeatInitialDelay; + // init continuous event stream + // not done on WinCE because keyboard is emulated and + // keyup is not generated + _currentKeyDown.ascii = event.kbd.ascii; + _currentKeyDown.keycode = event.kbd.keycode; + _currentKeyDown.flags = event.kbd.flags; + _keyRepeatTime = time + kKeyRepeatInitialDelay; #endif - activeDialog->handleKeyDown(event.kbd.ascii, event.kbd.keycode, event.kbd.flags); - break; - case OSystem::EVENT_KEYUP: - activeDialog->handleKeyUp(event.kbd.ascii, event.kbd.keycode, event.kbd.flags); - if (event.kbd.keycode == _currentKeyDown.keycode) - // only stop firing events if it's the current key - _currentKeyDown.keycode = 0; - break; - case OSystem::EVENT_MOUSEMOVE: - activeDialog->handleMouseMoved(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 0); - break; - // We don't distinguish between mousebuttons (for now at least) - case OSystem::EVENT_LBUTTONDOWN: - case OSystem::EVENT_RBUTTONDOWN: { - if (_lastClick.count && (time < _lastClick.time + kDoubleClickDelay) - && ABS(_lastClick.x - event.mouse.x) < 3 - && ABS(_lastClick.y - event.mouse.y) < 3) { - _lastClick.count++; - } else { - _lastClick.x = event.mouse.x; - _lastClick.y = event.mouse.y; - _lastClick.count = 1; - } - _lastClick.time = time; - } - activeDialog->handleMouseDown(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1, _lastClick.count); - break; - case OSystem::EVENT_LBUTTONUP: - case OSystem::EVENT_RBUTTONUP: - activeDialog->handleMouseUp(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1, _lastClick.count); - break; - case OSystem::EVENT_WHEELUP: - activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, -1); - break; - case OSystem::EVENT_WHEELDOWN: - activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1); - break; - case OSystem::EVENT_QUIT: - _system->quit(); - return; - case OSystem::EVENT_SCREEN_CHANGED: - updateColors(); - break; + activeDialog->handleKeyDown(event.kbd.ascii, event.kbd.keycode, event.kbd.flags); + break; + case OSystem::EVENT_KEYUP: + activeDialog->handleKeyUp(event.kbd.ascii, event.kbd.keycode, event.kbd.flags); + if (event.kbd.keycode == _currentKeyDown.keycode) + // only stop firing events if it's the current key + _currentKeyDown.keycode = 0; + break; + case OSystem::EVENT_MOUSEMOVE: + activeDialog->handleMouseMoved(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 0); + break; + // We don't distinguish between mousebuttons (for now at least) + case OSystem::EVENT_LBUTTONDOWN: + case OSystem::EVENT_RBUTTONDOWN: { + if (_lastClick.count && (time < _lastClick.time + kDoubleClickDelay) + && ABS(_lastClick.x - event.mouse.x) < 3 + && ABS(_lastClick.y - event.mouse.y) < 3) { + _lastClick.count++; + } else { + _lastClick.x = event.mouse.x; + _lastClick.y = event.mouse.y; + _lastClick.count = 1; + } + _lastClick.time = time; + } + activeDialog->handleMouseDown(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1, _lastClick.count); + break; + case OSystem::EVENT_LBUTTONUP: + case OSystem::EVENT_RBUTTONUP: + activeDialog->handleMouseUp(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1, _lastClick.count); + break; + case OSystem::EVENT_WHEELUP: + activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, -1); + break; + case OSystem::EVENT_WHEELDOWN: + activeDialog->handleMouseWheel(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y, 1); + break; + case OSystem::EVENT_QUIT: + _system->quit(); + return; + case OSystem::EVENT_SCREEN_CHANGED: + updateColors(); + break; } } |