Ticket #8510: listwidget.diff

File listwidget.diff, 2.9 KB (added by eriktorbjorn, 18 years ago)

Patch against current CVS

  • gui/ListWidget.cpp

    RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.cpp,v
    retrieving revision 1.61
    diff -u -r1.61 ListWidget.cpp
     
    5555
    5656        // FIXME: This flag should come from widget definition
    5757        _editable = true;
     58
     59        _textWidth = new int[_entriesPerPage];
     60
     61        for (int i = 0; i < _entriesPerPage; i++)
     62                _textWidth[i] = 0;
    5863}
    5964
    6065ListWidget::~ListWidget() {
     66        delete[] _textWidth;
    6167}
    6268
    6369void ListWidget::setSelected(int item) {
     
    319325                                g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y + 1 + kLineHeight * i, _x+_w-1, y+fontHeight-1), _hints, Theme::kWidgetBackgroundBorderSmall);
    320326                }
    321327
     328                Common::Rect r(getEditRect());
     329
    322330                // If in numbering mode, we first print a number prefix
    323331                if (_numberingMode != kListNumberingOff) {
    324332                        char temp[10];
    325333                        sprintf(temp, "%2d. ", (pos + _numberingMode));
    326334                        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);
    328336                }
    329337
    330                 Common::Rect r(getEditRect());
    331                 if (_selectedItem == pos && _editMode) {
     338                int maxWidth = _textWidth[i];
     339                int width;
    332340
     341                if (_selectedItem == pos && _editMode) {
    333342                        buffer = _editString;
    334343                        adjustOffset();
    335344                        deltax = -_editScrollOffset;
    336345
    337                         g_gui.theme()->drawText(Common::Rect(_x + r.left - deltax, y, _x+_w-2, y+fontHeight-1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted);
     346                        width = g_gui.getStringWidth(buffer);
     347                        if (width > maxWidth)
     348                                maxWidth = width;
     349
     350                        g_gui.theme()->drawText(Common::Rect(_x + r.left - deltax, y, _x + r.left - deltax + maxWidth, y + fontHeight - 1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted);
    338351                } else {
    339352                        buffer = _list[pos];
    340353                        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);
     354
     355                        width = g_gui.getStringWidth(buffer);
     356                        if (width > maxWidth)
     357                                maxWidth = width;
     358
     359                        g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + maxWidth, y + fontHeight - 1), buffer, Theme::kStateEnabled, Theme::kTextAlignLeft, inverted);
    342360                }
     361
     362                _textWidth[i] = maxWidth;
    343363        }
    344364}
    345365
  • gui/ListWidget.h

    RCS file: /cvsroot/scummvm/scummvm/gui/ListWidget.h,v
    retrieving revision 1.36
    diff -u -r1.36 ListWidget.h
     
    100100
    101101        void lostFocusWidget();
    102102        void scrollToCurrent();
     103
     104        int *_textWidth;
    103105};
    104106
    105107} // End of namespace GUI