diff options
author | Max Horn | 2005-05-15 18:02:10 +0000 |
---|---|---|
committer | Max Horn | 2005-05-15 18:02:10 +0000 |
commit | 841c600fef543703919733939b6374ced0c8a982 (patch) | |
tree | 874bda7a10bbe70801ddafde24bcc936d3dafc67 /gui/ListWidget.cpp | |
parent | f2646d3e531a72d7867400db9c5ef75adc9ea029 (diff) | |
download | scummvm-rg350-841c600fef543703919733939b6374ced0c8a982.tar.gz scummvm-rg350-841c600fef543703919733939b6374ced0c8a982.tar.bz2 scummvm-rg350-841c600fef543703919733939b6374ced0c8a982.zip |
Draw scrollbar arrows using drawLine, instead of hard coding bitmaps; add a param to the ListWidget constructor to choose a 'big' variant
svn-id: r18115
Diffstat (limited to 'gui/ListWidget.cpp')
-rw-r--r-- | gui/ListWidget.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 929a8a8319..f600676c07 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -27,16 +27,21 @@ namespace GUI { -ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h) - : EditableWidget(boss, x, y, w - kDefaultScrollBarWidth, h), CommandSender(boss) { +ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize ws) + : EditableWidget(boss, x, y, w, h), CommandSender(boss) { + + // TODO: When in kBigWidgetSize mode, use another font + _w = w - (ws == kBigWidgetSize ? kBigScrollBarWidth : kNormalScrollBarWidth); + _lineHeight = kLineHeight; + _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE; _type = kListWidget; _editMode = false; _numberingMode = kListNumberingOne; - _entriesPerPage = (_h - 2) / kLineHeight; + _entriesPerPage = (_h - 2) / _lineHeight; _currentPos = 0; _selectedItem = -1; - _scrollBar = new ScrollBarWidget(boss, _x + _w, _y, kDefaultScrollBarWidth, _h); + _scrollBar = new ScrollBarWidget(boss, _x + _w, _y, (ws == kBigWidgetSize ? kBigScrollBarWidth : kNormalScrollBarWidth), _h); _scrollBar->setTarget(this); _currentKeyDown = 0; @@ -144,7 +149,7 @@ void ListWidget::handleMouseWheel(int x, int y, int direction) { int ListWidget::findItem(int x, int y) const { - return (y - 1) / kLineHeight + _currentPos; + return (y - 1) / _lineHeight + _currentPos; } static int matchingCharsIgnoringCase(const char *x, const char *y, bool &stop) { @@ -301,14 +306,14 @@ void ListWidget::drawWidget(bool hilite) { // Draw the list items for (i = 0, pos = _currentPos; i < _entriesPerPage && pos < len; i++, pos++) { const OverlayColor textColor = (_selectedItem == pos && _hasFocus) ? gui->_bgcolor : gui->_textcolor; - const int y = _y + 2 + kLineHeight * i; + const int y = _y + 2 + _lineHeight * i; // Draw the selected item inverted, on a highlighted background. if (_selectedItem == pos) { if (_hasFocus) - gui->fillRect(_x + 1, _y + 1 + kLineHeight * i, _w - 1, kLineHeight, gui->_textcolorhi); + gui->fillRect(_x + 1, _y + 1 + _lineHeight * i, _w - 1, _lineHeight, gui->_textcolorhi); else - gui->frameRect(_x + 1, _y + 1 + kLineHeight * i, _w - 1, kLineHeight, gui->_textcolorhi); + gui->frameRect(_x + 1, _y + 1 + _lineHeight * i, _w - 1, _lineHeight, gui->_textcolorhi); } // If in numbering mode, we first print a number prefix @@ -339,8 +344,8 @@ void ListWidget::drawWidget(bool hilite) { } Common::Rect ListWidget::getEditRect() const { - Common::Rect r(2, 1, _w - 2 , kLineHeight); - const int offset = (_selectedItem - _currentPos) * kLineHeight; + Common::Rect r(2, 1, _w - 2 , _lineHeight); + const int offset = (_selectedItem - _currentPos) * _lineHeight; r.top += offset; r.bottom += offset; |