39#define DEFAULTWIDTH 190
71FXIMPLEMENT(
GNETLSTable, FXHorizontalFrame, GNETLSTableMap, ARRAYNUMBER(GNETLSTableMap))
103 for (
const auto& row :
myRows) {
104 for (
const auto& cell : row->getCells()) {
109 FXHorizontalFrame::enable();
116 for (
const auto& row :
myRows) {
117 for (
const auto& cell : row->getCells()) {
122 FXHorizontalFrame::disable();
135 int minimumTableWidth = 0;
137 Column* nameColumn =
nullptr;
141 if (column->getType() ==
'm') {
146 const auto minimunColWidth = column->getColumnMinimumWidth();
148 column->setColumnWidth(minimunColWidth);
150 minimumTableWidth += minimunColWidth;
158 const int scrollBarWidth =
myTLSPhasesParent->getTLSEditorParent()->getScrollBarWidth();
160 const auto frameAreaWidth =
myTLSPhasesParent->getTLSEditorParent()->getViewNet()->getViewParent()->getFrameAreaWidth() - 30;
162 if ((frameAreaWidth - (minimumTableWidth + minimumColNameWidth + scrollBarWidth)) > 0) {
163 nameColumn->
setColumnWidth(frameAreaWidth - minimumTableWidth - scrollBarWidth);
164 setWidth(frameAreaWidth);
167 setWidth(minimumTableWidth + minimumColNameWidth);
169 }
else if (minimumTableWidth > 0) {
170 setWidth(minimumTableWidth);
180 for (
const auto& row :
myRows) {
198 for (
int i = 0; i < (FXint)columnsType.size(); i++) {
202 for (
int i = 0; i < numberRow; i++) {
207 myRows.front()->disableButtons();
214 if ((row >= 0) && (row < (FXint)
myRows.size()) &&
215 (column >= 0) && (column < (FXint)
myColumns.size())) {
216 myRows.at(row)->setText(column, text);
218 if (
myColumns.at(column)->getType() ==
'u') {
229 if ((row >= 0) && (row < (FXint)
myRows.size()) &&
230 (column >= 0) && (column < (FXint)
myColumns.size())) {
231 return myRows.at(row)->getText(column);
239 return (
int)
myRows.size();
251 if ((row >= 0) && (row < (FXint)
myRows.size())) {
264 if ((column >= 0) && (column < (
int)
myColumns.size())) {
265 myColumns.at(column)->setColumnLabelTop(text, tooltip);
274 if ((column >= 0) && (column < (
int)
myColumns.size())) {
275 myColumns.at(column)->setColumnLabelBot(text);
285 if (tableTest->
row >= (
int)
myRows.size()) {
325 int selectedRow = -1;
327 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
329 for (
const auto& cell :
myRows.at(rowIndex)->getCells()) {
330 if ((cell->getTextField() == sender) || (cell->getAddButton() == sender)) {
331 selectedRow = rowIndex;
349 for (
int columnIndex = 0; columnIndex < (int)
myColumns.size(); columnIndex++) {
350 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
351 if (
myRows.at(rowIndex)->getCells().at(columnIndex)->getAddButton() == sender) {
352 myRows.at(rowIndex)->getCells().at(columnIndex)->getAddPhaseButton()->setFocus();
365 for (
int columnIndex = 0; columnIndex < (int)
myColumns.size(); columnIndex++) {
366 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
368 const auto textField =
myRows.at(rowIndex)->getCells().at(columnIndex)->getTextField();
369 if (textField == sender) {
371 if (
myTLSPhasesParent->changePhaseValue(columnIndex, rowIndex, textField->getText().text())) {
373 textField->killFocus();
390 FXEvent* eventInfo = (FXEvent*)ptr;
392 if (eventInfo->code == 65362) {
405 }
else if (eventInfo->code == 65364) {
420 return sender->handle(sender, sel, ptr);
428 for (
int indexRow = 0; indexRow < (int)
myRows.size(); indexRow++) {
430 for (
const auto& cell :
myRows.at(indexRow)->getCells()) {
431 if (cell->getAddPhaseButton() == sender) {
433 cell->hideMenuButtonPopup();
448 for (
int indexRow = 0; indexRow < (int)
myRows.size(); indexRow++) {
450 for (
const auto& cell :
myRows.at(indexRow)->getCells()) {
451 if (cell->getDuplicatePhaseButton() == sender) {
453 cell->hideMenuButtonPopup();
468 for (
int indexRow = 0; indexRow < (int)
myRows.size(); indexRow++) {
470 for (
const auto& cell :
myRows.at(indexRow)->getCells()) {
471 if (cell->getAddAllRedPhaseButton() == sender) {
473 cell->hideMenuButtonPopup();
488 for (
int indexRow = 0; indexRow < (int)
myRows.size(); indexRow++) {
490 for (
const auto& cell :
myRows.at(indexRow)->getCells()) {
491 if (cell->getAddAllYellowPhaseButton() == sender) {
493 cell->hideMenuButtonPopup();
508 for (
int indexRow = 0; indexRow < (int)
myRows.size(); indexRow++) {
510 for (
const auto& cell :
myRows.at(indexRow)->getCells()) {
511 if (cell->getAddAllGreenPhaseButton() == sender) {
513 cell->hideMenuButtonPopup();
528 for (
int indexRow = 0; indexRow < (int)
myRows.size(); indexRow++) {
530 for (
const auto& cell :
myRows.at(indexRow)->getCells()) {
531 if (cell->getAddAllGreenPriorityPhaseButton() == sender) {
533 cell->hideMenuButtonPopup();
548 for (
int indexRow = 0; indexRow < (int)
myRows.size(); indexRow++) {
550 for (
const auto& cell :
myRows.at(indexRow)->getCells()) {
551 if (cell->getButton() == sender) {
566 for (
int indexRow = 0; indexRow < (int)
myRows.size(); indexRow++) {
568 for (
const auto& cell :
myRows.at(indexRow)->getCells()) {
569 if (cell->getButton() == sender) {
584 for (
int indexRow = 0; indexRow < (int)
myRows.size(); indexRow++) {
586 for (
const auto& cell :
myRows.at(indexRow)->getCells()) {
587 if (cell->getButton() == sender) {
602 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
604 for (
const auto& cell :
myRows.at(rowIndex)->getCells()) {
605 if (cell->getIndexLabel()) {
607 cell->showIndexLabelBold();
609 cell->showIndexLabelNormal();
622 int durationCol = -1;
623 for (
int i = 0; i < (int)
myColumns.size(); i++) {
629 if (durationCol != -1) {
631 std::vector<double> durations;
633 for (
const auto& row :
myRows) {
634 durations.push_back(row->getCells().at(durationCol)->getDoubleValue());
637 for (
int i = 1; i < (int)durations.size(); i++) {
638 durations.at(i) += durations.at(i - 1);
641 for (
int i = 0; i < (int)
myRows.size(); i++) {
642 myRows.at(i)->getCells().at(durationCol)->setTooltip(
TL(
"Accumulated: ") +
toString(durations.at(i)));
652 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
653 for (
int cellIndex = 0; cellIndex < (int)
myRows.at(rowIndex)->getCells().size(); cellIndex++) {
654 if (
myRows.at(rowIndex)->getCells().at(cellIndex)->hasFocus()) {
685 indexLabel->create();
686 indexLabelBold->create();
688 indexLabelBold->hide();
689 indexLabelBold->setBackColor(FXRGBA(210, 233, 255, 255));
711 myTLSTable->getTLSPhasesParent()->getTLSEditorParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
712 (std::string(
"\t") +
TL(
"Add phase") + std::string(
"\t") +
TL(
"Add new phase.")).c_str(),
716 myTLSTable->getTLSPhasesParent()->getTLSEditorParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
717 (std::string(
"\t") +
TL(
"Default phase") + std::string(
"\t") +
TL(
"Add default phase.")).c_str(),
721 myTLSTable->getTLSPhasesParent()->getTLSEditorParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
722 (std::string(
"\t") +
TL(
"Duplicate phase") + std::string(
"\t") +
TL(
"Duplicate this phase.")).c_str(),
726 myTLSTable->getTLSPhasesParent()->getTLSEditorParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
727 (std::string(
"\t") +
TL(
"Red phase") + std::string(
"\t") +
TL(
"Add red phase.")).c_str(),
731 myTLSTable->getTLSPhasesParent()->getTLSEditorParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
732 (std::string(
"\t") +
TL(
"Yellow phase") + std::string(
"\t") +
TL(
"Add yellow phase.")).c_str(),
736 myTLSTable->getTLSPhasesParent()->getTLSEditorParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
737 (std::string(
"\t") +
TL(
"Green phase") + std::string(
"\t") +
TL(
"Add green phase.")).c_str(),
741 myTLSTable->getTLSPhasesParent()->getTLSEditorParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu(),
742 (std::string(
"\t") +
TL(
"Green priority phase") + std::string(
"\t") +
TL(
"Add green priority phase.")).c_str(),
1175 int columnWidth = 0;
1184 for (
const auto& row :
myTable->myRows) {
1186 const auto textField = row->getCells().at(
myIndex)->getTextField();
1188 const auto textFieldWidth = textField->getFont()->getTextWidth(textField->getText().text(), textField->getText().length() +
EXTRAMARGIN);
1190 if (textFieldWidth > columnWidth) {
1191 columnWidth = textFieldWidth;
1196 if (botLabelWidth > columnWidth) {
1197 columnWidth = botLabelWidth;
1211 for (
const auto& row :
myTable->myRows) {
1212 row->getCells().at(
myIndex)->getTextField()->setWidth(colWidth);
1239 const auto staticTooltipMenu = table->
getTLSPhasesParent()->getTLSEditorParent()->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu();
1241 for (
int columnIndex = 0; columnIndex < (FXint)table->
myColumns.size(); columnIndex++) {
1243 const int numCells = (int)
myCells.size();
1245 switch (table->
myColumns.at(columnIndex)->getType()) {
1248 auto indexLabel =
new FXLabel(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
1250 auto indexLabelBold =
new FXLabel(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
1253 indexLabel->setFont(
myTable->myIndexFont);
1254 indexLabelBold->setFont(
myTable->myIndexSelectedFont);
1255 myCells.push_back(
new Cell(table, indexLabel, indexLabelBold, columnIndex, numCells));
1266 myCells.push_back(
new Cell(table, textField, columnIndex, numCells));
1275 textField->setFont(
myTable->myProgramFont);
1276 myCells.push_back(
new Cell(table, textField, columnIndex, numCells));
1281 myCells.push_back(
new Cell(table, columnIndex, numCells));
1287 staticTooltipMenu, (std::string(
"\t") +
TL(
"Delete phase") + std::string(
"\t") +
TL(
"Delete this phase.")).c_str(),
1289 myCells.push_back(
new Cell(table, button, columnIndex, numCells));
1295 staticTooltipMenu, (std::string(
"\t") +
TL(
"Move phase up") + std::string(
"\t") +
TL(
"Move this phase up.")).c_str(),
1297 myCells.push_back(
new Cell(table, button, columnIndex, numCells));
1303 staticTooltipMenu, (std::string(
"\t") +
TL(
"Move phase down") + std::string(
"\t") +
TL(
"Move this phase down.")).c_str(),
1305 myCells.push_back(
new Cell(table, button, columnIndex, numCells));
1317 for (
const auto& cell :
myCells) {
1325 if (
myCells.at(index)->getTextField()) {
1326 return myCells.at(index)->getTextField()->getText().text();
1336 myCells.at(index)->getTextField()->setText(text.c_str());
1340const std::vector<GNETLSTable::Cell*>&
1349 for (
const auto& cell :
myCells) {
1350 if ((cell->getType() ==
'd') || (cell->getType() ==
'b') || (cell->getType() ==
't')) {
1351 cell->disableButton();
FXDEFMAP(GNETLSTable) GNETLSTableMap[]
@ MID_GNE_TLSTABLE_ADDPHASE
TLSTable button for add phase.
@ MID_GNE_TLSTABLE_COPYPHASE
TLSTable button for copy phase.
@ MID_GNE_TLSTABLE_ADDPHASEALLGREENPRIORITY
TLSTable button for add phase green priority.
@ MID_GNE_TLSTABLE_ADDPHASEALLYELLOW
TLSTable button for add phase yelllow.
@ MID_GNE_TLSTABLE_TEXTFIELD
TLSTable textField.
@ MID_GNE_TLSTABLE_ADDPHASEALLRED
TLSTable button for add phase red.
@ MID_GNE_TLSTABLE_MOVEDOWNPHASE
TLSTable button for move down phase.
@ MID_MBTTIP_FOCUS
callback for MFXMenuButtonTooltip
@ MID_GNE_TLSTABLE_ADDPHASEALLGREEN
TLSTable button for add phase green.
@ MID_GNE_TLSTABLE_REMOVEPHASE
TLSTable button for remove phase.
@ MID_GNE_TLSTABLE_MOVEUPPHASE
TLSTable button for move up phase.
#define GUIDesignTextColorRed
red color (for invalid text)
#define GUIDesignLabelFixed(width)
label, icon before text, text centered and custom width
#define GUIDesignButtonIcon
button only with icon
#define GUIDesignTextFieldTLSTable
text field with min width (used in TLS table)
#define GUIDesignAuxiliarFrameFixedWidth(width)
design for auxiliar (Without borders) frame with fixed width and extended height
#define GUIDesignTLSTableCheckableButtonIcon
checkable button only with icon used in TLSTable
#define GUIDesignTextColorBlack
black color (for correct text)
#define GUIDesignLabelThickedFixed(width)
label thicked, icon before text, text centered and custom width
@ TLSPHASEALLGREENPRIORITY
int GUIDesignHeight
the default height for GUI elements
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
GNEViewNet * getViewNet() const
get view net
GNETLSEditorFrame * getTLSEditorParent() const
get TLSEditor Parent
void showIndexLabelNormal()
show label index normal
MFXButtonTooltip * getDuplicatePhaseButton()
get duplicate phase button
MFXButtonTooltip * myAddAllGreenPriorityButton
add all green priority phase button
MFXButtonTooltip * myAddAllRedButton
add all red phase button
void enable()
Enable cell.
void showIndexLabelBold()
show label index bold
FXLabel * myIndexLabel
index label
FXLabel * myIndexLabelBold
index label bold
MFXButtonTooltip * getAddPhaseButton()
get add phase button
int getCol() const
column index
void setFocus()
set focus in the current cell
void setTooltip(const std::string &toolTip)
set tooltip
bool hasFocus() const
check if current cell has focus
Cell()
default constructor
GNETLSTable * myTLSTable
pointer to TLSTable parent
bool myDisableButton
disable button
FXPopup * myMenuButtonPopup
popup for buttons
MFXButtonTooltip * getAddAllGreenPriorityPhaseButton()
get add all green priority phase button
MFXButtonTooltip * getAddAllYellowPhaseButton()
get add all yellow phase button
MFXTextFieldIcon * getTextField() const
get textField
int getRow() const
row index
MFXTextFieldIcon * myTextField
MFXTextFieldIcon.
void disableButton()
disable button (used for delete, move up and move down)
MFXMenuButtonTooltip * myAddButton
menu button tooltip
void hideMenuButtonPopup()
hide menuButton popup
FXLabel * getIndexLabel() const
get index label
double getDoubleValue() const
get double value (only for types 'u' and 'd')
MFXButtonTooltip * getButton()
get remove, move up or move down button
MFXMenuButtonTooltip * getAddButton() const
get add button
MFXButtonTooltip * myAddAllYellowButton
add all yellow phase button
void disable()
Disable cell.
MFXButtonTooltip * getAddAllGreenPhaseButton()
get add all green phase button
char getType() const
get column type
MFXButtonTooltip * getAddAllRedPhaseButton()
get add all red phase button
MFXButtonTooltip * myButton
button
MFXButtonTooltip * myDuplicatePhaseButton
duplicate phase button
MFXButtonTooltip * myAddPhaseButton
add phase button
const int myCol
column index
MFXButtonTooltip * myAddAllGreenButton
add all green phase button
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
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(GNETLSEditorFrame::TLSPhases *TLSPhasesParent)
fox declaration
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 testTable(const InternalTestStep::TLSTableTest *tableTest)
test table (using internal tests)
long onCmdAddPhase(FXObject *, FXSelector, void *)
called when an add phase button is pressed
void updateIndexLabel()
update index labels
long onFocusRow(FXObject *, FXSelector, void *)
called when a row is focused
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)
GNETLSEditorFrame::TLSPhases * getTLSPhasesParent() const
@frame get pointer to TLSEditorFrame phases parent
std::vector< Column * > myColumns
columns
GNEViewParent * getViewParent() const
get the net object
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
MFXStaticToolTip * getStaticTooltipMenu() const
get static toolTip for menus
struct used for test TLS Tables
const int row
x coordinate
const FXSelector sel
selector
const std::string text
text
const int column
y coordinate
virtual void create()
Create server-side resources.
void setText(const FXString &text, FXbool notify=FALSE)
Change the text and move cursor to end.