38 #ifdef CHECK_MEMORY_LEAKS
40 #endif // CHECK_MEMORY_LEAKS
51 FXIMPLEMENT(
MFXAddEditTypedTable, FXTable, MFXAddEditTypedTableMap, ARRAYNUMBER(MFXAddEditTypedTableMap))
55 FXSelector sel, FXuint opts,
56 FXint x, FXint y, FXint w, FXint h,
57 FXint pl, FXint pr, FXint pt, FXint pb)
58 : FXTable(p, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb) {}
203 register FXTableItem* item = cells[r * ncols + c];
216 register FXTextField* field;
217 register FXuint justify = 0;
218 field =
new FXTextField(
this, 1, NULL, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
224 field->setJustify(justify);
225 field->setFont(getFont());
226 field->setBackColor(getBackColor());
227 field->setTextColor(getTextColor());
228 field->setSelBackColor(getSelBackColor());
229 field->setSelTextColor(getSelTextColor());
230 field->setText(item->getText());
237 register FXRealSpinDial* field;
239 field =
new FXRealSpinDial(
this, 1, NULL, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
246 field->setFont(getFont());
247 field->setBackColor(getBackColor());
248 field->setTextColor(getTextColor());
249 field->setSelBackColor(getSelBackColor());
250 field->setSelTextColor(getSelTextColor());
252 if (p.
format !=
"undefined") {
253 field->setFormatString((
char*) p.
format.c_str());
255 field->setRange(p.
min, p.
max);
296 FXTableRange tablerange = input;
300 FXRealSpinDial* dial =
dynamic_cast<FXRealSpinDial*
>(editor);
302 if (!dial->getDial().grabbed()) {
308 if (dynamic_cast<FXTextField*>(editor) != 0) {
315 if (notify && target) {
316 target->tryHandle(
this, FXSEL(SEL_REPLACED, message), (
void*)&tablerange);
326 register FXTableItem* item = cells[r * ncols + c];
328 cells[r * ncols + c] = item = createItem(
"", NULL, NULL);
329 if (isItemSelected(r, c)) {
330 item->setSelected(FALSE);
336 item->setFromControl(control);
339 item->setText(
toString(static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
342 item->setText(
toString((
int) static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
359 bool accepted =
true;
361 if (!target->handle(
this, FXSEL(SEL_CHANGED,
ID_TEXT_CHANGED), (
void*) &edited)) {
367 if (edited.
row == getNumRows() - 1) {
368 insertRows(getNumRows(), 1,
true);
369 for (
int i = 0; i < getNumColumns(); i++) {
370 setItemText(getNumRows() - 1, i,
"");
371 setItemJustify(getNumRows() - 1, i, JUSTIFY_CENTER_X);
381 register FXTableItem* item = cells[r * ncols + c];
388 item->setFromControl(control);
391 item->setText(
toString(static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
394 item->setText(
toString((
int) static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
409 if (!target->handle(
this, FXSEL(SEL_CHANGED,
ID_TEXT_CHANGED), (
void*) &edited)) {
418 FXEvent*
event = (FXEvent*)ptr;
421 flags &= ~FLAG_PRESSED;
422 flags |= FLAG_UPDATE;
425 setDragCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR));
426 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONRELEASE, message), ptr)) {
431 makePositionVisible(current.row, current.col);
437 if (event->click_count == 1) {
438 handle(
this, FXSEL(SEL_CLICKED, 0), (
void*)¤t);
439 }
else if (event->click_count == 2) {
440 handle(
this, FXSEL(SEL_DOUBLECLICKED, 0), (
void*)¤t);
441 }
else if (event->click_count == 3) {
442 handle(
this, FXSEL(SEL_TRIPLECLICKED, 0), (
void*)¤t);
446 if (0 <= current.row && 0 <= current.col && isItemEnabled(current.row, current.col)) {
447 handle(
this, FXSEL(SEL_COMMAND, 0), (
void*)¤t);
458 FXEvent*
event = (FXEvent*)ptr;
461 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
464 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONPRESS, message), ptr)) {
469 tablepos.row = rowAtY(event->win_y);
470 tablepos.col = colAtX(event->win_x);
473 if (tablepos.row < 0 || tablepos.row >= nrows || tablepos.col < 0 || tablepos.col >= ncols) {
474 setCurrentItem(-1, -1, TRUE);
479 bool wasEdited = editor != 0;
480 setCurrentItem(tablepos.row, tablepos.col, TRUE);
484 if (event->state & SHIFTMASK) {
485 if (0 <= anchor.row && 0 <= anchor.col) {
486 if (isItemEnabled(anchor.row, anchor.col)) {
487 extendSelection(current.row, current.col, TRUE);
490 setAnchorItem(current.row, current.col);
491 if (isItemEnabled(current.row, current.col)) {
492 extendSelection(current.row, current.col, TRUE);
497 if (isItemEnabled(current.row, current.col)) {
499 setAnchorItem(current.row, current.col);
500 extendSelection(current.row, current.col, TRUE);
502 setAnchorItem(current.row, current.col);
507 flags &= ~FLAG_UPDATE;
508 flags |= FLAG_PRESSED;
529 if (target && target->tryHandle(
this, FXSEL(SEL_CLICKED, message), ptr)) {
532 handle(
this, FXSEL(SEL_COMMAND, ID_START_INPUT), NULL);
547 if (target && target->tryHandle(
this, FXSEL(SEL_CLICKED, message), ptr)) {
550 handle(
this, FXSEL(SEL_COMMAND, ID_START_INPUT), NULL);
578 const std::string& format) {
610 const std::vector<std::string>& params) {
611 while ((
int)
myEnums.size() <= pos) {
612 myEnums.push_back(std::vector<std::string>());
620 const std::string& e) {
621 while ((
int)
myEnums.size() <= pos) {
622 myEnums.push_back(std::vector<std::string>());
628 const std::vector<std::string>&
std::vector< std::vector< std::string > > myEnums
void setItemFromControl_NoRelease(FXint r, FXint c, FXWindow *control)
static SUMOReal _2SUMOReal(const E *const data)
converts a char-type array into the SUMOReal value described by it
long onDoubleClicked(FXObject *, FXSelector, void *ptr)
void setEnums(int pos, const std::vector< std::string > ¶ms)
CellType getCellType(int pos) const
std::vector< NumberCellParams > myNumberCellParams
std::vector< CellType > myCellTypes
void setNumberCellParams(int pos, double min, double max, double steps1, double steps2, double steps3, const std::string &format)
void acceptInput(FXbool notify)
void setCellType(int pos, CellType t)
long onClicked(FXObject *, FXSelector, void *ptr)
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
long onLeftBtnRelease(FXObject *, FXSelector, void *ptr)
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
const std::vector< std::string > & getEnums(int pos) const
long onLeftBtnPress(FXObject *, FXSelector, void *ptr)
NumberCellParams getNumberCellParams(int pos) const
void addEnum(int pos, const std::string &e)
virtual FXWindow * getControlForItem(FXint r, FXint c)
virtual void setItemFromControl(FXint r, FXint c, FXWindow *control)
FXDEFMAP(MFXAddEditTypedTable) MFXAddEditTypedTableMap[]