Path: blob/main/src/netedit/dialogs/options/GNEOptionsEditorRow.h
193870 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 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,49const bool editable);5051/// @brief adjust input name size52void adjustNameSize();5354/// @brief get topic55const std::string& getTopic() const;5657/// @brief get name (Lower)58const std::string getNameLower() const;5960/// @brief get description (Lower)61const std::string getDescriptionLower() const;6263/// @brief update option (used after load options)64virtual void updateOption() = 0;6566/// @brief restore option (used for setting original options)67virtual void restoreOption() = 0;6869/// @brief called when user set value in textField/button/checkBox70virtual long onCmdSetOption(FXObject*, FXSelector, void*) = 0;7172/// @brief called when user press reset button73virtual long onCmdResetOption(FXObject*, FXSelector, void*) = 0;7475protected:76/// @brief FOX needs this77FOX_CONSTRUCTOR(OptionRow)7879/// @brief GNEOptionsEditor parent80GNEOptionsEditor* myOptionsEditor = nullptr;8182/// @brief topic83const std::string myTopic;8485/// @brief name86const std::string myName;8788/// @brief description89const std::string myDescription;9091/// @brief default value92const std::string myDefaultValue;9394/// @brief content frame95FXHorizontalFrame* myContentFrame = nullptr;9697/// @brief editable98const bool myEditable = true;99100/// @brief update reset button101void updateResetButton();102103private:104/// @brief get value105virtual std::string getValue() const = 0;106107/// @brief tooltip label for name108MFXLabelTooltip* myNameLabel = nullptr;109110// @brief reset button111FXButton* myResetButton = nullptr;112};113114/// @brief input string115class OptionString : public OptionRow {116117public:118/// @brief constructor119OptionString(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,120const std::string& name, const std::string& description, const std::string& defaultValue,121const bool editable);122123/// @brief update option124void updateOption();125126/// @brief restore option127void restoreOption();128129/// @brief called when user set value in textField/button/checkBox130long onCmdSetOption(FXObject*, FXSelector, void*);131132/// @brief called when user press reset button133long onCmdResetOption(FXObject*, FXSelector, void*);134135private:136/// @brief get value137std::string getValue() const;138139/// @brief text field140FXTextField* myStringTextField = nullptr;141};142143/// @brief input string vector144class OptionStringVector : public OptionRow {145146public:147/// @brief constructor148OptionStringVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,149const std::string& name, const std::string& description, const std::string& defaultValue,150const bool editable);151152/// @brief update option153void updateOption();154155/// @brief restore option156void restoreOption();157158/// @brief called when user set value in textField/button/checkBox159long onCmdSetOption(FXObject*, FXSelector, void*);160161/// @brief called when user press reset button162long onCmdResetOption(FXObject*, FXSelector, void*);163164private:165/// @brief get value166std::string getValue() const;167168/// @brief text field169FXTextField* myStringVectorTextField = nullptr;170};171172/// @brief input bool173class OptionBool : public OptionRow {174175public:176/// @brief constructor177OptionBool(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,178const std::string& name, const std::string& description, const std::string& defaultValue,179const bool editable);180181/// @brief update option182void updateOption();183184/// @brief restore option185void restoreOption();186187/// @brief called when user set value in textField/button/checkBox188long onCmdSetOption(FXObject*, FXSelector, void*);189190/// @brief called when user press reset button191long onCmdResetOption(FXObject*, FXSelector, void*);192193private:194/// @brief get value195std::string getValue() const;196197/// @brief menu check198FXCheckButton* myCheckButton = nullptr;199};200201/// @brief input int202class OptionInt : public OptionRow {203204public:205/// @brief206OptionInt(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,207const std::string& name, const std::string& description, const std::string& defaultValue,208const bool editable);209210/// @brief update option211void updateOption();212213/// @brief restore option214void restoreOption();215216/// @brief called when user set value in textField/button/checkBox217long onCmdSetOption(FXObject*, FXSelector, void*);218219/// @brief called when user press reset button220long onCmdResetOption(FXObject*, FXSelector, void*);221222private:223/// @brief get value224std::string getValue() const;225226/// @brief text field227FXTextField* myIntTextField = nullptr;228};229230/// @brief input int vector231class OptionIntVector : public OptionRow {232233public:234/// @brief235OptionIntVector(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,236const std::string& name, const std::string& description, const std::string& defaultValue,237const bool editable);238239/// @brief update option240void updateOption();241242/// @brief restore option243void restoreOption();244245/// @brief called when user set value in textField/button/checkBox246long onCmdSetOption(FXObject*, FXSelector, void*);247248/// @brief called when user press reset button249long onCmdResetOption(FXObject*, FXSelector, void*);250251private:252/// @brief get value253std::string getValue() const;254255/// @brief text field256FXTextField* myIntVectorTextField = nullptr;257};258259/// @brief input float260class OptionFloat : public OptionRow {261262public:263/// @brief constructor264OptionFloat(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,265const std::string& name, const std::string& description, const std::string& defaultValue,266const bool editable);267268/// @brief update option269void updateOption();270271/// @brief restore option272void restoreOption();273274/// @brief called when user set value in textField/button/checkBox275long onCmdSetOption(FXObject*, FXSelector, void*);276277/// @brief called when user press reset button278long onCmdResetOption(FXObject*, FXSelector, void*);279280private:281/// @brief get value282std::string getValue() const;283284/// @brief parse float xx to xx.00285std::string parseFloat(const std::string& value) const;286287/// @brief text field288FXTextField* myFloatTextField = nullptr;289};290291/// @brief input float292class OptionTime : public OptionRow {293294public:295/// @brief constructor296OptionTime(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,297const std::string& name, const std::string& description, const std::string& defaultValue,298const bool editable);299300/// @brief update option301void updateOption();302303/// @brief restore option304void restoreOption();305306/// @brief called when user set value in textField/button/checkBox307long onCmdSetOption(FXObject*, FXSelector, void*);308309/// @brief called when user press reset button310long onCmdResetOption(FXObject*, FXSelector, void*);311312private:313/// @brief get value314std::string getValue() const;315316/// @brief parse float xx to xx.00317std::string parseTime(const std::string& value) const;318319/// @brief text field320FXTextField* myTimeTextField = nullptr;321};322323/// @brief input filename324class OptionFilename : public OptionRow {325/// @brief FOX-declaration326FXDECLARE(GNEOptionsEditorRow::OptionFilename)327328public:329/// @brief constructor330OptionFilename(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,331const std::string& name, const std::string& description, const std::string& defaultValue,332const bool editable);333334/// @brief update option335void updateOption();336337/// @brief restore option338void restoreOption();339340/// @brief called when user press open dialog button341long onCmdOpenDialog(FXObject*, FXSelector, void*);342343/// @brief called when user set value in textField/button/checkBox344long onCmdSetOption(FXObject*, FXSelector, void*);345346/// @brief called when user press reset button347long onCmdResetOption(FXObject*, FXSelector, void*);348349protected:350/// @brief FOX needs this351OptionFilename();352353private:354/// @brief get value355std::string getValue() const;356357/// @brief open filename button358FXButton* myOpenFilenameButton = nullptr;359360/// @brief text field361FXTextField* myFilenameTextField = nullptr;362};363};364365366