From e04c285de305cc1da568cde431d31dc56009526c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 24 Dec 2012 12:53:50 +0300 Subject: Fix dropdown setupitem. --- src/gui/widgets/setupitem.cpp | 11 ++++++++--- src/gui/widgets/setupitem.h | 6 ++++-- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index cb6dc378a..d3c46e0ec 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -536,12 +536,14 @@ SetupItemDropDown::SetupItemDropDown(std::string text, SetupTabScroll *const parent, std::string eventName, gcn::ListModel *const model, + int width, const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), mLabel(nullptr), mModel(model), - mDropDown(nullptr) + mDropDown(nullptr), + mWidth(width) { mValueType = VSTR; createControls(); @@ -553,6 +555,7 @@ SetupItemDropDown::SetupItemDropDown(std::string text, SetupTabScroll *const parent, std::string eventName, gcn::ListModel *const model, + int width, std::string def, const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), @@ -583,6 +586,8 @@ void SetupItemDropDown::createControls() mDropDown = new DropDown(this, mModel); mDropDown->setActionEventId(mEventName); mDropDown->addActionListener(mParent); + mDropDown->setWidth(mWidth); + mDropDown->setSelected(atoi(mValue.c_str())); mWidget = mDropDown; // mTextField->setWidth(50); @@ -601,7 +606,7 @@ void SetupItemDropDown::fromWidget() if (!mDropDown) return; - mValue = mDropDown->getSelectedString(); + mValue = toString(mDropDown->getSelected()); } void SetupItemDropDown::toWidget() @@ -609,7 +614,7 @@ void SetupItemDropDown::toWidget() if (!mDropDown) return; - mDropDown->setSelectedString(mValue); + mDropDown->setSelected(atoi(mValue.c_str())); } diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index ec1a1de0b..34879c23c 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -267,12 +267,13 @@ class SetupItemDropDown final : public SetupItem SetupItemDropDown(std::string text, std::string description, std::string keyName, SetupTabScroll *const parent, std::string eventName, gcn::ListModel *const model, - const bool mainConfig = true); + int width, const bool mainConfig = true); SetupItemDropDown(std::string text, std::string description, std::string keyName, SetupTabScroll *const parent, std::string eventName, gcn::ListModel *const model, - std::string def, const bool mainConfig = true); + int width, std::string def, + const bool mainConfig = true); A_DELETE_COPY(SetupItemDropDown) @@ -289,6 +290,7 @@ class SetupItemDropDown final : public SetupItem Label *mLabel; gcn::ListModel *mModel; DropDown *mDropDown; + int mWidth; }; class SetupItemSlider final : public SetupItem -- cgit v1.2.3-60-g2f50