summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/dropdown.cpp33
-rw-r--r--src/gui/widgets/dropdown.h22
2 files changed, 41 insertions, 14 deletions
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index dad85a0af..8a543b310 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -30,6 +30,7 @@
#include "gui/sdlinput.h"
#include "gui/viewport.h"
+#include "gui/widgets/extendedlistmodel.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/popuplist.h"
#include "gui/widgets/scrollarea.h"
@@ -68,6 +69,7 @@ DropDown::DropDown(const Widget2 *const widget,
gcn::FocusListener(),
gcn::SelectionListener(),
Widget2(widget),
+ mExtended(extended),
mPopup(new PopupList(this, listModel, extended)),
mShadowColor(getThemeColor(Theme::DROPDOWN_SHADOW)),
mHighlightColor(getThemeColor(Theme::HIGHLIGHT)),
@@ -157,6 +159,7 @@ DropDown::DropDown(const Widget2 *const widget,
mFrameSize = mSkin->getOption("frameSize");
mPadding = mSkin->getPadding();
mImagePadding = mSkin->getOption("imagePadding");
+ mSpacing = mSkin->getOption("spacing");
}
adjustHeight();
}
@@ -226,12 +229,36 @@ void DropDown::draw(gcn::Graphics* graphics)
mHighlightColor.a = alpha;
mShadowColor.a = alpha;
- if (mPopup->getListModel() && mPopup->getSelected() >= 0)
+ gcn::ListModel *const model = mPopup->getListModel();
+ if (model && mPopup->getSelected() >= 0)
{
gcn::Font *const font = getFont();
graphics->setColor(mForegroundColor);
- font->drawString(graphics, mPopup->getListModel()->getElementAt(
- mPopup->getSelected()), mPadding, mPadding);
+ if (mExtended)
+ {
+ const int sel = mPopup->getSelected();
+ ExtendedListModel *const model2
+ = static_cast<ExtendedListModel *const>(model);
+ const Image *const image = model2->getImageAt(sel);
+ if (!image)
+ {
+ font->drawString(graphics, model->getElementAt(sel),
+ mPadding, mPadding);
+ }
+ else
+ {
+ static_cast<Graphics*>(graphics)->drawImage(
+ image, mImagePadding, (getHeight()
+ - image->getHeight()) / 2 + mPadding);
+ font->drawString(graphics, model->getElementAt(sel),
+ image->getWidth() + mImagePadding + mSpacing, mPadding);
+ }
+ }
+ else
+ {
+ font->drawString(graphics, model->getElementAt(
+ mPopup->getSelected()), mPadding, mPadding);
+ }
}
if (isFocused())
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index 1707857cb..295c8b527 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -25,17 +25,15 @@
#include "gui/widgets/widget2.h"
-#include "guichan/actionlistener.hpp"
-#include "guichan/basiccontainer.hpp"
-#include "guichan/focushandler.hpp"
-#include "guichan/focuslistener.hpp"
-#include "guichan/keylistener.hpp"
-#include "guichan/listmodel.hpp"
-#include "guichan/mouselistener.hpp"
-#include "guichan/selectionlistener.hpp"
-
-#include "guichan/widgets/listbox.hpp"
-#include "guichan/widgets/scrollarea.hpp"
+#include <guichan/actionlistener.hpp>
+#include <guichan/basiccontainer.hpp>
+#include <guichan/focushandler.hpp>
+#include <guichan/focuslistener.hpp>
+#include <guichan/keylistener.hpp>
+#include <guichan/listmodel.hpp>
+#include <guichan/mouselistener.hpp>
+#include <guichan/selectionlistener.hpp>
+#include <guichan/widgets/scrollarea.hpp>
#include "localconsts.h"
@@ -147,11 +145,13 @@ class DropDown final : public gcn::ActionListener,
*/
void drawButton(gcn::Graphics *graphics);
+ bool mExtended;
PopupList *mPopup;
gcn::Color mShadowColor;
gcn::Color mHighlightColor;
int mPadding;
int mImagePadding;
+ int mSpacing;
bool mDroppedDown;
bool mPushed;