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) {
88 for (
const auto& row :
myRows) {
108 std::string columnsType =
"ibfsssspscd";
109 for (
int i = 0; i < (FXint)columnsType.size(); i++) {
113 const int numDecals = decals.size() <
MAXROWS ? (int)decals.size() :
MAXROWS;
115 for (
int i = 0; i < numDecals; i++) {
117 const auto& decal = decals.at(i);
119 auto row =
new Row(
this);
121 row->getCells().at(2)->getTextField()->setText(decal.filename.c_str());
122 row->getCells().at(3)->getTextField()->setText(
toString(decal.centerX).c_str());
123 row->getCells().at(4)->getTextField()->setText(
toString(decal.centerY).c_str());
124 row->getCells().at(5)->getTextField()->setText(
toString(decal.width).c_str());
125 row->getCells().at(6)->getTextField()->setText(
toString(decal.height).c_str());
126 row->getCells().at(7)->getSpinner()->setValue(decal.rot);
127 row->getCells().at(8)->getTextField()->setText(
toString(decal.layer).c_str());
128 if (decal.screenRelative) {
129 row->getCells().at(9)->getCheckButton()->setCheck(
true);
130 row->getCells().at(9)->getCheckButton()->setText(
"true");
132 row->getCells().at(9)->getCheckButton()->setCheck(
false);
133 row->getCells().at(9)->getCheckButton()->setText(
"false");
138 myColumns.at(2)->setColumnLabel(
"filename",
"");
139 myColumns.at(3)->setColumnLabel(
"centerX",
"");
140 myColumns.at(4)->setColumnLabel(
"centerY",
"");
141 myColumns.at(5)->setColumnLabel(
"width",
"");
142 myColumns.at(6)->setColumnLabel(
"height",
"");
143 myColumns.at(7)->setColumnLabel(
"rotation",
"");
144 myColumns.at(8)->setColumnLabel(
"layer",
"");
145 myColumns.at(9)->setColumnLabel(
"sRel",
"screen relative");
155 if ((row >= 0) && (row < (FXint)
myRows.size()) &&
156 (column >= 0) && (column < (FXint)
myColumns.size())) {
157 myRows.at(row)->setText(column, text);
166 if ((row >= 0) && (row < (FXint)
myRows.size()) &&
167 (column >= 0) && (column < (FXint)
myColumns.size())) {
168 return myRows.at(row)->getText(column);
176 return (
int)
myRows.size();
188 if ((row >= 0) && (row < (FXint)
myRows.size())) {
201 if ((column >= 0) && (column < (
int)
myColumns.size())) {
202 myColumns.at(column)->setColumnLabel(text, tooltip);
211 int selectedRow = -1;
213 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
215 for (
const auto& cell :
myRows.at(rowIndex)->getCells()) {
216 if ((cell->getTextField() == sender) || (cell->getButton() == sender)) {
217 selectedRow = rowIndex;
235 FXEvent* eventInfo = (FXEvent*)ptr;
237 if (eventInfo->code == 65362) {
250 }
else if (eventInfo->code == 65364) {
265 return sender->handle(sender, sel, ptr);
275 const std::string value =
dynamic_cast<FXTextField*
>(sender)->getText().text();
277 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
279 if (
myRows.at(rowIndex)->getCells().at(2)->getTextField() == sender) {
280 decals.at(rowIndex).filename = value;
281 }
else if (
myRows.at(rowIndex)->getCells().at(3)->getTextField() == sender) {
283 }
else if (
myRows.at(rowIndex)->getCells().at(4)->getTextField() == sender) {
285 }
else if (
myRows.at(rowIndex)->getCells().at(5)->getTextField() == sender) {
287 }
else if (
myRows.at(rowIndex)->getCells().at(6)->getTextField() == sender) {
289 }
else if (
myRows.at(rowIndex)->getCells().at(8)->getTextField() == sender) {
304 const auto value =
dynamic_cast<FXRealSpinner*
>(sender)->getValue();
306 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
307 if (
myRows.at(rowIndex)->getCells().at(7)->getSpinner() == sender) {
308 decals.at(rowIndex).rot = value;
322 auto checkButton =
dynamic_cast<FXCheckButton*
>(sender);
324 checkButton->setText((checkButton->getCheck() == TRUE) ?
"true" :
"false");
326 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
327 if (
myRows.at(rowIndex)->getCells().at(9)->getCheckButton() == sender) {
328 decals.at(rowIndex).screenRelative = (checkButton->getCheck() == TRUE) ?
true :
false;
340 FXFileDialog opendialog(
this,
TL(
"Open decal"));
342 opendialog.setSelectMode(SELECTFILE_EXISTING);
345 opendialog.setPatternList(
TL(
"All files (*)"));
351 opendialog.execute();
353 if (!opendialog.getFilename().empty()) {
357 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
358 if (
myRows.at(rowIndex)->getCells().at(1)->getButton() == sender) {
360 myRows.at(rowIndex)->getCells().at(2)->getTextField()->setText(opendialog.getFilename());
362 decals.at(rowIndex).filename = opendialog.getFilename().text();
386 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE), ptr);
388 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE), ptr);
398 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
399 if (
myRows.at(rowIndex)->getCells().back()->getButton() == sender) {
401 decals.erase(decals.begin() + rowIndex);
416 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
418 for (
const auto& cell :
myRows.at(rowIndex)->getCells()) {
419 if (cell->getIndexLabel()) {
421 cell->showIndexLabelBold();
423 cell->showIndexLabelNormal();
435 for (
int rowIndex = 0; rowIndex < (int)
myRows.size(); rowIndex++) {
436 for (
int cellIndex = 0; cellIndex < (int)
myRows.at(rowIndex)->getCells().size(); cellIndex++) {
437 if (
myRows.at(rowIndex)->getCells().at(cellIndex)->hasFocus()) {
452 myDecalsTable(decalsTable),
453 myTextField(textField),
460 myDecalsTable(decalsTable),
461 myIndexLabel(indexLabel),
462 myIndexLabelBold(indexLabelBold),
466 indexLabelBold->hide();
467 indexLabelBold->setBackColor(FXRGBA(210, 233, 255, 255));
472 myDecalsTable(decalsTable),
480 myDecalsTable(decalsTable),
481 myCheckButton(checkButton),
488 myDecalsTable(decalsTable),
503 if (myIndexLabelBold) {
504 delete myIndexLabelBold;
510 delete myCheckButton;
518 if (myTextField && myTextField->hasFocus()) {
520 }
else if (myButton && myButton->hasFocus()) {
522 }
else if (myCheckButton && myCheckButton->hasFocus()) {
534 myTextField->setFocus();
535 }
else if (myButton) {
536 myButton->setFocus();
537 }
else if (myCheckButton) {
538 myCheckButton->setFocus();
563 return myCheckButton;
575 myIndexLabel->show();
576 myIndexLabelBold->hide();
578 myIndexLabel->recalc();
579 myIndexLabelBold->recalc();
585 myIndexLabel->hide();
586 myIndexLabelBold->show();
588 myIndexLabel->recalc();
589 myIndexLabelBold->recalc();
607 return myDecalsTable->myColumns.at(myCol)->getType();
678 delete myVerticalFrame;
684 return myVerticalCellFrame;
696 return myTopLabel->getText();
702 myTopLabel->setText(text.c_str());
703 myTopLabel->setTipText(tooltip.c_str());
716 if ((myType ==
's') || (myType ==
'p') || (myType ==
'c')) {
718 columnWidth = myTopLabel->getFont()->getTextWidth(myTopLabel->getText().text(), myTopLabel->getText().length() +
EXTRAMARGIN);
721 for (
const auto& row : myTable->myRows) {
722 if (row->getCells().at(myIndex)->getTextField()) {
723 row->getCells().at(myIndex)->getTextField()->setWidth(columnWidth);
724 }
else if (row->getCells().at(myIndex)->getButton()) {
725 row->getCells().at(myIndex)->getButton()->setWidth(columnWidth);
726 }
else if (row->getCells().at(myIndex)->getSpinner()) {
727 row->getCells().at(myIndex)->getSpinner()->setWidth(columnWidth);
731 myVerticalFrame->setWidth(columnWidth);
732 myTopLabel->setWidth(columnWidth);
733 myVerticalCellFrame->setWidth(columnWidth);
749 for (
int columnIndex = 0; columnIndex < (FXint)table->
myColumns.size(); columnIndex++) {
751 const int numCells = (int)
myCells.size();
753 switch (table->
myColumns.at(columnIndex)->getType()) {
756 auto textField =
new FXTextField(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
758 myCells.push_back(
new Cell(table, textField, columnIndex, numCells));
763 auto textField =
new FXTextField(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
765 myCells.push_back(
new Cell(table, textField, columnIndex, numCells));
772 myCells.push_back(
new Cell(table, spinner, columnIndex, numCells));
777 auto indexLabel =
new FXLabel(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
779 auto indexLabelBold =
new FXLabel(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
784 myCells.push_back(
new Cell(table, indexLabel, indexLabelBold, columnIndex, numCells));
789 auto checkableButton =
new FXCheckButton(table->
myColumns.at(columnIndex)->getVerticalCellFrame(),
791 myCells.push_back(
new Cell(table, checkableButton, columnIndex, numCells));
797 "",
TL(
"Open decal"),
TL(
"Open decal."),
799 myCells.push_back(
new Cell(table, button, columnIndex, numCells));
805 "",
TL(
"Remove decal"),
TL(
"Remove decal."),
807 myCells.push_back(
new Cell(table, button, columnIndex, numCells));
819 for (
const auto& cell : myCells) {
827 if (myCells.at(index)->getTextField()) {
828 return myCells.at(index)->getTextField()->getText().text();
838 myCells.at(index)->getTextField()->setText(text.c_str());
842const 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 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[]
int GUIDesignHeight
the default size for GUI elements
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static FXButton * buildFXButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXIcon *ic, FXObject *tgt, FXSelector sel, FXuint opts=BUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build button
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.