Path: blob/main/src/netedit/dialogs/options/GNEOptionsEditorRow.h
169684 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GNEOptionsEditorRow.h14/// @author Pablo Alvarez Lopez15/// @date May 202316///17// Row used in GNEOptionsEditor to edit options18/****************************************************************************/19#pragma once20#include <config.h>2122#include <string>23#include <utils/foxtools/fxheader.h>2425// ===========================================================================26// class declaration27// ===========================================================================2829class GNEOptionsEditor;30class MFXLabelTooltip;3132// ===========================================================================33// class definitions34// ===========================================================================3536class GNEOptionsEditorRow {3738public:3940/// @brief input option41class OptionRow : public FXHorizontalFrame {42/// @brief FOX-declaration43FXDECLARE_ABSTRACT(GNEOptionsEditorRow::OptionRow)4445public:46/// @brief constructor47OptionRow(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,48const std::string& name, const std::string& description, const std::string& defaultValue);4950/// @brief adjust input name size51void adjustNameSize();5253/// @brief get topic54const std::string& getTopic() const;5556/// @brief get name (Lower)57const std::string getNameLower() const;5859/// @brief get description (Lower)60const std::string getDescriptionLower() const;6162/// @brief update option (used after load options)63virtual void updateOption() = 0;6465/// @brief restore option (used for setting original options)66virtual void restoreOption() = 0;6768/// @brief called when user set value in textField/button/checkBox69virtual long onCmdSetOption(FXObject*, FXSelector, void*) = 0;7071/// @brief called when user press reset button72virtual long onCmdResetOption(FXObject*, FXSelector, void*) = 0;7374protected:75/// @brief FOX needs this76FOX_CONSTRUCTOR(OptionRow)7778/// @brief GNEOptionsEditor parent79GNEOptionsEditor* myOptionsEditor = nullptr;8081/// @brief topic82const std::string myTopic;8384/// @brief name85const std::string myName;8687/// @brief description88const std::string myDescription;8990/// @brief default value91const std::string myDefaultValue;9293/// @brief content frame94FXHorizontalFrame* myContentFrame = nullptr;9596/// @brief update reset button97void updateResetButton();9899private:100/// @brief get value101virtual std::string getValue() const = 0;102103/// @brief tooltip label for name104MFXLabelTooltip* myNameLabel = nullptr;105106// @brief reset button107FXButton* myResetButton = nullptr;108};109110/// @brief input string111class OptionString : public OptionRow {112113public:114/// @brief constructor115OptionString(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,116const std::string& name, const std::string& description, const std::string& defaultValue);117118/// @brief update option119void updateOption();120121/// @brief restore option122void restoreOption();123124/// @brief called when user set value in textField/button/checkBox125long onCmdSetOption(FXObject*, FXSelector, void*);126127/// @brief called when user press reset button128long onCmdResetOption(FXObject*, FXSelector, void*);129130private:131/// @brief get value132std::string getValue() const;133134/// @brief text field135FXTextField* myStringTextField = nullptr;136};137138/// @brief input string vector139class OptionStringVector : public OptionRow {140141public:142/// @brief constructor143OptionStringVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,144const std::string& name, const std::string& description, const std::string& defaultValue);145146/// @brief update option147void updateOption();148149/// @brief restore option150void restoreOption();151152/// @brief called when user set value in textField/button/checkBox153long onCmdSetOption(FXObject*, FXSelector, void*);154155/// @brief called when user press reset button156long onCmdResetOption(FXObject*, FXSelector, void*);157158private:159/// @brief get value160std::string getValue() const;161162/// @brief text field163FXTextField* myStringVectorTextField = nullptr;164};165166/// @brief input bool167class OptionBool : public OptionRow {168169public:170/// @brief constructor171OptionBool(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,172const std::string& name, const std::string& description, const std::string& defaultValue);173174/// @brief update option175void updateOption();176177/// @brief restore option178void restoreOption();179180/// @brief called when user set value in textField/button/checkBox181long onCmdSetOption(FXObject*, FXSelector, void*);182183/// @brief called when user press reset button184long onCmdResetOption(FXObject*, FXSelector, void*);185186private:187/// @brief get value188std::string getValue() const;189190/// @brief menu check191FXCheckButton* myCheckButton = nullptr;192};193194/// @brief input int195class OptionInt : public OptionRow {196197public:198/// @brief199OptionInt(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,200const std::string& name, const std::string& description, const std::string& defaultValue);201202/// @brief update option203void updateOption();204205/// @brief restore option206void restoreOption();207208/// @brief called when user set value in textField/button/checkBox209long onCmdSetOption(FXObject*, FXSelector, void*);210211/// @brief called when user press reset button212long onCmdResetOption(FXObject*, FXSelector, void*);213214private:215/// @brief get value216std::string getValue() const;217218/// @brief text field219FXTextField* myIntTextField = nullptr;220};221222/// @brief input int vector223class OptionIntVector : public OptionRow {224225public:226/// @brief227OptionIntVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,228const std::string& name, const std::string& description, const std::string& defaultValue);229230/// @brief update option231void updateOption();232233/// @brief restore option234void restoreOption();235236/// @brief called when user set value in textField/button/checkBox237long onCmdSetOption(FXObject*, FXSelector, void*);238239/// @brief called when user press reset button240long onCmdResetOption(FXObject*, FXSelector, void*);241242private:243/// @brief get value244std::string getValue() const;245246/// @brief text field247FXTextField* myIntVectorTextField = nullptr;248};249250/// @brief input float251class OptionFloat : public OptionRow {252253public:254/// @brief constructor255OptionFloat(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,256const std::string& name, const std::string& description, const std::string& defaultValue);257258/// @brief update option259void updateOption();260261/// @brief restore option262void restoreOption();263264/// @brief called when user set value in textField/button/checkBox265long onCmdSetOption(FXObject*, FXSelector, void*);266267/// @brief called when user press reset button268long onCmdResetOption(FXObject*, FXSelector, void*);269270private:271/// @brief get value272std::string getValue() const;273274/// @brief parse float xx to xx.00275std::string parseFloat(const std::string& value) const;276277/// @brief text field278FXTextField* myFloatTextField = nullptr;279};280281/// @brief input float282class OptionTime : public OptionRow {283284public:285/// @brief constructor286OptionTime(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,287const std::string& name, const std::string& description, const std::string& defaultValue);288289/// @brief update option290void updateOption();291292/// @brief restore option293void restoreOption();294295/// @brief called when user set value in textField/button/checkBox296long onCmdSetOption(FXObject*, FXSelector, void*);297298/// @brief called when user press reset button299long onCmdResetOption(FXObject*, FXSelector, void*);300301private:302/// @brief get value303std::string getValue() const;304305/// @brief parse float xx to xx.00306std::string parseTime(const std::string& value) const;307308/// @brief text field309FXTextField* myTimeTextField = nullptr;310};311312/// @brief input filename313class OptionFilename : public OptionRow {314/// @brief FOX-declaration315FXDECLARE(GNEOptionsEditorRow::OptionFilename)316317public:318/// @brief constructor319OptionFilename(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,320const std::string& name, const std::string& description, const std::string& defaultValue);321322/// @brief update option323void updateOption();324325/// @brief restore option326void restoreOption();327328/// @brief called when user press open dialog button329long onCmdOpenDialog(FXObject*, FXSelector, void*);330331/// @brief called when user set value in textField/button/checkBox332long onCmdSetOption(FXObject*, FXSelector, void*);333334/// @brief called when user press reset button335long onCmdResetOption(FXObject*, FXSelector, void*);336337protected:338/// @brief FOX needs this339OptionFilename();340341private:342/// @brief get value343std::string getValue() const;344345/// @brief open filename button346FXButton* myOpenFilenameButton = nullptr;347348/// @brief text field349FXTextField* myFilenameTextField = nullptr;350};351};352353354