38 FXIMPLEMENT(
MFXAddEditTypedTable, FXTable, MFXAddEditTypedTableMap, ARRAYNUMBER(MFXAddEditTypedTableMap))
42 FXSelector sel, FXuint opts,
43 FXint x, FXint y, FXint w, FXint h,
44 FXint pl, FXint pr, FXint pt, FXint pb)
45 : FXTable(p, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb) {}
190 FXTableItem* item = cells[r * ncols + c];
191 if (item ==
nullptr) {
205 field =
new FXTextField(
this, 1,
nullptr, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
211 field->setJustify(justify);
212 field->setFont(getFont());
213 field->setBackColor(getBackColor());
214 field->setTextColor(getTextColor());
215 field->setSelBackColor(getSelBackColor());
216 field->setSelTextColor(getSelTextColor());
217 field->setText(item->getText());
224 FXRealSpinner* field;
226 field =
new FXRealSpinner(
this, 1,
nullptr, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
233 field->setFont(getFont());
234 field->setBackColor(getBackColor());
235 field->setTextColor(getTextColor());
236 field->setSelBackColor(getSelBackColor());
237 field->setSelTextColor(getSelTextColor());
239 if (p.
format !=
"undefined") {
242 field->setIncrement(p.
steps2);
243 field->setRange(p.
min, p.
max);
284 FXTableRange tablerange = input;
286 FXRealSpinner* dial =
dynamic_cast<FXRealSpinner*
>(editor);
287 if (dial !=
nullptr) {
290 if (
dynamic_cast<FXTextField*
>(editor) !=
nullptr) {
297 if (notify && target) {
298 target->tryHandle(
this, FXSEL(SEL_REPLACED, message), (
void*)&tablerange);
308 FXTableItem* item = cells[r * ncols + c];
309 if (item ==
nullptr) {
310 cells[r * ncols + c] = item = createItem(
"",
nullptr,
nullptr);
311 if (isItemSelected(r, c)) {
312 item->setSelected(FALSE);
318 item->setFromControl(control);
321 item->setText(
toString(
static_cast<FXRealSpinner*
>(control)->getValue()).c_str());
324 item->setText(
toString((
int)
static_cast<FXRealSpinner*
>(control)->getValue()).c_str());
341 bool accepted =
true;
343 if (!target->handle(
this, FXSEL(SEL_CHANGED,
ID_TEXT_CHANGED), (
void*) &edited)) {
349 if (edited.
row == getNumRows() - 1) {
350 insertRows(getNumRows(), 1,
true);
351 for (
int i = 0; i < getNumColumns(); i++) {
352 setItemText(getNumRows() - 1, i,
"");
353 setItemJustify(getNumRows() - 1, i, JUSTIFY_CENTER_X);
363 FXTableItem* item = cells[r * ncols + c];
364 if (item ==
nullptr) {
370 item->setFromControl(control);
373 item->setText(
toString(
static_cast<FXRealSpinner*
>(control)->getValue()).c_str());
376 item->setText(
toString((
int)
static_cast<FXRealSpinner*
>(control)->getValue()).c_str());
391 if (!target->handle(
this, FXSEL(SEL_CHANGED,
ID_TEXT_CHANGED), (
void*) &edited)) {
400 FXEvent*
event = (FXEvent*)ptr;
403 flags &= ~FLAG_PRESSED;
404 flags |= FLAG_UPDATE;
407 setDragCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR));
408 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONRELEASE, message), ptr)) {
413 makePositionVisible(current.row, current.col);
419 if (event->click_count == 1) {
420 handle(
this, FXSEL(SEL_CLICKED, 0), (
void*)¤t);
421 }
else if (event->click_count == 2) {
422 handle(
this, FXSEL(SEL_DOUBLECLICKED, 0), (
void*)¤t);
423 }
else if (event->click_count == 3) {
424 handle(
this, FXSEL(SEL_TRIPLECLICKED, 0), (
void*)¤t);
428 if (0 <= current.row && 0 <= current.col && isItemEnabled(current.row, current.col)) {
429 handle(
this, FXSEL(SEL_COMMAND, 0), (
void*)¤t);
440 FXEvent*
event = (FXEvent*)ptr;
443 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
446 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONPRESS, message), ptr)) {
451 tablepos.row = rowAtY(event->win_y);
452 tablepos.col = colAtX(event->win_x);
455 if (tablepos.row < 0 || tablepos.row >= nrows || tablepos.col < 0 || tablepos.col >= ncols) {
456 setCurrentItem(-1, -1, TRUE);
461 bool wasEdited = editor !=
nullptr;
462 setCurrentItem(tablepos.row, tablepos.col, TRUE);
466 if (event->state & SHIFTMASK) {
467 if (0 <= anchor.row && 0 <= anchor.col) {
468 if (isItemEnabled(anchor.row, anchor.col)) {
469 extendSelection(current.row, current.col, TRUE);
472 setAnchorItem(current.row, current.col);
473 if (isItemEnabled(current.row, current.col)) {
474 extendSelection(current.row, current.col, TRUE);
479 if (isItemEnabled(current.row, current.col)) {
481 setAnchorItem(current.row, current.col);
482 extendSelection(current.row, current.col, TRUE);
484 setAnchorItem(current.row, current.col);
489 flags &= ~FLAG_UPDATE;
490 flags |= FLAG_PRESSED;
511 if (target && target->tryHandle(
this, FXSEL(SEL_CLICKED, message), ptr)) {
514 handle(
this, FXSEL(SEL_COMMAND, ID_START_INPUT),
nullptr);
529 if (target && target->tryHandle(
this, FXSEL(SEL_CLICKED, message), ptr)) {
532 handle(
this, FXSEL(SEL_COMMAND, ID_START_INPUT),
nullptr);
560 const std::string& format) {
592 const std::vector<std::string>& params) {
593 while ((
int)
myEnums.size() <= pos) {
594 myEnums.push_back(std::vector<std::string>());
602 const std::string& e) {
603 while ((
int)
myEnums.size() <= pos) {
604 myEnums.push_back(std::vector<std::string>());
610 const std::vector<std::string>&
FXDEFMAP(MFXAddEditTypedTable) MFXAddEditTypedTableMap[]
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
std::vector< std::vector< std::string > > myEnums
virtual FXWindow * getControlForItem(FXint r, FXint c)
std::vector< NumberCellParams > myNumberCellParams
long onClicked(FXObject *, FXSelector, void *ptr)
long onLeftBtnRelease(FXObject *, FXSelector, void *ptr)
void addEnum(int pos, const std::string &e)
long onDoubleClicked(FXObject *, FXSelector, void *ptr)
void setCellType(int pos, CellType t)
NumberCellParams getNumberCellParams(int pos) const
void setNumberCellParams(int pos, double min, double max, double steps1, double steps2, double steps3, const std::string &format)
void setItemFromControl_NoRelease(FXint r, FXint c, FXWindow *control)
void setEnums(int pos, const std::vector< std::string > ¶ms)
long onLeftBtnPress(FXObject *, FXSelector, void *ptr)
void acceptInput(FXbool notify)
CellType getCellType(int pos) const
virtual void setItemFromControl(FXint r, FXint c, FXWindow *control)
const std::vector< std::string > & getEnums(int pos) const
std::vector< CellType > myCellTypes
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...