aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorMax Horn2003-11-18 23:44:28 +0000
committerMax Horn2003-11-18 23:44:28 +0000
commit7d0fcb71a893a86d4297230e6fa473e35cdaa6a0 (patch)
treedbcc1137b00048f9e2cf0afe605b631e7c306df7 /gui
parent151a2dcc44fd0f58d66b58c53693eac1fbf3e7f6 (diff)
downloadscummvm-rg350-7d0fcb71a893a86d4297230e6fa473e35cdaa6a0.tar.gz
scummvm-rg350-7d0fcb71a893a86d4297230e6fa473e35cdaa6a0.tar.bz2
scummvm-rg350-7d0fcb71a893a86d4297230e6fa473e35cdaa6a0.zip
cleanup; fixed return/enter in ListWidget when not in editing mode
svn-id: r11346
Diffstat (limited to 'gui')
-rw-r--r--gui/EditTextWidget.cpp21
-rw-r--r--gui/ListWidget.cpp35
-rw-r--r--gui/ListWidget.h3
3 files changed, 27 insertions, 32 deletions
diff --git a/gui/EditTextWidget.cpp b/gui/EditTextWidget.cpp
index e66d9e2cbc..ce6a828b69 100644
--- a/gui/EditTextWidget.cpp
+++ b/gui/EditTextWidget.cpp
@@ -45,11 +45,7 @@ void EditTextWidget::handleTickle() {
uint32 time = g_system->get_msecs();
if (_caretTime < time) {
_caretTime = time + kCaretBlinkTime;
- if (_caretVisible) {
- drawCaret(true);
- } else {
- drawCaret(false);
- }
+ drawCaret(_caretVisible);
}
}
@@ -157,7 +153,7 @@ void EditTextWidget::drawWidget(bool hilite) {
g_gui.drawString(_label, _x + 2, _y + 3, _w - 6, g_gui._textcolor, kTextAlignLeft, -_labelOffset, false);
}
-int EditTextWidget::getCaretPos() {
+int EditTextWidget::getCaretPos() const {
int caretpos = 0;
for (int i = 0; i < _pos; i++)
caretpos += g_gui.getCharWidth(_label[i]);
@@ -176,8 +172,7 @@ void EditTextWidget::drawCaret(bool erase) {
int x = getAbsX() + 2;
int y = getAbsY() + 1;
- int width = getCaretPos();
- x += width;
+ x += getCaretPos();
g_gui.vLine(x, y, y + kLineHeight, color);
g_gui.addDirtyRect(x, y, 2, kLineHeight);
@@ -185,8 +180,6 @@ void EditTextWidget::drawCaret(bool erase) {
_caretVisible = !erase;
}
-
-
bool EditTextWidget::adjustOffset() {
// check if the caret is still within the textbox; if it isn't,
// adjust _labelOffset
@@ -197,15 +190,11 @@ bool EditTextWidget::adjustOffset() {
// scroll left
_labelOffset += caretpos;
return true;
- }
- else if (caretpos >= _w - 6)
- {
+ } else if (caretpos >= _w - 6) {
// scroll right
_labelOffset -= (_w - 6 - caretpos);
return true;
- }
- else if (_labelOffset > 0)
- {
+ } else if (_labelOffset > 0) {
int width = g_gui.getStringWidth(_label);
if (width - _labelOffset < (_w - 6)) {
// scroll right
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index 85a0b19da2..734d24b488 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -89,11 +89,7 @@ void ListWidget::handleTickle() {
uint32 time = g_system->get_msecs();
if (_editMode && _caretTime < time) {
_caretTime = time + kCaretBlinkTime;
- if (_caretVisible) {
- drawCaret(true);
- } else {
- drawCaret(false);
- }
+ drawCaret(_caretVisible);
}
}
@@ -178,7 +174,8 @@ bool ListWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
dirty = true;
_editMode = true;
_backupString = _list[_selectedItem];
- }
+ } else
+ sendCommand(kListItemActivatedCmd, _selectedItem);
}
break;
case 256+17: // up arrow
@@ -285,6 +282,21 @@ void ListWidget::drawWidget(bool hilite) {
}
}
+int ListWidget::getCaretPos() const {
+ int caretpos = 0;
+ NewGui *gui = &g_gui;
+
+ if (_numberingMode == kListNumberingZero || _numberingMode == kListNumberingOne) {
+ char temp[10];
+ sprintf(temp, "%2d. ", (_selectedItem + _numberingMode));
+ caretpos += gui->getStringWidth(temp);
+ }
+
+ caretpos += gui->getStringWidth(_list[_selectedItem]);
+
+ return caretpos;
+}
+
void ListWidget::drawCaret(bool erase) {
// Only draw if item is visible
if (_selectedItem < _currentPos || _selectedItem >= _currentPos + _entriesPerPage)
@@ -298,19 +310,10 @@ void ListWidget::drawCaret(bool erase) {
int16 color = erase ? gui->_textcolorhi : gui->_bgcolor;
int x = getAbsX() + 3;
int y = getAbsY() + 1;
- Common::String buffer;
y += (_selectedItem - _currentPos) * kLineHeight;
- if (_numberingMode == kListNumberingZero || _numberingMode == kListNumberingOne) {
- char temp[10];
- sprintf(temp, "%2d. ", (_selectedItem + _numberingMode));
- buffer = temp;
- buffer += _list[_selectedItem];
- } else
- buffer = _list[_selectedItem];
-
- x += gui->getStringWidth(buffer);
+ x += getCaretPos();
gui->vLine(x, y, y+kLineHeight, color);
gui->addDirtyRect(x, y, 2, kLineHeight);
diff --git a/gui/ListWidget.h b/gui/ListWidget.h
index 1e895af47a..4739ddbb0f 100644
--- a/gui/ListWidget.h
+++ b/gui/ListWidget.h
@@ -89,7 +89,10 @@ public:
protected:
void drawWidget(bool hilite);
+
+ int getCaretPos() const;
void drawCaret(bool erase);
+
void lostFocusWidget();
void scrollToCurrent();
};