Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/dialogs/options/GNEOptionsEditorRow.cpp
193833 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file GNEOptionsEditorRow.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date May 2023
17
///
18
// Row used in GNEOptionsEditor to edit options
19
/****************************************************************************/
20
#include <config.h>
21
22
#include <netedit/dialogs/GNEDialog.h>
23
#include <netedit/GNEApplicationWindow.h>
24
#include <utils/common/MsgHandler.h>
25
#include <utils/common/StringTokenizer.h>
26
#include <utils/foxtools/MFXLabelTooltip.h>
27
#include <utils/gui/div/GUIDesigns.h>
28
29
#include "GNEOptionsEditorRow.h"
30
#include "GNEOptionsEditor.h"
31
32
// ===========================================================================
33
// Defines
34
// ===========================================================================
35
36
#define MARGIN 4
37
#define MINNAMEWIDTH 200
38
39
// ===========================================================================
40
// FOX callback mapping
41
// ===========================================================================
42
43
FXDEFMAP(GNEOptionsEditorRow::OptionRow) OptionRowMap[] = {
44
FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNEOptionsEditorRow::OptionRow::onCmdSetOption),
45
FXMAPFUNC(SEL_COMMAND, MID_GNE_RESET, GNEOptionsEditorRow::OptionRow::onCmdResetOption),
46
};
47
48
FXDEFMAP(GNEOptionsEditorRow::OptionFilename) OptionFilenameMap[] = {
49
FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE_DIALOG, GNEOptionsEditorRow::OptionFilename::onCmdOpenDialog),
50
};
51
52
// Object implementation
53
FXIMPLEMENT_ABSTRACT(GNEOptionsEditorRow::OptionRow, FXHorizontalFrame, OptionRowMap, ARRAYNUMBER(OptionRowMap))
54
FXIMPLEMENT_ABSTRACT(GNEOptionsEditorRow::OptionFilename, GNEOptionsEditorRow::OptionRow, OptionFilenameMap, ARRAYNUMBER(OptionFilenameMap))
55
56
// ===========================================================================
57
// method definitions
58
// ===========================================================================
59
60
// ---------------------------------------------------------------------------
61
// GNEOptionsEditorRow::OptionRow - methods
62
// ---------------------------------------------------------------------------
63
64
GNEOptionsEditorRow::OptionRow::OptionRow(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
65
const std::string& name, const std::string& description, const std::string& defaultValue, const bool editable) :
66
FXHorizontalFrame(parent, GUIDesignAuxiliarHorizontalFrame),
67
myOptionsEditor(optionsEditor),
68
myTopic(topic),
69
myName(name),
70
myDescription(description),
71
myDefaultValue(defaultValue),
72
myEditable(editable) {
73
// build label with name (default width 150)
74
myNameLabel = new MFXLabelTooltip(this, myOptionsEditor->myDialog->getApplicationWindow()->getStaticTooltipMenu(),
75
name.c_str(), nullptr, GUIDesignLabelThickedFixed(MINNAMEWIDTH));
76
// set description as tooltip
77
myNameLabel->setTipText(description.c_str());
78
// create content frame
79
myContentFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
80
// Create reset button
81
myResetButton = GUIDesigns::buildFXButton(this, "", "", TL("Reset value"), GUIIconSubSys::getIcon(GUIIcon::RESET), this, MID_GNE_RESET, GUIDesignButtonIcon);
82
}
83
84
85
void
86
GNEOptionsEditorRow::OptionRow::adjustNameSize() {
87
const int nameWidth = myNameLabel->getFont()->getTextWidth(myNameLabel->getText().text(), myNameLabel->getText().length() + MARGIN);
88
if (nameWidth > MINNAMEWIDTH) {
89
myNameLabel->setWidth(nameWidth);
90
}
91
}
92
93
94
const std::string&
95
GNEOptionsEditorRow::OptionRow::getTopic() const {
96
return myTopic;
97
}
98
99
100
const std::string
101
GNEOptionsEditorRow::OptionRow::getNameLower() const {
102
return StringUtils::to_lower_case(myName);
103
}
104
105
106
const std::string
107
GNEOptionsEditorRow::OptionRow::getDescriptionLower() const {
108
return StringUtils::to_lower_case(myDescription);
109
}
110
111
112
void
113
GNEOptionsEditorRow::OptionRow::updateResetButton() {
114
if (getValue() != myDefaultValue) {
115
myResetButton->enable();
116
} else {
117
myResetButton->disable();
118
}
119
}
120
121
// ---------------------------------------------------------------------------
122
// GNEOptionsEditorRow::OptionString - methods
123
// ---------------------------------------------------------------------------
124
125
GNEOptionsEditorRow::OptionString::OptionString(GNEOptionsEditor* optionsEditor, FXComposite* parent,
126
const std::string& topic, const std::string& name, const std::string& description,
127
const std::string& defaultValue, const bool editable) :
128
OptionRow(optionsEditor, parent, topic, name, description, defaultValue, editable) {
129
myStringTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
130
myStringTextField->setText(myOptionsEditor->myOptionsContainer.getString(name).c_str());
131
if (!editable) {
132
myStringTextField->disable();
133
}
134
updateOption();
135
}
136
137
138
void
139
GNEOptionsEditorRow::OptionString::updateOption() {
140
myStringTextField->setText(myOptionsEditor->myOptionsContainer.getString(myName).c_str());
141
updateResetButton();
142
}
143
144
145
void
146
GNEOptionsEditorRow::OptionString::restoreOption() {
147
myStringTextField->setText(myOptionsEditor->myOriginalOptionsContainer.getString(myName).c_str());
148
onCmdSetOption(nullptr, 0, nullptr);
149
}
150
151
152
long
153
GNEOptionsEditorRow::OptionString::onCmdSetOption(FXObject*, FXSelector, void*) {
154
myOptionsEditor->myOptionsContainer.resetWritable();
155
myOptionsEditor->myOptionsContainer.set(myName, myStringTextField->getText().text());
156
myOptionsEditor->myOptionsModified = true;
157
updateResetButton();
158
return 1;
159
}
160
161
162
long
163
GNEOptionsEditorRow::OptionString::onCmdResetOption(FXObject*, FXSelector, void*) {
164
myStringTextField->setText(myDefaultValue.c_str());
165
updateResetButton();
166
return 1;
167
}
168
169
170
std::string
171
GNEOptionsEditorRow::OptionString::getValue() const {
172
return myStringTextField->getText().text();
173
}
174
175
176
GNEOptionsEditorRow::OptionStringVector::OptionStringVector(GNEOptionsEditor* optionsEditor, FXComposite* parent,
177
const std::string& topic, const std::string& name, const std::string& description,
178
const std::string& defaultValue, const bool editable) :
179
OptionRow(optionsEditor, parent, topic, name, description, defaultValue, editable) {
180
myStringVectorTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
181
if (!editable) {
182
myStringVectorTextField->disable();
183
}
184
updateOption();
185
}
186
187
188
void
189
GNEOptionsEditorRow::OptionStringVector::updateOption() {
190
myStringVectorTextField->setText(toString(myOptionsEditor->myOptionsContainer.getStringVector(myName)).c_str());
191
updateResetButton();
192
}
193
194
195
void
196
GNEOptionsEditorRow::OptionStringVector::restoreOption() {
197
myStringVectorTextField->setText(toString(myOptionsEditor->myOriginalOptionsContainer.getStringVector(myName)).c_str());
198
onCmdSetOption(nullptr, 0, nullptr);
199
}
200
201
202
long
203
GNEOptionsEditorRow::OptionStringVector::onCmdSetOption(FXObject*, FXSelector, void*) {
204
myOptionsEditor->myOptionsContainer.resetWritable();
205
myOptionsEditor->myOptionsContainer.set(myName, myStringVectorTextField->getText().text());
206
myOptionsEditor->myOptionsModified = true;
207
updateResetButton();
208
return 1;
209
}
210
211
212
long
213
GNEOptionsEditorRow::OptionStringVector::onCmdResetOption(FXObject*, FXSelector, void*) {
214
myStringVectorTextField->setText(myDefaultValue.c_str());
215
updateResetButton();
216
return 1;
217
}
218
219
220
std::string
221
GNEOptionsEditorRow::OptionStringVector::getValue() const {
222
return myStringVectorTextField->getText().text();
223
}
224
225
// ---------------------------------------------------------------------------
226
// GNEOptionsEditorRow::OptionBool - methods
227
// ---------------------------------------------------------------------------
228
229
GNEOptionsEditorRow::OptionBool::OptionBool(GNEOptionsEditor* optionsEditor, FXComposite* parent,
230
const std::string& topic, const std::string& name, const std::string& description,
231
const std::string& defaultValue, const bool editable) :
232
OptionRow(optionsEditor, parent, topic, name, description, defaultValue, editable) {
233
myCheckButton = new FXCheckButton(myContentFrame, "", this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);
234
if (!editable) {
235
myCheckButton->disable();
236
}
237
updateOption();
238
}
239
240
241
void
242
GNEOptionsEditorRow::OptionBool::updateOption() {
243
if (myOptionsEditor->myOptionsContainer.getBool(myName)) {
244
myCheckButton->setCheck(TRUE);
245
myCheckButton->setText(TL("true"));
246
} else {
247
myCheckButton->setCheck(FALSE);
248
myCheckButton->setText(TL("false"));
249
}
250
updateResetButton();
251
}
252
253
254
void
255
GNEOptionsEditorRow::OptionBool::restoreOption() {
256
if (myOptionsEditor->myOriginalOptionsContainer.getBool(myName)) {
257
myCheckButton->setCheck(TRUE);
258
myCheckButton->setText(TL("true"));
259
} else {
260
myCheckButton->setCheck(FALSE);
261
myCheckButton->setText(TL("false"));
262
}
263
onCmdSetOption(nullptr, 0, nullptr);
264
}
265
266
267
long
268
GNEOptionsEditorRow::OptionBool::onCmdSetOption(FXObject*, FXSelector, void*) {
269
myOptionsEditor->myOptionsContainer.resetWritable();
270
if (myCheckButton->getCheck()) {
271
myOptionsEditor->myOptionsContainer.set(myName, "true");
272
myCheckButton->setText(TL("true"));
273
} else {
274
myOptionsEditor->myOptionsContainer.set(myName, "false");
275
myCheckButton->setText(TL("false"));
276
}
277
myOptionsEditor->myOptionsModified = true;
278
// special checks for Debug flags
279
if ((myName == "gui-testing-debug") && myOptionsEditor->myOptionsContainer.isSet("gui-testing-debug")) {
280
MsgHandler::enableDebugMessages(myOptionsEditor->myOptionsContainer.getBool("gui-testing-debug"));
281
}
282
if ((myName == "gui-testing-debug-gl") && myOptionsEditor->myOptionsContainer.isSet("gui-testing-debug-gl")) {
283
MsgHandler::enableDebugGLMessages(myOptionsEditor->myOptionsContainer.getBool("gui-testing-debug-gl"));
284
}
285
updateResetButton();
286
return 1;
287
}
288
289
290
long
291
GNEOptionsEditorRow::OptionBool::onCmdResetOption(FXObject*, FXSelector, void*) {
292
if (myDefaultValue.empty()) {
293
myCheckButton->setCheck(FALSE);
294
myCheckButton->setText(TL("false"));
295
} else if (StringUtils::toBool(myDefaultValue)) {
296
myCheckButton->setCheck(TRUE);
297
myCheckButton->setText(TL("true"));
298
} else {
299
myCheckButton->setCheck(FALSE);
300
myCheckButton->setText(TL("false"));
301
}
302
updateResetButton();
303
return 1;
304
}
305
306
307
std::string
308
GNEOptionsEditorRow::OptionBool::getValue() const {
309
return myCheckButton->getCheck() ? "true" : "false";
310
}
311
312
// ---------------------------------------------------------------------------
313
// GNEOptionsEditorRow::OptionInt - methods
314
// ---------------------------------------------------------------------------
315
316
GNEOptionsEditorRow::OptionInt::OptionInt(GNEOptionsEditor* optionsEditor, FXComposite* parent,
317
const std::string& topic, const std::string& name, const std::string& description,
318
const std::string& defaultValue, const bool editable) :
319
OptionRow(optionsEditor, parent, topic, name, description, defaultValue, editable) {
320
myIntTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextFieldRestricted(TEXTFIELD_INTEGER));
321
if (!editable) {
322
myIntTextField->disable();
323
}
324
updateOption();
325
}
326
327
328
void
329
GNEOptionsEditorRow::OptionInt::updateOption() {
330
myIntTextField->setText(toString(myOptionsEditor->myOptionsContainer.getInt(myName)).c_str());
331
updateResetButton();
332
}
333
334
335
void
336
GNEOptionsEditorRow::OptionInt::restoreOption() {
337
myIntTextField->setText(toString(myOptionsEditor->myOriginalOptionsContainer.getInt(myName)).c_str());
338
onCmdSetOption(nullptr, 0, nullptr);
339
}
340
341
342
long
343
GNEOptionsEditorRow::OptionInt::onCmdSetOption(FXObject*, FXSelector, void*) {
344
if (myIntTextField->getText().empty()) {
345
myIntTextField->setText(myDefaultValue.c_str());
346
} else {
347
myOptionsEditor->myOptionsContainer.resetWritable();
348
myOptionsEditor->myOptionsContainer.set(myName, myIntTextField->getText().text());
349
myOptionsEditor->myOptionsModified = true;
350
}
351
updateResetButton();
352
return 1;
353
}
354
355
356
long
357
GNEOptionsEditorRow::OptionInt::onCmdResetOption(FXObject*, FXSelector, void*) {
358
myIntTextField->setText(myDefaultValue.c_str());
359
updateResetButton();
360
return 1;
361
}
362
363
364
std::string
365
GNEOptionsEditorRow::OptionInt::getValue() const {
366
return myIntTextField->getText().text();
367
}
368
369
// ---------------------------------------------------------------------------
370
// GNEOptionsEditorRow::OptionIntVector - methods
371
// ---------------------------------------------------------------------------
372
373
GNEOptionsEditorRow::OptionIntVector::OptionIntVector(GNEOptionsEditor* optionsEditor, FXComposite* parent,
374
const std::string& topic, const std::string& name, const std::string& description,
375
const std::string& defaultValue, const bool editable) :
376
OptionRow(optionsEditor, parent, topic, name, description, defaultValue, editable) {
377
myIntVectorTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
378
myIntVectorTextField->setText(toString(myOptionsEditor->myOptionsContainer.getIntVector(name)).c_str());
379
if (!editable) {
380
myIntVectorTextField->disable();
381
}
382
updateOption();
383
}
384
385
386
void
387
GNEOptionsEditorRow::OptionIntVector::updateOption() {
388
myIntVectorTextField->setText(toString(myOptionsEditor->myOptionsContainer.getIntVector(myName)).c_str());
389
updateResetButton();
390
}
391
392
393
void
394
GNEOptionsEditorRow::OptionIntVector::restoreOption() {
395
myIntVectorTextField->setText(toString(myOptionsEditor->myOriginalOptionsContainer.getIntVector(myName)).c_str());
396
onCmdSetOption(nullptr, 0, nullptr);
397
}
398
399
400
long
401
GNEOptionsEditorRow::OptionIntVector::onCmdSetOption(FXObject*, FXSelector, void*) {
402
try {
403
// check that int vector can be parsed
404
const auto intVector = StringTokenizer(myIntVectorTextField->getText().text()).getVector();
405
for (const auto& intValue : intVector) {
406
StringUtils::toInt(intValue);
407
}
408
myOptionsEditor->myOptionsContainer.resetWritable();
409
myOptionsEditor->myOptionsContainer.set(myName, myIntVectorTextField->getText().text());
410
myIntVectorTextField->setTextColor(GUIDesignTextColorBlack);
411
myOptionsEditor->myOptionsModified = true;
412
} catch (...) {
413
myIntVectorTextField->setTextColor(GUIDesignTextColorRed);
414
}
415
updateResetButton();
416
return 1;
417
}
418
419
420
long
421
GNEOptionsEditorRow::OptionIntVector::onCmdResetOption(FXObject*, FXSelector, void*) {
422
myIntVectorTextField->setText(myDefaultValue.c_str());
423
updateResetButton();
424
return 1;
425
}
426
427
428
std::string
429
GNEOptionsEditorRow::OptionIntVector::getValue() const {
430
return myIntVectorTextField->getText().text();
431
}
432
433
// ---------------------------------------------------------------------------
434
// GNEOptionsEditorRow::OptionFloat - methods
435
// ---------------------------------------------------------------------------
436
437
GNEOptionsEditorRow::OptionFloat::OptionFloat(GNEOptionsEditor* optionsEditor, FXComposite* parent,
438
const std::string& topic, const std::string& name, const std::string& description,
439
const std::string& defaultValue, const bool editable) :
440
OptionRow(optionsEditor, parent, topic, name, description, parseFloat(defaultValue), editable) {
441
myFloatTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextFieldRestricted(TEXTFIELD_REAL));
442
myFloatTextField->setText(toString(myOptionsEditor->myOptionsContainer.getFloat(name)).c_str());
443
if (!editable) {
444
myFloatTextField->disable();
445
}
446
updateOption();
447
}
448
449
450
void
451
GNEOptionsEditorRow::OptionFloat::updateOption() {
452
myFloatTextField->setText(toString(myOptionsEditor->myOptionsContainer.getFloat(myName)).c_str());
453
updateResetButton();
454
}
455
456
457
void
458
GNEOptionsEditorRow::OptionFloat::restoreOption() {
459
myFloatTextField->setText(toString(myOptionsEditor->myOriginalOptionsContainer.getFloat(myName)).c_str());
460
onCmdSetOption(nullptr, 0, nullptr);
461
}
462
463
464
long
465
GNEOptionsEditorRow::OptionFloat::onCmdSetOption(FXObject*, FXSelector, void*) {
466
// avoid empty values
467
if (myFloatTextField->getText().empty()) {
468
myFloatTextField->setText(myDefaultValue.c_str());
469
} else {
470
myOptionsEditor->myOptionsContainer.resetWritable();
471
myOptionsEditor->myOptionsContainer.set(myName, myFloatTextField->getText().text());
472
myOptionsEditor->myOptionsModified = true;
473
}
474
updateResetButton();
475
return 1;
476
}
477
478
479
long
480
GNEOptionsEditorRow::OptionFloat::onCmdResetOption(FXObject*, FXSelector, void*) {
481
myFloatTextField->setText(myDefaultValue.c_str());
482
updateResetButton();
483
return 1;
484
}
485
486
487
std::string
488
GNEOptionsEditorRow::OptionFloat::getValue() const {
489
return myFloatTextField->getText().text();
490
}
491
492
493
std::string
494
GNEOptionsEditorRow::OptionFloat::parseFloat(const std::string& value) const {
495
try {
496
return toString(StringUtils::toDouble(value));
497
} catch (...) {
498
return value;
499
}
500
}
501
502
// ---------------------------------------------------------------------------
503
// GNEOptionsEditorRow::OptionTime - methods
504
// ---------------------------------------------------------------------------
505
506
GNEOptionsEditorRow::OptionTime::OptionTime(GNEOptionsEditor* optionsEditor, FXComposite* parent,
507
const std::string& topic, const std::string& name, const std::string& description,
508
const std::string& defaultValue, const bool editable) :
509
OptionRow(optionsEditor, parent, topic, name, description, parseTime(defaultValue), editable) {
510
myTimeTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
511
myTimeTextField->setText(toString(myOptionsEditor->myOptionsContainer.getString(name)).c_str());
512
if (!editable) {
513
myTimeTextField->disable();
514
}
515
updateOption();
516
}
517
518
519
void
520
GNEOptionsEditorRow::OptionTime::updateOption() {
521
myTimeTextField->setText(toString(myOptionsEditor->myOptionsContainer.getString(myName)).c_str());
522
updateResetButton();
523
}
524
525
526
void
527
GNEOptionsEditorRow::OptionTime::restoreOption() {
528
myTimeTextField->setText(toString(myOptionsEditor->myOriginalOptionsContainer.getString(myName)).c_str());
529
onCmdSetOption(nullptr, 0, nullptr);
530
}
531
532
533
long
534
GNEOptionsEditorRow::OptionTime::onCmdSetOption(FXObject*, FXSelector, void*) {
535
// avoid empty values
536
if (myTimeTextField->getText().empty()) {
537
myTimeTextField->setText(myDefaultValue.c_str());
538
} else {
539
myOptionsEditor->myOptionsContainer.resetWritable();
540
myOptionsEditor->myOptionsContainer.set(myName, myTimeTextField->getText().text());
541
myOptionsEditor->myOptionsModified = true;
542
}
543
updateResetButton();
544
return 1;
545
}
546
547
548
long
549
GNEOptionsEditorRow::OptionTime::onCmdResetOption(FXObject*, FXSelector, void*) {
550
myTimeTextField->setText(myDefaultValue.c_str());
551
updateResetButton();
552
return 1;
553
}
554
555
556
std::string
557
GNEOptionsEditorRow::OptionTime::getValue() const {
558
return myTimeTextField->getText().text();
559
}
560
561
562
std::string
563
GNEOptionsEditorRow::OptionTime::parseTime(const std::string& value) const {
564
try {
565
return time2string(string2time(value));
566
} catch (...) {
567
return value;
568
}
569
}
570
571
// ---------------------------------------------------------------------------
572
// GNEOptionsEditorRow::OptionFilename - methods
573
// ---------------------------------------------------------------------------
574
575
GNEOptionsEditorRow::OptionFilename::OptionFilename(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
576
const std::string& name, const std::string& description, const std::string& defaultValue, const bool editable) :
577
OptionRow(optionsEditor, parent, topic, name, description, defaultValue, editable) {
578
myOpenFilenameButton = GUIDesigns::buildFXButton(myContentFrame, "", "", TL("Select filename"),
579
GUIIconSubSys::getIcon(GUIIcon::OPEN), this, MID_GNE_SET_ATTRIBUTE_DIALOG, GUIDesignButtonIcon);
580
myFilenameTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
581
if (!editable) {
582
myOpenFilenameButton->disable();
583
myFilenameTextField->disable();
584
}
585
updateOption();
586
}
587
588
589
void
590
GNEOptionsEditorRow::OptionFilename::updateOption() {
591
myFilenameTextField->setText(myOptionsEditor->myOptionsContainer.getString(myName).c_str());
592
updateResetButton();
593
}
594
595
596
void
597
GNEOptionsEditorRow::OptionFilename::restoreOption() {
598
myFilenameTextField->setText(myOptionsEditor->myOriginalOptionsContainer.getString(myName).c_str());
599
onCmdSetOption(nullptr, 0, nullptr);
600
}
601
602
603
long
604
GNEOptionsEditorRow::OptionFilename::onCmdOpenDialog(FXObject*, FXSelector, void*) {
605
// get open mode
606
GNEFileDialog::OpenMode openMode = (myName.find("output") != std::string::npos) ? GNEFileDialog::OpenMode::SAVE : GNEFileDialog::OpenMode::LOAD_SINGLE;
607
// open dialog
608
const GNEFileDialog XMLFileDialog(myOptionsEditor->myDialog->getApplicationWindow(), myOptionsEditor->myDialog,
609
TL("XML file"),
610
SUMOXMLDefinitions::XMLFileExtensions.getStrings(), openMode,
611
GNEFileDialog::ConfigType::NETEDIT);
612
// check that file is valid
613
if (XMLFileDialog.getResult() == GNEDialog::Result::ACCEPT) {
614
myFilenameTextField->setText(XMLFileDialog.getFilename().c_str(), TRUE);
615
}
616
updateResetButton();
617
return 1;
618
}
619
620
621
long
622
GNEOptionsEditorRow::OptionFilename::onCmdSetOption(FXObject*, FXSelector, void*) {
623
if (SUMOXMLDefinitions::isValidFilename(myFilenameTextField->getText().text())) {
624
myOptionsEditor->myOptionsContainer.resetWritable();
625
myOptionsEditor->myOptionsContainer.set(myName, myFilenameTextField->getText().text());
626
myFilenameTextField->setTextColor(GUIDesignTextColorBlack);
627
myOptionsEditor->myOptionsModified = true;
628
} else {
629
myFilenameTextField->setTextColor(GUIDesignTextColorRed);
630
}
631
updateResetButton();
632
return 1;
633
}
634
635
636
long
637
GNEOptionsEditorRow::OptionFilename::onCmdResetOption(FXObject*, FXSelector, void*) {
638
myFilenameTextField->setText(myDefaultValue.c_str());
639
updateResetButton();
640
return 1;
641
}
642
643
644
GNEOptionsEditorRow::OptionFilename::OptionFilename() {}
645
646
647
std::string
648
GNEOptionsEditorRow::OptionFilename::getValue() const {
649
return myFilenameTextField->getText().text();
650
}
651
652
/****************************************************************************/
653
654