RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
retrieving revision 1.61
diff -u -r1.61 ListWidget.cpp
|
|
|
55 | 55 | |
56 | 56 | // FIXME: This flag should come from widget definition |
57 | 57 | _editable = true; |
| 58 | |
| 59 | _textWidth = new int[_entriesPerPage]; |
| 60 | |
| 61 | for (int i = 0; i < _entriesPerPage; i++) |
| 62 | _textWidth[i] = 0; |
58 | 63 | } |
59 | 64 | |
60 | 65 | ListWidget::~ListWidget() { |
| 66 | delete[] _textWidth; |
61 | 67 | } |
62 | 68 | |
63 | 69 | void ListWidget::setSelected(int item) { |
… |
… |
|
316 | 322 | if (_hasFocus) |
317 | 323 | inverted = true; |
318 | 324 | else |
319 | | g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y + 1 + kLineHeight * i, _x+_w-1, y+fontHeight-1), _hints, Theme::kWidgetBackgroundBorderSmall); |
| 325 | g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y + 1 + kLineHeight * i, _x + _w - 1, y + fontHeight - 1), _hints, Theme::kWidgetBackgroundBorderSmall); |
320 | 326 | } |
321 | 327 | |
| 328 | Common::Rect r(getEditRect()); |
| 329 | |
322 | 330 | // If in numbering mode, we first print a number prefix |
323 | 331 | if (_numberingMode != kListNumberingOff) { |
324 | 332 | char temp[10]; |
325 | 333 | sprintf(temp, "%2d. ", (pos + _numberingMode)); |
326 | 334 | buffer = temp; |
327 | | g_gui.theme()->drawText(Common::Rect(_x+2, y, _x+_w-2, y+fontHeight-1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted); |
| 335 | g_gui.theme()->drawText(Common::Rect(_x + 2, y, _x + r.left, y + fontHeight - 1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted); |
328 | 336 | } |
329 | 337 | |
330 | | Common::Rect r(getEditRect()); |
331 | | if (_selectedItem == pos && _editMode) { |
| 338 | int width; |
332 | 339 | |
| 340 | if (_selectedItem == pos && _editMode) { |
333 | 341 | buffer = _editString; |
334 | 342 | adjustOffset(); |
335 | 343 | deltax = -_editScrollOffset; |
336 | | |
337 | | g_gui.theme()->drawText(Common::Rect(_x + r.left - deltax, y, _x+_w-2, y+fontHeight-1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted); |
| 344 | width = _w - r.left + deltax - 2; |
| 345 | g_gui.theme()->drawText(Common::Rect(_x + r.left - deltax, y, _x + r.left - deltax + width, y + fontHeight - 1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted); |
338 | 346 | } else { |
| 347 | int maxWidth = _textWidth[i]; |
339 | 348 | buffer = _list[pos]; |
340 | 349 | deltax = 0; |
341 | | g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x+_w-2, y+fontHeight-1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted); |
| 350 | if (_selectedItem != pos) |
| 351 | width = g_gui.getStringWidth(buffer); |
| 352 | else |
| 353 | width = _w - r.left - 2; |
| 354 | if (width > maxWidth) |
| 355 | maxWidth = width; |
| 356 | g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + maxWidth, y + fontHeight - 1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted); |
342 | 357 | } |
| 358 | |
| 359 | _textWidth[i] = width; |
343 | 360 | } |
344 | 361 | } |
345 | 362 | |
RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.h,v
retrieving revision 1.36
diff -u -r1.36 ListWidget.h
|
|
|
100 | 100 | |
101 | 101 | void lostFocusWidget(); |
102 | 102 | void scrollToCurrent(); |
| 103 | |
| 104 | int *_textWidth; |
103 | 105 | }; |
104 | 106 | |
105 | 107 | } // End of namespace GUI |