20
20
21
21
#include < netedit/changes/GNEChange_Attribute.h>
22
22
#include < netedit/dialogs/basic/GNEWarningBasicDialog.h>
23
+ #include < netedit/dialogs/GNEColorDialog.h>
24
+ #include < netedit/dialogs/GNEVClassesDialog.h>
23
25
#include < netedit/GNEApplicationWindow.h>
24
26
#include < netedit/GNENet.h>
25
27
#include < netedit/GNEUndoList.h>
34
36
// ===========================================================================
35
37
36
38
FXDEFMAP (GNEAttributeCarrierDialog::AttributeTextField) AttributeTextFieldMap[] = {
37
- FXMAPFUNC (SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNEAttributeCarrierDialog::AttributeTextField::onCmdSetAttribute),
38
- FXMAPFUNC (SEL_COMMAND, MID_GNE_SET_ATTRIBUTE_BOOL, GNEAttributeCarrierDialog::AttributeTextField::onCmdSetBoolAttribute),
39
+ FXMAPFUNC (SEL_COMMAND, MID_GNE_ATTRIBUTESEDITORROW_SETATTRIBUTE, GNEAttributeCarrierDialog::AttributeTextField::onCmdSetAttribute),
40
+ FXMAPFUNC (SEL_COMMAND, MID_GNE_ATTRIBUTESEDITORROW_OPENDIALOG_COLOR, GNEAttributeCarrierDialog::AttributeTextField::onCmdOpenColorDialog),
41
+ FXMAPFUNC (SEL_COMMAND, MID_GNE_ATTRIBUTESEDITORROW_OPENDIALOG_ALLOW, GNEAttributeCarrierDialog::AttributeTextField::onCmdOpenVClassDialog),
39
42
};
40
43
41
44
// Object implementation
@@ -52,14 +55,27 @@ FXIMPLEMENT(GNEAttributeCarrierDialog::AttributeTextField, FXHorizontalFrame, At
52
55
GNEAttributeCarrierDialog::AttributeTextField::AttributeTextField(GNEAttributeCarrierDialog* ACDialog, FXVerticalFrame* verticalFrame,
53
56
const GNEAttributeProperties* attrProperty) :
54
57
FXHorizontalFrame(verticalFrame, GUIDesignAuxiliarHorizontalFrame),
55
- myACDialog (ACDialog),
58
+ myACDialogParent (ACDialog),
56
59
myAttrProperty(attrProperty) {
57
- // create label
58
- new FXLabel (this , attrProperty->getAttrStr ().c_str (), nullptr , GUIDesignLabelThickedFixed (100 ));
60
+ // get static tooltip menu
61
+ const auto tooltipMenu = ACDialog->getElement ()->getNet ()->getViewNet ()->getViewParent ()->getGNEAppWindows ()->getStaticTooltipMenu ();
62
+ // check if create button or label
63
+ if (attrProperty->isVClass () && (attrProperty->getAttr () != SUMO_ATTR_DISALLOW)) {
64
+ myAttributeButton = new MFXButtonTooltip (this , tooltipMenu, attrProperty->getAttrStr (), nullptr , this ,
65
+ MID_GNE_ATTRIBUTESEDITORROW_OPENDIALOG_ALLOW, GUIDesignButtonAttribute);
66
+ myAttributeButton->setTipText (TL (" Open dialog for editing vClasses" ));
67
+ } else if (attrProperty->isColor ()) {
68
+ myAttributeButton = new MFXButtonTooltip (this , tooltipMenu, attrProperty->getAttrStr (), GUIIconSubSys::getIcon (GUIIcon::COLORWHEEL), this ,
69
+ MID_GNE_ATTRIBUTESEDITORROW_OPENDIALOG_COLOR, GUIDesignButtonAttribute);
70
+ myAttributeButton->setTipText (TL (" Open dialog for editing color" ));
71
+ } else {
72
+ // create label
73
+ new FXLabel (this , attrProperty->getAttrStr ().c_str (), nullptr , GUIDesignLabelThickedFixed (100 ));
74
+ }
59
75
// continue depending of attr type
60
76
if (attrProperty->isBool ()) {
61
77
// create lef boolean checkBox for enable/disable attributes
62
- myCheckButton = new FXCheckButton (this , " bool" , this , MID_GNE_SET_ATTRIBUTE_BOOL, GUIDesignCheckButtonAttribute );
78
+ myCheckButton = new FXCheckButton (this , " bool" , this , MID_GNE_ATTRIBUTESEDITORROW_SETATTRIBUTE, GUIDesignCheckButton );
63
79
// continue depending of current value
64
80
if (ACDialog->getElement ()->getAttribute (attrProperty->getAttr ()) == GNEAttributeCarrier::TRUE_STR) {
65
81
myCheckButton->setCheck (TRUE );
@@ -70,45 +86,74 @@ GNEAttributeCarrierDialog::AttributeTextField::AttributeTextField(GNEAttributeCa
70
86
}
71
87
} else {
72
88
// create text field
73
- myTextField = new MFXTextFieldTooltip (this , ACDialog->getElement ()->getNet ()->getViewNet ()->getViewParent ()->getGNEAppWindows ()->getStaticTooltipMenu (),
74
- GUIDesignTextFieldNCol, this , MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
89
+ myTextField = new MFXTextFieldTooltip (this , tooltipMenu, GUIDesignTextFieldNCol, this , MID_GNE_ATTRIBUTESEDITORROW_SETATTRIBUTE, GUIDesignTextField);
75
90
// set attribute
76
91
myTextField->setText (ACDialog->getElement ()->getAttribute (attrProperty->getAttr ()).c_str ());
77
92
}
78
93
}
79
94
80
95
81
96
long
82
- GNEAttributeCarrierDialog::AttributeTextField::onCmdSetAttribute (FXObject*, FXSelector, void *) {
83
- if (myACDialog->getElement ()->isValid (myAttrProperty->getAttr (), myTextField->getText ().text ())) {
84
- // set attribute
85
- myACDialog->getElement ()->setAttribute (myAttrProperty->getAttr (), myTextField->getText ().text (), myACDialog->getElement ()->getNet ()->getViewNet ()->getUndoList ());
86
- // set valid color and kill focus
87
- myTextField->setTextColor (GUIDesignTextColorBlack);
88
- myTextField->setBackColor (GUIDesignBackgroundColorWhite);
89
- myTextField->killFocus ();
90
- } else {
91
- // set invalid color
92
- myTextField->setTextColor (GUIDesignTextColorRed);
93
- // set background color
94
- if (myTextField->getText ().empty ()) {
95
- myTextField->setTextColor (GUIDesignBackgroundColorRed);
96
- } else {
97
+ GNEAttributeCarrierDialog::AttributeTextField::onCmdSetAttribute (FXObject* obj, FXSelector, void *) {
98
+ auto undoList = myACDialogParent->getElement ()->getNet ()->getViewNet ()->getUndoList ();
99
+ if (obj == myTextField) {
100
+ if (myACDialogParent->getElement ()->isValid (myAttrProperty->getAttr (), myTextField->getText ().text ())) {
101
+ // set attribute
102
+ myACDialogParent->getElement ()->setAttribute (myAttrProperty->getAttr (), myTextField->getText ().text (), undoList);
103
+ // set valid color and kill focus
104
+ myTextField->setTextColor (GUIDesignTextColorBlack);
97
105
myTextField->setBackColor (GUIDesignBackgroundColorWhite);
106
+ myTextField->killFocus ();
107
+ } else {
108
+ // set invalid color
109
+ myTextField->setTextColor (GUIDesignTextColorRed);
110
+ // set background color
111
+ if (myTextField->getText ().empty ()) {
112
+ myTextField->setTextColor (GUIDesignBackgroundColorRed);
113
+ } else {
114
+ myTextField->setBackColor (GUIDesignBackgroundColorWhite);
115
+ }
116
+ }
117
+ } else if (obj == myCheckButton) {
118
+ if (myCheckButton->getCheck () == TRUE ) {
119
+ myACDialogParent->getElement ()->setAttribute (myAttrProperty->getAttr (), GNEAttributeCarrier::TRUE_STR, undoList);
120
+ myCheckButton->setText (TL (" true" ));
121
+ } else {
122
+ myACDialogParent->getElement ()->setAttribute (myAttrProperty->getAttr (), GNEAttributeCarrier::FALSE_STR, undoList);
123
+ myCheckButton->setText (TL (" false" ));
98
124
}
99
125
}
100
126
return 1 ;
101
127
}
102
128
103
129
104
130
long
105
- GNEAttributeCarrierDialog::AttributeTextField::onCmdSetBoolAttribute (FXObject*, FXSelector, void *) {
106
- if (myCheckButton->getCheck () == TRUE ) {
107
- myACDialog->getElement ()->setAttribute (myAttrProperty->getAttr (), GNEAttributeCarrier::TRUE_STR, myACDialog->getElement ()->getNet ()->getViewNet ()->getUndoList ());
108
- myCheckButton->setText (TL (" true" ));
109
- } else {
110
- myACDialog->getElement ()->setAttribute (myAttrProperty->getAttr (), GNEAttributeCarrier::FALSE_STR, myACDialog->getElement ()->getNet ()->getViewNet ()->getUndoList ());
111
- myCheckButton->setText (TL (" false" ));
131
+ GNEAttributeCarrierDialog::AttributeTextField::onCmdOpenColorDialog (FXObject*, FXSelector, void *) {
132
+ RGBColor color = RGBColor::BLACK;
133
+ // If previous attribute wasn't correct, set black as default color
134
+ if (GNEAttributeCarrier::canParse<RGBColor>(myTextField->getText ().text ())) {
135
+ color = GNEAttributeCarrier::parse<RGBColor>(myTextField->getText ().text ());
136
+ } else if (myAttrProperty->hasDefaultValue ()) {
137
+ color = myAttrProperty->getDefaultColorValue ();
138
+ }
139
+ // declare colorDialog
140
+ const auto colorDialog = new GNEColorDialog (myACDialogParent->getApplicationWindow (), color);
141
+ // continue depending of result
142
+ if (colorDialog->getResult () == GNEDialog::Result::ACCEPT) {
143
+ myTextField->setText (toString (colorDialog->getColor ()).c_str (), TRUE );
144
+ }
145
+ return 1 ;
146
+ }
147
+
148
+
149
+ long
150
+ GNEAttributeCarrierDialog::AttributeTextField::onCmdOpenVClassDialog (FXObject*, FXSelector, void *) {
151
+ // declare allowVClassesDialog
152
+ const auto allowVClassesDialog = new GNEVClassesDialog (myACDialogParent->getApplicationWindow (), myAttrProperty->getAttr (),
153
+ myTextField->getText ().text ());
154
+ // continue depending of result
155
+ if (allowVClassesDialog->getResult () == GNEDialog::Result::ACCEPT) {
156
+ myTextField->setText (allowVClassesDialog->getModifiedVClasses ().c_str (), TRUE );
112
157
}
113
158
return 1 ;
114
159
}
0 commit comments