47 FXIMPLEMENT(
MFXAddEditTypedTable, FXTable, MFXAddEditTypedTableMap, ARRAYNUMBER(MFXAddEditTypedTableMap))
51 FXSelector sel, FXuint opts,
52 FXint x, FXint y, FXint w, FXint h,
53 FXint pl, FXint pr, FXint pt, FXint pb)
54 : FXTable(p, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb) {}
199 register FXTableItem* item = cells[r * ncols + c];
212 register FXTextField* field;
213 register FXuint justify = 0;
214 field =
new FXTextField(
this, 1, NULL, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
220 field->setJustify(justify);
221 field->setFont(getFont());
222 field->setBackColor(getBackColor());
223 field->setTextColor(getTextColor());
224 field->setSelBackColor(getSelBackColor());
225 field->setSelTextColor(getSelTextColor());
226 field->setText(item->getText());
233 register FXRealSpinDial* field;
235 field =
new FXRealSpinDial(
this, 1, NULL, 0, TEXTFIELD_ENTER_ONLY, 0, 0, 0, 0, getMarginLeft(), getMarginRight(), getMarginTop(), getMarginBottom());
242 field->setFont(getFont());
243 field->setBackColor(getBackColor());
244 field->setTextColor(getTextColor());
245 field->setSelBackColor(getSelBackColor());
246 field->setSelTextColor(getSelTextColor());
248 if (p.
format !=
"undefined") {
249 field->setFormatString((
char*) p.
format.c_str());
251 field->setRange(p.
min, p.
max);
292 FXTableRange tablerange = input;
296 FXRealSpinDial* dial =
dynamic_cast<FXRealSpinDial*
>(editor);
298 if (!dial->getDial().grabbed()) {
304 if (dynamic_cast<FXTextField*>(editor) != 0) {
311 if (notify && target) {
312 target->tryHandle(
this, FXSEL(SEL_REPLACED, message), (
void*)&tablerange);
322 register FXTableItem* item = cells[r * ncols + c];
324 cells[r * ncols + c] = item = createItem(
"", NULL, NULL);
325 if (isItemSelected(r, c)) {
326 item->setSelected(FALSE);
332 item->setFromControl(control);
335 item->setText(
toString(static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
338 item->setText(
toString((
int) static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
355 bool accepted =
true;
357 if (!target->handle(
this, FXSEL(SEL_CHANGED,
ID_TEXT_CHANGED), (
void*) &edited)) {
363 if (edited.
row == getNumRows() - 1) {
364 insertRows(getNumRows(), 1,
true);
365 for (
int i = 0; i < getNumColumns(); i++) {
366 setItemText(getNumRows() - 1, i,
"");
367 setItemJustify(getNumRows() - 1, i, JUSTIFY_CENTER_X);
377 register FXTableItem* item = cells[r * ncols + c];
384 item->setFromControl(control);
387 item->setText(
toString(static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
390 item->setText(
toString((
int) static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
405 if (!target->handle(
this, FXSEL(SEL_CHANGED,
ID_TEXT_CHANGED), (
void*) &edited)) {
414 FXEvent*
event = (FXEvent*)ptr;
417 flags &= ~FLAG_PRESSED;
418 flags |= FLAG_UPDATE;
421 setDragCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR));
422 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONRELEASE, message), ptr)) {
427 makePositionVisible(current.row, current.col);
433 if (event->click_count == 1) {
434 handle(
this, FXSEL(SEL_CLICKED, 0), (
void*)¤t);
435 }
else if (event->click_count == 2) {
436 handle(
this, FXSEL(SEL_DOUBLECLICKED, 0), (
void*)¤t);
437 }
else if (event->click_count == 3) {
438 handle(
this, FXSEL(SEL_TRIPLECLICKED, 0), (
void*)¤t);
442 if (0 <= current.row && 0 <= current.col && isItemEnabled(current.row, current.col)) {
443 handle(
this, FXSEL(SEL_COMMAND, 0), (
void*)¤t);
454 FXEvent*
event = (FXEvent*)ptr;
457 handle(
this, FXSEL(SEL_FOCUS_SELF, 0), ptr);
460 if (target && target->tryHandle(
this, FXSEL(SEL_LEFTBUTTONPRESS, message), ptr)) {
465 tablepos.row = rowAtY(event->win_y);
466 tablepos.col = colAtX(event->win_x);
469 if (tablepos.row < 0 || tablepos.row >= nrows || tablepos.col < 0 || tablepos.col >= ncols) {
470 setCurrentItem(-1, -1, TRUE);
475 bool wasEdited = editor != 0;
476 setCurrentItem(tablepos.row, tablepos.col, TRUE);
480 if (event->state & SHIFTMASK) {
481 if (0 <= anchor.row && 0 <= anchor.col) {
482 if (isItemEnabled(anchor.row, anchor.col)) {
483 extendSelection(current.row, current.col, TRUE);
486 setAnchorItem(current.row, current.col);
487 if (isItemEnabled(current.row, current.col)) {
488 extendSelection(current.row, current.col, TRUE);
493 if (isItemEnabled(current.row, current.col)) {
495 setAnchorItem(current.row, current.col);
496 extendSelection(current.row, current.col, TRUE);
498 setAnchorItem(current.row, current.col);
503 flags &= ~FLAG_UPDATE;
504 flags |= FLAG_PRESSED;
525 if (target && target->tryHandle(
this, FXSEL(SEL_CLICKED, message), ptr)) {
528 handle(
this, FXSEL(SEL_COMMAND, ID_START_INPUT), NULL);
543 if (target && target->tryHandle(
this, FXSEL(SEL_CLICKED, message), ptr)) {
546 handle(
this, FXSEL(SEL_COMMAND, ID_START_INPUT), NULL);
574 const std::string& format) {
606 const std::vector<std::string>& params) {
607 while ((
int)
myEnums.size() <= pos) {
608 myEnums.push_back(std::vector<std::string>());
616 const std::string& e) {
617 while ((
int)
myEnums.size() <= pos) {
618 myEnums.push_back(std::vector<std::string>());
624 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[]