Eclipse SUMO - Simulation of Urban MObility
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-2024 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 
30 class GNEOptionsDialog;
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
40 
41 public:
42 
44  class InputOption : public FXHorizontalFrame {
46  FXDECLARE_ABSTRACT(GNEOptionsDialogElements::InputOption)
47 
48  public:
50  InputOption(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
51  const std::string& name, const std::string& description, const std::string& defaultValue);
52 
54  void adjustNameSize();
55 
57  const std::string& getTopic() const;
58 
60  const std::string getNameLower() const;
61 
63  const std::string getDescriptionLower() const;
64 
66  virtual void updateOption() = 0;
67 
69  virtual void restoreOption() = 0;
70 
72  virtual long onCmdSetOption(FXObject*, FXSelector, void*) = 0;
73 
75  virtual long onCmdResetOption(FXObject*, FXSelector, void*) = 0;
76 
78  long onUpdResetOption(FXObject*, FXSelector, void*);
79 
80  protected:
82  FOX_CONSTRUCTOR(InputOption)
83 
84 
86 
88  const std::string myTopic;
89 
91  const std::string myName;
92 
94  const std::string myDescription;
95 
97  const std::string myDefaultValue;
98 
100  FXHorizontalFrame* myContentFrame = nullptr;
101 
102  private:
104  virtual std::string getValue() const = 0;
105 
108 
109  // @brief reset button
110  FXButton* myResetButton = nullptr;
111  };
112 
115 
116  public:
118  InputString(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
119  const std::string& name, const std::string& description, const std::string& defaultValue);
120 
122  void updateOption();
123 
125  void restoreOption();
126 
128  long onCmdSetOption(FXObject*, FXSelector, void*);
129 
131  long onCmdResetOption(FXObject*, FXSelector, void*);
132 
133  private:
135  std::string getValue() const;
136 
138  FXTextField* myStringTextField = nullptr;
139  };
140 
143 
144  public:
146  InputStringVector(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
147  const std::string& name, const std::string& description, const std::string& defaultValue);
148 
150  void updateOption();
151 
153  void restoreOption();
154 
156  long onCmdSetOption(FXObject*, FXSelector, void*);
157 
159  long onCmdResetOption(FXObject*, FXSelector, void*);
160 
161  private:
163  std::string getValue() const;
164 
166  FXTextField* myStringVectorTextField = nullptr;
167  };
168 
170  class InputBool : public InputOption {
171 
172  public:
174  InputBool(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
175  const std::string& name, const std::string& description, const std::string& defaultValue);
176 
178  void updateOption();
179 
181  void restoreOption();
182 
184  long onCmdSetOption(FXObject*, FXSelector, void*);
185 
187  long onCmdResetOption(FXObject*, FXSelector, void*);
188 
189  private:
191  std::string getValue() const;
192 
194  FXCheckButton* myCheckButton = nullptr;
195  };
196 
198  class InputInt : public InputOption {
199 
200  public:
202  InputInt(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
203  const std::string& name, const std::string& description, const std::string& defaultValue);
204 
206  void updateOption();
207 
209  void restoreOption();
210 
212  long onCmdSetOption(FXObject*, FXSelector, void*);
213 
215  long onCmdResetOption(FXObject*, FXSelector, void*);
216 
217  private:
219  std::string getValue() const;
220 
222  FXTextField* myIntTextField = nullptr;
223  };
224 
226  class InputIntVector : public InputOption {
227 
228  public:
230  InputIntVector(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
231  const std::string& name, const std::string& description, const std::string& defaultValue);
232 
234  void updateOption();
235 
237  void restoreOption();
238 
240  long onCmdSetOption(FXObject*, FXSelector, void*);
241 
243  long onCmdResetOption(FXObject*, FXSelector, void*);
244 
245  private:
247  std::string getValue() const;
248 
250  FXTextField* myIntVectorTextField = nullptr;
251  };
252 
254  class InputFloat : public InputOption {
255 
256  public:
258  InputFloat(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
259  const std::string& name, const std::string& description, const std::string& defaultValue);
260 
262  void updateOption();
263 
265  void restoreOption();
266 
268  long onCmdSetOption(FXObject*, FXSelector, void*);
269 
271  long onCmdResetOption(FXObject*, FXSelector, void*);
272 
273  private:
275  std::string getValue() const;
276 
278  std::string parseFloat(const std::string& value) const;
279 
281  FXTextField* myFloatTextField = nullptr;
282  };
283 
285  class InputTime : public InputOption {
286 
287  public:
289  InputTime(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
290  const std::string& name, const std::string& description, const std::string& defaultValue);
291 
293  void updateOption();
294 
296  void restoreOption();
297 
299  long onCmdSetOption(FXObject*, FXSelector, void*);
300 
302  long onCmdResetOption(FXObject*, FXSelector, void*);
303 
304  private:
306  std::string getValue() const;
307 
309  std::string parseTime(const std::string& value) const;
310 
312  FXTextField* myTimeTextField = nullptr;
313  };
314 
316  class InputFilename : public InputOption {
319 
320  public:
322  InputFilename(GNEOptionsDialog* GUIDialogOptions, FXComposite* parent, const std::string& topic,
323  const std::string& name, const std::string& description, const std::string& defaultValue);
324 
326  void updateOption();
327 
329  void restoreOption();
330 
332  long onCmdOpenDialog(FXObject*, FXSelector, void*);
333 
335  long onCmdSetOption(FXObject*, FXSelector, void*);
336 
338  long onCmdResetOption(FXObject*, FXSelector, void*);
339 
340  protected:
342  InputFilename();
343 
344  private:
346  std::string getValue() const;
347 
349  FXButton* myOpenFilenameButton = nullptr;
350 
352  FXTextField* myFilenameTextField = nullptr;
353  };
354 };
virtual long onCmdResetOption(FXObject *, FXSelector, void *)=0
called when user press reset button
const std::string myDescription
description
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
InputOption(GNEOptionsDialog *GUIDialogOptions, FXComposite *parent, const std::string &topic, const std::string &name, const std::string &description, const std::string &defaultValue)
FOX-declaration.
FXHorizontalFrame * myContentFrame
content frame
Definition: json.hpp:4471
every row value