Skip to content

Commit

Permalink
can now set int and float options refs #457
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/behr_mi/git/sumo_synched/trunk@18821 afbd958f-9f77-42d5-a016-97a22340ccf4
  • Loading branch information
namdre committed Sep 10, 2015
1 parent d98da18 commit 792b270
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
53 changes: 52 additions & 1 deletion sumo/src/netedit/GNEDialog_Wizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <utils/options/OptionsCont.h>
#include <utils/gui/images/GUIIconSubSys.h>
#include <utils/gui/windows/GUIAppEnum.h>
#include <utils/common/ToString.h>
#include "GNEDialog_Wizard.h"

#ifdef CHECK_MEMORY_LEAKS
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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;
}


/****************************************************************************/
32 changes: 32 additions & 0 deletions sumo/src/netedit/GNEDialog_Wizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};


};


Expand Down

0 comments on commit 792b270

Please sign in to comment.