46 FXIMPLEMENT(
MFXAddEditTypedTable, FXTable, MFXAddEditTypedTableMap, ARRAYNUMBER(MFXAddEditTypedTableMap))
50 FXSelector sel, FXuint opts,
51 FXint x, FXint y, FXint w, FXint h,
52 FXint pl, FXint pr, FXint pt, FXint pb)
53 : FXTable(p, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb) {}
198 FXTableItem* item = cells[r * ncols + c];
213 field =
new FXTextField(
this, 1, NULL, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
219 field->setJustify(justify);
220 field->setFont(getFont());
221 field->setBackColor(getBackColor());
222 field->setTextColor(getTextColor());
223 field->setSelBackColor(getSelBackColor());
224 field->setSelTextColor(getSelTextColor());
225 field->setText(item->getText());
232 FXRealSpinDial* field;
234 field =
new FXRealSpinDial(
this, 1, NULL, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
241 field->setFont(getFont());
242 field->setBackColor(getBackColor());
243 field->setTextColor(getTextColor());
244 field->setSelBackColor(getSelBackColor());
245 field->setSelTextColor(getSelTextColor());
247 if (p.
format !=
"undefined") {
248 field->setFormatString((
char*) p.
format.c_str());
250 field->setRange(p.
min, p.
max);
291 FXTableRange tablerange = input;
295 FXRealSpinDial* dial =
dynamic_cast<FXRealSpinDial*
>(editor);
297 if (!dial->getDial().grabbed()) {
303 if (dynamic_cast<FXTextField*>(editor) != 0) {
310 if (notify && target) {
311 target->tryHandle(
this, FXSEL(SEL_REPLACED, message), (
void*)&tablerange);
321 FXTableItem* item = cells[r * ncols + c];
323 cells[r * ncols + c] = item = createItem(
"", NULL, NULL);
324 if (isItemSelected(r, c)) {
325 item->setSelected(FALSE);
331 item->setFromControl(control);
334 item->setText(
toString(static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
337 item->setText(
toString((
int) static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
354 bool accepted =
true;
356 if (!target->handle(
this, FXSEL(SEL_CHANGED,
ID_TEXT_CHANGED), (
void*) &edited)) {
362 if (edited.
row == getNumRows() - 1) {
363 insertRows(getNumRows(), 1,
true);
364 for (
int i = 0; i < getNumColumns(); i++) {
365 setItemText(getNumRows() - 1, i,
"");
366 setItemJustify(getNumRows() - 1, i, JUSTIFY_CENTER_X);
376 FXTableItem* item = cells[r * ncols + c];
383 item->setFromControl(control);
386 item->setText(
toString(static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
389 item->setText(
toString((
int) static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
404 if (!target->handle(
this, FXSEL(SEL_CHANGED,
ID_TEXT_CHANGED), (
void*) &edited)) {
413 FXEvent*
event = (FXEvent*)ptr;
416 flags &= ~FLAG_PRESSED;
417 flags |= FLAG_UPDATE;
420 setDragCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR));
421 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONRELEASE, message), ptr)) {
426 makePositionVisible(current.row, current.col);
432 if (event->click_count == 1) {
433 handle(
this, FXSEL(SEL_CLICKED, 0), (
void*)¤t);
434 }
else if (event->click_count == 2) {
435 handle(
this, FXSEL(SEL_DOUBLECLICKED, 0), (
void*)¤t);
436 }
else if (event->click_count == 3) {
437 handle(
this, FXSEL(SEL_TRIPLECLICKED, 0), (
void*)¤t);
441 if (0 <= current.row && 0 <= current.col && isItemEnabled(current.row, current.col)) {
442 handle(
this, FXSEL(SEL_COMMAND, 0), (
void*)¤t);
453 FXEvent*
event = (FXEvent*)ptr;
456 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
459 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONPRESS, message), ptr)) {
464 tablepos.row = rowAtY(event->win_y);
465 tablepos.col = colAtX(event->win_x);
468 if (tablepos.row < 0 || tablepos.row >= nrows || tablepos.col < 0 || tablepos.col >= ncols) {
469 setCurrentItem(-1, -1, TRUE);
474 bool wasEdited = editor != 0;
475 setCurrentItem(tablepos.row, tablepos.col, TRUE);
479 if (event->state & SHIFTMASK) {
480 if (0 <= anchor.row && 0 <= anchor.col) {
481 if (isItemEnabled(anchor.row, anchor.col)) {
482 extendSelection(current.row, current.col, TRUE);
485 setAnchorItem(current.row, current.col);
486 if (isItemEnabled(current.row, current.col)) {
487 extendSelection(current.row, current.col, TRUE);
492 if (isItemEnabled(current.row, current.col)) {
494 setAnchorItem(current.row, current.col);
495 extendSelection(current.row, current.col, TRUE);
497 setAnchorItem(current.row, current.col);
502 flags &= ~FLAG_UPDATE;
503 flags |= FLAG_PRESSED;
524 if (target && target->tryHandle(
this, FXSEL(SEL_CLICKED, message), ptr)) {
527 handle(
this, FXSEL(SEL_COMMAND, ID_START_INPUT), NULL);
542 if (target && target->tryHandle(
this, FXSEL(SEL_CLICKED, message), ptr)) {
545 handle(
this, FXSEL(SEL_COMMAND, ID_START_INPUT), NULL);
573 const std::string& format) {
605 const std::vector<std::string>& params) {
606 while ((
int)
myEnums.size() <= pos) {
607 myEnums.push_back(std::vector<std::string>());
615 const std::string& e) {
616 while ((
int)
myEnums.size() <= pos) {
617 myEnums.push_back(std::vector<std::string>());
623 const std::vector<std::string>&
std::vector< std::vector< std::string > > myEnums
void setItemFromControl_NoRelease(FXint r, FXint c, FXWindow *control)
long onDoubleClicked(FXObject *, FXSelector, void *ptr)
void setEnums(int pos, const std::vector< std::string > ¶ms)
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)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
CellType getCellType(int pos) const
long onClicked(FXObject *, FXSelector, void *ptr)
long onLeftBtnRelease(FXObject *, FXSelector, void *ptr)
const std::vector< std::string > & getEnums(int pos) const
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
NumberCellParams getNumberCellParams(int pos) const
long onLeftBtnPress(FXObject *, FXSelector, void *ptr)
static double _2double(const E *const data)
converts a char-type array into the double value described by it
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[]