diff options
author | Torbjörn Andersson | 2005-06-03 11:33:15 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2005-06-03 11:33:15 +0000 |
commit | 7dfa96a8b882a216a8a4ee8715871f18a5622921 (patch) | |
tree | 865bd943a656277af3fabd3dc7bb712eeb3b05b5 /gui | |
parent | 36e8989a6e452324e2f57cddee3ea0e6db0264c3 (diff) | |
download | scummvm-rg350-7dfa96a8b882a216a8a4ee8715871f18a5622921.tar.gz scummvm-rg350-7dfa96a8b882a216a8a4ee8715871f18a5622921.tar.bz2 scummvm-rg350-7dfa96a8b882a216a8a4ee8715871f18a5622921.zip |
Cleanup.
svn-id: r18319
Diffstat (limited to 'gui')
-rw-r--r-- | gui/EditTextWidget.cpp | 4 | ||||
-rw-r--r-- | gui/ListWidget.cpp | 24 | ||||
-rw-r--r-- | gui/ListWidget.h | 1 | ||||
-rw-r--r-- | gui/editable.cpp | 18 | ||||
-rw-r--r-- | gui/editable.h | 1 |
5 files changed, 16 insertions, 32 deletions
diff --git a/gui/EditTextWidget.cpp b/gui/EditTextWidget.cpp index e64a1c43bc..91b85d3b06 100644 --- a/gui/EditTextWidget.cpp +++ b/gui/EditTextWidget.cpp @@ -50,7 +50,7 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) { uint i; for (i = 0; i < _editString.size(); ++i) { - width += _font->getCharWidth(_editString[i]); + width += g_gui.getCharWidth(_editString[i]); if (width >= x) break; } @@ -68,7 +68,7 @@ void EditTextWidget::drawWidget(bool hilite) { // Draw the text adjustOffset(); - g_gui.drawString(_font, _editString, _x + 2, _y + 2, getEditRect().width(), g_gui._textcolor, kTextAlignLeft, -_editScrollOffset, false); + g_gui.drawString(_editString, _x + 2, _y + 2, getEditRect().width(), g_gui._textcolor, kTextAlignLeft, -_editScrollOffset, false); } Common::Rect EditTextWidget::getEditRect() const { diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 6274f78175..3104c65b27 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -35,13 +35,12 @@ ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h, WidgetSize w } else { _w = w - kNormalScrollBarWidth; } - _lineHeight = _font->getFontHeight() + 2; _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE; _type = kListWidget; _editMode = false; _numberingMode = kListNumberingOne; - _entriesPerPage = (_h - 2) / _lineHeight; + _entriesPerPage = (_h - 2) / kLineHeight; _currentPos = 0; _selectedItem = -1; _scrollBar = new ScrollBarWidget(boss, _x + _w, _y, (ws == kBigWidgetSize ? kBigScrollBarWidth : kNormalScrollBarWidth), _h); @@ -152,7 +151,7 @@ void ListWidget::handleMouseWheel(int x, int y, int direction) { int ListWidget::findItem(int x, int y) const { - return (y - 1) / _lineHeight + _currentPos; + return (y - 1) / kLineHeight + _currentPos; } static int matchingCharsIgnoringCase(const char *x, const char *y, bool &stop) { @@ -300,7 +299,6 @@ void ListWidget::drawWidget(bool hilite) { int i, pos, len = _list.size(); Common::String buffer; int deltax; - Graphics::Surface *surf = &g_gui.getScreen(); // Draw a thin frame around the list. gui->hLine(_x, _y, _x + _w - 1, gui->_color); @@ -310,14 +308,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 + _lineHeight * i; + const int y = _y + 2 + kLineHeight * i; // Draw the selected item inverted, on a highlighted background. if (_selectedItem == pos) { if (_hasFocus) - gui->fillRect(_x + 1, _y + 1 + _lineHeight * i, _w - 1, _lineHeight, gui->_textcolorhi); + gui->fillRect(_x + 1, _y + 1 + kLineHeight * i, _w - 1, kLineHeight, gui->_textcolorhi); else - gui->frameRect(_x + 1, _y + 1 + _lineHeight * i, _w - 1, _lineHeight, gui->_textcolorhi); + gui->frameRect(_x + 1, _y + 1 + kLineHeight * i, _w - 1, kLineHeight, gui->_textcolorhi); } // If in numbering mode, we first print a number prefix @@ -325,7 +323,7 @@ void ListWidget::drawWidget(bool hilite) { char temp[10]; sprintf(temp, "%2d. ", (pos + _numberingMode)); buffer = temp; - _font->drawString(surf, buffer, _x + 2, y, _w - 4, textColor); + gui->drawString(buffer, _x + 2, y, _w - 4, textColor); } Common::Rect r(getEditRect()); @@ -335,18 +333,18 @@ void ListWidget::drawWidget(bool hilite) { adjustOffset(); deltax = -_editScrollOffset; - _font->drawString(surf, buffer, _x + r.left, y, r.width(), textColor, kTextAlignLeft, deltax, false); + gui->drawString(buffer, _x + r.left, y, r.width(), textColor, kTextAlignLeft, deltax, false); } else { buffer = _list[pos]; deltax = 0; - _font->drawString(surf, buffer, _x + r.left, y, r.width(), textColor); + gui->drawString(buffer, _x + r.left, y, r.width(), textColor); } } } Common::Rect ListWidget::getEditRect() const { - Common::Rect r(2, 1, _w - 2 , _lineHeight); - const int offset = (_selectedItem - _currentPos) * _lineHeight; + Common::Rect r(2, 1, _w - 2 , kLineHeight); + const int offset = (_selectedItem - _currentPos) * kLineHeight; r.top += offset; r.bottom += offset; @@ -354,7 +352,7 @@ Common::Rect ListWidget::getEditRect() const { char temp[10]; // FIXME: Assumes that all digits have the same width. sprintf(temp, "%2d. ", (_list.size() - 1 + _numberingMode)); - r.left += _font->getStringWidth(temp); + r.left += g_gui.getStringWidth(temp); } return r; diff --git a/gui/ListWidget.h b/gui/ListWidget.h index 652489cfa3..93c97e4816 100644 --- a/gui/ListWidget.h +++ b/gui/ListWidget.h @@ -56,7 +56,6 @@ protected: int _selectedItem; ScrollBarWidget *_scrollBar; int _currentKeyDown; - int _lineHeight; String _quickSelectStr; uint32 _quickSelectTime; diff --git a/gui/editable.cpp b/gui/editable.cpp index 78510dcc71..cc55ee16f9 100644 --- a/gui/editable.cpp +++ b/gui/editable.cpp @@ -34,18 +34,6 @@ EditableWidget::EditableWidget(GuiObject *boss, int x, int y, int w, int h, Widg _caretInverse = false; _editScrollOffset = 0; - - switch (ws) { - case kNormalWidgetSize: - _font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); - break; - case kBigWidgetSize: - _font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - break; - default: - _font = &g_gui.getFont(); - break; - } } EditableWidget::~EditableWidget() { @@ -57,7 +45,7 @@ void EditableWidget::setEditString(const String &str) { _editString = str; _caretPos = _editString.size(); - _editScrollOffset = (_font->getStringWidth(_editString) - (getEditRect().width())); + _editScrollOffset = (g_gui.getStringWidth(_editString) - (getEditRect().width())); if (_editScrollOffset < 0) _editScrollOffset = 0; } @@ -142,7 +130,7 @@ bool EditableWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { int EditableWidget::getCaretOffset() const { int caretpos = 0; for (int i = 0; i < _caretPos; i++) - caretpos += _font->getCharWidth(_editString[i]); + caretpos += g_gui.getCharWidth(_editString[i]); caretpos -= _editScrollOffset; @@ -196,7 +184,7 @@ bool EditableWidget::adjustOffset() { _editScrollOffset -= (editWidth - caretpos); return true; } else if (_editScrollOffset > 0) { - const int strWidth = _font->getStringWidth(_editString); + const int strWidth = g_gui.getStringWidth(_editString); if (strWidth - _editScrollOffset < editWidth) { // scroll right _editScrollOffset = (strWidth - editWidth); diff --git a/gui/editable.h b/gui/editable.h index 7f48aa295e..41bb28da91 100644 --- a/gui/editable.h +++ b/gui/editable.h @@ -35,7 +35,6 @@ class EditableWidget : public Widget { public: typedef Common::String String; protected: - const Graphics::Font *_font; String _editString; bool _caretVisible; |