55FXIMPLEMENT(
MFXDecalsTable, FXVerticalFrame, MFXDecalsTableMap, ARRAYNUMBER(MFXDecalsTableMap))
67 myIndexFont(new FXFont(getApp(), "Segoe UI", 9)),
68 myIndexSelectedFont(new FXFont(getApp(), "Segoe UI", 9, FXFont::Bold)),
69 myDialogViewSettings(dialogViewSettingsParent) {
73 myAddButton =
new FXButton(
this,
74 (std::string(
"\t") +
TL(
"Add decal") + std::string(
"\t") +
TL(
"Add decal.")).c_str(),
89 for (
const auto& row :
myRows) {
109 std::string columnsType =
"ibfsssspscd";
110 for (
int i = 0; i < (FXint)columnsType.size(); i++) {
114 const int numDecals = decals.size() <
MAXROWS ? (int)decals.size() :
MAXROWS;
116 for (
int i = 0; i < numDecals; i++) {
118 const auto& decal = decals.at(i);
120 auto row =
new Row(
this);
122 row->getCells().at(2)->getTextField()->setText(decal.filename.c_str());
123 row->getCells().at(3)->getTextField()->setText(
toString(decal.centerX).c_str());
124 row->getCells().at(4)->getTextField()->setText(
toString(decal.centerY).c_str());
125 row->getCells().at(5)->getTextField()->setText(
toString(decal.width).c_str());
126 row->getCells().at(6)->getTextField()->setText(
toString(decal.height).c_str());
127 row->getCells().at(7)->getSpinner()->setValue(decal.rot);
128 row->getCells().at(8)->getTextField()->setText(
toString(decal.layer).c_str());
129 if (decal.screenRelative) {
130 row->getCells().at(9)->getCheckButton()->setCheck(
true);
131 row->getCells().at(9)->getCheckButton()->setText(
"true");
133 row->getCells().at(9)->getCheckButton()->setCheck(
false);
134 row->getCells().at(9)->getCheckButton()->setText(
"false");
139 myColumns.at(2)->setColumnLabel(
"filename",
"");
140 myColumns.at(3)->setColumnLabel(
"centerX",
"");
141 myColumns.at(4)->setColumnLabel(
"centerY",
"");
142 myColumns.at(5)->setColumnLabel(
"width",
"");
143 myColumns.at(6)->setColumnLabel(
"height",
"");
144 myColumns.at(7)->setColumnLabel(
"rotation",
"");
145 myColumns.at(8)->setColumnLabel(
"layer",
"");
146 myColumns.at(9)->setColumnLabel(
"sRel",
"screen relative");
156 if ((row >= 0) && (row < (FXint)
myRows.size()) &&
157 (column >= 0) && (column < (FXint)
myColumns.size())) {
158 myRows.at(row)->setText(column, text);
167 if ((row >= 0) && (row < (FXint)
myRows.size()) &&
168 (column >= 0) && (column < (FXint)
myColumns.size())) {
169 return myRows.at(row)->getText(column);
177 return (
int)
myRows.size();
189 if ((row >= 0) && (row < (FXint)
myRows.size())) {
202 if ((column >= 0) && (column < (
int)
myColumns.size())) {
203 myColumns.at(column)->setColumnLabel(text, tooltip);
212 int selectedRow = -1;
214 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
216 for (
const auto& cell :
myRows.at(rowIndex)->getCells()) {
217 if ((cell->getTextField() == sender) || (cell->getButton() == sender)) {
218 selectedRow = rowIndex;
236 FXEvent* eventInfo = (FXEvent*)ptr;
238 if (eventInfo->code == 65362) {
251 }
else if (eventInfo->code == 65364) {
266 return sender->handle(sender, sel, ptr);
276 const std::string value =
dynamic_cast<FXTextField*
>(sender)->getText().text();
278 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
280 if (
myRows.at(rowIndex)->getCells().at(2)->getTextField() == sender) {
281 decals.at(rowIndex).filename = value;
282 }
else if (
myRows.at(rowIndex)->getCells().at(3)->getTextField() == sender) {
284 }
else if (
myRows.at(rowIndex)->getCells().at(4)->getTextField() == sender) {
286 }
else if (
myRows.at(rowIndex)->getCells().at(5)->getTextField() == sender) {
288 }
else if (
myRows.at(rowIndex)->getCells().at(6)->getTextField() == sender) {
290 }
else if (
myRows.at(rowIndex)->getCells().at(8)->getTextField() == sender) {
305 const auto value =
dynamic_cast<FXRealSpinner*
>(sender)->getValue();
307 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
308 if (
myRows.at(rowIndex)->getCells().at(7)->getSpinner() == sender) {
309 decals.at(rowIndex).rot = value;
323 auto checkButton =
dynamic_cast<FXCheckButton*
>(sender);
325 checkButton->setText((checkButton->getCheck() == TRUE) ?
"true" :
"false");
327 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
328 if (
myRows.at(rowIndex)->getCells().at(9)->getCheckButton() == sender) {
329 decals.at(rowIndex).screenRelative = (checkButton->getCheck() == TRUE) ?
true :
false;
341 FXFileDialog opendialog(
this,
TL(
"Open decal"));
343 opendialog.setSelectMode(SELECTFILE_EXISTING);
346 opendialog.setPatternList(
TL(
"All files (*)"));
352 opendialog.execute();
354 if (!opendialog.getFilename().empty()) {
358 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
359 if (
myRows.at(rowIndex)->getCells().at(1)->getButton() == sender) {
361 myRows.at(rowIndex)->getCells().at(2)->getTextField()->setText(opendialog.getFilename());
363 decals.at(rowIndex).filename = opendialog.getFilename().text();
387 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE), ptr);
389 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE), ptr);
399 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
400 if (
myRows.at(rowIndex)->getCells().back()->getButton() == sender) {
402 decals.erase(decals.begin() + rowIndex);
417 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
419 for (
const auto& cell :
myRows.at(rowIndex)->getCells()) {
420 if (cell->getIndexLabel()) {
422 cell->showIndexLabelBold();
424 cell->showIndexLabelNormal();
436 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
437 for (
int cellIndex = 0; cellIndex < (int)
myRows.at(rowIndex)->getCells().size(); cellIndex++) {
438 if (
myRows.at(rowIndex)->getCells().at(cellIndex)->hasFocus()) {
453 myDecalsTable(decalsTable),
454 myTextField(textField),
461 myDecalsTable(decalsTable),
462 myIndexLabel(indexLabel),
463 myIndexLabelBold(indexLabelBold),
467 indexLabelBold->hide();
468 indexLabelBold->setBackColor(FXRGBA(210, 233, 255, 255));
473 myDecalsTable(decalsTable),
481 myDecalsTable(decalsTable),
482 myCheckButton(checkButton),
489 myDecalsTable(decalsTable),
504 if (myIndexLabelBold) {
505 delete myIndexLabelBold;
511 delete myCheckButton;
519 if (myTextField && myTextField->hasFocus()) {
521 }
else if (myButton && myButton->hasFocus()) {
523 }
else if (myCheckButton && myCheckButton->hasFocus()) {
535 myTextField->setFocus();
536 }
else if (myButton) {
537 myButton->setFocus();
538 }
else if (myCheckButton) {
539 myCheckButton->setFocus();
564 return myCheckButton;
576 myIndexLabel->show();
577 myIndexLabelBold->hide();
579 myIndexLabel->recalc();
580 myIndexLabelBold->recalc();
586 myIndexLabel->hide();
587 myIndexLabelBold->show();
589 myIndexLabel->recalc();
590 myIndexLabelBold->recalc();
608 return myDecalsTable->myColumns.at(myCol)->getType();
679 delete myVerticalFrame;
685 return myVerticalCellFrame;
697 return myTopLabel->getText();
703 myTopLabel->setText(text.c_str());
704 myTopLabel->setTipText(tooltip.c_str());
717 if ((myType ==
's') || (myType ==
'p') || (myType ==
'c')) {
719 columnWidth = myTopLabel->getFont()->getTextWidth(myTopLabel->getText().text(), myTopLabel->getText().length() +
EXTRAMARGING);
722 for (
const auto& row : myTable->myRows) {
723 if (row->getCells().at(myIndex)->getTextField()) {
724 row->getCells().at(myIndex)->getTextField()->setWidth(columnWidth);
725 }
else if (row->getCells().at(myIndex)->getButton()) {
726 row->getCells().at(myIndex)->getButton()->setWidth(columnWidth);
727 }
else if (row->getCells().at(myIndex)->getSpinner()) {
728 row->getCells().at(myIndex)->getSpinner()->setWidth(columnWidth);
732 myVerticalFrame->setWidth(columnWidth);
733 myTopLabel->setWidth(columnWidth);
734 myVerticalCellFrame->setWidth(columnWidth);
750 for (
int columnIndex = 0; columnIndex < (FXint)table->
myColumns.size(); columnIndex++) {
752 const int numCells = (int)
myCells.size();
754 switch (table->
myColumns.at(columnIndex)->getType()) {
757 auto textField =
new FXTextField(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
759 myCells.push_back(
new Cell(table, textField, columnIndex, numCells));
764 auto textField =
new FXTextField(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
766 myCells.push_back(
new Cell(table, textField, columnIndex, numCells));
773 myCells.push_back(
new Cell(table, spinner, columnIndex, numCells));
778 auto indexLabel =
new FXLabel(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
780 auto indexLabelBold =
new FXLabel(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
785 myCells.push_back(
new Cell(table, indexLabel, indexLabelBold, columnIndex, numCells));
790 auto checkableButton =
new FXCheckButton(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
792 myCells.push_back(
new Cell(table, checkableButton, columnIndex, numCells));
797 auto button =
new FXButton(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
798 (std::string(
"\t") +
TL(
"Open decal") + std::string(
"\t") +
TL(
"Open decal.")).c_str(),
800 myCells.push_back(
new Cell(table, button, columnIndex, numCells));
805 auto button =
new FXButton(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
806 (std::string(
"\t") +
TL(
"Remove decal") + std::string(
"\t") +
TL(
"Remove decal.")).c_str(),
808 myCells.push_back(
new Cell(table, button, columnIndex, numCells));
820 for (
const auto& cell : myCells) {
828 if (myCells.at(index)->getTextField()) {
829 return myCells.at(index)->getTextField()->getText().text();
839 myCells.at(index)->getTextField()->setText(text.c_str());
843const std::vector<MFXDecalsTable::Cell*>&
@ MID_DECALSTABLE_CHECKBOX
checkbox
@ MID_DECALSTABLE_ADD
add row
@ MID_MBTTIP_FOCUS
callback for MFXMenuButtonTooltip
@ MID_DECALSTABLE_TEXTFIELD
textField
@ MID_DECALSTABLE_OPEN
open decal
@ MID_DECALSTABLE_REMOVE
add row
@ MID_DECALSTABLE_SPINNER
spinner
#define GUIDesignMFXCheckableButton
checkable button extended over frame
#define GUIDesignAuxiliarFrameFixHeight
design for auxiliar vertical frames with fixed height (DecalsTable)
#define GUIDesignLabelFixed(width)
label, icon before text, text centered and custom width
#define GUIDesignButtonIcon
button only with icon
#define GUIDesignHeight
define a standard height for all elements (Change it carefully)
#define GUIDesignTextField
#define GUIDesignSpinDialDecalsTable
design for standard spin dial
#define GUIDesignTextFieldNCol
Num of column of text field.
#define GUIDesignAuxiliarFrameFixWidth
design for auxiliar vertical frames with fixed width (used in TLSTable and DecalsTable)
#define GUIDesignLabelThick(justify)
label extended over frame with thick and with text justify to left
#define GUIDesignTextFieldFixedRestricted(width, type)
text field with fixed width
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frame extended in all directions
#define GUIDesignLabelThickedFixed(width)
label thicked, icon before text, text centered and custom width
FXString gCurrentFolder
The folder used as last.
FXDEFMAP(MFXDecalsTable) MFXDecalsTableMap[]
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
The dialog to change the view (gui) settings.
GUISUMOAbstractView * getSUMOAbstractView()
get GUISUMOAbstractView parent
GUIMainWindow * getGUIMainWindowParent()
Returns the GUIMainWindow parent.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
MFXStaticToolTip * getStaticTooltipMenu() const
get static toolTip for menus
std::vector< Decal > & getDecals()
The list of decals to show.
GUIGlChildWindow * getGUIGlChildWindow()
get GUIGlChildWindow
char getType() const
get column type
Cell()
default constructor
FXRealSpinner * getSpinner()
get spinner
FXButton * getButton()
get open button
int getRow() const
row index
void showIndexLabelBold()
show label index bold
void setFocus()
set focus in the current cell
FXTextField * getTextField() const
get textField
void showIndexLabelNormal()
show label index normal
bool hasFocus() const
check if current cell has focus
FXCheckButton * getCheckButton()
get check button
FXLabel * getIndexLabel() const
get index label
int getCol() const
column index
char getType() const
get column type
MFXLabelTooltip * myTopLabel
column top tooltip label
FXVerticalFrame * myVerticalCellFrame
vertical frame
const char myType
column type
FXVerticalFrame * getVerticalCellFrame() const
get vertical cell frame
void setColumnLabel(const std::string &text, const std::string &tooltip)
set column label
void adjustColumnWidth()
adjust column width
Column()
default constructor
FXVerticalFrame * myVerticalFrame
vertical frame
FXString getColumnLabel() const
get column label
std::vector< Cell * > myCells
list wtih cells
MFXDecalsTable * myTable
poiner to table parent
void setText(int index, const std::string &text) const
set text
const std::vector< Cell * > & getCells() const
get cells
std::string getText(int index) const
get text
bool moveFocus()
move focus to current row
long onCmdAddRow(FXObject *, FXSelector, void *)
called when add row button is pressed
std::vector< Column * > myColumns
columns
int getCurrentSelectedRow() const
Get current selected row.
FXHorizontalFrame * myColumnsFrame
horizontal columns frame
int getNumRows() const
Get number of rows.
long onFocusRow(FXObject *, FXSelector, void *)
called when a row is focused
~MFXDecalsTable()
destructor (Called automatically)
long onCmdRemoveRow(FXObject *, FXSelector, void *)
called when remove row button is pressed
int myCurrentSelectedRow
current selected row
void selectRow(const int rowIndex)
Select a row.
long onCmdEditRowSpinner(FXObject *, FXSelector, void *)
called when a spinner is updated
void setItemText(FXint row, FXint column, const std::string &text)
Modify cell text.
long onCmdEditRowCheckBox(FXObject *, FXSelector, void *)
called when a checkBox is updated
FXFont * myIndexSelectedFont
font for index selected
void fillTable()
fill table
long onCmdEditRowString(FXObject *, FXSelector, void *)
called when a string is updated
void setColumnLabel(const int column, const std::string &text, const std::string &tooltip="")
Change column header text.
FXFont * myIndexFont
font for index
std::vector< Row * > myRows
rows
std::string getItemText(const int row, const int column) const
Return cell text.
void clearTable()
clear table
void updateIndexLabel()
update index labels
long onCmdKeyPress(FXObject *, FXSelector, void *)
called when a key is pressed
GUIDialog_ViewSettings * myDialogViewSettings
@frame pointer to GUIDialog_ViewSettings parent
long onCmdOpenDecal(FXObject *, FXSelector, void *)
called when open decal button is pressed
long onUpdAddRow(FXObject *, FXSelector, void *)
update add row button
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
A decal (an image) that can be shown.