Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNETLSTable.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// Table used in GNETLSFrame for editing TLS programs
19/****************************************************************************/
20#ifndef GNETLSTable_h
21#define GNETLSTable_h
22#include <config.h>
23
24#include <vector>
25
28
29// ===========================================================================
30// class declaration
31// ===========================================================================
32
34class MFXLabelTooltip;
36
37// ===========================================================================
38// class definitions
39// ===========================================================================
43class GNETLSTable : public FXHorizontalFrame {
45 FXDECLARE(GNETLSTable)
46
47public:
50
53
55 void enable();
56
58 void disable();
59
62
64 void recalcTableWidth();
65
67 void clearTable();
68
70 void setItemText(FXint row, FXint column, const std::string& text);
71
73 std::string getItemText(const int row, const int column) const;
74
76 int getNumRows() const;
77
79 int getCurrentSelectedRow() const;
80
82 void selectRow(const int rowIndex);
83
85 void setColumnLabelTop(const int column, const std::string& text, const std::string& tooltip = "");
86
88 void setColumnLabelBot(const int column, const std::string& text);
89
102 void setTableSize(const std::string& columnsType, const int numberRow);
103
107 long onFocusRow(FXObject*, FXSelector, void*);
108
110 long onCmdAddPhasePressed(FXObject*, FXSelector, void*);
111
113 long onCmdEditRow(FXObject*, FXSelector, void*);
114
116 long onCmdKeyPress(FXObject*, FXSelector, void*);
117
119 long onCmdAddPhase(FXObject*, FXSelector, void*);
120
122 long onCmdDuplicatePhase(FXObject*, FXSelector, void*);
123
125 long onCmdAddPhaseAllRed(FXObject*, FXSelector, void*);
126
128 long onCmdAddPhaseAllYellow(FXObject*, FXSelector, void*);
129
131 long onCmdAddPhaseAllGreen(FXObject*, FXSelector, void*);
132
134 long onCmdAddPhaseAllGreenPriority(FXObject*, FXSelector, void*);
135
137 long onCmdRemovePhase(FXObject*, FXSelector, void*);
138
140 long onCmdMoveUpPhase(FXObject*, FXSelector, void*);
141
143 long onCmdMoveDownPhase(FXObject*, FXSelector, void*);
144
146
147protected:
149 FOX_CONSTRUCTOR(GNETLSTable)
150
151
153
154 public:
156 Cell(GNETLSTable* TLSTable, MFXTextFieldTooltip* textField, int col, int row);
157
159 Cell(GNETLSTable* TLSTable, FXLabel* indexLabel, FXLabel* indexLabelBold, int col, int row);
160
162 Cell(GNETLSTable* TLSTable, MFXButtonTooltip* button, int col, int row);
163
165 Cell(GNETLSTable* TLSTable, int col, int row);
166
168 ~Cell();
169
171 void enable();
172
174 void disable();
175
177 bool hasFocus() const;
178
180 void setFocus();
181
183 double getDoubleValue() const;
184
186 void setTooltip(const std::string& toolTip);
187
189 MFXTextFieldTooltip* getTextField() const;
190
192 FXLabel* getIndexLabel() const;
193
195 MFXMenuButtonTooltip* getAddButton() const;
196
198 MFXButtonTooltip* getButton();
199
201 MFXButtonTooltip* getAddPhaseButton();
202
204 MFXButtonTooltip* getDuplicatePhaseButton();
205
207 MFXButtonTooltip* getAddAllRedPhaseButton();
208
210 MFXButtonTooltip* getAddAllYellowPhaseButton();
211
213 MFXButtonTooltip* getAddAllGreenPhaseButton();
214
216 MFXButtonTooltip* getAddAllGreenPriorityPhaseButton();
217
219 void showIndexLabelNormal();
220
222 void showIndexLabelBold();
223
225 int getCol() const;
226
228 int getRow() const;
229
231 char getType() const;
232
234 void hideMenuButtonPopup();
235
237 void disableButton();
238
239 private:
241 GNETLSTable* myTLSTable = nullptr;
242
244 MFXTextFieldTooltip* myTextField = nullptr;
245
247 FXLabel* myIndexLabel = nullptr;
248
250 FXLabel* myIndexLabelBold = nullptr;
251
253 MFXButtonTooltip* myButton = nullptr;
254
256 FXPopup* myMenuButtonPopup = nullptr;
257
259 MFXMenuButtonTooltip* myAddButton = nullptr;
260
262 MFXButtonTooltip* myAddPhaseButton = nullptr;
263
265 MFXButtonTooltip* myDuplicatePhaseButton = nullptr;
266
268 MFXButtonTooltip* myAddAllRedButton = nullptr;
269
271 MFXButtonTooltip* myAddAllYellowButton = nullptr;
272
274 MFXButtonTooltip* myAddAllGreenButton = nullptr;
275
277 MFXButtonTooltip* myAddAllGreenPriorityButton = nullptr;
278
280 const int myCol;
281
283 const int myRow;
284
286 bool myDisableButton = false;
287
289 Cell();
290 };
291
293 class Column {
294
295 public:
297 Column(GNETLSTable* table, const int index, const char type);
298
300 ~Column();
301
303 FXVerticalFrame* getVerticalCellFrame() const;
304
306 char getType() const;
307
309 FXString getColumnLabelTop() const;
310
312 void setColumnLabelTop(const std::string& text, const std::string& tooltip);
313
315 void setColumnLabelBot(const std::string& text);
316
319
321 void setColumnWidth(const int colWidth);
322
323 private:
326
328 FXVerticalFrame* myVerticalFrame = nullptr;
329
332
334 FXVerticalFrame* myVerticalCellFrame = nullptr;
335
337 FXLabel* myBotLabel = nullptr;
338
340 const int myIndex;
341
343 const char myType;
344
346 bool isTextFieldColumn() const;
347
349 Column();
350 };
351
353 class Row {
354
355 public:
357 Row(GNETLSTable* table);
358
360 ~Row();
361
363 std::string getText(int index) const;
364
366 void setText(int index, const std::string& text) const;
367
369 const std::vector<Cell*>& getCells() const;
370
372 void disableButtons();
373
374 protected:
377
379 std::vector<Cell*> myCells;
380
381 private:
383 Row();
384 };
385
387 void updateIndexLabel();
388
391
393 bool moveFocus();
394
396 FXFont* myProgramFont = nullptr;
397
399 FXFont* myIndexFont = nullptr;
400
402 FXFont* myIndexSelectedFont = nullptr;
403
406
408 std::vector<Column*> myColumns;
409
411 std::vector<Row*> myRows;
412
415
416private:
418 GNETLSTable(const GNETLSTable&) = delete;
419
422};
423
424#endif
FOX needs this.
const int myRow
row index
const int myCol
column index
int getColumnMinimumWidth()
get column minimum width
const char myType
column type
FXVerticalFrame * myVerticalFrame
vertical frame
FXLabel * myBotLabel
column bot label
Column()
default constructor
FXVerticalFrame * getVerticalCellFrame() const
get vertical cell frame
FXVerticalFrame * myVerticalCellFrame
vertical frame
void setColumnLabelTop(const std::string &text, const std::string &tooltip)
set column label top
bool isTextFieldColumn() const
check if current type correspond to a textField
GNETLSTable * myTable
pointer to table
char getType() const
get column type
const int myIndex
column index
FXString getColumnLabelTop() const
get column label top
void setColumnLabelBot(const std::string &text)
set column label boit
MFXLabelTooltip * myTopLabel
column top tooltip label
void setColumnWidth(const int colWidth)
set colum width
void setText(int index, const std::string &text) const
set text
Row()
default constructor
GNETLSTable * myTable
poiner to table parent
std::vector< Cell * > myCells
list wtih cells
void disableButtons()
disable row buttons
const std::vector< Cell * > & getCells() const
get cells
std::string getText(int index) const
get text
GNETLSTable(const GNETLSTable &)=delete
Invalidated duplicate constructor.
GNETLSEditorFrame::TLSPhases * myTLSPhasesParent
@frame pointer to TLSEditorFrame phases parent
int getNumRows() const
Get number of rows.
int myCurrentSelectedRow
current selected row
long onCmdDuplicatePhase(FXObject *, FXSelector, void *)
called when a duplicate phase button is pressed
long onCmdEditRow(FXObject *, FXSelector, void *)
called when a row is modified
FXFont * myIndexSelectedFont
font for index selected
long onCmdAddPhaseAllRed(FXObject *, FXSelector, void *)
called when an add all green red phase button is pressed
long onCmdAddPhaseAllGreenPriority(FXObject *, FXSelector, void *)
called when an add all green red phase button is pressed
long onCmdAddPhase(FXObject *, FXSelector, void *)
called when an add phase button is pressed
void updateIndexLabel()
update index labels
long onFocusRow(FXObject *, FXSelector, void *)
void setColumnLabelBot(const int column, const std::string &text)
Change column bottom text.
void clearTable()
clear table
void selectRow(const int rowIndex)
Select a row.
long onCmdMoveUpPhase(FXObject *, FXSelector, void *)
called when a move up phase button is pressed
~GNETLSTable()
destructor (Called automatically)
int getCurrentSelectedRow() const
Get current selected row.
long onCmdAddPhasePressed(FXObject *, FXSelector, void *)
called when add phase button is selected
FXFont * myIndexFont
font for index
void enable()
Enable table.
long onCmdAddPhaseAllYellow(FXObject *, FXSelector, void *)
called when an add all green red phase button is pressed
std::string getItemText(const int row, const int column) const
Return cell text.
long onCmdKeyPress(FXObject *, FXSelector, void *)
called when a key is pressed
long onCmdAddPhaseAllGreen(FXObject *, FXSelector, void *)
called when an add all green red phase button is pressed
bool moveFocus()
move focus to current row
void setColumnLabelTop(const int column, const std::string &text, const std::string &tooltip="")
Change column header text.
void setItemText(FXint row, FXint column, const std::string &text)
Modify cell text.
std::vector< Row * > myRows
rows
long onCmdRemovePhase(FXObject *, FXSelector, void *)
called when a remove phase button is pressed
void updateAccumulatedDuration()
update accumulated duration();
void setTableSize(const std::string &columnsType, const int numberRow)
Set the table size to nr rows and nc columns; all existing items will be removed. Format: s -> select...
FXFont * myProgramFont
font for the phase table
void disable()
Disable table.
long onCmdMoveDownPhase(FXObject *, FXSelector, void *)
called when a move up phase button is pressed
void recalcTableWidth()
recalc width (call when all labels and contents are fill)
GNETLSTable & operator=(const GNETLSTable &)=delete
Invalidated assignment operator.
GNETLSEditorFrame::TLSPhases * getTLSPhasesParent() const
@frame get pointer to TLSEditorFrame phases parent
std::vector< Column * > myColumns
columns
every row value