Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEOptionsEditorRow.h
Go to the documentation of this file.
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/****************************************************************************/
18// Row used in GNEOptionsEditor to edit options
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
23#include <string>
25
26// ===========================================================================
27// class declaration
28// ===========================================================================
29
31class MFXLabelTooltip;
32
33// ===========================================================================
34// class definitions
35// ===========================================================================
36
38
39public:
40
42 class OptionRow : public FXHorizontalFrame {
44 FXDECLARE_ABSTRACT(GNEOptionsEditorRow::OptionRow)
45
46 public:
48 OptionRow(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
49 const std::string& name, const std::string& description, const std::string& defaultValue,
50 const bool editable, const bool requireSaveNetwork);
51
53 void adjustNameSize();
54
56 const std::string& getTopic() const;
57
59 const std::string getNameLower() const;
60
62 const std::string getDescriptionLower() const;
63
65 bool isEditable() const;
66
68 virtual void updateOption() = 0;
69
71 virtual void restoreOption() = 0;
72
74 virtual long onCmdSetOption(FXObject*, FXSelector, void*) = 0;
75
77 virtual long onCmdResetOption(FXObject*, FXSelector, void*) = 0;
78
79 protected:
81 FOX_CONSTRUCTOR(OptionRow)
82
83
85
87 const std::string myTopic;
88
90 const std::string myName;
91
93 const std::string myDescription;
94
96 const std::string myDefaultValue;
97
99 FXHorizontalFrame* myContentFrame = nullptr;
100
102 const bool myEditable = true;
103
105 const bool myRequireSaveNetwork = false;
106
108 void updateResetButton();
109
110 private:
112 virtual std::string getValue() const = 0;
113
116
117 // @brief reset button
118 FXButton* myResetButton = nullptr;
119 };
120
123
124 public:
126 OptionString(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
127 const std::string& name, const std::string& description, const std::string& defaultValue,
128 const bool editable, const bool requireSaveNetwork);
129
131 void updateOption();
132
134 void restoreOption();
135
137 long onCmdSetOption(FXObject*, FXSelector, void*);
138
140 long onCmdResetOption(FXObject*, FXSelector, void*);
141
142 private:
144 std::string getValue() const;
145
147 FXTextField* myStringTextField = nullptr;
148 };
149
152
153 public:
155 OptionStringVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
156 const std::string& name, const std::string& description, const std::string& defaultValue,
157 const bool editable, const bool requireSaveNetwork);
158
160 void updateOption();
161
163 void restoreOption();
164
166 long onCmdSetOption(FXObject*, FXSelector, void*);
167
169 long onCmdResetOption(FXObject*, FXSelector, void*);
170
171 private:
173 std::string getValue() const;
174
176 FXTextField* myStringVectorTextField = nullptr;
177 };
178
180 class OptionBool : public OptionRow {
181
182 public:
184 OptionBool(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
185 const std::string& name, const std::string& description, const std::string& defaultValue,
186 const bool editable, const bool requireSaveNetwork);
187
189 void updateOption();
190
192 void restoreOption();
193
195 long onCmdSetOption(FXObject*, FXSelector, void*);
196
198 long onCmdResetOption(FXObject*, FXSelector, void*);
199
200 private:
202 std::string getValue() const;
203
205 FXCheckButton* myCheckButton = nullptr;
206 };
207
209 class OptionInt : public OptionRow {
210
211 public:
213 OptionInt(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
214 const std::string& name, const std::string& description, const std::string& defaultValue,
215 const bool editable, const bool requireSaveNetwork);
216
218 void updateOption();
219
221 void restoreOption();
222
224 long onCmdSetOption(FXObject*, FXSelector, void*);
225
227 long onCmdResetOption(FXObject*, FXSelector, void*);
228
229 private:
231 std::string getValue() const;
232
234 FXTextField* myIntTextField = nullptr;
235 };
236
238 class OptionIntVector : public OptionRow {
239
240 public:
242 OptionIntVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
243 const std::string& name, const std::string& description, const std::string& defaultValue,
244 const bool editable, const bool requireSaveNetwork);
245
247 void updateOption();
248
250 void restoreOption();
251
253 long onCmdSetOption(FXObject*, FXSelector, void*);
254
256 long onCmdResetOption(FXObject*, FXSelector, void*);
257
258 private:
260 std::string getValue() const;
261
263 FXTextField* myIntVectorTextField = nullptr;
264 };
265
267 class OptionFloat : public OptionRow {
268
269 public:
271 OptionFloat(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
272 const std::string& name, const std::string& description, const std::string& defaultValue,
273 const bool editable, const bool requireSaveNetwork);
274
276 void updateOption();
277
279 void restoreOption();
280
282 long onCmdSetOption(FXObject*, FXSelector, void*);
283
285 long onCmdResetOption(FXObject*, FXSelector, void*);
286
287 private:
289 std::string getValue() const;
290
292 std::string parseFloat(const std::string& value) const;
293
295 FXTextField* myFloatTextField = nullptr;
296 };
297
299 class OptionTime : public OptionRow {
300
301 public:
303 OptionTime(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
304 const std::string& name, const std::string& description, const std::string& defaultValue,
305 const bool editable, const bool requireSaveNetwork);
306
308 void updateOption();
309
311 void restoreOption();
312
314 long onCmdSetOption(FXObject*, FXSelector, void*);
315
317 long onCmdResetOption(FXObject*, FXSelector, void*);
318
319 private:
321 std::string getValue() const;
322
324 std::string parseTime(const std::string& value) const;
325
327 FXTextField* myTimeTextField = nullptr;
328 };
329
331 class OptionFilename : public OptionRow {
334
335 public:
337 OptionFilename(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
338 const std::string& name, const std::string& description, const std::string& defaultValue,
339 const bool editable, const bool requireSaveNetwork);
340
342 void updateOption();
343
345 void restoreOption();
346
348 long onCmdOpenDialog(FXObject*, FXSelector, void*);
349
351 long onCmdSetOption(FXObject*, FXSelector, void*);
352
354 long onCmdResetOption(FXObject*, FXSelector, void*);
355
356 protected:
359
360 private:
362 std::string getValue() const;
363
365 FXButton* myOpenFilenameButton = nullptr;
366
368 FXTextField* myFilenameTextField = nullptr;
369 };
370};
GNEOptionsEditor * myOptionsEditor
FOX needs this.
const std::string myDefaultValue
default value
MFXLabelTooltip * myNameLabel
tooltip label for name
const std::string getDescriptionLower() const
get description (Lower)
const std::string & getTopic() const
get topic
void updateResetButton()
update reset button
bool isEditable() const
check if option is editable
virtual long onCmdSetOption(FXObject *, FXSelector, void *)=0
called when user set value in textField/button/checkBox
const std::string getNameLower() const
get name (Lower)
virtual std::string getValue() const =0
get value
FXHorizontalFrame * myContentFrame
content frame
void adjustNameSize()
adjust input name size
virtual void restoreOption()=0
restore option (used for setting original options)
virtual long onCmdResetOption(FXObject *, FXSelector, void *)=0
called when user press reset button
const bool myRequireSaveNetwork
require save network
virtual void updateOption()=0
update option (used after load options)
const std::string myDescription
description
Definition json.hpp:4471
every row value