diff --git a/sumo/src/netedit/GNEDialog_Wizard.cpp b/sumo/src/netedit/GNEDialog_Wizard.cpp index d1f82906a874..ec0f742c705f 100644 --- a/sumo/src/netedit/GNEDialog_Wizard.cpp +++ b/sumo/src/netedit/GNEDialog_Wizard.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "GNEDialog_Wizard.h" #ifdef CHECK_MEMORY_LEAKS @@ -51,10 +52,18 @@ FXDEFMAP(GNEDialog_Wizard::InputString) InputStringMap[] = { FXDEFMAP(GNEDialog_Wizard::InputBool) InputBoolMap[] = { FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNEDialog_Wizard::InputBool::onCmdSetOption), }; +FXDEFMAP(GNEDialog_Wizard::InputInt) InputIntMap[] = { + FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNEDialog_Wizard::InputInt::onCmdSetOption), +}; +FXDEFMAP(GNEDialog_Wizard::InputFloat) InputFloatMap[] = { + FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNEDialog_Wizard::InputFloat::onCmdSetOption), +}; // Object implementation FXIMPLEMENT(GNEDialog_Wizard::InputString, FXHorizontalFrame, InputStringMap, ARRAYNUMBER(InputStringMap)) FXIMPLEMENT(GNEDialog_Wizard::InputBool, FXHorizontalFrame, InputBoolMap, ARRAYNUMBER(InputBoolMap)) +FXIMPLEMENT(GNEDialog_Wizard::InputInt, FXHorizontalFrame, InputIntMap, ARRAYNUMBER(InputIntMap)) +FXIMPLEMENT(GNEDialog_Wizard::InputFloat, FXHorizontalFrame, InputFloatMap, ARRAYNUMBER(InputFloatMap)) // =========================================================================== // method definitions @@ -84,8 +93,12 @@ GNEDialog_Wizard::GNEDialog_Wizard(FXWindow* parent, const char* name, int widt new InputString(tabContent, name); } else if (type == "BOOL") { new InputBool(tabContent, name); + } else if (type == "INT") { + new InputInt(tabContent, name); + } else if (type == "FLOAT") { + new InputFloat(tabContent, name); } - // @todo types INT, FLOAT, (type INT[] is only used in microsim) + // @todo missing types (type INT[] is only used in microsim) } } @@ -137,4 +150,42 @@ GNEDialog_Wizard::InputBool::onCmdSetOption(FXObject*, FXSelector, void*) { } +GNEDialog_Wizard::InputInt::InputInt(FXComposite* parent, const std::string& name) : + FXHorizontalFrame(parent, LAYOUT_FILL_X), + myName(name) { + OptionsCont& oc = OptionsCont::getOptions(); + new FXLabel(this, name.c_str()); + myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_INTEGER | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2); + myTextField->setText(toString(oc.getInt(name)).c_str()); +} + + +long +GNEDialog_Wizard::InputInt::onCmdSetOption(FXObject*, FXSelector, void*) { + OptionsCont& oc = OptionsCont::getOptions(); + oc.resetWritable(); + oc.set(myName, myTextField->getText().text()); + return 1; +} + + +GNEDialog_Wizard::InputFloat::InputFloat(FXComposite* parent, const std::string& name) : + FXHorizontalFrame(parent, LAYOUT_FILL_X), + myName(name) { + OptionsCont& oc = OptionsCont::getOptions(); + new FXLabel(this, name.c_str()); + myTextField = new FXTextField(this, 100, this, MID_GNE_SET_ATTRIBUTE, TEXTFIELD_REAL | LAYOUT_RIGHT, 0, 0, 0, 0, 4, 2, 0, 2); + myTextField->setText(toString(oc.getFloat(name)).c_str()); +} + + +long +GNEDialog_Wizard::InputFloat::onCmdSetOption(FXObject*, FXSelector, void*) { + OptionsCont& oc = OptionsCont::getOptions(); + oc.resetWritable(); + oc.set(myName, myTextField->getText().text()); + return 1; +} + + /****************************************************************************/ diff --git a/sumo/src/netedit/GNEDialog_Wizard.h b/sumo/src/netedit/GNEDialog_Wizard.h index 925a7b148e4e..16544a140046 100644 --- a/sumo/src/netedit/GNEDialog_Wizard.h +++ b/sumo/src/netedit/GNEDialog_Wizard.h @@ -89,6 +89,38 @@ class GNEDialog_Wizard : public FXDialogBox { }; + class InputInt : public FXHorizontalFrame { + // FOX-declarations + FXDECLARE(GNEDialog_Wizard::InputInt) + public: + InputInt(FXComposite* parent, const std::string& name); + /// @brief try to set new attribute value + long onCmdSetOption(FXObject*, FXSelector, void*); + protected: + /// @brief FOX needs this + InputInt() {} + private: + std::string myName; + FXTextField* myTextField; + }; + + + class InputFloat : public FXHorizontalFrame { + // FOX-declarations + FXDECLARE(GNEDialog_Wizard::InputFloat) + public: + InputFloat(FXComposite* parent, const std::string& name); + /// @brief try to set new attribute value + long onCmdSetOption(FXObject*, FXSelector, void*); + protected: + /// @brief FOX needs this + InputFloat() {} + private: + std::string myName; + FXTextField* myTextField; + }; + + };