diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-08-15 23:04:44 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-08-16 00:24:50 +0300 |
commit | b1f8a2eaab592b59b5946bdbe38f0d8f775cc434 (patch) | |
tree | 96d80ba45ad1ddaf5038d983b90365854efb4753 /src/gui/widgets/setupitem.cpp | |
parent | dec741233dc709950fe542bcd4f69b254b33eb80 (diff) | |
download | plus-b1f8a2eaab592b59b5946bdbe38f0d8f775cc434.tar.gz plus-b1f8a2eaab592b59b5946bdbe38f0d8f775cc434.tar.bz2 plus-b1f8a2eaab592b59b5946bdbe38f0d8f775cc434.tar.xz plus-b1f8a2eaab592b59b5946bdbe38f0d8f775cc434.zip |
Add drop down widget for setup pages.
Known issue: popup listbox drawed under other widgets.
Diffstat (limited to 'src/gui/widgets/setupitem.cpp')
-rw-r--r-- | src/gui/widgets/setupitem.cpp | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index fd2c937dc..698e133dd 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -28,6 +28,7 @@ #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" +#include "gui/widgets/dropdown.h" #include "gui/widgets/horizontcontainer.h" #include "gui/widgets/inttextfield.h" #include "gui/widgets/label.h" @@ -330,7 +331,6 @@ void SetupItemTextField::apply(std::string eventName) save(); } - SetupItemIntTextField::SetupItemIntTextField(std::string text, std::string description, std::string keyName, @@ -454,6 +454,8 @@ void SetupItemIntTextField::apply(std::string eventName) save(); } + + SetupItemLabel::SetupItemLabel(std::string text, std::string description, SetupTabScroll *parent, bool separator) : SetupItem(text, description, "", parent, "", "", true), @@ -505,3 +507,85 @@ void SetupItemLabel::action(const gcn::ActionEvent &event A_UNUSED) void SetupItemLabel::apply(std::string eventName A_UNUSED) { } + + +SetupItemDropDown::SetupItemDropDown(std::string text, + std::string description, + std::string keyName, + SetupTabScroll *parent, + std::string eventName, + gcn::ListModel *model, + bool mainConfig) : + SetupItem(text, description, keyName, parent, eventName, mainConfig), + mHorizont(0), + mLabel(0), + mModel(model), + mDropDown(0) +{ + mValueType = VSTR; + createControls(); +} + +SetupItemDropDown::SetupItemDropDown(std::string text, + std::string description, + std::string keyName, + SetupTabScroll *parent, + std::string eventName, + gcn::ListModel *model, + std::string def, + bool mainConfig) : + SetupItem(text, description, keyName, parent, eventName, def, mainConfig), + mHorizont(0), + mLabel(0), + mModel(model), + mDropDown(0) +{ + mValueType = VSTR; + createControls(); +} + +SetupItemDropDown::~SetupItemDropDown() +{ + mHorizont = 0; + mWidget = 0; + mModel = 0; + mDropDown = 0; + mLabel = 0; +} + +void SetupItemDropDown::createControls() +{ + load(); + mHorizont = new HorizontContainer(32, 2); + + mLabel = new Label(mText); + mDropDown = new DropDown(mModel); + mDropDown->setActionEventId(mEventName); + mDropDown->addActionListener(mParent); + + mWidget = mDropDown; +// mTextField->setWidth(50); + mHorizont->add(mLabel); + mHorizont->add(mDropDown); + + mParent->getContainer()->add(mHorizont, true, 4); + mParent->addControl(this); + mParent->addActionListener(this); + mWidget->addActionListener(this); +} + +void SetupItemDropDown::fromWidget() +{ + if (!mDropDown) + return; + + mValue = mDropDown->getSelectedString(); +} + +void SetupItemDropDown::toWidget() +{ + if (!mDropDown) + return; + + mDropDown->setSelectedString(mValue); +} |