diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/extendedlistbox.cpp | 33 | ||||
-rw-r--r-- | src/gui/widgets/listbox.cpp | 15 | ||||
-rw-r--r-- | src/gui/widgets/listbox.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/shoplistbox.cpp | 5 |
4 files changed, 44 insertions, 10 deletions
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index bb138b456..bad1472ac 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -82,18 +82,37 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); ++i, y += height) { - const Image *const image = model->getImageAt(i); + if (i != mSelected) + { + const Image *const image = model->getImageAt(i); + if (!image) + { + graphics->drawText(mListModel->getElementAt(i), + mPadding, y + textPos); + } + else + { + g->drawImage(image, mImagePadding, y + (height + - image->getHeight()) / 2 + mPadding); + graphics->drawText(mListModel->getElementAt(i), + image->getWidth() + mImagePadding + mSpacing, y + textPos); + } + } + } + if (mSelected >= 0) + { + const Image *const image = model->getImageAt(mSelected); if (!image) { - graphics->drawText(mListModel->getElementAt(i), - mPadding, y + textPos); + graphics->drawText(mListModel->getElementAt(mSelected), + mPadding, mSelected * height + textPos); } else { - g->drawImage(image, mImagePadding, y + (height - - image->getHeight()) / 2 + mPadding); - graphics->drawText(mListModel->getElementAt(i), - image->getWidth() + mImagePadding + mSpacing, y + textPos); + graphics->setColor(mForegroundSelectedColor); + graphics->drawText(mListModel->getElementAt(mSelected), + image->getWidth() + mImagePadding + mSpacing, + mSelected * height + textPos); } } BLOCK_END("ExtendedListBox::draw") 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") } diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 442840a29..36f48e7b7 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -89,6 +89,7 @@ class ListBox : public gcn::ListBox, protected: gcn::Color mHighlightColor; + gcn::Color mForegroundSelectedColor; bool mDistributeMousePressed; int mOldSelected; int mPadding; diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 86c2e2e67..7d23189d1 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -155,7 +155,10 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) graphics->drawImage(icon, mPadding, y + mPadding); } } - graphics->setColor(mForegroundColor); + if (mSelected == i) + graphics->setColor(mForegroundSelectedColor); + else + graphics->setColor(mForegroundColor); graphics->drawText(mListModel->getElementAt(i), ITEM_ICON_SIZE + mPadding, y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2 + mPadding); |