![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * T a b l e W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1999,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXTable.h,v 1.182 2009/01/16 11:14:51 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXTABLE_H 00024 #define FXTABLE_H 00025 00026 #ifndef FXSCROLLAREA_H 00027 #include "FXScrollArea.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 class FXIcon; 00034 class FXFont; 00035 class FXTable; 00036 class FXHeader; 00037 class FXButton; 00038 00039 00040 /// Default cell margin 00041 enum { DEFAULT_MARGIN = 2 }; 00042 00043 00044 00045 /// Table options 00046 enum { 00047 TABLE_COL_SIZABLE = 0x00100000, /// Columns are resizable 00048 TABLE_ROW_SIZABLE = 0x00200000, /// Rows are resizable 00049 TABLE_NO_COLSELECT = 0x00400000, /// Disallow column selections 00050 TABLE_NO_ROWSELECT = 0x00800000, /// Disallow row selections 00051 TABLE_READONLY = 0x01000000, /// Table is NOT editable 00052 TABLE_COL_RENUMBER = 0x02000000, /// Renumber columns 00053 TABLE_ROW_RENUMBER = 0x04000000 /// Renumber rows 00054 }; 00055 00056 00057 /// Position in table 00058 struct FXTablePos { 00059 FXint row; 00060 FXint col; 00061 }; 00062 00063 00064 /// Range of table cells 00065 struct FXTableRange { 00066 FXTablePos fm; 00067 FXTablePos to; 00068 }; 00069 00070 00071 /// Item in table 00072 class FXAPI FXTableItem : public FXObject { 00073 FXDECLARE(FXTableItem) 00074 friend class FXTable; 00075 protected: 00076 FXString label; 00077 FXIcon *icon; 00078 void *data; 00079 FXuint state; 00080 private: 00081 FXTableItem(const FXTableItem&); 00082 FXTableItem& operator=(const FXTableItem&); 00083 protected: 00084 FXTableItem():icon(NULL),data(NULL),state(0){} 00085 FXint textWidth(const FXTable* table) const; 00086 FXint textHeight(const FXTable* table) const; 00087 virtual void draw(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00088 virtual void drawBorders(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00089 virtual void drawContent(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00090 virtual void drawPattern(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00091 virtual void drawBackground(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00092 public: 00093 enum{ 00094 SELECTED = 0x00000001, /// Selected 00095 FOCUS = 0x00000002, /// Focus 00096 DISABLED = 0x00000004, /// Disabled 00097 DRAGGABLE = 0x00000008, /// Draggable 00098 RESERVED1 = 0x00000010, /// Reserved 00099 RESERVED2 = 0x00000020, /// Reserved 00100 ICONOWNED = 0x00000040, /// Icon owned by table item 00101 RIGHT = 0x00002000, /// Align on right (default) 00102 LEFT = 0x00004000, /// Align on left 00103 CENTER_X = 0, /// Aling centered horizontally 00104 TOP = 0x00008000, /// Align on top 00105 BOTTOM = 0x00010000, /// Align on bottom 00106 CENTER_Y = 0, /// Aling centered vertically (default) 00107 BEFORE = 0x00020000, /// Icon before the text 00108 AFTER = 0x00040000, /// Icon after the text 00109 ABOVE = 0x00080000, /// Icon above the text 00110 BELOW = 0x00100000, /// Icon below the text 00111 LBORDER = 0x00200000, /// Draw left border 00112 RBORDER = 0x00400000, /// Draw right border 00113 TBORDER = 0x00800000, /// Draw top border 00114 BBORDER = 0x01000000 /// Draw bottom border 00115 }; 00116 public: 00117 00118 /// Construct new table item 00119 FXTableItem(const FXString& text,FXIcon* ic=NULL,void* ptr=NULL):label(text),icon(ic),data(ptr),state(RIGHT|CENTER_Y){} 00120 00121 /// Change item's text label 00122 virtual void setText(const FXString& txt); 00123 00124 /// Return item's text label 00125 virtual FXString getText() const { return label; } 00126 00127 /// Change item's icon, deleting the old icon if it was owned 00128 virtual void setIcon(FXIcon* icn,FXbool owned=false); 00129 00130 /// Return item's icon 00131 virtual FXIcon* getIcon() const { return icon; } 00132 00133 /// Change item's user data 00134 void setData(void* ptr){ data=ptr; } 00135 00136 /// Get item's user data 00137 void* getData() const { return data; } 00138 00139 /// Make item draw as focused 00140 virtual void setFocus(FXbool focus); 00141 00142 /// Return true if item has focus 00143 FXbool hasFocus() const { return (state&FOCUS)!=0; } 00144 00145 /// Select item 00146 virtual void setSelected(FXbool selected); 00147 00148 /// Return true if this item is selected 00149 FXbool isSelected() const { return (state&SELECTED)!=0; } 00150 00151 /// Enable or disable item 00152 virtual void setEnabled(FXbool enabled); 00153 00154 /// Return true if this item is enabled 00155 FXbool isEnabled() const { return (state&DISABLED)==0; } 00156 00157 /// Make item draggable 00158 virtual void setDraggable(FXbool draggable); 00159 00160 /// Return true if this item is draggable 00161 FXbool isDraggable() const { return (state&DRAGGABLE)!=0; } 00162 00163 /// Change item content justification 00164 virtual void setJustify(FXuint justify=RIGHT|CENTER_Y); 00165 00166 /// Return item content justification 00167 FXuint getJustify() const { return state&(RIGHT|LEFT|TOP|BOTTOM); } 00168 00169 /// Change item icon position 00170 virtual void setIconPosition(FXuint mode); 00171 00172 /// Return item icon position 00173 FXuint getIconPosition() const { return state&(BEFORE|AFTER|ABOVE|BELOW); } 00174 00175 /// Change item borders 00176 virtual void setBorders(FXuint borders=0); 00177 00178 /// Return item borders 00179 FXuint getBorders() const { return state&(LBORDER|RBORDER|TBORDER|BBORDER); } 00180 00181 /// Change item background stipple 00182 virtual void setStipple(FXStipplePattern pattern); 00183 00184 /// Return item background stipple 00185 FXStipplePattern getStipple() const; 00186 00187 /// Create input control for editing this item 00188 virtual FXWindow* getControlFor(FXTable* table); 00189 00190 /// Set value from input control 00191 virtual void setFromControl(FXWindow* control); 00192 00193 /// Return width of item 00194 virtual FXint getWidth(const FXTable* table) const; 00195 00196 /// Return height of item 00197 virtual FXint getHeight(const FXTable* table) const; 00198 00199 /// Create server-side resources 00200 virtual void create(); 00201 00202 /// Detach server-side resources 00203 virtual void detach(); 00204 00205 /// Destroy server-side resources 00206 virtual void destroy(); 00207 00208 /// Save to stream 00209 virtual void save(FXStream& store) const; 00210 00211 /// Load from stream 00212 virtual void load(FXStream& store); 00213 00214 /// Destroy item and free icon if owned 00215 virtual ~FXTableItem(); 00216 }; 00217 00218 00219 /// Combobox Item 00220 class FXAPI FXComboTableItem : public FXTableItem { 00221 FXDECLARE(FXComboTableItem) 00222 protected: 00223 FXString selections; 00224 private: 00225 FXComboTableItem(const FXComboTableItem&); 00226 FXComboTableItem& operator=(const FXComboTableItem&); 00227 protected: 00228 FXComboTableItem(){} 00229 public: 00230 00231 /// Construct new table item 00232 FXComboTableItem(const FXString& text,FXIcon* ic=NULL,void* ptr=NULL); 00233 00234 /// Create input control for editing this item 00235 virtual FXWindow *getControlFor(FXTable* table); 00236 00237 /// Set value from input control 00238 virtual void setFromControl(FXWindow *control); 00239 00240 /// Set selections as newline-separated strings 00241 void setSelections(const FXString& strings); 00242 00243 /// Return selections 00244 const FXString& getSelections() const { return selections; } 00245 }; 00246 00247 00248 /** 00249 * The Table widget displays a table of items, each with a text and optional 00250 * icon. A column Header control provide captions for each column, and a row 00251 * Header control provides captions for each row. Columns are resizable by 00252 * means of the column Header control if the TABLE_COL_SIZABLE option is passed. 00253 * Likewise, rows in the table are resizable if the TABLE_ROW_SIZABLE option is 00254 * specified. An entire row (column) can be selected by clicking on the a button 00255 * in the row (column) Header control. Passing TABLE_NO_COLSELECT disables column 00256 * selection, and passing TABLE_NO_ROWSELECT disables column selection. 00257 * When TABLE_COL_RENUMBER is specified, columns are automatically renumbered when 00258 * columns are added or removed. Similarly, TABLE_ROW_RENUMBER will cause row numbers 00259 * to be recalculated automatically when rows are added or removed. 00260 * To disable editing of cells in the table, the TABLE_READONLY can be specified. 00261 * Cells in the table may or may not have items in them. When populating a cell 00262 * for the first time, an item will be automatically created if necessary. Thus, 00263 * a cell in the table takes no space unless it has actual contents. 00264 * Moreover, a contiguous, rectangular region of cells in the table may refer to 00265 * one single item; in that case, the item will be stretched to cover all the 00266 * cells in the region, and no grid lines will be drawn interior to the spanning 00267 * item. 00268 * The Table widget issues SEL_SELECTED or SEL_DESELECTED when cells are selected 00269 * or deselected, respectively. The table position affected is passed along as the 00270 * 3rd parameter of these messages. 00271 * Whenever the current (focus) item is changed, a SEL_CHANGED message is sent with 00272 * the new table position as a parameter. 00273 * When items are added to the table, a SEL_INSERTED message is sent, with the table 00274 * range of the newly added cells as the parameter in the message. 00275 * When items are removed from the table, a SEL_DELETED message is sent prior to the 00276 * removal of the items, and the table range of the removed cells is passed as a parameter. 00277 * A SEL_REPLACED message is sent when the contents of a cell are changed, either through 00278 * editing or by other means; the parameter is the range of affected cells. This message 00279 * is sent prior to the change. 00280 * SEL_CLICKED, SEL_DOUBLECLICKED, and SEL_TRIPLECLICKED messages are sent when a cell 00281 * is clicked, double-clicked, or triple-clicked, respectively. 00282 * A SEL_COMMAND is sent when an enabled item is clicked inside the table. 00283 */ 00284 class FXAPI FXTable : public FXScrollArea { 00285 FXDECLARE(FXTable) 00286 protected: 00287 FXHeader *colHeader; // Column header 00288 FXHeader *rowHeader; // Row header 00289 FXButton *cornerButton; // Corner button 00290 FXTableItem **cells; // Cells 00291 FXWindow *editor; // Editor widget 00292 FXFont *font; // Font 00293 FXint nrows; // Number of rows 00294 FXint ncols; // Number of columns 00295 FXint visiblerows; // Visible rows 00296 FXint visiblecols; // Visible columns 00297 FXint margintop; // Margin top 00298 FXint marginbottom; // Margin bottom 00299 FXint marginleft; // Margin left 00300 FXint marginright; // Margin right 00301 FXColor textColor; // Normal text color 00302 FXColor baseColor; // Base color 00303 FXColor hiliteColor; // Highlight color 00304 FXColor shadowColor; // Shadow color 00305 FXColor borderColor; // Border color 00306 FXColor selbackColor; // Select background color 00307 FXColor seltextColor; // Select text color 00308 FXColor gridColor; // Grid line color 00309 FXColor stippleColor; // Stipple color 00310 FXColor cellBorderColor; // Cell border color 00311 FXint cellBorderWidth; // Cell border width 00312 FXColor cellBackColor[2][2]; // Row/Column even/odd background color 00313 FXint defColWidth; // Default column width [if uniform columns] 00314 FXint defRowHeight; // Default row height [if uniform rows] 00315 FXTablePos current; // Current position 00316 FXTablePos anchor; // Anchor position 00317 FXTableRange input; // Input cell 00318 FXTableRange selection; // Range of selected cells 00319 FXString clipped; // Clipped text 00320 FXbool hgrid; // Horizontal grid lines shown 00321 FXbool vgrid; // Vertical grid lines shown 00322 FXuchar mode; // Mode widget is in 00323 FXint grabx; // Grab point x 00324 FXint graby; // Grab point y 00325 FXint rowcol; // Row or column being resized 00326 FXString help; 00327 public: 00328 static FXDragType csvType; 00329 static const FXchar csvTypeName[]; 00330 protected: 00331 FXTable(); 00332 FXint startRow(FXint row,FXint col) const; 00333 FXint startCol(FXint row,FXint col) const; 00334 FXint endRow(FXint row,FXint col) const; 00335 FXint endCol(FXint row,FXint col) const; 00336 void spanningRange(FXint& sr,FXint& er,FXint& sc,FXint& ec,FXint anchrow,FXint anchcol,FXint currow,FXint curcol); 00337 virtual void moveContents(FXint x,FXint y); 00338 virtual void drawCell(FXDC& dc,FXint sr,FXint er,FXint sc,FXint ec); 00339 virtual void drawRange(FXDC& dc,FXint rlo,FXint rhi,FXint clo,FXint chi); 00340 virtual void drawHGrid(FXDC& dc,FXint rlo,FXint rhi,FXint clo,FXint chi); 00341 virtual void drawVGrid(FXDC& dc,FXint rlo,FXint rhi,FXint clo,FXint chi); 00342 virtual void drawContents(FXDC& dc,FXint x,FXint y,FXint w,FXint h); 00343 virtual FXTableItem* createItem(const FXString& text,FXIcon* icon,void* ptr); 00344 virtual FXWindow* getControlForItem(FXint r,FXint c); 00345 virtual void setItemFromControl(FXint r,FXint c,FXWindow* control); 00346 virtual void updateColumnNumbers(FXint lo,FXint hi); 00347 virtual void updateRowNumbers(FXint lo,FXint hi); 00348 protected: 00349 enum { 00350 MOUSE_NONE, 00351 MOUSE_SCROLL, 00352 MOUSE_DRAG, 00353 MOUSE_SELECT 00354 }; 00355 private: 00356 FXTable(const FXTable&); 00357 FXTable& operator=(const FXTable&); 00358 public: 00359 long onPaint(FXObject*,FXSelector,void*); 00360 long onEnter(FXObject*,FXSelector,void*); 00361 long onLeave(FXObject*,FXSelector,void*); 00362 long onFocusIn(FXObject*,FXSelector,void*); 00363 long onFocusOut(FXObject*,FXSelector,void*); 00364 long onMotion(FXObject*,FXSelector,void*); 00365 long onKeyPress(FXObject*,FXSelector,void*); 00366 long onKeyRelease(FXObject*,FXSelector,void*); 00367 long onLeftBtnPress(FXObject*,FXSelector,void*); 00368 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00369 long onRightBtnPress(FXObject*,FXSelector,void*); 00370 long onRightBtnRelease(FXObject*,FXSelector,void*); 00371 long onUngrabbed(FXObject*,FXSelector,void*); 00372 long onSelectionLost(FXObject*,FXSelector,void*); 00373 long onSelectionGained(FXObject*,FXSelector,void*); 00374 long onSelectionRequest(FXObject*,FXSelector,void* ptr); 00375 long onClipboardLost(FXObject*,FXSelector,void*); 00376 long onClipboardGained(FXObject*,FXSelector,void*); 00377 long onClipboardRequest(FXObject*,FXSelector,void*); 00378 long onAutoScroll(FXObject*,FXSelector,void*); 00379 long onCommand(FXObject*,FXSelector,void*); 00380 long onClicked(FXObject*,FXSelector,void*); 00381 long onDoubleClicked(FXObject*,FXSelector,void*); 00382 long onTripleClicked(FXObject*,FXSelector,void*); 00383 long onQueryTip(FXObject*,FXSelector,void*); 00384 long onQueryHelp(FXObject*,FXSelector,void*); 00385 long onTipTimer(FXObject*,FXSelector,void*); 00386 00387 long onCmdToggleEditable(FXObject*,FXSelector,void*); 00388 long onUpdToggleEditable(FXObject*,FXSelector,void*); 00389 00390 // Visual characteristics 00391 long onCmdHorzGrid(FXObject*,FXSelector,void*); 00392 long onUpdHorzGrid(FXObject*,FXSelector,void*); 00393 long onCmdVertGrid(FXObject*,FXSelector,void*); 00394 long onUpdVertGrid(FXObject*,FXSelector,void*); 00395 00396 // Row/Column manipulations 00397 long onCmdDeleteColumn(FXObject*,FXSelector,void*); 00398 long onUpdDeleteColumn(FXObject*,FXSelector,void*); 00399 long onCmdDeleteRow(FXObject*,FXSelector,void*); 00400 long onUpdDeleteRow(FXObject*,FXSelector,void*); 00401 long onCmdInsertColumn(FXObject*,FXSelector,void*); 00402 long onUpdInsertColumn(FXObject*,FXSelector,void*); 00403 long onCmdInsertRow(FXObject*,FXSelector,void*); 00404 long onUpdInsertRow(FXObject*,FXSelector,void*); 00405 00406 // Movement 00407 long onCmdMoveRight(FXObject*,FXSelector,void*); 00408 long onCmdMoveLeft(FXObject*,FXSelector,void*); 00409 long onCmdMoveUp(FXObject*,FXSelector,void*); 00410 long onCmdMoveDown(FXObject*,FXSelector,void*); 00411 long onCmdMoveHome(FXObject*,FXSelector,void*); 00412 long onCmdMoveEnd(FXObject*,FXSelector,void*); 00413 long onCmdMoveTop(FXObject*,FXSelector,void*); 00414 long onCmdMoveBottom(FXObject*,FXSelector,void*); 00415 long onCmdMovePageDown(FXObject*,FXSelector,void*); 00416 long onCmdMovePageUp(FXObject*,FXSelector,void*); 00417 00418 // Mark and extend 00419 long onCmdMark(FXObject*,FXSelector,void*); 00420 long onCmdExtend(FXObject*,FXSelector,void*); 00421 00422 // Changing Selection 00423 long onUpdSelectCell(FXObject*,FXSelector,void*); 00424 long onCmdSelectCell(FXObject*,FXSelector,void*); 00425 long onUpdSelectRow(FXObject*,FXSelector,void*); 00426 long onCmdSelectRow(FXObject*,FXSelector,void*); 00427 long onUpdSelectColumn(FXObject*,FXSelector,void*); 00428 long onCmdSelectColumn(FXObject*,FXSelector,void*); 00429 long onCmdSelectRowIndex(FXObject*,FXSelector,void*); 00430 long onCmdSelectColumnIndex(FXObject*,FXSelector,void*); 00431 long onUpdSelectAll(FXObject*,FXSelector,void*); 00432 long onCmdSelectAll(FXObject*,FXSelector,void*); 00433 long onUpdDeselectAll(FXObject*,FXSelector,void*); 00434 long onCmdDeselectAll(FXObject*,FXSelector,void*); 00435 00436 // Manipulation Selection 00437 long onCmdCutSel(FXObject*,FXSelector,void*); 00438 long onCmdCopySel(FXObject*,FXSelector,void*); 00439 long onCmdDeleteSel(FXObject*,FXSelector,void*); 00440 long onCmdPasteSel(FXObject*,FXSelector,void*); 00441 long onUpdHaveSelection(FXObject*,FXSelector,void*); 00442 00443 // Edit control 00444 long onCmdStartInput(FXObject*,FXSelector,void*); 00445 long onUpdStartInput(FXObject*,FXSelector,void*); 00446 long onCmdAcceptInput(FXObject*,FXSelector,void*); 00447 long onUpdAcceptInput(FXObject*,FXSelector,void*); 00448 long onCmdCancelInput(FXObject*,FXSelector,void*); 00449 public: 00450 00451 enum { 00452 ID_HORZ_GRID=FXScrollArea::ID_LAST, 00453 ID_VERT_GRID, 00454 ID_TOGGLE_EDITABLE, 00455 ID_DELETE_COLUMN, 00456 ID_DELETE_ROW, 00457 ID_INSERT_COLUMN, 00458 ID_INSERT_ROW, 00459 ID_SELECT_COLUMN_INDEX, 00460 ID_SELECT_ROW_INDEX, 00461 ID_SELECT_COLUMN, 00462 ID_SELECT_ROW, 00463 ID_SELECT_CELL, 00464 ID_SELECT_ALL, 00465 ID_DESELECT_ALL, 00466 ID_MOVE_LEFT, 00467 ID_MOVE_RIGHT, 00468 ID_MOVE_UP, 00469 ID_MOVE_DOWN, 00470 ID_MOVE_HOME, 00471 ID_MOVE_END, 00472 ID_MOVE_TOP, 00473 ID_MOVE_BOTTOM, 00474 ID_MOVE_PAGEDOWN, 00475 ID_MOVE_PAGEUP, 00476 ID_START_INPUT, 00477 ID_CANCEL_INPUT, 00478 ID_ACCEPT_INPUT, 00479 ID_MARK, 00480 ID_EXTEND, 00481 ID_CUT_SEL, 00482 ID_COPY_SEL, 00483 ID_PASTE_SEL, 00484 ID_DELETE_SEL, 00485 ID_LAST 00486 }; 00487 00488 public: 00489 00490 /** 00491 * Construct a new table. 00492 * The table is initially empty, and reports a default size based on 00493 * the scroll areas's scrollbar placement policy. 00494 */ 00495 FXTable(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); 00496 00497 /// Return default width 00498 virtual FXint getDefaultWidth(); 00499 00500 /// Return default height 00501 virtual FXint getDefaultHeight(); 00502 00503 /// Computes content width 00504 virtual FXint getContentWidth(); 00505 00506 /// Computes content height 00507 virtual FXint getContentHeight(); 00508 00509 /// Return visible area x position 00510 virtual FXint getVisibleX() const; 00511 00512 /// Return visible area y position 00513 virtual FXint getVisibleY() const; 00514 00515 /// Return visible area width 00516 virtual FXint getVisibleWidth() const; 00517 00518 /// Return visible area height 00519 virtual FXint getVisibleHeight() const; 00520 00521 /// Create the server-side resources 00522 virtual void create(); 00523 00524 /// Detach the server-side resources 00525 virtual void detach(); 00526 00527 /// Perform layout 00528 virtual void layout(); 00529 00530 /// Mark this window's layout as dirty 00531 virtual void recalc(); 00532 00533 /// Table widget can receive focus 00534 virtual FXbool canFocus() const; 00535 00536 /// Move the focus to this window 00537 virtual void setFocus(); 00538 00539 /// Remove the focus from this window 00540 virtual void killFocus(); 00541 00542 /// Notification that focus moved to new child 00543 virtual void changeFocus(FXWindow *child); 00544 00545 /// Return button in the top/left corner 00546 FXButton* getCornerButton() const { return cornerButton; } 00547 00548 /// Return column header control 00549 FXHeader* getColumnHeader() const { return colHeader; } 00550 00551 /// Return row header control 00552 FXHeader* getRowHeader() const { return rowHeader; } 00553 00554 /// Change visible rows 00555 void setVisibleRows(FXint nvrows); 00556 00557 /// return number of visible rows 00558 FXint getVisibleRows() const { return visiblerows; } 00559 00560 /// Change visible columns 00561 void setVisibleColumns(FXint nvcols); 00562 00563 /// Return number of visible columns 00564 FXint getVisibleColumns() const { return visiblecols; } 00565 00566 /// Return true if table is editable 00567 FXbool isEditable() const; 00568 00569 /// Set editable flag 00570 void setEditable(FXbool edit=true); 00571 00572 /// Show or hide horizontal grid 00573 void showHorzGrid(FXbool on=true); 00574 00575 /// Is horizontal grid shown 00576 FXbool isHorzGridShown() const { return hgrid; } 00577 00578 /// Show or hide vertical grid 00579 void showVertGrid(FXbool on=true); 00580 00581 /// Is vertical grid shown 00582 FXbool isVertGridShown() const { return vgrid; } 00583 00584 /// Get number of rows 00585 FXint getNumRows() const { return nrows; } 00586 00587 /// Get number of columns 00588 FXint getNumColumns() const { return ncols; } 00589 00590 /// Change top cell margin 00591 void setMarginTop(FXint pt); 00592 00593 /// Return top cell margin 00594 FXint getMarginTop() const { return margintop; } 00595 00596 /// Change bottom cell margin 00597 void setMarginBottom(FXint pb); 00598 00599 /// Return bottom cell margin 00600 FXint getMarginBottom() const { return marginbottom; } 00601 00602 /// Change left cell margin 00603 void setMarginLeft(FXint pl); 00604 00605 /// Return left cell margin 00606 FXint getMarginLeft() const { return marginleft; } 00607 00608 /// Change right cell margin 00609 void setMarginRight(FXint pr); 00610 00611 /// Return right cell margin 00612 FXint getMarginRight() const { return marginright; } 00613 00614 /** 00615 * Start input mode for the cell at the given position. 00616 * An input control is created which is used to edit the cell; 00617 * it is filled by the original item's contents if the cell contained 00618 * an item. You can enter input mode also by sending the table an 00619 * ID_START_INPUT message. 00620 * Return true if editing of the cell has been started. 00621 */ 00622 virtual FXbool startInput(FXint row,FXint col); 00623 00624 /** 00625 * Cancel input mode. The input control is immediately deleted 00626 * and the cell will retain its old value. You can also cancel 00627 * input mode by sending the table an ID_CANCEL_INPUT message. 00628 * Return true if editing of the cell has been cancelled. 00629 */ 00630 virtual FXbool cancelInput(); 00631 00632 /** 00633 * End input mode and accept the new value from the control. 00634 * The item in the cell will be set to the value from the control, 00635 * and the control will be deleted. If true is passed, a SEL_REPLACED 00636 * callback will be generated to signify to the target that this call 00637 * has a new value. You can also accept the input by sending the table 00638 * an ID_ACCEPT_INPUT message. 00639 * Return true if the new value of the cell has been accepted. 00640 */ 00641 virtual FXbool acceptInput(FXbool notify=false); 00642 00643 /** 00644 * Determine column containing x. 00645 * Returns -1 if x left of first column, and ncols if x right of last column; 00646 * otherwise, returns column in table containing x. 00647 */ 00648 FXint colAtX(FXint x) const; 00649 00650 /** 00651 * Determine row containing y. 00652 * Returns -1 if y above first row, and nrows if y below last row; 00653 * otherwise, returns row in table containing y. 00654 */ 00655 FXint rowAtY(FXint y) const; 00656 00657 /// Return the item at the given index 00658 FXTableItem *getItem(FXint row,FXint col) const; 00659 00660 /// Replace the item with a [possibly subclassed] item 00661 void setItem(FXint row,FXint col,FXTableItem* item,FXbool notify=false); 00662 00663 /// Set the table size to nr rows and nc columns; all existing items will be removed 00664 virtual void setTableSize(FXint nr,FXint nc,FXbool notify=false); 00665 00666 /// Insert new row 00667 virtual void insertRows(FXint row,FXint nr=1,FXbool notify=false); 00668 00669 /// Insert new column 00670 virtual void insertColumns(FXint col,FXint nc=1,FXbool notify=false); 00671 00672 /// Remove rows of cells 00673 virtual void removeRows(FXint row,FXint nr=1,FXbool notify=false); 00674 00675 /// Remove column of cells 00676 virtual void removeColumns(FXint col,FXint nc=1,FXbool notify=false); 00677 00678 /// Extract item from table 00679 virtual FXTableItem* extractItem(FXint row,FXint col,FXbool notify=false); 00680 00681 /// Clear single cell 00682 virtual void removeItem(FXint row,FXint col,FXbool notify=false); 00683 00684 /// Clear all cells in the given range 00685 virtual void removeRange(FXint startrow,FXint endrow,FXint startcol,FXint endcol,FXbool notify=false); 00686 00687 /// Remove all items from table 00688 virtual void clearItems(FXbool notify=false); 00689 00690 /// Scroll to make cell at r,c fully visible 00691 virtual void makePositionVisible(FXint r,FXint c); 00692 00693 /// Return true if item partially visible 00694 FXbool isItemVisible(FXint r,FXint c) const; 00695 00696 /** 00697 * Change column header height mode to fixed or variable. 00698 * In variable height mode, the column header will size to 00699 * fit the contents in it. In fixed mode, the size is 00700 * explicitly set using setColumnHeaderHeight(). 00701 * The default is to determine the column header height 00702 * based on the contents, using the LAYOUT_MIN_HEIGHT option. 00703 */ 00704 void setColumnHeaderMode(FXuint hint=LAYOUT_FIX_HEIGHT); 00705 00706 /// Return column header height mode 00707 FXuint getColumnHeaderMode() const; 00708 00709 /** 00710 * Change row header width mode to fixed or variable. 00711 * In variable width mode, the row header will size to 00712 * fit the contents in it. In fixed mode, the size is 00713 * explicitly set using setRowHeaderWidth(). 00714 * The default is to determine the column header height 00715 * based on the contents, using the LAYOUT_MIN_WIDTH option. 00716 */ 00717 void setRowHeaderMode(FXuint hint=LAYOUT_FIX_WIDTH); 00718 00719 /// Return row header width mode 00720 FXuint getRowHeaderMode() const; 00721 00722 /// Set column header font 00723 void setColumnHeaderFont(FXFont* fnt); 00724 00725 /// Return column header font 00726 FXFont* getColumnHeaderFont() const; 00727 00728 /// Set row header font 00729 void setRowHeaderFont(FXFont* fnt); 00730 00731 /// Return row header font 00732 FXFont* getRowHeaderFont() const; 00733 00734 /// Change column header height 00735 void setColumnHeaderHeight(FXint h); 00736 00737 /// Return column header height 00738 FXint getColumnHeaderHeight() const; 00739 00740 /// Change row header width 00741 void setRowHeaderWidth(FXint w); 00742 00743 /// Return row header width 00744 FXint getRowHeaderWidth() const; 00745 00746 /// Get X coordinate of column 00747 FXint getColumnX(FXint col) const; 00748 00749 /// Get Y coordinate of row 00750 FXint getRowY(FXint row) const; 00751 00752 /// Change column width 00753 virtual void setColumnWidth(FXint col,FXint cwidth); 00754 00755 /// Get column width 00756 FXint getColumnWidth(FXint col) const; 00757 00758 /// Change row height 00759 virtual void setRowHeight(FXint row,FXint rheight); 00760 00761 /// Get row height 00762 FXint getRowHeight(FXint row) const; 00763 00764 /// Change default column width 00765 void setDefColumnWidth(FXint cwidth); 00766 00767 /// Get default column width 00768 FXint getDefColumnWidth() const { return defColWidth; } 00769 00770 /// Change default row height 00771 void setDefRowHeight(FXint rheight); 00772 00773 /// Get default row height 00774 FXint getDefRowHeight() const { return defRowHeight; } 00775 00776 /// Return minimum row height 00777 FXint getMinRowHeight(FXint r) const; 00778 00779 /// Return minimum column width 00780 FXint getMinColumnWidth(FXint c) const; 00781 00782 /// Fit row heights to contents 00783 void fitRowsToContents(FXint row,FXint nr=1); 00784 00785 /// Fit column widths to contents 00786 void fitColumnsToContents(FXint col,FXint nc=1); 00787 00788 /// Change column header text 00789 void setColumnText(FXint index,const FXString& text); 00790 00791 /// Return text of column header at index 00792 FXString getColumnText(FXint index) const; 00793 00794 /// Change row header text 00795 void setRowText(FXint index,const FXString& text); 00796 00797 /// Return text of row header at index 00798 FXString getRowText(FXint index) const; 00799 00800 /// Change column header icon 00801 void setColumnIcon(FXint index,FXIcon* icon); 00802 00803 /// Return icon of column header at index 00804 FXIcon* getColumnIcon(FXint index) const; 00805 00806 /// Change row header icon 00807 void setRowIcon(FXint index,FXIcon* icon); 00808 00809 /// Return icon of row header at index 00810 FXIcon* getRowIcon(FXint index) const; 00811 00812 /// Change column header tip text 00813 void setColumnTipText(FXint index,const FXString& text); 00814 00815 /// Return tip text of column header at index 00816 FXString getColumnTipText(FXint index) const; 00817 00818 /// Change row header tip text 00819 void setRowTipText(FXint index,const FXString& text); 00820 00821 /// Return tip text of row header at index 00822 FXString getRowTipText(FXint index) const; 00823 00824 /// Change column header icon position, e.g. FXHeaderItem::BEFORE, etc. 00825 void setColumnIconPosition(FXint index,FXuint m); 00826 00827 /// Return icon position of column header at index 00828 FXuint getColumnIconPosition(FXint index) const; 00829 00830 /// Change row header icon position, e.g. FXHeaderItem::BEFORE, etc. 00831 void setRowIconPosition(FXint index,FXuint m); 00832 00833 /// Return icon position of row header at index 00834 FXuint getRowIconPosition(FXint index) const; 00835 00836 /// Change column header justify, e.g. FXHeaderItem::RIGHT, etc. 00837 void setColumnJustify(FXint index,FXuint justify); 00838 00839 /// Return justify of column header at index 00840 FXuint getColumnJustify(FXint index) const; 00841 00842 /// Change row header justify, e.g. FXHeaderItem::RIGHT, etc. 00843 void setRowJustify(FXint index,FXuint justify); 00844 00845 /// Return justify of row header at index 00846 FXuint getRowJustify(FXint index) const; 00847 00848 /// Modify cell text 00849 void setItemText(FXint r,FXint c,const FXString& text,FXbool notify=false); 00850 00851 /// Return cell text 00852 FXString getItemText(FXint r,FXint c) const; 00853 00854 /// Modify cell icon, deleting the old icon if it was owned 00855 void setItemIcon(FXint r,FXint c,FXIcon* icon,FXbool owned=false,FXbool notify=false); 00856 00857 /// Return cell icon 00858 FXIcon* getItemIcon(FXint r,FXint c) const; 00859 00860 /// Modify cell user-data 00861 void setItemData(FXint r,FXint c,void* ptr); 00862 void* getItemData(FXint r,FXint c) const; 00863 00864 /** 00865 * Extract cells from given range as text, each column separated by a string cs, 00866 * and each row separated by a string rs. 00867 */ 00868 void extractText(FXchar*& text,FXint& size,FXint startrow,FXint endrow,FXint startcol,FXint endcol,const FXchar* cs="\t",const FXchar* rs="\n") const; 00869 void extractText(FXString& text,FXint startrow,FXint endrow,FXint startcol,FXint endcol,const FXchar* cs="\t",const FXchar* rs="\n") const; 00870 00871 /** 00872 * Overlay text over given cell range; the text is interpreted as 00873 * a number of columns separated by a character from the set cs, and 00874 * a number of rows separated by a character from the set rs. 00875 * Cells outside the given cell range are unaffected. 00876 */ 00877 void overlayText(FXint startrow,FXint endrow,FXint startcol,FXint endcol,const FXchar* text,FXint size,const FXchar* cs="\t,",const FXchar* rs="\n",FXbool notify=false); 00878 void overlayText(FXint startrow,FXint endrow,FXint startcol,FXint endcol,const FXString& text,const FXchar* cs="\t,",const FXchar* rs="\n",FXbool notify=false); 00879 00880 /** 00881 * Determine the number of rows and columns in a block of text 00882 * where columns are separated by characters from the set cs, and rows 00883 * are separated by characters from the set rs. 00884 */ 00885 void countText(FXint& nr,FXint& nc,const FXchar* text,FXint size,const FXchar* cs="\t,",const FXchar* rs="\n") const; 00886 void countText(FXint& nr,FXint& nc,const FXString& text,const FXchar* cs="\t,",const FXchar* rs="\n") const; 00887 00888 /// Return true if its a spanning cell 00889 FXbool isItemSpanning(FXint r,FXint c) const; 00890 00891 /// Repaint cells between grid lines sr,er and grid lines sc,ec 00892 void updateRange(FXint sr,FXint er,FXint sc,FXint ec) const; 00893 00894 /// Repaint cell at r,c 00895 void updateItem(FXint r,FXint c) const; 00896 00897 /// Enable item 00898 virtual FXbool enableItem(FXint r,FXint c); 00899 00900 /// Disable item 00901 virtual FXbool disableItem(FXint r,FXint c); 00902 00903 /// Is item enabled and editable 00904 FXbool isItemEnabled(FXint r,FXint c) const; 00905 00906 /** 00907 * Change item justification. Horizontal justification is controlled by passing 00908 * FXTableItem::RIGHT, FXTableItem::LEFT, or FXTableItem::CENTER_X. 00909 * Vertical justification is controlled by FXTableItem::TOP, FXTableItem::BOTTOM, 00910 * or FXTableItem::CENTER_Y. 00911 * The default is a combination of FXTableItem::RIGHT and FXTableItem::CENTER_Y. 00912 */ 00913 void setItemJustify(FXint r,FXint c,FXuint justify); 00914 00915 /// Return item justification 00916 FXuint getItemJustify(FXint r,FXint c) const; 00917 00918 /** 00919 * Change relative position of icon and text of item. 00920 * Passing FXTableItem::BEFORE or FXTableItem::AFTER places the icon 00921 * before or after the text, and passing FXTableItem::ABOVE or 00922 * FXTableItem::BELOW places it above or below the text, respectively. 00923 * The default is 0 which places the text on top of the icon. 00924 */ 00925 void setItemIconPosition(FXint r,FXint c,FXuint m); 00926 00927 /// Return relative icon and text position 00928 FXuint getItemIconPosition(FXint r,FXint c) const; 00929 00930 /** 00931 * Change item borders style. Borders on each side of the item can be turned 00932 * controlled individually using FXTableItem::LBORDER, FXTableItem::RBORDER, 00933 * FXTableItem::TBORDER and FXTableItem::BBORDER. 00934 */ 00935 void setItemBorders(FXint r,FXint c,FXuint borders); 00936 00937 /// Return item border style 00938 FXuint getItemBorders(FXint r,FXint c) const; 00939 00940 /// Change item background stipple style 00941 void setItemStipple(FXint r,FXint c,FXStipplePattern pat); 00942 00943 /// return item background stipple style 00944 FXStipplePattern getItemStipple(FXint r,FXint c) const; 00945 00946 /// Change current item 00947 virtual void setCurrentItem(FXint r,FXint c,FXbool notify=false); 00948 00949 /// Get row number of current item 00950 FXint getCurrentRow() const { return current.row; } 00951 00952 /// Get column number of current item 00953 FXint getCurrentColumn() const { return current.col; } 00954 00955 /// Is item current 00956 FXbool isItemCurrent(FXint r,FXint c) const; 00957 00958 /// Change anchor item 00959 void setAnchorItem(FXint r,FXint c); 00960 00961 /// Get row number of anchor item 00962 FXint getAnchorRow() const { return anchor.row; } 00963 00964 /// Get column number of anchor item 00965 FXint getAnchorColumn() const { return anchor.col; } 00966 00967 /// Get selection start row; returns -1 if no selection 00968 FXint getSelStartRow() const { return selection.fm.row; } 00969 00970 /// Get selection start column; returns -1 if no selection 00971 FXint getSelStartColumn() const { return selection.fm.col; } 00972 00973 /// Get selection end row; returns -1 if no selection 00974 FXint getSelEndRow() const { return selection.to.row; } 00975 00976 /// Get selection end column; returns -1 if no selection 00977 FXint getSelEndColumn() const { return selection.to.col; } 00978 00979 /// Is cell selected 00980 FXbool isItemSelected(FXint r,FXint c) const; 00981 00982 /// Is row of cells selected 00983 FXbool isRowSelected(FXint r) const; 00984 00985 /// Is column selected 00986 FXbool isColumnSelected(FXint c) const; 00987 00988 /// Is anything selected 00989 FXbool isAnythingSelected() const; 00990 00991 /// Select a row 00992 virtual FXbool selectRow(FXint row,FXbool notify=false); 00993 00994 /// Select a column 00995 virtual FXbool selectColumn(FXint col,FXbool notify=false); 00996 00997 /// Select range 00998 virtual FXbool selectRange(FXint startrow,FXint endrow,FXint startcol,FXint endcol,FXbool notify=false); 00999 01000 /// Extend selection 01001 virtual FXbool extendSelection(FXint r,FXint c,FXbool notify=false); 01002 01003 /// Kill selection 01004 virtual FXbool killSelection(FXbool notify=false); 01005 01006 /// Change font 01007 void setFont(FXFont* fnt); 01008 01009 /// Return current font 01010 FXFont* getFont() const { return font; } 01011 01012 /// Obtain colors of various parts 01013 FXColor getTextColor() const { return textColor; } 01014 FXColor getBaseColor() const { return baseColor; } 01015 FXColor getHiliteColor() const { return hiliteColor; } 01016 FXColor getShadowColor() const { return shadowColor; } 01017 FXColor getBorderColor() const { return borderColor; } 01018 FXColor getSelBackColor() const { return selbackColor; } 01019 FXColor getSelTextColor() const { return seltextColor; } 01020 FXColor getGridColor() const { return gridColor; } 01021 FXColor getStippleColor() const { return stippleColor; } 01022 FXColor getCellBorderColor() const { return cellBorderColor; } 01023 01024 /// Change colors of various parts 01025 void setTextColor(FXColor clr); 01026 void setBaseColor(FXColor clr); 01027 void setHiliteColor(FXColor clr); 01028 void setShadowColor(FXColor clr); 01029 void setBorderColor(FXColor clr); 01030 void setSelBackColor(FXColor clr); 01031 void setSelTextColor(FXColor clr); 01032 void setGridColor(FXColor clr); 01033 void setStippleColor(FXColor clr); 01034 void setCellBorderColor(FXColor clr); 01035 01036 /// Change cell background color for even/odd rows/columns 01037 void setCellColor(FXint r,FXint c,FXColor clr); 01038 01039 /// Obtain cell background color for even/odd rows/columns 01040 FXColor getCellColor(FXint r,FXint c) const; 01041 01042 /// Change cell border width 01043 void setCellBorderWidth(FXint borderwidth); 01044 01045 /// Return cell border width 01046 FXint getCellBorderWidth() const { return cellBorderWidth; } 01047 01048 /// Change table style 01049 void setTableStyle(FXuint style); 01050 01051 /// Return table style 01052 FXuint getTableStyle() const; 01053 01054 /// Set column renumbering 01055 void setColumnRenumbering(FXbool flag); 01056 01057 /// Get column renumbering 01058 FXbool getColumnRenumbering() const; 01059 01060 /// Set row renumbering 01061 void setRowRenumbering(FXbool flag); 01062 01063 /// Get row renumbering 01064 FXbool getRowRenumbering() const; 01065 01066 /// Change help text 01067 void setHelpText(const FXString& text){ help=text; } 01068 const FXString& getHelpText() const { return help; } 01069 01070 /// Serialize 01071 virtual void save(FXStream& store) const; 01072 virtual void load(FXStream& store); 01073 01074 virtual ~FXTable(); 01075 }; 01076 01077 } 01078 01079 #endif
![]() |