diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-03 18:27:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-03 18:27:38 +0300 |
commit | 7004d2a474babb208c9f987c0e5c3b774b088513 (patch) | |
tree | 2e6209f0b94421cb233d8688574760671b1bbc16 /src/gui/widgets/extendedlistbox.cpp | |
parent | 9df0183f9a45d92a6be9e3ef9c7641b903134ba3 (diff) | |
download | manaverse-7004d2a474babb208c9f987c0e5c3b774b088513.tar.gz manaverse-7004d2a474babb208c9f987c0e5c3b774b088513.tar.bz2 manaverse-7004d2a474babb208c9f987c0e5c3b774b088513.tar.xz manaverse-7004d2a474babb208c9f987c0e5c3b774b088513.zip |
improve extendedlistbox
Diffstat (limited to 'src/gui/widgets/extendedlistbox.cpp')
-rw-r--r-- | src/gui/widgets/extendedlistbox.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 603827130..accb52ddc 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -39,7 +39,7 @@ ExtendedListBox::ExtendedListBox(const Widget2 *const widget, gcn::ListModel *const listModel, const std::string &skin, - int rowHeight) : + const int rowHeight) : ListBox(widget, listModel, skin), mRowHeight(rowHeight), mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0), @@ -74,7 +74,8 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) gcn::Font *const font = getFont(); const int height = getRowHeight(); - int textPos = (height - font->getHeight()) / 2 + mPadding; + const int pad2 = 2 + mPadding; + int textPos = (height - font->getHeight()) / pad2; if (textPos < 0) textPos = 0; @@ -85,13 +86,24 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) graphics->setColor(mHighlightColor); graphics->fillRectangle(gcn::Rectangle(mPadding, height * mSelected + mPadding, - getWidth() - 2 * mPadding, height)); + getWidth() - pad2, height)); } - // Draw the list elements + const int sz = mListModel->getNumberOfElements(); + for (int i = 0, y = 0; i < sz; ++i, y += height) + { + if (i != mSelected) + { + const Image *const image = model->getImageAt(i); + if (image) + { + g->drawImage(image, mImagePadding, y + (height + - image->getHeight()) / 2 + mPadding); + } + } + } g->setColorAll(mForegroundColor, mForegroundColor2); - for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); - ++i, y += height) + for (int i = 0, y = 0; i < sz; ++i, y += height) { if (i != mSelected) { @@ -103,8 +115,6 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) } else { - g->drawImage(image, mImagePadding, y + (height - - image->getHeight()) / 2 + mPadding); font->drawString(graphics, mListModel->getElementAt(i), image->getWidth() + mImagePadding + mSpacing, y + textPos); } |