summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/widgets/horizontcontainer.h3
-rw-r--r--src/gui/widgets/setupitem.cpp86
-rw-r--r--src/gui/widgets/setupitem.h29
-rw-r--r--src/gui/widgets/vertcontainer.cpp2
-rw-r--r--src/guichan/include/guichan/basiccontainer.hpp2
5 files changed, 119 insertions, 3 deletions
diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h
index 4a959190e..80014c171 100644
--- a/src/gui/widgets/horizontcontainer.h
+++ b/src/gui/widgets/horizontcontainer.h
@@ -41,8 +41,11 @@ class HorizontContainer : public Container, public gcn::WidgetListener
{
public:
HorizontContainer(int height, int spacing);
+
virtual void add(gcn::Widget *widget);
+
virtual void clear();
+
void widgetResized(const gcn::Event &event);
protected:
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);
+}
diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h
index 3396edea3..15d2d41ea 100644
--- a/src/gui/widgets/setupitem.h
+++ b/src/gui/widgets/setupitem.h
@@ -42,6 +42,7 @@
class CheckBox;
class Configuration;
class ContainerPlacer;
+class DropDown;
class EditDialog;
class HorizontContainer;
class IntTextField;
@@ -241,4 +242,32 @@ class SetupItemLabel : public SetupItem
bool mIsSeparator;
};
+class SetupItemDropDown : public SetupItem
+{
+ public:
+ SetupItemDropDown(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, gcn::ListModel *model,
+ bool mainConfig = true);
+
+ SetupItemDropDown(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, gcn::ListModel *model,
+ std::string def, bool mainConfig = true);
+
+ ~SetupItemDropDown();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ protected:
+ HorizontContainer *mHorizont;
+ Label *mLabel;
+ gcn::ListModel *mModel;
+ DropDown *mDropDown;
+};
+
#endif
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index d65274f20..ea6b4d520 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -49,7 +49,7 @@ void VertContainer::add(gcn::Widget *widget, bool resizable, int spacing)
widget->setPosition(mLeftSpacing, mNextY);
if (resizable)
{
- widget->setSize(getWidth() - mLeftSpacing, mVerticalItemSize);
+ widget->setSize(getWidth() - mLeftSpacing, mVerticalItemSize * 5);
mResizableWidgets.push_back(widget);
}
else if (widget->getHeight() > mVerticalItemSize)
diff --git a/src/guichan/include/guichan/basiccontainer.hpp b/src/guichan/include/guichan/basiccontainer.hpp
index b63b83cd8..998e1f601 100644
--- a/src/guichan/include/guichan/basiccontainer.hpp
+++ b/src/guichan/include/guichan/basiccontainer.hpp
@@ -132,7 +132,7 @@ namespace gcn
* @see remove, clear
*/
virtual void clear();
-
+
/**
* Draws the children widgets of the basic container.
*