#include <MFXAddEditTypedTable.h>

Definition at line 48 of file MFXAddEditTypedTable.h.
Public Types | |
| enum | { ID_TEXT_CHANGED = FXTable::ID_LAST, ID_LAST } |
Public Member Functions | |
| void | addEnum (size_t pos, const std::string &e) |
| void | cancelInput () |
| CellType | getCellType (size_t pos) const |
| const std::vector< std::string > & | getEnums (size_t pos) const |
| NumberCellParams | getNumberCellParams (size_t pos) const |
| MFXAddEditTypedTable (FXComposite *p, FXObject *tgt=NULL, FXSelector sel=0, FXuint opts=0, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_MARGIN, FXint pr=DEFAULT_MARGIN, FXint pt=DEFAULT_MARGIN, FXint pb=DEFAULT_MARGIN) | |
| long | onClicked (FXObject *, FXSelector, void *ptr) |
| long | onDoubleClicked (FXObject *, FXSelector, void *ptr) |
| long | onLeftBtnPress (FXObject *, FXSelector, void *ptr) |
| long | onLeftBtnRelease (FXObject *, FXSelector, void *ptr) |
| void | setCellType (size_t pos, CellType t) |
| void | setEnums (size_t pos, const std::vector< std::string > ¶ms) |
| void | setNumberCellParams (size_t pos, double min, double max, double steps1, double steps2, double steps3, const std::string &format) |
| ~MFXAddEditTypedTable () | |
Protected Member Functions | |
| void | acceptInput (FXbool notify) |
| virtual FXWindow * | getControlForItem (FXint r, FXint c) |
| MFXAddEditTypedTable () | |
| virtual void | setItemFromControl (FXint r, FXint c, FXWindow *control) |
| void | setItemFromControl_NoRelease (FXint r, FXint c, FXWindow *control) |
Protected Attributes | |
| std::vector< CellType > | myCellTypes |
| std::vector< std::vector < std::string > > | myEnums |
| std::vector< NumberCellParams > | myNumberCellParams |
Data Structures | |
| struct | EditedTableItem |
| struct | NumberCellParams |
| anonymous enum |
Definition at line 136 of file MFXAddEditTypedTable.h.
00136 { 00137 ID_TEXT_CHANGED = FXTable::ID_LAST, 00138 ID_LAST 00139 };
| MFXAddEditTypedTable::MFXAddEditTypedTable | ( | FXComposite * | p, | |
| FXObject * | tgt = NULL, |
|||
| FXSelector | sel = 0, |
|||
| FXuint | opts = 0, |
|||
| FXint | x = 0, |
|||
| FXint | y = 0, |
|||
| FXint | w = 0, |
|||
| FXint | h = 0, |
|||
| FXint | pl = DEFAULT_MARGIN, |
|||
| FXint | pr = DEFAULT_MARGIN, |
|||
| FXint | pt = DEFAULT_MARGIN, |
|||
| FXint | pb = DEFAULT_MARGIN | |||
| ) |
| MFXAddEditTypedTable::~MFXAddEditTypedTable | ( | ) |
| MFXAddEditTypedTable::MFXAddEditTypedTable | ( | ) | [inline, protected] |
| void MFXAddEditTypedTable::acceptInput | ( | FXbool | notify | ) | [protected] |
Definition at line 291 of file MFXAddEditTypedTable.cpp.
References cancelInput(), setItemFromControl(), and setItemFromControl_NoRelease().
00291 { 00292 bool set = false; 00293 FXTableRange tablerange=input; 00294 if (editor) { 00295 // 00296 // 00297 FXRealSpinDial *dial = dynamic_cast<FXRealSpinDial*>(editor); 00298 if (dial!=0) { 00299 if (!dial->getDial().grabbed()) { 00300 set = true; 00301 } else { 00302 setItemFromControl_NoRelease(input.fm.row,input.fm.col,editor); 00303 } 00304 } 00305 if (dynamic_cast<FXTextField*>(editor)!=0) { 00306 set = true; 00307 } 00308 } 00309 if (set) { 00310 setItemFromControl(input.fm.row,input.fm.col,editor); 00311 cancelInput(); 00312 if (notify && target) { 00313 target->tryHandle(this,FXSEL(SEL_REPLACED,message),(void*)&tablerange); 00314 } 00315 } 00316 }
| void MFXAddEditTypedTable::addEnum | ( | size_t | pos, | |
| const std::string & | e | |||
| ) |
| void MFXAddEditTypedTable::cancelInput | ( | ) |
Definition at line 278 of file MFXAddEditTypedTable.cpp.
Referenced by acceptInput().
00278 { 00279 if (editor) { 00280 delete editor; 00281 input.fm.row=-1; 00282 input.to.row=-1; 00283 input.fm.col=-1; 00284 input.to.col=-1; 00285 editor=NULL; 00286 } 00287 }
Definition at line 546 of file MFXAddEditTypedTable.cpp.
References CT_UNDEFINED, and myCellTypes.
Referenced by getControlForItem(), setItemFromControl(), and setItemFromControl_NoRelease().
00546 { 00547 if (myCellTypes.size()<=pos) { 00548 return CT_UNDEFINED; 00549 } 00550 return myCellTypes[pos]; 00551 }
| FXWindow * MFXAddEditTypedTable::getControlForItem | ( | FXint | r, | |
| FXint | c | |||
| ) | [protected, virtual] |
Definition at line 201 of file MFXAddEditTypedTable.cpp.
References CT_BOOL, CT_ENUM, CT_INT, CT_REAL, CT_STRING, CT_UNDEFINED, MFXAddEditTypedTable::NumberCellParams::format, getCellType(), getNumberCellParams(), MFXAddEditTypedTable::NumberCellParams::max, MFXAddEditTypedTable::NumberCellParams::min, MFXAddEditTypedTable::NumberCellParams::steps1, MFXAddEditTypedTable::NumberCellParams::steps2, and MFXAddEditTypedTable::NumberCellParams::steps3.
00201 { 00202 register FXTableItem* item=cells[r*ncols+c]; 00203 if (item==NULL) { 00204 return 0; 00205 cells[r*ncols+c]=item=createItem("",NULL,NULL); 00206 if (isItemSelected(r,c)) item->setSelected(FALSE); 00207 } 00208 delete editor; 00209 editor=NULL; 00210 switch (getCellType(c)) { 00211 case CT_UNDEFINED: 00212 case CT_STRING: { 00213 register FXTextField *field; 00214 register FXuint justify=0; 00215 field=new FXTextField(this,1,NULL,0,TEXTFIELD_ENTER_ONLY,0,0,0,0,getMarginLeft(),getMarginRight(),getMarginTop(),getMarginBottom()); 00216 // !!! if(state&LEFT) justify|=JUSTIFY_LEFT; 00217 // !!! if(state&RIGHT) justify|=JUSTIFY_RIGHT; 00218 // !!! if(state&TOP) justify|=JUSTIFY_TOP; 00219 // !!! if(state&BOTTOM) justify|=JUSTIFY_BOTTOM; 00220 field->create(); 00221 field->setJustify(justify); 00222 field->setFont(getFont()); 00223 field->setBackColor(getBackColor()); 00224 field->setTextColor(getTextColor()); 00225 field->setSelBackColor(getSelBackColor()); 00226 field->setSelTextColor(getSelTextColor()); 00227 field->setText(item->getText()); 00228 field->selectAll(); 00229 return field; 00230 } 00231 case CT_REAL: 00232 // return myNumberEditor; 00233 case CT_INT: { 00234 register FXRealSpinDial *field; 00235 //register FXuint justify=0; 00236 field=new FXRealSpinDial(this,1,NULL,0,TEXTFIELD_ENTER_ONLY,0,0,0,0,getMarginLeft(),getMarginRight(),getMarginTop(),getMarginBottom()); 00237 // !!! if(state&LEFT) justify|=JUSTIFY_LEFT; 00238 // !!! if(state&RIGHT) justify|=JUSTIFY_RIGHT; 00239 // !!! if(state&TOP) justify|=JUSTIFY_TOP; 00240 // !!! if(state&BOTTOM) justify|=JUSTIFY_BOTTOM; 00241 field->create(); 00242 // field->setJustify(justify); 00243 field->setFont(getFont()); 00244 field->setBackColor(getBackColor()); 00245 field->setTextColor(getTextColor()); 00246 field->setSelBackColor(getSelBackColor()); 00247 field->setSelTextColor(getSelTextColor()); 00248 NumberCellParams p = getNumberCellParams(c); 00249 if (p.format!="undefined") { 00250 field->setFormatString((char*) p.format.c_str()); 00251 field->setIncrements(p.steps1, p.steps2, p.steps3); 00252 field->setRange(p.min, p.max); 00253 } 00254 try { 00255 if (getCellType(c)==CT_REAL) { 00256 field->setValue(TplConvert<char>::_2SUMOReal(item->getText().text())); 00257 } else { 00258 field->setValue(TplConvert<char>::_2int(item->getText().text())); 00259 } 00260 } catch (NumberFormatException &) { 00261 field->setValue(0); 00262 } 00263 field->selectAll(); 00264 return field; 00265 } 00266 case CT_BOOL: 00267 // return myBoolEditor; 00268 case CT_ENUM: 00269 // return myEnumEditor; 00270 default: 00271 throw 1; 00272 } 00273 }
| const std::vector< std::string > & MFXAddEditTypedTable::getEnums | ( | size_t | pos | ) | const |
Definition at line 618 of file MFXAddEditTypedTable.cpp.
References myEnums.
00618 { 00619 return myEnums[pos]; 00620 }
| MFXAddEditTypedTable::NumberCellParams MFXAddEditTypedTable::getNumberCellParams | ( | size_t | pos | ) | const |
Definition at line 586 of file MFXAddEditTypedTable.cpp.
References MFXAddEditTypedTable::NumberCellParams::format, and myNumberCellParams.
Referenced by getControlForItem().
00586 { 00587 if (myNumberCellParams.size()<=pos) { 00588 NumberCellParams np; 00589 np.format = "undefined"; 00590 return np; 00591 } 00592 return myNumberCellParams[pos]; 00593 }
| long MFXAddEditTypedTable::onClicked | ( | FXObject * | , | |
| FXSelector | , | |||
| void * | ptr | |||
| ) |
Definition at line 511 of file MFXAddEditTypedTable.cpp.
00511 { 00512 if (editor) { 00513 delete editor; 00514 input.fm.row=-1; 00515 input.to.row=-1; 00516 input.fm.col=-1; 00517 input.to.col=-1; 00518 editor=NULL; 00519 current.row=-1; 00520 current.col=-1; 00521 } 00522 if (target && target->tryHandle(this,FXSEL(SEL_CLICKED,message),ptr)) return 1; 00523 handle(this,FXSEL(SEL_COMMAND,ID_START_INPUT),NULL); 00524 return 1; 00525 }
| long MFXAddEditTypedTable::onDoubleClicked | ( | FXObject * | , | |
| FXSelector | , | |||
| void * | ptr | |||
| ) |
Definition at line 529 of file MFXAddEditTypedTable.cpp.
00529 { 00530 if (editor) { 00531 delete editor; 00532 input.fm.row=-1; 00533 input.to.row=-1; 00534 input.fm.col=-1; 00535 input.to.col=-1; 00536 editor=NULL; 00537 } else { 00538 if (target && target->tryHandle(this,FXSEL(SEL_CLICKED,message),ptr)) return 1; 00539 handle(this,FXSEL(SEL_COMMAND,ID_START_INPUT),NULL); 00540 } 00541 return 1; 00542 }
| long MFXAddEditTypedTable::onLeftBtnPress | ( | FXObject * | , | |
| FXSelector | , | |||
| void * | ptr | |||
| ) |
Definition at line 452 of file MFXAddEditTypedTable.cpp.
00452 { 00453 FXEvent* event=(FXEvent*)ptr; 00454 FXTablePos tablepos; 00455 flags&=~FLAG_TIP; 00456 handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr); 00457 if (isEnabled()) { 00458 grab(); 00459 if (target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1; 00460 00461 // Cell being clicked on 00462 tablepos.row=rowAtY(event->win_y); 00463 tablepos.col=colAtX(event->win_x); 00464 00465 // Outside table 00466 if (tablepos.row<0 || tablepos.row>=nrows || tablepos.col<0 || tablepos.col>=ncols) { 00467 setCurrentItem(-1, -1,TRUE); 00468 return 0; 00469 } 00470 00471 // Change current item 00472 bool wasEdited = editor!=0; 00473 setCurrentItem(tablepos.row,tablepos.col,TRUE); 00474 if (!wasEdited) { 00475 00476 // Select or deselect 00477 if (event->state&SHIFTMASK) { 00478 if (0<=anchor.row && 0<=anchor.col) { 00479 if (isItemEnabled(anchor.row,anchor.col)) { 00480 extendSelection(current.row,current.col,TRUE); 00481 } 00482 } else { 00483 setAnchorItem(current.row,current.col); 00484 if (isItemEnabled(current.row,current.col)) { 00485 extendSelection(current.row,current.col,TRUE); 00486 } 00487 } 00488 mode=MOUSE_SELECT; 00489 } else { 00490 if (isItemEnabled(current.row,current.col)) { 00491 killSelection(TRUE); 00492 setAnchorItem(current.row,current.col); 00493 extendSelection(current.row,current.col,TRUE); 00494 } else { 00495 setAnchorItem(current.row,current.col); 00496 } 00497 mode=MOUSE_SELECT; 00498 } 00499 } 00500 flags&=~FLAG_UPDATE; 00501 flags|=FLAG_PRESSED; 00502 return 1; 00503 } 00504 return 0; 00505 }
| long MFXAddEditTypedTable::onLeftBtnRelease | ( | FXObject * | , | |
| FXSelector | , | |||
| void * | ptr | |||
| ) |
Definition at line 414 of file MFXAddEditTypedTable.cpp.
00414 { 00415 FXEvent* event=(FXEvent*)ptr; 00416 if (isEnabled()) { 00417 ungrab(); 00418 flags&=~FLAG_PRESSED; 00419 flags|=FLAG_UPDATE; 00420 mode=MOUSE_NONE; 00421 stopAutoScroll(); 00422 setDragCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR)); 00423 if (target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONRELEASE,message),ptr)) return 1; 00424 00425 // Scroll to make item visibke 00426 makePositionVisible(current.row,current.col); 00427 00428 // Update anchor 00429 //setAnchorItem(current.row,current.col); // FIXME look into the selection stuff 00430 00431 // Generate clicked callbacks 00432 if (event->click_count==1) { 00433 handle(this,FXSEL(SEL_CLICKED,0),(void*)¤t); 00434 } else if (event->click_count==2) { 00435 handle(this,FXSEL(SEL_DOUBLECLICKED,0),(void*)¤t); 00436 } else if (event->click_count==3) { 00437 handle(this,FXSEL(SEL_TRIPLECLICKED,0),(void*)¤t); 00438 } 00439 00440 // Command callback only when clicked on item 00441 if (0<=current.row && 0<=current.col && isItemEnabled(current.row,current.col)) { 00442 handle(this,FXSEL(SEL_COMMAND,0),(void*)¤t); 00443 } 00444 return 1; 00445 } 00446 return 0; 00447 }
Definition at line 555 of file MFXAddEditTypedTable.cpp.
References CT_UNDEFINED, and myCellTypes.
Referenced by GUIDialog_ViewSettings::rebuildColorMatrices().
00555 { 00556 while (myCellTypes.size()<pos+1) { 00557 myCellTypes.push_back(CT_UNDEFINED); 00558 } 00559 myCellTypes[pos] = t; 00560 }
| void MFXAddEditTypedTable::setEnums | ( | size_t | pos, | |
| const std::vector< std::string > & | params | |||
| ) |
| void MFXAddEditTypedTable::setItemFromControl | ( | FXint | r, | |
| FXint | c, | |||
| FXWindow * | control | |||
| ) | [protected, virtual] |
Definition at line 322 of file MFXAddEditTypedTable.cpp.
References MFXAddEditTypedTable::EditedTableItem::col, CT_BOOL, CT_ENUM, CT_INT, CT_REAL, CT_STRING, CT_UNDEFINED, getCellType(), ID_TEXT_CHANGED, MFXAddEditTypedTable::EditedTableItem::item, MFXAddEditTypedTable::EditedTableItem::row, toString(), and MFXAddEditTypedTable::EditedTableItem::updateOnly.
Referenced by acceptInput().
00322 { 00323 register FXTableItem* item=cells[r*ncols+c]; 00324 if (item==NULL) { 00325 cells[r*ncols+c]=item=createItem("",NULL,NULL); 00326 if (isItemSelected(r,c)) item->setSelected(FALSE); 00327 } 00328 switch (getCellType(c)) { 00329 case CT_UNDEFINED: 00330 case CT_STRING: 00331 item->setFromControl(control); 00332 break; 00333 case CT_REAL: 00334 item->setText(toString(static_cast<FXRealSpinDial*>(control)->getValue()).c_str()); 00335 break; 00336 case CT_INT: 00337 item->setText(toString((int) static_cast<FXRealSpinDial*>(control)->getValue()).c_str()); 00338 break; 00339 case CT_BOOL: 00340 // return myBoolEditor; 00341 case CT_ENUM: 00342 // return myEnumEditor; 00343 default: 00344 throw 1; 00345 } 00346 // current.row = -1; 00347 // current.col = -1; 00348 EditedTableItem edited; 00349 edited.item = item; 00350 edited.row = r; 00351 edited.col = c; 00352 edited.updateOnly = false; 00353 killSelection(true); 00354 bool accepted = true; 00355 if (target) { 00356 if (!target->handle(this,FXSEL(SEL_CHANGED, ID_TEXT_CHANGED), (void*) &edited)) { 00357 accepted = false; 00358 // !!! item->setText(myPreviousText); 00359 } 00360 } 00361 if (accepted) { 00362 if (edited.row==getNumRows()-1) { 00363 insertRows(getNumRows(), 1, true); 00364 for (int i=0; i<getNumColumns(); i++) { 00365 setItemText(getNumRows()-1, i, ""); 00366 setItemJustify(getNumRows()-1, i, JUSTIFY_CENTER_X); 00367 } 00368 } 00369 } 00370 mode = MOUSE_NONE; 00371 }
| void MFXAddEditTypedTable::setItemFromControl_NoRelease | ( | FXint | r, | |
| FXint | c, | |||
| FXWindow * | control | |||
| ) | [protected] |
Definition at line 375 of file MFXAddEditTypedTable.cpp.
References MFXAddEditTypedTable::EditedTableItem::col, CT_BOOL, CT_ENUM, CT_INT, CT_REAL, CT_STRING, CT_UNDEFINED, getCellType(), ID_TEXT_CHANGED, MFXAddEditTypedTable::EditedTableItem::item, MFXAddEditTypedTable::EditedTableItem::row, toString(), and MFXAddEditTypedTable::EditedTableItem::updateOnly.
Referenced by acceptInput().
00375 { 00376 register FXTableItem* item=cells[r*ncols+c]; 00377 if (item==NULL) { 00378 return; 00379 } 00380 switch (getCellType(c)) { 00381 case CT_UNDEFINED: 00382 case CT_STRING: 00383 item->setFromControl(control); 00384 break; 00385 case CT_REAL: 00386 item->setText(toString(static_cast<FXRealSpinDial*>(control)->getValue()).c_str()); 00387 break; 00388 case CT_INT: 00389 item->setText(toString((int) static_cast<FXRealSpinDial*>(control)->getValue()).c_str()); 00390 break; 00391 case CT_BOOL: 00392 // return myBoolEditor; 00393 case CT_ENUM: 00394 // return myEnumEditor; 00395 default: 00396 throw 1; 00397 } 00398 EditedTableItem edited; 00399 edited.item = item; 00400 edited.row = r; 00401 edited.col = c; 00402 edited.updateOnly = true; 00403 bool accepted = true; 00404 if (target) { 00405 if (!target->handle(this,FXSEL(SEL_CHANGED, ID_TEXT_CHANGED), (void*) &edited)) { 00406 accepted = false; 00407 // !!! item->setText(myPreviousText); 00408 } 00409 } 00410 }
| void MFXAddEditTypedTable::setNumberCellParams | ( | size_t | pos, | |
| double | min, | |||
| double | max, | |||
| double | steps1, | |||
| double | steps2, | |||
| double | steps3, | |||
| const std::string & | format | |||
| ) |
Definition at line 563 of file MFXAddEditTypedTable.cpp.
References MFXAddEditTypedTable::NumberCellParams::format, MFXAddEditTypedTable::NumberCellParams::max, MFXAddEditTypedTable::NumberCellParams::min, myNumberCellParams, MFXAddEditTypedTable::NumberCellParams::pos, MFXAddEditTypedTable::NumberCellParams::steps1, MFXAddEditTypedTable::NumberCellParams::steps2, and MFXAddEditTypedTable::NumberCellParams::steps3.
Referenced by GUIDialog_ViewSettings::rebuildColorMatrices().
00567 { 00568 while (myNumberCellParams.size()<=pos) { 00569 NumberCellParams np; 00570 np.format = "undefined"; 00571 myNumberCellParams.push_back(np); 00572 } 00573 NumberCellParams np; 00574 np.pos = pos; 00575 np.min = min; 00576 np.max = max; 00577 np.steps1 = steps1; 00578 np.steps2 = steps2; 00579 np.steps3 = steps3; 00580 np.format = format; 00581 myNumberCellParams[pos] = np; 00582 }
std::vector<CellType> MFXAddEditTypedTable::myCellTypes [protected] |
Definition at line 154 of file MFXAddEditTypedTable.h.
Referenced by getCellType(), and setCellType().
std::vector<std::vector<std::string> > MFXAddEditTypedTable::myEnums [protected] |
Definition at line 156 of file MFXAddEditTypedTable.h.
Referenced by addEnum(), getEnums(), and setEnums().
std::vector<NumberCellParams> MFXAddEditTypedTable::myNumberCellParams [protected] |
Definition at line 155 of file MFXAddEditTypedTable.h.
Referenced by getNumberCellParams(), and setNumberCellParams().
1.5.6