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 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 virtual void updateOption() = 0;
66
68 virtual void restoreOption() = 0;
69
71 virtual long onCmdSetOption(FXObject*, FXSelector, void*) = 0;
72
74 virtual long onCmdResetOption(FXObject*, FXSelector, void*) = 0;
75
76 protected:
78 FOX_CONSTRUCTOR(OptionRow)
79
80
82
84 const std::string myTopic;
85
87 const std::string myName;
88
90 const std::string myDescription;
91
93 const std::string myDefaultValue;
94
96 FXHorizontalFrame* myContentFrame = nullptr;
97
99 const bool myEditable = true;
100
102 void updateResetButton();
103
104 private:
106 virtual std::string getValue() const = 0;
107
110
111 // @brief reset button
112 FXButton* myResetButton = nullptr;
113 };
114
117
118 public:
120 OptionString(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
121 const std::string& name, const std::string& description, const std::string& defaultValue,
122 const bool editable);
123
125 void updateOption();
126
128 void restoreOption();
129
131 long onCmdSetOption(FXObject*, FXSelector, void*);
132
134 long onCmdResetOption(FXObject*, FXSelector, void*);
135
136 private:
138 std::string getValue() const;
139
141 FXTextField* myStringTextField = nullptr;
142 };
143
146
147 public:
149 OptionStringVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
150 const std::string& name, const std::string& description, const std::string& defaultValue,
151 const bool editable);
152
154 void updateOption();
155
157 void restoreOption();
158
160 long onCmdSetOption(FXObject*, FXSelector, void*);
161
163 long onCmdResetOption(FXObject*, FXSelector, void*);
164
165 private:
167 std::string getValue() const;
168
170 FXTextField* myStringVectorTextField = nullptr;
171 };
172
174 class OptionBool : public OptionRow {
175
176 public:
178 OptionBool(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
179 const std::string& name, const std::string& description, const std::string& defaultValue,
180 const bool editable);
181
183 void updateOption();
184
186 void restoreOption();
187
189 long onCmdSetOption(FXObject*, FXSelector, void*);
190
192 long onCmdResetOption(FXObject*, FXSelector, void*);
193
194 private:
196 std::string getValue() const;
197
199 FXCheckButton* myCheckButton = nullptr;
200 };
201
203 class OptionInt : public OptionRow {
204
205 public:
207 OptionInt(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
208 const std::string& name, const std::string& description, const std::string& defaultValue,
209 const bool editable);
210
212 void updateOption();
213
215 void restoreOption();
216
218 long onCmdSetOption(FXObject*, FXSelector, void*);
219
221 long onCmdResetOption(FXObject*, FXSelector, void*);
222
223 private:
225 std::string getValue() const;
226
228 FXTextField* myIntTextField = nullptr;
229 };
230
232 class OptionIntVector : public OptionRow {
233
234 public:
236 OptionIntVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
237 const std::string& name, const std::string& description, const std::string& defaultValue,
238 const bool editable);
239
241 void updateOption();
242
244 void restoreOption();
245
247 long onCmdSetOption(FXObject*, FXSelector, void*);
248
250 long onCmdResetOption(FXObject*, FXSelector, void*);
251
252 private:
254 std::string getValue() const;
255
257 FXTextField* myIntVectorTextField = nullptr;
258 };
259
261 class OptionFloat : public OptionRow {
262
263 public:
265 OptionFloat(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
266 const std::string& name, const std::string& description, const std::string& defaultValue,
267 const bool editable);
268
270 void updateOption();
271
273 void restoreOption();
274
276 long onCmdSetOption(FXObject*, FXSelector, void*);
277
279 long onCmdResetOption(FXObject*, FXSelector, void*);
280
281 private:
283 std::string getValue() const;
284
286 std::string parseFloat(const std::string& value) const;
287
289 FXTextField* myFloatTextField = nullptr;
290 };
291
293 class OptionTime : public OptionRow {
294
295 public:
297 OptionTime(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
298 const std::string& name, const std::string& description, const std::string& defaultValue,
299 const bool editable);
300
302 void updateOption();
303
305 void restoreOption();
306
308 long onCmdSetOption(FXObject*, FXSelector, void*);
309
311 long onCmdResetOption(FXObject*, FXSelector, void*);
312
313 private:
315 std::string getValue() const;
316
318 std::string parseTime(const std::string& value) const;
319
321 FXTextField* myTimeTextField = nullptr;
322 };
323
325 class OptionFilename : public OptionRow {
328
329 public:
331 OptionFilename(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
332 const std::string& name, const std::string& description, const std::string& defaultValue,
333 const bool editable);
334
336 void updateOption();
337
339 void restoreOption();
340
342 long onCmdOpenDialog(FXObject*, FXSelector, void*);
343
345 long onCmdSetOption(FXObject*, FXSelector, void*);
346
348 long onCmdResetOption(FXObject*, FXSelector, void*);
349
350 protected:
353
354 private:
356 std::string getValue() const;
357
359 FXButton* myOpenFilenameButton = nullptr;
360
362 FXTextField* myFilenameTextField = nullptr;
363 };
364};
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