Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/foxtools/MFXDecalsTable.h
169678 views
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
/****************************************************************************/
14
/// @file MFXDecalsTable.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Feb 2023
17
///
18
// Table used for show and edit decal values
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <vector>
24
25
#include <utils/common/UtilExceptions.h>
26
#include <utils/foxtools/MFXLabelTooltip.h>
27
28
// ===========================================================================
29
// class declaration
30
// ===========================================================================
31
32
class GUIDialog_ViewSettings;
33
34
// ===========================================================================
35
// class definitions
36
// ===========================================================================
37
/**
38
* @class MFXDecalsTable
39
*/
40
class MFXDecalsTable : public FXVerticalFrame {
41
/// @brief fox declaration
42
FXDECLARE(MFXDecalsTable)
43
44
public:
45
/// @brief constructor (Exactly like the FXButton constructor)
46
MFXDecalsTable(GUIDialog_ViewSettings* dialogViewSettingsParent, FXComposite* parent);
47
48
/// @brief destructor (Called automatically)
49
~MFXDecalsTable();
50
51
/// @brief clear table
52
void clearTable();
53
54
/// @brief Modify cell text
55
void setItemText(FXint row, FXint column, const std::string& text);
56
57
/// @brief Return cell text
58
std::string getItemText(const int row, const int column) const;
59
60
/// @brief Get number of rows
61
int getNumRows() const;
62
63
/// @brief Get current selected row
64
int getCurrentSelectedRow() const;
65
66
/// @brief Select a row
67
void selectRow(const int rowIndex);
68
69
/// @brief Change column header text
70
void setColumnLabel(const int column, const std::string& text, const std::string& tooltip = "");
71
72
/// @brief fill table
73
void fillTable();
74
75
/// @name FOX callbacks
76
/// @{
77
78
/// @brief called when a row is focused
79
long onFocusRow(FXObject*, FXSelector, void*);
80
81
/// @brief called when a key is pressed
82
long onCmdKeyPress(FXObject*, FXSelector, void*);
83
84
/// @brief called when a string is updated
85
long onCmdEditRowString(FXObject*, FXSelector, void*);
86
87
/// @brief called when a spinner is updated
88
long onCmdEditRowSpinner(FXObject*, FXSelector, void*);
89
90
/// @brief called when a checkBox is updated
91
long onCmdEditRowCheckBox(FXObject*, FXSelector, void*);
92
93
/// @brief called when open decal button is pressed
94
long onCmdOpenDecal(FXObject*, FXSelector, void*);
95
96
/// @brief called when add row button is pressed
97
long onCmdAddRow(FXObject*, FXSelector, void*);
98
99
/// @brief update add row button
100
long onUpdAddRow(FXObject*, FXSelector, void*);
101
102
/// @brief called when remove row button is pressed
103
long onCmdRemoveRow(FXObject*, FXSelector, void*);
104
105
/// @}
106
107
protected:
108
/// @brief FOX needs this
109
FOX_CONSTRUCTOR(MFXDecalsTable)
110
111
/// @brief table cell
112
class Cell {
113
114
public:
115
/// @brief constructor for textField
116
Cell(MFXDecalsTable* decalsTable, FXTextField* textField, int col, int row);
117
118
/// @brief constructor for index label
119
Cell(MFXDecalsTable* decalsTable, FXLabel* indexLabel, FXLabel* indexLabelBold, int col, int row);
120
121
/// @brief constructor for buttons
122
Cell(MFXDecalsTable* decalsTable, FXButton* button, int col, int row);
123
124
/// @brief constructor for check buttons
125
Cell(MFXDecalsTable* decalsTable, FXCheckButton* checkButton, int col, int row);
126
127
/// @brief constructor for spinners
128
Cell(MFXDecalsTable* decalsTable, FXRealSpinner* spinner, int col, int row);
129
130
/// @brief destructor
131
~Cell();
132
133
/// @brief check if current cell has focus
134
bool hasFocus() const;
135
136
/// @brief set focus in the current cell
137
void setFocus();
138
139
/// @brief get textField
140
FXTextField* getTextField() const;
141
142
/// @brief get index label
143
FXLabel* getIndexLabel() const;
144
145
/// @brief get open button
146
FXButton* getButton();
147
148
/// @brief get check button
149
FXCheckButton* getCheckButton();
150
151
/// @brief get spinner
152
FXRealSpinner* getSpinner();
153
154
/// @brief show label index normal
155
void showIndexLabelNormal();
156
157
/// @brief show label index bold
158
void showIndexLabelBold();
159
160
/// @brief column index
161
int getCol() const;
162
163
/// @brief row index
164
int getRow() const;
165
166
/// @brief get column type
167
char getType() const;
168
169
private:
170
/// @brief pointer to decals table parent
171
MFXDecalsTable* myDecalsTable = nullptr;
172
173
/// @brief FXTextField
174
FXTextField* myTextField = nullptr;
175
176
/// @brief index label
177
FXLabel* myIndexLabel = nullptr;
178
179
/// @brief index label bold
180
FXLabel* myIndexLabelBold = nullptr;
181
182
/// @brief button
183
FXButton* myButton = nullptr;
184
185
/// @brief spinner
186
FXRealSpinner* mySpinner = nullptr;
187
188
/// @brief check button
189
FXCheckButton* myCheckButton = nullptr;
190
191
/// @brief column index
192
const int myCol;
193
194
/// @brief row index
195
const int myRow;
196
197
/// @brief default constructor
198
Cell();
199
};
200
201
/// @brief table column
202
class Column {
203
204
public:
205
/// @brief constructor
206
Column(MFXDecalsTable* table, const int index, const char type);
207
208
/// @brief destructor
209
~Column();
210
211
/// @brief get vertical cell frame
212
FXVerticalFrame* getVerticalCellFrame() const;
213
214
/// @brief get column type
215
char getType() const;
216
217
/// @brief get column label
218
FXString getColumnLabel() const;
219
220
/// @brief set column label
221
void setColumnLabel(const std::string& text, const std::string& tooltip);
222
223
private:
224
/// @brief pointer to table
225
MFXDecalsTable* myTable = nullptr;
226
227
/// @brief vertical frame
228
FXVerticalFrame* myVerticalFrame = nullptr;
229
230
/// @brief column top tooltip label
231
MFXLabelTooltip* myTopLabel = nullptr;
232
233
/// @brief vertical frame
234
FXVerticalFrame* myVerticalCellFrame = nullptr;
235
236
/// @brief column index
237
const int myIndex;
238
239
/// @brief column type
240
const char myType;
241
242
/// @brief adjust column width
243
void adjustColumnWidth();
244
245
/// @brief default constructor
246
Column();
247
};
248
249
/// @brief table row
250
class Row {
251
252
public:
253
/// @brief constructor
254
Row(MFXDecalsTable* table);
255
256
/// @brief destructor
257
~Row();
258
259
/// @brief get text
260
std::string getText(int index) const;
261
262
/// @brief set text
263
void setText(int index, const std::string& text) const;
264
265
/// @brief get cells
266
const std::vector<Cell*>& getCells() const;
267
268
/// @brief disable row buttons
269
void disableButtons();
270
271
protected:
272
/// @brief poiner to table parent
273
MFXDecalsTable* myTable = nullptr;
274
275
/// @brief list wtih cells
276
std::vector<Cell*> myCells;
277
278
private:
279
/// @brief default constructor
280
Row();
281
};
282
283
/// @brief update index labels
284
void updateIndexLabel();
285
286
/// @brief move focus to current row
287
bool moveFocus();
288
289
/// @brief horizontal columns frame
290
FXHorizontalFrame* myColumnsFrame = nullptr;
291
292
/// @brief font for index
293
FXFont* myIndexFont = nullptr;
294
295
/// @brief font for index selected
296
FXFont* myIndexSelectedFont = nullptr;
297
298
/// @frame pointer to GUIDialog_ViewSettings parent
299
GUIDialog_ViewSettings* myDialogViewSettings = nullptr;
300
301
/// @brief columns
302
std::vector<Column*> myColumns;
303
304
/// @brief rows
305
std::vector<Row*> myRows;
306
307
/// @brief add button
308
FXButton* myAddButton = nullptr;
309
310
/// @brief current selected row
311
int myCurrentSelectedRow = -1;
312
313
private:
314
/// @brief Invalidated duplicate constructor.
315
MFXDecalsTable(const MFXDecalsTable&) = delete;
316
317
/// @brief Invalidated assignment operator.
318
MFXDecalsTable& operator=(const MFXDecalsTable&) = delete;
319
};
320
321