summaryrefslogtreecommitdiff
path: root/src/gui/widgets/listbox.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-24 22:32:04 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-24 22:32:04 +0300
commit4e95f451a793dbac5dbc31361cdc5049de48c3cc (patch)
tree02a1cc506638edd2deb2074abd97330a74435c3a /src/gui/widgets/listbox.cpp
parent22e4c80cc35e552ef39639a874f3c54f11fde747 (diff)
downloadmanaverse-4e95f451a793dbac5dbc31361cdc5049de48c3cc.tar.gz
manaverse-4e95f451a793dbac5dbc31361cdc5049de48c3cc.tar.bz2
manaverse-4e95f451a793dbac5dbc31361cdc5049de48c3cc.tar.xz
manaverse-4e95f451a793dbac5dbc31361cdc5049de48c3cc.zip
Add color for selected text in listboxes.
New theme color: LISTBOX_SELECTED
Diffstat (limited to 'src/gui/widgets/listbox.cpp')
-rw-r--r--src/gui/widgets/listbox.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 4de4e360f..87ecc9460 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -46,6 +46,7 @@ ListBox::ListBox(const Widget2 *const widget,
gcn::ListBox(listModel),
Widget2(widget),
mHighlightColor(getThemeColor(Theme::HIGHLIGHT)),
+ mForegroundSelectedColor(getThemeColor(Theme::LISTBOX_SELECTED)),
mDistributeMousePressed(true),
mOldSelected(-1),
mPadding(0)
@@ -102,13 +103,23 @@ void ListBox::draw(gcn::Graphics *graphics)
height * mSelected + mPadding, getWidth() - 2 * mPadding, height));
}
+ const int sel = getSelected();
+ if (sel >= 0)
+ {
+ graphics->setColor(mForegroundSelectedColor);
+ graphics->drawText(mListModel->getElementAt(sel),
+ mPadding, sel * height + mPadding);
+ }
// Draw the list elements
graphics->setColor(mForegroundColor);
for (int i = 0, y = 0; i < mListModel->getNumberOfElements();
++i, y += height)
{
- graphics->drawText(mListModel->getElementAt(i),
- mPadding, y + mPadding);
+ if (i != sel)
+ {
+ graphics->drawText(mListModel->getElementAt(i),
+ mPadding, y + mPadding);
+ }
}
BLOCK_END("ListBox::draw")
}