/****************************************************************************/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 MFXDecalsTable.h14/// @author Pablo Alvarez Lopez15/// @date Feb 202316///17// Table used for show and edit decal values18/****************************************************************************/19#pragma once20#include <config.h>2122#include <vector>2324#include <utils/common/UtilExceptions.h>25#include <utils/foxtools/MFXLabelTooltip.h>2627// ===========================================================================28// class declaration29// ===========================================================================3031class GUIDialog_ViewSettings;3233// ===========================================================================34// class definitions35// ===========================================================================36/**37* @class MFXDecalsTable38*/39class MFXDecalsTable : public FXVerticalFrame {40/// @brief fox declaration41FXDECLARE(MFXDecalsTable)4243public:44/// @brief constructor (Exactly like the FXButton constructor)45MFXDecalsTable(GUIDialog_ViewSettings* dialogViewSettingsParent, FXComposite* parent);4647/// @brief destructor (Called automatically)48~MFXDecalsTable();4950/// @brief clear table51void clearTable();5253/// @brief Modify cell text54void setItemText(FXint row, FXint column, const std::string& text);5556/// @brief Return cell text57std::string getItemText(const int row, const int column) const;5859/// @brief Get number of rows60int getNumRows() const;6162/// @brief Get current selected row63int getCurrentSelectedRow() const;6465/// @brief Select a row66void selectRow(const int rowIndex);6768/// @brief Change column header text69void setColumnLabel(const int column, const std::string& text, const std::string& tooltip = "");7071/// @brief fill table72void fillTable();7374/// @name FOX callbacks75/// @{7677/// @brief called when a row is focused78long onFocusRow(FXObject*, FXSelector, void*);7980/// @brief called when a key is pressed81long onCmdKeyPress(FXObject*, FXSelector, void*);8283/// @brief called when a string is updated84long onCmdEditRowString(FXObject*, FXSelector, void*);8586/// @brief called when a spinner is updated87long onCmdEditRowSpinner(FXObject*, FXSelector, void*);8889/// @brief called when a checkBox is updated90long onCmdEditRowCheckBox(FXObject*, FXSelector, void*);9192/// @brief called when open decal button is pressed93long onCmdOpenDecal(FXObject*, FXSelector, void*);9495/// @brief called when add row button is pressed96long onCmdAddRow(FXObject*, FXSelector, void*);9798/// @brief update add row button99long onUpdAddRow(FXObject*, FXSelector, void*);100101/// @brief called when remove row button is pressed102long onCmdRemoveRow(FXObject*, FXSelector, void*);103104/// @}105106protected:107/// @brief FOX needs this108FOX_CONSTRUCTOR(MFXDecalsTable)109110/// @brief table cell111class Cell {112113public:114/// @brief constructor for textField115Cell(MFXDecalsTable* decalsTable, FXTextField* textField, int col, int row);116117/// @brief constructor for index label118Cell(MFXDecalsTable* decalsTable, FXLabel* indexLabel, FXLabel* indexLabelBold, int col, int row);119120/// @brief constructor for buttons121Cell(MFXDecalsTable* decalsTable, FXButton* button, int col, int row);122123/// @brief constructor for check buttons124Cell(MFXDecalsTable* decalsTable, FXCheckButton* checkButton, int col, int row);125126/// @brief constructor for spinners127Cell(MFXDecalsTable* decalsTable, FXRealSpinner* spinner, int col, int row);128129/// @brief destructor130~Cell();131132/// @brief check if current cell has focus133bool hasFocus() const;134135/// @brief set focus in the current cell136void setFocus();137138/// @brief get textField139FXTextField* getTextField() const;140141/// @brief get index label142FXLabel* getIndexLabel() const;143144/// @brief get open button145FXButton* getButton();146147/// @brief get check button148FXCheckButton* getCheckButton();149150/// @brief get spinner151FXRealSpinner* getSpinner();152153/// @brief show label index normal154void showIndexLabelNormal();155156/// @brief show label index bold157void showIndexLabelBold();158159/// @brief column index160int getCol() const;161162/// @brief row index163int getRow() const;164165/// @brief get column type166char getType() const;167168private:169/// @brief pointer to decals table parent170MFXDecalsTable* myDecalsTable = nullptr;171172/// @brief FXTextField173FXTextField* myTextField = nullptr;174175/// @brief index label176FXLabel* myIndexLabel = nullptr;177178/// @brief index label bold179FXLabel* myIndexLabelBold = nullptr;180181/// @brief button182FXButton* myButton = nullptr;183184/// @brief spinner185FXRealSpinner* mySpinner = nullptr;186187/// @brief check button188FXCheckButton* myCheckButton = nullptr;189190/// @brief column index191const int myCol;192193/// @brief row index194const int myRow;195196/// @brief default constructor197Cell();198};199200/// @brief table column201class Column {202203public:204/// @brief constructor205Column(MFXDecalsTable* table, const int index, const char type);206207/// @brief destructor208~Column();209210/// @brief get vertical cell frame211FXVerticalFrame* getVerticalCellFrame() const;212213/// @brief get column type214char getType() const;215216/// @brief get column label217FXString getColumnLabel() const;218219/// @brief set column label220void setColumnLabel(const std::string& text, const std::string& tooltip);221222private:223/// @brief pointer to table224MFXDecalsTable* myTable = nullptr;225226/// @brief vertical frame227FXVerticalFrame* myVerticalFrame = nullptr;228229/// @brief column top tooltip label230MFXLabelTooltip* myTopLabel = nullptr;231232/// @brief vertical frame233FXVerticalFrame* myVerticalCellFrame = nullptr;234235/// @brief column index236const int myIndex;237238/// @brief column type239const char myType;240241/// @brief adjust column width242void adjustColumnWidth();243244/// @brief default constructor245Column();246};247248/// @brief table row249class Row {250251public:252/// @brief constructor253Row(MFXDecalsTable* table);254255/// @brief destructor256~Row();257258/// @brief get text259std::string getText(int index) const;260261/// @brief set text262void setText(int index, const std::string& text) const;263264/// @brief get cells265const std::vector<Cell*>& getCells() const;266267/// @brief disable row buttons268void disableButtons();269270protected:271/// @brief poiner to table parent272MFXDecalsTable* myTable = nullptr;273274/// @brief list wtih cells275std::vector<Cell*> myCells;276277private:278/// @brief default constructor279Row();280};281282/// @brief update index labels283void updateIndexLabel();284285/// @brief move focus to current row286bool moveFocus();287288/// @brief horizontal columns frame289FXHorizontalFrame* myColumnsFrame = nullptr;290291/// @brief font for index292FXFont* myIndexFont = nullptr;293294/// @brief font for index selected295FXFont* myIndexSelectedFont = nullptr;296297/// @frame pointer to GUIDialog_ViewSettings parent298GUIDialog_ViewSettings* myDialogViewSettings = nullptr;299300/// @brief columns301std::vector<Column*> myColumns;302303/// @brief rows304std::vector<Row*> myRows;305306/// @brief add button307FXButton* myAddButton = nullptr;308309/// @brief current selected row310int myCurrentSelectedRow = -1;311312private:313/// @brief Invalidated duplicate constructor.314MFXDecalsTable(const MFXDecalsTable&) = delete;315316/// @brief Invalidated assignment operator.317MFXDecalsTable& operator=(const MFXDecalsTable&) = delete;318};319320321