40 FXIMPLEMENT(
MFXAddEditTypedTable, FXTable, MFXAddEditTypedTableMap, ARRAYNUMBER(MFXAddEditTypedTableMap))
44 FXSelector sel, FXuint opts,
45 FXint x, FXint y, FXint w, FXint h,
46 FXint pl, FXint pr, FXint pt, FXint pb)
47 : FXTable(p, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb) {}
192 FXTableItem* item = cells[r * ncols + c];
193 if (item ==
nullptr) {
207 field =
new FXTextField(
this, 1,
nullptr, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
213 field->setJustify(justify);
214 field->setFont(getFont());
215 field->setBackColor(getBackColor());
216 field->setTextColor(getTextColor());
217 field->setSelBackColor(getSelBackColor());
218 field->setSelTextColor(getSelTextColor());
219 field->setText(item->getText());
226 FXRealSpinner* field;
228 field =
new FXRealSpinner(
this, 1,
nullptr, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
235 field->setFont(getFont());
236 field->setBackColor(getBackColor());
237 field->setTextColor(getTextColor());
238 field->setSelBackColor(getSelBackColor());
239 field->setSelTextColor(getSelTextColor());
241 if (p.
format !=
"undefined") {
244 field->setIncrement(p.
steps2);
245 field->setRange(p.
min, p.
max);
286 FXTableRange tablerange = input;
288 FXRealSpinner* dial = dynamic_cast<FXRealSpinner*>(editor);
289 if (dial !=
nullptr) {
292 if (dynamic_cast<FXTextField*>(editor) !=
nullptr) {
299 if (notify && target) {
300 target->tryHandle(
this, FXSEL(SEL_REPLACED, message), (
void*)&tablerange);
310 FXTableItem* item = cells[r * ncols + c];
311 if (item ==
nullptr) {
312 cells[r * ncols + c] = item = createItem(
"",
nullptr,
nullptr);
313 if (isItemSelected(r, c)) {
314 item->setSelected(FALSE);
320 item->setFromControl(control);
323 item->setText(
toString(static_cast<FXRealSpinner*>(control)->getValue()).c_str());
326 item->setText(
toString((
int) static_cast<FXRealSpinner*>(control)->getValue()).c_str());
343 bool accepted =
true;
345 if (!target->handle(
this, FXSEL(SEL_CHANGED,
ID_TEXT_CHANGED), (
void*) &edited)) {
351 if (edited.
row == getNumRows() - 1) {
352 insertRows(getNumRows(), 1,
true);
353 for (
int i = 0; i < getNumColumns(); i++) {
354 setItemText(getNumRows() - 1, i,
"");
355 setItemJustify(getNumRows() - 1, i, JUSTIFY_CENTER_X);
365 FXTableItem* item = cells[r * ncols + c];
366 if (item ==
nullptr) {
372 item->setFromControl(control);
375 item->setText(
toString(static_cast<FXRealSpinner*>(control)->getValue()).c_str());
378 item->setText(
toString((
int) static_cast<FXRealSpinner*>(control)->getValue()).c_str());
393 if (!target->handle(
this, FXSEL(SEL_CHANGED,
ID_TEXT_CHANGED), (
void*) &edited)) {
402 FXEvent*
event = (FXEvent*)ptr;
405 flags &= ~FLAG_PRESSED;
406 flags |= FLAG_UPDATE;
409 setDragCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR));
410 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONRELEASE, message), ptr)) {
415 makePositionVisible(current.row, current.col);
421 if (event->click_count == 1) {
422 handle(
this, FXSEL(SEL_CLICKED, 0), (
void*)¤t);
423 }
else if (event->click_count == 2) {
424 handle(
this, FXSEL(SEL_DOUBLECLICKED, 0), (
void*)¤t);
425 }
else if (event->click_count == 3) {
426 handle(
this, FXSEL(SEL_TRIPLECLICKED, 0), (
void*)¤t);
430 if (0 <= current.row && 0 <= current.col && isItemEnabled(current.row, current.col)) {
431 handle(
this, FXSEL(SEL_COMMAND, 0), (
void*)¤t);
442 FXEvent*
event = (FXEvent*)ptr;
445 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
448 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONPRESS, message), ptr)) {
453 tablepos.row = rowAtY(event->win_y);
454 tablepos.col = colAtX(event->win_x);
457 if (tablepos.row < 0 || tablepos.row >= nrows || tablepos.col < 0 || tablepos.col >= ncols) {
458 setCurrentItem(-1, -1, TRUE);
463 bool wasEdited = editor !=
nullptr;
464 setCurrentItem(tablepos.row, tablepos.col, TRUE);
468 if (event->state & SHIFTMASK) {
469 if (0 <= anchor.row && 0 <= anchor.col) {
470 if (isItemEnabled(anchor.row, anchor.col)) {
471 extendSelection(current.row, current.col, TRUE);
474 setAnchorItem(current.row, current.col);
475 if (isItemEnabled(current.row, current.col)) {
476 extendSelection(current.row, current.col, TRUE);
481 if (isItemEnabled(current.row, current.col)) {
483 setAnchorItem(current.row, current.col);
484 extendSelection(current.row, current.col, TRUE);
486 setAnchorItem(current.row, current.col);
491 flags &= ~FLAG_UPDATE;
492 flags |= FLAG_PRESSED;
513 if (target && target->tryHandle(
this, FXSEL(SEL_CLICKED, message), ptr)) {
516 handle(
this, FXSEL(SEL_COMMAND, ID_START_INPUT),
nullptr);
531 if (target && target->tryHandle(
this, FXSEL(SEL_CLICKED, message), ptr)) {
534 handle(
this, FXSEL(SEL_COMMAND, ID_START_INPUT),
nullptr);
562 const std::string& format) {
594 const std::vector<std::string>& params) {
595 while ((
int)
myEnums.size() <= pos) {
596 myEnums.push_back(std::vector<std::string>());
604 const std::string& e) {
605 while ((
int)
myEnums.size() <= pos) {
606 myEnums.push_back(std::vector<std::string>());
612 const std::vector<std::string>&