Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEOptionsDialogElements.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// A Dialog for setting options (see OptionsCont)
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
24#include <string>
25
26// ===========================================================================
27// class declaration
28// ===========================================================================
29
31
32// ===========================================================================
33// class definitions
34// ===========================================================================
35
37
38public:
39
41 class InputOption : public FXHorizontalFrame {
44
45 public:
47 InputOption(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
48 const std::string& name, const std::string& description, const std::string& defaultValue);
49
51 void adjustNameSize();
52
54 const std::string& getTopic() const;
55
57 const std::string getNameLower() const;
58
60 const std::string getDescriptionLower() const;
61
63 virtual void updateOption() = 0;
64
66 virtual void restoreOption() = 0;
67
69 virtual long onCmdSetOption(FXObject*, FXSelector, void*) = 0;
70
72 virtual long onCmdResetOption(FXObject*, FXSelector, void*) = 0;
73
75 long onUpdResetOption(FXObject*, FXSelector, void*);
76
77 protected:
79 FOX_CONSTRUCTOR(InputOption)
80
81
83
85 const std::string myTopic;
86
88 const std::string myName;
89
91 const std::string myDescription;
92
94 const std::string myDefaultValue;
95
97 FXHorizontalFrame* myContentFrame = nullptr;
98
99 private:
101 virtual std::string getValue() const = 0;
102
105
106 // @brief reset button
107 FXButton* myResetButton = nullptr;
108 };
109
112
113 public:
115 InputString(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
116 const std::string& name, const std::string& description, const std::string& defaultValue);
117
119 void updateOption();
120
122 void restoreOption();
123
125 long onCmdSetOption(FXObject*, FXSelector, void*);
126
128 long onCmdResetOption(FXObject*, FXSelector, void*);
129
130 private:
132 std::string getValue() const;
133
135 FXTextField* myStringTextField = nullptr;
136 };
137
140
141 public:
143 InputStringVector(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
144 const std::string& name, const std::string& description, const std::string& defaultValue);
145
147 void updateOption();
148
150 void restoreOption();
151
153 long onCmdSetOption(FXObject*, FXSelector, void*);
154
156 long onCmdResetOption(FXObject*, FXSelector, void*);
157
158 private:
160 std::string getValue() const;
161
163 FXTextField* myStringVectorTextField = nullptr;
164 };
165
167 class InputBool : public InputOption {
168
169 public:
171 InputBool(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
172 const std::string& name, const std::string& description, const std::string& defaultValue);
173
175 void updateOption();
176
178 void restoreOption();
179
181 long onCmdSetOption(FXObject*, FXSelector, void*);
182
184 long onCmdResetOption(FXObject*, FXSelector, void*);
185
186 private:
188 std::string getValue() const;
189
191 FXCheckButton* myCheckButton = nullptr;
192 };
193
195 class InputInt : public InputOption {
196
197 public:
199 InputInt(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
200 const std::string& name, const std::string& description, const std::string& defaultValue);
201
203 void updateOption();
204
206 void restoreOption();
207
209 long onCmdSetOption(FXObject*, FXSelector, void*);
210
212 long onCmdResetOption(FXObject*, FXSelector, void*);
213
214 private:
216 std::string getValue() const;
217
219 FXTextField* myIntTextField = nullptr;
220 };
221
224
225 public:
227 InputIntVector(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
228 const std::string& name, const std::string& description, const std::string& defaultValue);
229
231 void updateOption();
232
234 void restoreOption();
235
237 long onCmdSetOption(FXObject*, FXSelector, void*);
238
240 long onCmdResetOption(FXObject*, FXSelector, void*);
241
242 private:
244 std::string getValue() const;
245
247 FXTextField* myIntVectorTextField = nullptr;
248 };
249
251 class InputFloat : public InputOption {
252
253 public:
255 InputFloat(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
256 const std::string& name, const std::string& description, const std::string& defaultValue);
257
259 void updateOption();
260
262 void restoreOption();
263
265 long onCmdSetOption(FXObject*, FXSelector, void*);
266
268 long onCmdResetOption(FXObject*, FXSelector, void*);
269
270 private:
272 std::string getValue() const;
273
275 std::string parseFloat(const std::string& value) const;
276
278 FXTextField* myFloatTextField = nullptr;
279 };
280
282 class InputTime : public InputOption {
283
284 public:
286 InputTime(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
287 const std::string& name, const std::string& description, const std::string& defaultValue);
288
290 void updateOption();
291
293 void restoreOption();
294
296 long onCmdSetOption(FXObject*, FXSelector, void*);
297
299 long onCmdResetOption(FXObject*, FXSelector, void*);
300
301 private:
303 std::string getValue() const;
304
306 std::string parseTime(const std::string& value) const;
307
309 FXTextField* myTimeTextField = nullptr;
310 };
311
313 class InputFilename : public InputOption {
316
317 public:
319 InputFilename(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
320 const std::string& name, const std::string& description, const std::string& defaultValue);
321
323 void updateOption();
324
326 void restoreOption();
327
329 long onCmdOpenDialog(FXObject*, FXSelector, void*);
330
332 long onCmdSetOption(FXObject*, FXSelector, void*);
333
335 long onCmdResetOption(FXObject*, FXSelector, void*);
336
337 protected:
340
341 private:
343 std::string getValue() const;
344
346 FXButton* myOpenFilenameButton = nullptr;
347
349 FXTextField* myFilenameTextField = nullptr;
350 };
351};
virtual long onCmdResetOption(FXObject *, FXSelector, void *)=0
called when user press reset button
const std::string myDefaultValue
default value
GNEOptionsDialog * myGUIDialogOptions
FOX needs this.
const std::string & getTopic() const
get topic
const std::string getNameLower() const
get name (Lower)
long onUpdResetOption(FXObject *, FXSelector, void *)
update reset button
const std::string getDescriptionLower() const
get description (Lower)
MFXLabelTooltip * myNameLabel
tooltip label for name
virtual void restoreOption()=0
restore option (used for setting original options)
virtual void updateOption()=0
update option (used after load options)
virtual long onCmdSetOption(FXObject *, FXSelector, void *)=0
called when user set value in textField/button/checkBox
virtual std::string getValue() const =0
get value
FXHorizontalFrame * myContentFrame
content frame
Definition json.hpp:4471
every row value