aboutsummaryrefslogtreecommitdiff
path: root/gui/ListWidget.cpp
diff options
context:
space:
mode:
authorNorbert Lange2009-08-24 17:51:47 +0000
committerNorbert Lange2009-08-24 17:51:47 +0000
commit917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5 (patch)
treee652563203a00f8acecfaafbf93c64dbfbd13f25 /gui/ListWidget.cpp
parent5f87d5090cfcb34cda3c1f5d430e0865344d7366 (diff)
parentdd7868acc2512c9761d892e67a4837f4dc38bdc0 (diff)
downloadscummvm-rg350-917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5.tar.gz
scummvm-rg350-917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5.tar.bz2
scummvm-rg350-917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5.zip
Merge with trunk
svn-id: r43701
Diffstat (limited to 'gui/ListWidget.cpp')
-rw-r--r--gui/ListWidget.cpp59
1 files changed, 53 insertions, 6 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index 7551acac48..195256b66f 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -64,6 +64,7 @@ ListWidget::ListWidget(GuiObject *boss, const String &name, uint32 cmd)
_editable = true;
_quickSelect = true;
+ _editColor = ThemeEngine::kFontColorNormal;
}
ListWidget::ListWidget(GuiObject *boss, int x, int y, int w, int h, uint32 cmd)
@@ -141,7 +142,17 @@ void ListWidget::setSelected(int item) {
}
}
-void ListWidget::setList(const StringList &list) {
+ThemeEngine::FontColor ListWidget::getSelectionColor() const {
+ if (_listColors.empty())
+ return ThemeEngine::kFontColorNormal;
+
+ if (_filter.empty())
+ return _listColors[_selectedItem];
+ else
+ return _listColors[_listIndex[_selectedItem]];
+}
+
+void ListWidget::setList(const StringList &list, const ColorList *colors) {
if (_editMode && _caretVisible)
drawCaret(true);
@@ -150,6 +161,12 @@ void ListWidget::setList(const StringList &list) {
_list = list;
_filter.clear();
_listIndex.clear();
+ _listColors.clear();
+
+ if (colors) {
+ _listColors = *colors;
+ assert(_listColors.size() == _dataList.size());
+ }
int size = list.size();
if (_currentPos >= size)
@@ -162,7 +179,19 @@ void ListWidget::setList(const StringList &list) {
scrollBarRecalc();
}
-void ListWidget::append(const String &s) {
+void ListWidget::append(const String &s, ThemeEngine::FontColor color) {
+ if (_dataList.size() == _listColors.size()) {
+ // If the color list has the size of the data list, we append the color.
+ _listColors.push_back(color);
+ } else if (!_listColors.size() && color != ThemeEngine::kFontColorNormal) {
+ // If it's the first entry to use a non default color, we will fill
+ // up all other entries of the color list with the default color and
+ // add the requested color for the new entry.
+ for (uint i = 0; i < _dataList.size(); ++i)
+ _listColors.push_back(ThemeEngine::kFontColorNormal);
+ _listColors.push_back(color);
+ }
+
_dataList.push_back(s);
_list.push_back(s);
@@ -431,17 +460,27 @@ void ListWidget::drawWidget() {
int width;
+ ThemeEngine::FontColor color = ThemeEngine::kFontColorNormal;
+
+ if (!_listColors.empty()) {
+ if (_filter.empty() || _selectedItem == -1)
+ color = _listColors[pos];
+ else
+ color = _listColors[_listIndex[pos]];
+ }
+
if (_selectedItem == pos && _editMode) {
buffer = _editString;
+ color = _editColor;
adjustOffset();
width = _w - r.left - _hlRightPadding - _leftPadding - scrollbarW;
- g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2),
- buffer, _state, Graphics::kTextAlignLeft, inverted, pad, true);
+ g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2), buffer, _state,
+ Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
} else {
buffer = _list[pos];
width = _w - r.left - scrollbarW;
- g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2),
- buffer, _state, Graphics::kTextAlignLeft, inverted, pad, true);
+ g_gui.theme()->drawText(Common::Rect(_x + r.left, y, _x + r.left + width, y + fontHeight - 2), buffer, _state,
+ Graphics::kTextAlignLeft, inverted, pad, true, ThemeEngine::kFontStyleBold, color);
}
_textWidth[i] = width;
@@ -499,6 +538,14 @@ void ListWidget::startEditMode() {
if (_editable && !_editMode && _selectedItem >= 0) {
_editMode = true;
setEditString(_list[_selectedItem]);
+ if (_listColors.empty()) {
+ _editColor = ThemeEngine::kFontColorNormal;
+ } else {
+ if (_filter.empty())
+ _editColor = _listColors[_selectedItem];
+ else
+ _editColor = _listColors[_listIndex[_selectedItem]];
+ }
draw();
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
}