35FXIMPLEMENT(
MFXAddEditTypedTable, FXTable, MFXAddEditTypedTableMap, ARRAYNUMBER(MFXAddEditTypedTableMap))
39 FXSelector sel, FXuint opts,
40 FXint x, FXint y, FXint w, FXint h,
41 FXint pl, FXint pr, FXint pt, FXint pb)
42 : FXTable(p, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb) {}
187 FXTableItem* item = cells[r * ncols + c];
188 if (item ==
nullptr) {
202 field =
new FXTextField(
this, 1,
nullptr, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
208 field->setJustify(justify);
209 field->setFont(getFont());
210 field->setBackColor(getBackColor());
211 field->setTextColor(getTextColor());
212 field->setSelBackColor(getSelBackColor());
213 field->setSelTextColor(getSelTextColor());
214 field->setText(item->getText());
221 FXRealSpinner* field;
223 field =
new FXRealSpinner(
this, 1,
nullptr, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
230 field->setFont(getFont());
231 field->setBackColor(getBackColor());
232 field->setTextColor(getTextColor());
233 field->setSelBackColor(getSelBackColor());
234 field->setSelTextColor(getSelTextColor());
236 if (p.
format !=
"undefined") {
239 field->setIncrement(p.
steps2);
240 field->setRange(p.
min, p.
max);
281 FXTableRange tablerange = input;
283 FXRealSpinner* dial =
dynamic_cast<FXRealSpinner*
>(editor);
284 if (dial !=
nullptr) {
287 if (
dynamic_cast<FXTextField*
>(editor) !=
nullptr) {
294 if (notify && target) {
295 target->tryHandle(
this, FXSEL(SEL_REPLACED, message), (
void*)&tablerange);
305 FXTableItem* item = cells[r * ncols + c];
306 if (item ==
nullptr) {
307 cells[r * ncols + c] = item = createItem(
"",
nullptr,
nullptr);
308 if (isItemSelected(r, c)) {
309 item->setSelected(FALSE);
315 item->setFromControl(control);
318 item->setText(
toString(
static_cast<FXRealSpinner*
>(control)->getValue()).c_str());
321 item->setText(
toString((
int)
static_cast<FXRealSpinner*
>(control)->getValue()).c_str());
338 bool accepted =
true;
340 if (!target->handle(
this, FXSEL(SEL_CHANGED,
ID_TEXT_CHANGED), (
void*) &edited)) {
346 if (edited.
row == getNumRows() - 1) {
347 insertRows(getNumRows(), 1,
true);
348 for (
int i = 0; i < getNumColumns(); i++) {
349 setItemText(getNumRows() - 1, i,
"");
350 setItemJustify(getNumRows() - 1, i, JUSTIFY_CENTER_X);
360 FXTableItem* item = cells[r * ncols + c];
361 if (item ==
nullptr) {
367 item->setFromControl(control);
370 item->setText(
toString(
static_cast<FXRealSpinner*
>(control)->getValue()).c_str());
373 item->setText(
toString((
int)
static_cast<FXRealSpinner*
>(control)->getValue()).c_str());
388 if (!target->handle(
this, FXSEL(SEL_CHANGED,
ID_TEXT_CHANGED), (
void*) &edited)) {
397 FXEvent*
event = (FXEvent*)ptr;
400 flags &= ~FLAG_PRESSED;
401 flags |= FLAG_UPDATE;
404 setDragCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR));
405 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONRELEASE, message), ptr)) {
410 makePositionVisible(current.row, current.col);
416 if (event->click_count == 1) {
417 handle(
this, FXSEL(SEL_CLICKED, 0), (
void*)¤t);
418 }
else if (event->click_count == 2) {
419 handle(
this, FXSEL(SEL_DOUBLECLICKED, 0), (
void*)¤t);
420 }
else if (event->click_count == 3) {
421 handle(
this, FXSEL(SEL_TRIPLECLICKED, 0), (
void*)¤t);
425 if (0 <= current.row && 0 <= current.col && isItemEnabled(current.row, current.col)) {
426 handle(
this, FXSEL(SEL_COMMAND, 0), (
void*)¤t);
437 FXEvent*
event = (FXEvent*)ptr;
440 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
443 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONPRESS, message), ptr)) {
448 tablepos.row = rowAtY(event->win_y);
449 tablepos.col = colAtX(event->win_x);
452 if (tablepos.row < 0 || tablepos.row >= nrows || tablepos.col < 0 || tablepos.col >= ncols) {
453 setCurrentItem(-1, -1, TRUE);
458 bool wasEdited = editor !=
nullptr;
459 setCurrentItem(tablepos.row, tablepos.col, TRUE);
463 if (event->state & SHIFTMASK) {
464 if (0 <= anchor.row && 0 <= anchor.col) {
465 if (isItemEnabled(anchor.row, anchor.col)) {
466 extendSelection(current.row, current.col, TRUE);
469 setAnchorItem(current.row, current.col);
470 if (isItemEnabled(current.row, current.col)) {
471 extendSelection(current.row, current.col, TRUE);
476 if (isItemEnabled(current.row, current.col)) {
478 setAnchorItem(current.row, current.col);
479 extendSelection(current.row, current.col, TRUE);
481 setAnchorItem(current.row, current.col);
486 flags &= ~FLAG_UPDATE;
487 flags |= FLAG_PRESSED;
508 if (target && target->tryHandle(
this, FXSEL(SEL_CLICKED, message), ptr)) {
511 handle(
this, FXSEL(SEL_COMMAND, ID_START_INPUT),
nullptr);
526 if (target && target->tryHandle(
this, FXSEL(SEL_CLICKED, message), ptr)) {
529 handle(
this, FXSEL(SEL_COMMAND, ID_START_INPUT),
nullptr);
557 const std::string& format) {
589 const std::vector<std::string>& params) {
590 while ((
int)
myEnums.size() <= pos) {
591 myEnums.push_back(std::vector<std::string>());
599 const std::string& e) {
600 while ((
int)
myEnums.size() <= pos) {
601 myEnums.push_back(std::vector<std::string>());
607const 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,...