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);
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 void updateResetButton();
106
107 private:
109 virtual std::string getValue() const = 0;
110
113
114 // @brief reset button
115 FXButton* myResetButton = nullptr;
116 };
117
120
121 public:
123 OptionString(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
124 const std::string& name, const std::string& description, const std::string& defaultValue,
125 const bool editable);
126
128 void updateOption();
129
131 void restoreOption();
132
134 long onCmdSetOption(FXObject*, FXSelector, void*);
135
137 long onCmdResetOption(FXObject*, FXSelector, void*);
138
139 private:
141 std::string getValue() const;
142
144 FXTextField* myStringTextField = nullptr;
145 };
146
149
150 public:
152 OptionStringVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
153 const std::string& name, const std::string& description, const std::string& defaultValue,
154 const bool editable);
155
157 void updateOption();
158
160 void restoreOption();
161
163 long onCmdSetOption(FXObject*, FXSelector, void*);
164
166 long onCmdResetOption(FXObject*, FXSelector, void*);
167
168 private:
170 std::string getValue() const;
171
173 FXTextField* myStringVectorTextField = nullptr;
174 };
175
177 class OptionBool : public OptionRow {
178
179 public:
181 OptionBool(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
182 const std::string& name, const std::string& description, const std::string& defaultValue,
183 const bool editable);
184
186 void updateOption();
187
189 void restoreOption();
190
192 long onCmdSetOption(FXObject*, FXSelector, void*);
193
195 long onCmdResetOption(FXObject*, FXSelector, void*);
196
197 private:
199 std::string getValue() const;
200
202 FXCheckButton* myCheckButton = nullptr;
203 };
204
206 class OptionInt : public OptionRow {
207
208 public:
210 OptionInt(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
211 const std::string& name, const std::string& description, const std::string& defaultValue,
212 const bool editable);
213
215 void updateOption();
216
218 void restoreOption();
219
221 long onCmdSetOption(FXObject*, FXSelector, void*);
222
224 long onCmdResetOption(FXObject*, FXSelector, void*);
225
226 private:
228 std::string getValue() const;
229
231 FXTextField* myIntTextField = nullptr;
232 };
233
235 class OptionIntVector : public OptionRow {
236
237 public:
239 OptionIntVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
240 const std::string& name, const std::string& description, const std::string& defaultValue,
241 const bool editable);
242
244 void updateOption();
245
247 void restoreOption();
248
250 long onCmdSetOption(FXObject*, FXSelector, void*);
251
253 long onCmdResetOption(FXObject*, FXSelector, void*);
254
255 private:
257 std::string getValue() const;
258
260 FXTextField* myIntVectorTextField = nullptr;
261 };
262
264 class OptionFloat : public OptionRow {
265
266 public:
268 OptionFloat(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
269 const std::string& name, const std::string& description, const std::string& defaultValue,
270 const bool editable);
271
273 void updateOption();
274
276 void restoreOption();
277
279 long onCmdSetOption(FXObject*, FXSelector, void*);
280
282 long onCmdResetOption(FXObject*, FXSelector, void*);
283
284 private:
286 std::string getValue() const;
287
289 std::string parseFloat(const std::string& value) const;
290
292 FXTextField* myFloatTextField = nullptr;
293 };
294
296 class OptionTime : public OptionRow {
297
298 public:
300 OptionTime(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
301 const std::string& name, const std::string& description, const std::string& defaultValue,
302 const bool editable);
303
305 void updateOption();
306
308 void restoreOption();
309
311 long onCmdSetOption(FXObject*, FXSelector, void*);
312
314 long onCmdResetOption(FXObject*, FXSelector, void*);
315
316 private:
318 std::string getValue() const;
319
321 std::string parseTime(const std::string& value) const;
322
324 FXTextField* myTimeTextField = nullptr;
325 };
326
328 class OptionFilename : public OptionRow {
331
332 public:
334 OptionFilename(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
335 const std::string& name, const std::string& description, const std::string& defaultValue,
336 const bool editable);
337
339 void updateOption();
340
342 void restoreOption();
343
345 long onCmdOpenDialog(FXObject*, FXSelector, void*);
346
348 long onCmdSetOption(FXObject*, FXSelector, void*);
349
351 long onCmdResetOption(FXObject*, FXSelector, void*);
352
353 protected:
356
357 private:
359 std::string getValue() const;
360
362 FXButton* myOpenFilenameButton = nullptr;
363
365 FXTextField* myFilenameTextField = nullptr;
366 };
367};
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
virtual void updateOption()=0
update option (used after load options)
const std::string myDescription
description
Definition json.hpp:4471
every row value