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-2025 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
52 void adjustNameSize();
53
55 const std::string& getTopic() const;
56
58 const std::string getNameLower() const;
59
61 const std::string getDescriptionLower() const;
62
64 virtual void updateOption() = 0;
65
67 virtual void restoreOption() = 0;
68
70 virtual long onCmdSetOption(FXObject*, FXSelector, void*) = 0;
71
73 virtual long onCmdResetOption(FXObject*, FXSelector, void*) = 0;
74
75 protected:
77 FOX_CONSTRUCTOR(OptionRow)
78
79
81
83 const std::string myTopic;
84
86 const std::string myName;
87
89 const std::string myDescription;
90
92 const std::string myDefaultValue;
93
95 FXHorizontalFrame* myContentFrame = nullptr;
96
98 void updateResetButton();
99
100 private:
102 virtual std::string getValue() const = 0;
103
106
107 // @brief reset button
108 FXButton* myResetButton = nullptr;
109 };
110
113
114 public:
116 OptionString(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
117 const std::string& name, const std::string& description, const std::string& defaultValue);
118
120 void updateOption();
121
123 void restoreOption();
124
126 long onCmdSetOption(FXObject*, FXSelector, void*);
127
129 long onCmdResetOption(FXObject*, FXSelector, void*);
130
131 private:
133 std::string getValue() const;
134
136 FXTextField* myStringTextField = nullptr;
137 };
138
141
142 public:
144 OptionStringVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
145 const std::string& name, const std::string& description, const std::string& defaultValue);
146
148 void updateOption();
149
151 void restoreOption();
152
154 long onCmdSetOption(FXObject*, FXSelector, void*);
155
157 long onCmdResetOption(FXObject*, FXSelector, void*);
158
159 private:
161 std::string getValue() const;
162
164 FXTextField* myStringVectorTextField = nullptr;
165 };
166
168 class OptionBool : public OptionRow {
169
170 public:
172 OptionBool(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
173 const std::string& name, const std::string& description, const std::string& defaultValue);
174
176 void updateOption();
177
179 void restoreOption();
180
182 long onCmdSetOption(FXObject*, FXSelector, void*);
183
185 long onCmdResetOption(FXObject*, FXSelector, void*);
186
187 private:
189 std::string getValue() const;
190
192 FXCheckButton* myCheckButton = nullptr;
193 };
194
196 class OptionInt : public OptionRow {
197
198 public:
200 OptionInt(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
201 const std::string& name, const std::string& description, const std::string& defaultValue);
202
204 void updateOption();
205
207 void restoreOption();
208
210 long onCmdSetOption(FXObject*, FXSelector, void*);
211
213 long onCmdResetOption(FXObject*, FXSelector, void*);
214
215 private:
217 std::string getValue() const;
218
220 FXTextField* myIntTextField = nullptr;
221 };
222
224 class OptionIntVector : public OptionRow {
225
226 public:
228 OptionIntVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
229 const std::string& name, const std::string& description, const std::string& defaultValue);
230
232 void updateOption();
233
235 void restoreOption();
236
238 long onCmdSetOption(FXObject*, FXSelector, void*);
239
241 long onCmdResetOption(FXObject*, FXSelector, void*);
242
243 private:
245 std::string getValue() const;
246
248 FXTextField* myIntVectorTextField = nullptr;
249 };
250
252 class OptionFloat : public OptionRow {
253
254 public:
256 OptionFloat(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
257 const std::string& name, const std::string& description, const std::string& defaultValue);
258
260 void updateOption();
261
263 void restoreOption();
264
266 long onCmdSetOption(FXObject*, FXSelector, void*);
267
269 long onCmdResetOption(FXObject*, FXSelector, void*);
270
271 private:
273 std::string getValue() const;
274
276 std::string parseFloat(const std::string& value) const;
277
279 FXTextField* myFloatTextField = nullptr;
280 };
281
283 class OptionTime : public OptionRow {
284
285 public:
287 OptionTime(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
288 const std::string& name, const std::string& description, const std::string& defaultValue);
289
291 void updateOption();
292
294 void restoreOption();
295
297 long onCmdSetOption(FXObject*, FXSelector, void*);
298
300 long onCmdResetOption(FXObject*, FXSelector, void*);
301
302 private:
304 std::string getValue() const;
305
307 std::string parseTime(const std::string& value) const;
308
310 FXTextField* myTimeTextField = nullptr;
311 };
312
314 class OptionFilename : public OptionRow {
317
318 public:
320 OptionFilename(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
321 const std::string& name, const std::string& description, const std::string& defaultValue);
322
324 void updateOption();
325
327 void restoreOption();
328
330 long onCmdOpenDialog(FXObject*, FXSelector, void*);
331
333 long onCmdSetOption(FXObject*, FXSelector, void*);
334
336 long onCmdResetOption(FXObject*, FXSelector, void*);
337
338 protected:
341
342 private:
344 std::string getValue() const;
345
347 FXButton* myOpenFilenameButton = nullptr;
348
350 FXTextField* myFilenameTextField = nullptr;
351 };
352};
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
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
virtual void updateOption()=0
update option (used after load options)
const std::string myDescription
description
Definition json.hpp:4471
every row value