Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXTable.h

00001 /******************************************************************************** 00002 * * 00003 * T a b l e W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1999,2005 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (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 GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXTable.h,v 1.150 2005/02/06 17:20:00 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXTABLE_H 00025 #define FXTABLE_H 00026 00027 #ifndef FXSCROLLAREA_H 00028 #include "FXScrollArea.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 class FXIcon; 00035 class FXFont; 00036 class FXTable; 00037 class FXHeader; 00038 class FXButton; 00039 00040 00041 /// Default cell margin 00042 enum { DEFAULT_MARGIN = 2 }; 00043 00044 00045 00046 /// Table options 00047 enum { 00048 TABLE_COL_SIZABLE = 0x00100000, /// Columns are resizable 00049 TABLE_ROW_SIZABLE = 0x00200000, /// Rows are resizable 00050 TABLE_HEADERS_SIZABLE = 0x00400000, /// Headers are sizable 00051 TABLE_NO_COLSELECT = 0x00900000, /// Disallow column selections 00052 TABLE_NO_ROWSELECT = 0x01000000, /// Disallow row selections 00053 TABLE_READONLY = 0x02000000 /// Table is NOT editable 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 protected: 00081 FXTableItem():icon(NULL),data(NULL),state(0){} 00082 FXint textWidth(const FXTable* table) const; 00083 FXint textHeight(const FXTable* table) const; 00084 virtual void draw(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00085 virtual void drawBorders(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00086 virtual void drawContent(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00087 virtual void drawPattern(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00088 virtual void drawBackground(const FXTable* table,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 00089 public: 00090 enum{ 00091 SELECTED = 0x00000001, /// Selected 00092 FOCUS = 0x00000002, /// Focus 00093 DISABLED = 0x00000004, /// Disabled 00094 DRAGGABLE = 0x00000008, /// Draggable 00095 RESERVED1 = 0x00000010, /// Reserved 00096 RESERVED2 = 0x00000020, /// Reserved 00097 ICONOWNED = 0x00000040, /// Icon owned by table item 00098 RIGHT = 0x00002000, /// Align on right 00099 LEFT = 0x00004000, /// Align on left 00100 CENTER_X = 0, /// Aling centered horizontally (default) 00101 TOP = 0x00008000, /// Align on top 00102 BOTTOM = 0x00010000, /// Align on bottom 00103 CENTER_Y = 0, /// Aling centered vertically (default) 00104 BEFORE = 0x00020000, /// Icon before the text 00105 AFTER = 0x00040000, /// Icon after the text 00106 ABOVE = 0x00080000, /// Icon above the text 00107 BELOW = 0x00100000, /// Icon below the text 00108 LBORDER = 0x00200000, /// Draw left border 00109 RBORDER = 0x00400000, /// Draw right border 00110 TBORDER = 0x00800000, /// Draw top border 00111 BBORDER = 0x01000000 /// Draw bottom border 00112 }; 00113 public: 00114 00115 /// Construct new table item 00116 FXTableItem(const FXString& text,FXIcon* ic=NULL,void* ptr=NULL):label(text),icon(ic),data(ptr),state(RIGHT|CENTER_Y){} 00117 00118 /// Change item's text label 00119 virtual void setText(const FXString& txt); 00120 00121 /// Return item's text label 00122 virtual FXString getText() const { return label; } 00123 00124 /// Change item's icon, deleting the old icon if it was owned 00125 virtual void setIcon(FXIcon* icn,FXbool owned=FALSE); 00126 00127 /// Return item's icon 00128 virtual FXIcon* getIcon() const { return icon; } 00129 00130 /// Change item's user data 00131 void setData(void* ptr){ data=ptr; } 00132 00133 /// Get item's user data 00134 void* getData() const { return data; } 00135 00136 /// Make item draw as focused 00137 virtual void setFocus(FXbool focus); 00138 00139 /// Return true if item has focus 00140 FXbool hasFocus() const { return (state&FOCUS)!=0; } 00141 00142 /// Select item 00143 virtual void setSelected(FXbool selected); 00144 00145 /// Return true if this item is selected 00146 FXbool isSelected() const { return (state&SELECTED)!=0; } 00147 00148 /// Enable or disable item 00149 virtual void setEnabled(FXbool enabled); 00150 00151 /// Return true if this item is enabled 00152 FXbool isEnabled() const { return (state&DISABLED)==0; } 00153 00154 /// Make item draggable 00155 virtual void setDraggable(FXbool draggable); 00156 00157 /// Return true if this item is draggable 00158 FXbool isDraggable() const { return (state&DRAGGABLE)!=0; } 00159 00160 /// Change item content justification 00161 virtual void setJustify(FXuint justify=RIGHT|CENTER_Y); 00162 00163 /// Return item content justification 00164 FXuint getJustify() const { return state&(RIGHT|LEFT|TOP|BOTTOM); } 00165 00166 /// Change item icon position 00167 virtual void setIconPosition(FXuint mode); 00168 00169 /// Return item icon position 00170 FXuint getIconPosition() const { return state&(BEFORE|AFTER|ABOVE|BELOW); } 00171 00172 /// Change item borders 00173 virtual void setBorders(FXuint borders=0); 00174 00175 /// Return item borders 00176 FXuint getBorders() const { return state&(LBORDER|RBORDER|TBORDER|BBORDER); } 00177 00178 /// Change item background stipple 00179 virtual void setStipple(FXStipplePattern pattern); 00180 00181 /// Return item background stipple 00182 FXStipplePattern getStipple() const; 00183 00184 /// Create input control for editing this item 00185 virtual FXWindow *getControlFor(FXTable* table); 00186 00187 /// Set value from input control 00188 virtual void setFromControl(FXWindow *control); 00189 00190 /// Return width of item 00191 virtual FXint getWidth(const FXTable* table) const; 00192 00193 /// Return height of item 00194 virtual FXint getHeight(const FXTable* table) const; 00195 00196 /// Create server-side resources 00197 virtual void create(); 00198 00199 /// Detach server-side resources 00200 virtual void detach(); 00201 00202 /// Destroy server-side resources 00203 virtual void destroy(); 00204 00205 /// Save to stream 00206 virtual void save(FXStream& store) const; 00207 00208 /// Load from stream 00209 virtual void load(FXStream& store); 00210 00211 /// Destroy item and free icon if owned 00212 virtual ~FXTableItem(); 00213 }; 00214 00215 00216 00217 /// Table Widget 00218 class FXAPI FXTable : public FXScrollArea { 00219 FXDECLARE(FXTable) 00220 protected: 00221 FXHeader *colHeader; // Column header 00222 FXHeader *rowHeader; // Row header 00223 FXButton *cornerButton; // Corner button 00224 FXTableItem **cells; // Cells 00225 FXWindow *editor; // Editor widget 00226 FXFont *font; // Font 00227 FXint nrows; // Number of rows 00228 FXint ncols; // Number of columns 00229 FXint visiblerows; // Visible rows 00230 FXint visiblecols; // Visible columns 00231 FXint margintop; // Margin top 00232 FXint marginbottom; // Margin bottom 00233 FXint marginleft; // Margin left 00234 FXint marginright; // Margin right 00235 FXColor textColor; // Normal text color 00236 FXColor baseColor; // Base color 00237 FXColor hiliteColor; // Highlight color 00238 FXColor shadowColor; // Shadow color 00239 FXColor borderColor; // Border color 00240 FXColor selbackColor; // Select background color 00241 FXColor seltextColor; // Select text color 00242 FXColor gridColor; // Grid line color 00243 FXColor stippleColor; // Stipple color 00244 FXColor cellBorderColor; // Cell border color 00245 FXint cellBorderWidth; // Cell border width 00246 FXColor cellBackColor[2][2]; // Row/Column even/odd background color 00247 FXint defColWidth; // Default column width [if uniform columns] 00248 FXint defRowHeight; // Default row height [if uniform rows] 00249 FXTablePos current; // Current position 00250 FXTablePos anchor; // Anchor position 00251 FXTableRange input; // Input cell 00252 FXTableRange selection; // Range of selected cells 00253 FXchar *clipbuffer; // Clipped text 00254 FXint cliplength; // Length of clipped text 00255 FXbool hgrid; // Horizontal grid lines shown 00256 FXbool vgrid; // Vertical grid lines shown 00257 FXuchar mode; // Mode widget is in 00258 FXint grabx; // Grab point x 00259 FXint graby; // Grab point y 00260 FXint rowcol; // Row or column being resized 00261 FXString help; 00262 public: 00263 static FXDragType csvType; 00264 static const FXchar csvTypeName[]; 00265 protected: 00266 FXTable(); 00267 FXint startRow(FXint row,FXint col) const; 00268 FXint startCol(FXint row,FXint col) const; 00269 FXint endRow(FXint row,FXint col) const; 00270 FXint endCol(FXint row,FXint col) const; 00271 void spanningRange(FXint& sr,FXint& er,FXint& sc,FXint& ec,FXint anchrow,FXint anchcol,FXint currow,FXint curcol); 00272 virtual void moveContents(FXint x,FXint y); 00273 virtual void drawCell(FXDC& dc,FXint sr,FXint er,FXint sc,FXint ec); 00274 virtual void drawRange(FXDC& dc,FXint rlo,FXint rhi,FXint clo,FXint chi); 00275 virtual void drawHGrid(FXDC& dc,FXint rlo,FXint rhi,FXint clo,FXint chi); 00276 virtual void drawVGrid(FXDC& dc,FXint rlo,FXint rhi,FXint clo,FXint chi); 00277 virtual void drawContents(FXDC& dc,FXint x,FXint y,FXint w,FXint h); 00278 virtual FXTableItem* createItem(const FXString& text,FXIcon* icon,void* ptr); 00279 virtual FXWindow *getControlForItem(FXint r,FXint c); 00280 virtual void setItemFromControl(FXint r,FXint c,FXWindow *control); 00281 void countText(FXint& nr,FXint& nc,const FXchar* text,FXint size,FXchar cs='\t',FXchar rs='\n') const; 00282 protected: 00283 enum { 00284 MOUSE_NONE, 00285 MOUSE_SCROLL, 00286 MOUSE_DRAG, 00287 MOUSE_SELECT, 00288 MOUSE_COL_SIZE, 00289 MOUSE_ROW_SIZE 00290 }; 00291 private: 00292 FXTable(const FXTable&); 00293 FXTable& operator=(const FXTable&); 00294 public: 00295 long onPaint(FXObject*,FXSelector,void*); 00296 long onFocusIn(FXObject*,FXSelector,void*); 00297 long onFocusOut(FXObject*,FXSelector,void*); 00298 long onMotion(FXObject*,FXSelector,void*); 00299 long onKeyPress(FXObject*,FXSelector,void*); 00300 long onKeyRelease(FXObject*,FXSelector,void*); 00301 long onLeftBtnPress(FXObject*,FXSelector,void*); 00302 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00303 long onRightBtnPress(FXObject*,FXSelector,void*); 00304 long onRightBtnRelease(FXObject*,FXSelector,void*); 00305 long onUngrabbed(FXObject*,FXSelector,void*); 00306 long onSelectionLost(FXObject*,FXSelector,void*); 00307 long onSelectionGained(FXObject*,FXSelector,void*); 00308 long onSelectionRequest(FXObject*,FXSelector,void* ptr); 00309 long onClipboardLost(FXObject*,FXSelector,void*); 00310 long onClipboardGained(FXObject*,FXSelector,void*); 00311 long onClipboardRequest(FXObject*,FXSelector,void*); 00312 long onAutoScroll(FXObject*,FXSelector,void*); 00313 long onCommand(FXObject*,FXSelector,void*); 00314 long onClicked(FXObject*,FXSelector,void*); 00315 long onDoubleClicked(FXObject*,FXSelector,void*); 00316 long onTripleClicked(FXObject*,FXSelector,void*); 00317 00318 long onCmdToggleEditable(FXObject*,FXSelector,void*); 00319 long onUpdToggleEditable(FXObject*,FXSelector,void*); 00320 00321 // Visual characteristics 00322 long onCmdHorzGrid(FXObject*,FXSelector,void*); 00323 long onUpdHorzGrid(FXObject*,FXSelector,void*); 00324 long onCmdVertGrid(FXObject*,FXSelector,void*); 00325 long onUpdVertGrid(FXObject*,FXSelector,void*); 00326 00327 // Row/Column manipulations 00328 long onCmdDeleteColumn(FXObject*,FXSelector,void*); 00329 long onUpdDeleteColumn(FXObject*,FXSelector,void*); 00330 long onCmdDeleteRow(FXObject*,FXSelector,void*); 00331 long onUpdDeleteRow(FXObject*,FXSelector,void*); 00332 long onCmdInsertColumn(FXObject*,FXSelector,void*); 00333 long onUpdInsertColumn(FXObject*,FXSelector,void*); 00334 long onCmdInsertRow(FXObject*,FXSelector,void*); 00335 long onUpdInsertRow(FXObject*,FXSelector,void*); 00336 00337 // Movement 00338 long onCmdMoveRight(FXObject*,FXSelector,void*); 00339 long onCmdMoveLeft(FXObject*,FXSelector,void*); 00340 long onCmdMoveUp(FXObject*,FXSelector,void*); 00341 long onCmdMoveDown(FXObject*,FXSelector,void*); 00342 long onCmdMoveHome(FXObject*,FXSelector,void*); 00343 long onCmdMoveEnd(FXObject*,FXSelector,void*); 00344 long onCmdMoveTop(FXObject*,FXSelector,void*); 00345 long onCmdMoveBottom(FXObject*,FXSelector,void*); 00346 long onCmdMovePageDown(FXObject*,FXSelector,void*); 00347 long onCmdMovePageUp(FXObject*,FXSelector,void*); 00348 00349 // Mark and extend 00350 long onCmdMark(FXObject*,FXSelector,void*); 00351 long onCmdExtend(FXObject*,FXSelector,void*); 00352 00353 // Changing Selection 00354 long onCmdSelectCell(FXObject*,FXSelector,void*); 00355 long onCmdSelectRow(FXObject*,FXSelector,void*); 00356 long onCmdSelectColumn(FXObject*,FXSelector,void*); 00357 long onCmdSelectRowIndex(FXObject*,FXSelector,void*); 00358 long onCmdSelectColumnIndex(FXObject*,FXSelector,void*); 00359 long onCmdSelectAll(FXObject*,FXSelector,void*); 00360 long onCmdDeselectAll(FXObject*,FXSelector,void*); 00361 00362 // Manipulation Selection 00363 long onCmdCutSel(FXObject*,FXSelector,void*); 00364 long onCmdCopySel(FXObject*,FXSelector,void*); 00365 long onCmdDeleteSel(FXObject*,FXSelector,void*); 00366 long onCmdPasteSel(FXObject*,FXSelector,void*); 00367 long onUpdHaveSelection(FXObject*,FXSelector,void*); 00368 00369 // Edit control 00370 long onCmdStartInput(FXObject*,FXSelector,void*); 00371 long onUpdStartInput(FXObject*,FXSelector,void*); 00372 long onCmdAcceptInput(FXObject*,FXSelector,void*); 00373 long onUpdAcceptInput(FXObject*,FXSelector,void*); 00374 long onCmdCancelInput(FXObject*,FXSelector,void*); 00375 public: 00376 00377 enum { 00378 ID_HORZ_GRID=FXScrollArea::ID_LAST, 00379 ID_VERT_GRID, 00380 ID_TOGGLE_EDITABLE, 00381 ID_DELETE_COLUMN, 00382 ID_DELETE_ROW, 00383 ID_INSERT_COLUMN, 00384 ID_INSERT_ROW, 00385 ID_SELECT_COLUMN_INDEX, 00386 ID_SELECT_ROW_INDEX, 00387 ID_SELECT_COLUMN, 00388 ID_SELECT_ROW, 00389 ID_SELECT_CELL, 00390 ID_SELECT_ALL, 00391 ID_DESELECT_ALL, 00392 ID_MOVE_LEFT, 00393 ID_MOVE_RIGHT, 00394 ID_MOVE_UP, 00395 ID_MOVE_DOWN, 00396 ID_MOVE_HOME, 00397 ID_MOVE_END, 00398 ID_MOVE_TOP, 00399 ID_MOVE_BOTTOM, 00400 ID_MOVE_PAGEDOWN, 00401 ID_MOVE_PAGEUP, 00402 ID_START_INPUT, 00403 ID_CANCEL_INPUT, 00404 ID_ACCEPT_INPUT, 00405 ID_MARK, 00406 ID_EXTEND, 00407 ID_CUT_SEL, 00408 ID_COPY_SEL, 00409 ID_PASTE_SEL, 00410 ID_DELETE_SEL, 00411 ID_LAST 00412 }; 00413 00414 public: 00415 00416 /** 00417 * Construct a new table. 00418 * The table is initially empty, and reports a default size based on 00419 * the scroll areas's scrollbar placement policy. 00420 */ 00421 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); 00422 00423 /// Return default width 00424 virtual FXint getDefaultWidth(); 00425 00426 /// Return default height 00427 virtual FXint getDefaultHeight(); 00428 00429 /// Computes content width 00430 virtual FXint getContentWidth(); 00431 00432 /// Computes content height 00433 virtual FXint getContentHeight(); 00434 00435 /// Create the server-side resources 00436 virtual void create(); 00437 00438 /// Detach the server-side resources 00439 virtual void detach(); 00440 00441 /// Perform layout 00442 virtual void layout(); 00443 00444 /// Mark this window's layout as dirty 00445 virtual void recalc(); 00446 00447 /// Table widget can receive focus 00448 virtual FXbool canFocus() const; 00449 00450 /// Move the focus to this window 00451 virtual void setFocus(); 00452 00453 /// Remove the focus from this window 00454 virtual void killFocus(); 00455 00456 /// Notification that focus moved to new child 00457 virtual void changeFocus(FXWindow *child); 00458 00459 /// Return column header control 00460 FXHeader* getColumnHeader() const { return colHeader; } 00461 00462 /// Return row header control 00463 FXHeader* getRowHeader() const { return rowHeader; } 00464 00465 /// Change visible rows 00466 void setVisibleRows(FXint nvrows); 00467 00468 /// return number of visible rows 00469 FXint getVisibleRows() const { return visiblerows; } 00470 00471 /// Change visible columns 00472 void setVisibleColumns(FXint nvcols); 00473 00474 /// Return number of visible columns 00475 FXint getVisibleColumns() const { return visiblecols; } 00476 00477 /// Return TRUE if table is editable 00478 FXbool isEditable() const; 00479 00480 /// Set editable flag 00481 void setEditable(FXbool edit=TRUE); 00482 00483 /// Show or hide horizontal grid 00484 void showHorzGrid(FXbool on=TRUE); 00485 00486 /// Is horizontal grid shown 00487 FXbool isHorzGridShown() const { return hgrid; } 00488 00489 /// Show or hide vertical grid 00490 void showVertGrid(FXbool on=TRUE); 00491 00492 /// Is vertical grid shown 00493 FXbool isVertGridShown() const { return vgrid; } 00494 00495 /// Get number of rows 00496 FXint getNumRows() const { return nrows; } 00497 00498 /// Get number of columns 00499 FXint getNumColumns() const { return ncols; } 00500 00501 /// Change top cell margin 00502 void setMarginTop(FXint pt); 00503 00504 /// Return top cell margin 00505 FXint getMarginTop() const { return margintop; } 00506 00507 /// Change bottom cell margin 00508 void setMarginBottom(FXint pb); 00509 00510 /// Return bottom cell margin 00511 FXint getMarginBottom() const { return marginbottom; } 00512 00513 /// Change left cell margin 00514 void setMarginLeft(FXint pl); 00515 00516 /// Return left cell margin 00517 FXint getMarginLeft() const { return marginleft; } 00518 00519 /// Change right cell margin 00520 void setMarginRight(FXint pr); 00521 00522 /// Return right cell margin 00523 FXint getMarginRight() const { return marginright; } 00524 00525 /** 00526 * Start input mode for the cell at the given position. 00527 * An input control is created which is used to edit the cell; 00528 * it is filled by the original item's contents if the cell contained 00529 * an item. You can enter input mode also by sending the table an 00530 * ID_START_INPUT message. 00531 */ 00532 virtual void startInput(FXint row,FXint col); 00533 00534 /** 00535 * Cancel input mode. The input control is immediately deleted 00536 * and the cell will retain its old value. You can also cancel 00537 * input mode by sending the table an ID_CANCEL_INPUT message. 00538 */ 00539 virtual void cancelInput(); 00540 00541 /** 00542 * End input mode and accept the new value from the control. 00543 * The item in the cell will be set to the value from the control, 00544 * and the control will be deleted. If TRUE is passed, a SEL_REPLACED 00545 * callback will be generated to signify to the target that this call 00546 * has a new value. You can also accept the input by sending the table 00547 * an ID_ACCEPT_INPUT message. 00548 */ 00549 virtual void acceptInput(FXbool notify=FALSE); 00550 00551 /** 00552 * Determine column containing x. 00553 * Returns -1 if x left of first column, and ncols if x right of last column; 00554 * otherwise, returns column in table containing x. 00555 */ 00556 FXint colAtX(FXint x) const; 00557 00558 /** 00559 * Determine row containing y. 00560 * Returns -1 if y above first row, and nrows if y below last row; 00561 * otherwise, returns row in table containing y. 00562 */ 00563 FXint rowAtY(FXint y) const; 00564 00565 /// Return the item at the given index 00566 FXTableItem *getItem(FXint row,FXint col) const; 00567 00568 /// Replace the item with a [possibly subclassed] item 00569 void setItem(FXint row,FXint col,FXTableItem* item,FXbool notify=FALSE); 00570 00571 /// Set the table size to nr rows and nc columns; all existing items will be removed 00572 virtual void setTableSize(FXint nr,FXint nc,FXbool notify=FALSE); 00573 00574 /// Insert new row 00575 virtual void insertRows(FXint row,FXint nr=1,FXbool notify=FALSE); 00576 00577 /// Insert new column 00578 virtual void insertColumns(FXint col,FXint nc=1,FXbool notify=FALSE); 00579 00580 /// Remove rows of cells 00581 virtual void removeRows(FXint row,FXint nr=1,FXbool notify=FALSE); 00582 00583 /// Remove column of cells 00584 virtual void removeColumns(FXint col,FXint nc=1,FXbool notify=FALSE); 00585 00586 /// Clear single cell 00587 virtual void removeItem(FXint row,FXint col,FXbool notify=FALSE); 00588 00589 /// Clear all cells in the given range 00590 virtual void removeRange(FXint startrow,FXint endrow,FXint startcol,FXint endcol,FXbool notify=FALSE); 00591 00592 /// Remove all items from table 00593 virtual void clearItems(FXbool notify=FALSE); 00594 00595 /// Scroll to make cell at r,c fully visible 00596 virtual void makePositionVisible(FXint r,FXint c); 00597 00598 /// Return TRUE if item partially visible 00599 FXbool isItemVisible(FXint r,FXint c) const; 00600 00601 /** 00602 * Change column header height mode to fixed or variable. 00603 * In variable height mode, the column header will size to 00604 * fit the contents in it. In fixed mode, the size is 00605 * explicitly set using setColumnHeaderHeight(). 00606 */ 00607 void setColumnHeaderMode(FXuint hint=LAYOUT_FIX_HEIGHT); 00608 00609 /// Return column header height mode 00610 FXuint getColumnHeaderMode() const; 00611 00612 /** 00613 * Change row header width mode to fixed or variable. 00614 * In variable width mode, the row header will size to 00615 * fit the contents in it. In fixed mode, the size is 00616 * explicitly set using setRowHeaderWidth(). 00617 */ 00618 void setRowHeaderMode(FXuint hint=LAYOUT_FIX_WIDTH); 00619 00620 /// Return row header width mode 00621 FXuint getRowHeaderMode() const; 00622 00623 /// Change column header height 00624 void setColumnHeaderHeight(FXint h); 00625 00626 /// Return column header height 00627 FXint getColumnHeaderHeight() const; 00628 00629 /// Change row header width 00630 void setRowHeaderWidth(FXint w); 00631 00632 /// Return row header width 00633 FXint getRowHeaderWidth() const; 00634 00635 /// Get X coordinate of column 00636 FXint getColumnX(FXint col) const; 00637 00638 /// Get Y coordinate of row 00639 FXint getRowY(FXint row) const; 00640 00641 /// Change column width 00642 virtual void setColumnWidth(FXint col,FXint cwidth); 00643 00644 /// Get column width 00645 FXint getColumnWidth(FXint col) const; 00646 00647 /// Change row height 00648 virtual void setRowHeight(FXint row,FXint rheight); 00649 00650 /// Get row height 00651 FXint getRowHeight(FXint row) const; 00652 00653 /// Change default column width 00654 void setDefColumnWidth(FXint cwidth); 00655 00656 /// Get default column width 00657 FXint getDefColumnWidth() const { return defColWidth; } 00658 00659 /// Change default row height 00660 void setDefRowHeight(FXint rheight); 00661 00662 /// Get default row height 00663 FXint getDefRowHeight() const { return defRowHeight; } 00664 00665 /// Return minimum row height 00666 FXint getMinRowHeight(FXint r) const; 00667 00668 /// Return minimum column width 00669 FXint getMinColumnWidth(FXint c) const; 00670 00671 /// Fit row heights to contents 00672 void fitRowsToContents(FXint row,FXint nr=1); 00673 00674 /// Fit column widths to contents 00675 void fitColumnsToContents(FXint col,FXint nc=1); 00676 00677 /// Change column header 00678 void setColumnText(FXint index,const FXString& text); 00679 00680 /// Return text of column header at index 00681 FXString getColumnText(FXint index) const; 00682 00683 /// Change row header 00684 void setRowText(FXint index,const FXString& text); 00685 00686 /// Return text of row header at index 00687 FXString getRowText(FXint index) const; 00688 00689 /// Modify cell text 00690 void setItemText(FXint r,FXint c,const FXString& text); 00691 00692 /// Return cell text 00693 FXString getItemText(FXint r,FXint c) const; 00694 00695 /// Modify cell icon, deleting the old icon if it was owned 00696 void setItemIcon(FXint r,FXint c,FXIcon* icon,FXbool owned=FALSE); 00697 00698 /// Return cell icon 00699 FXIcon* getItemIcon(FXint r,FXint c) const; 00700 00701 /// Modify cell user-data 00702 void setItemData(FXint r,FXint c,void* ptr); 00703 void* getItemData(FXint r,FXint c) const; 00704 00705 /// Extract cells from given range as text. 00706 void extractText(FXchar*& text,FXint& size,FXint startrow,FXint endrow,FXint startcol,FXint endcol,FXchar cs='\t',FXchar rs='\n') const; 00707 00708 /// Overlay text over given cell range 00709 void overlayText(FXint startrow,FXint endrow,FXint startcol,FXint endcol,const FXchar* text,FXint size,FXchar cs='\t',FXchar rs='\n'); 00710 00711 /// Return TRUE if its a spanning cell 00712 FXbool isItemSpanning(FXint r,FXint c) const; 00713 00714 /// Repaint cells between grid lines sr,er and grid lines sc,ec 00715 void updateRange(FXint sr,FXint er,FXint sc,FXint ec) const; 00716 00717 /// Repaint cell at r,c 00718 void updateItem(FXint r,FXint c) const; 00719 00720 /// Enable item 00721 virtual FXbool enableItem(FXint r,FXint c); 00722 00723 /// Disable item 00724 virtual FXbool disableItem(FXint r,FXint c); 00725 00726 /// Is item enabled 00727 FXbool isItemEnabled(FXint r,FXint c) const; 00728 00729 /** 00730 * Change item justification. Horizontal justification is controlled by passing 00731 * FXTableItem::RIGHT, FXTableItem::LEFT, or FXTableItem::CENTER_X. 00732 * Vertical justification is controlled by FXTableItem::TOP, FXTableItem::BOTTOM, 00733 * or FXTableItem::CENTER_Y. 00734 * The default is a combination of FXTableItem::RIGHT and FXTableItem::CENTER_Y. 00735 */ 00736 void setItemJustify(FXint r,FXint c,FXuint justify); 00737 00738 /// Return item justification 00739 FXuint getItemJustify(FXint r,FXint c) const; 00740 00741 /** 00742 * Change relative position of icon and text of item. 00743 * Passing FXTableItem::BEFORE or FXTableItem::AFTER places the icon 00744 * before or after the text, and passing FXTableItem::ABOVE or 00745 * FXTableItem::BELOW places it above or below the text, respectively. 00746 * The default is 0 which places the text on top of the icon. 00747 */ 00748 void setItemIconPosition(FXint r,FXint c,FXuint mode); 00749 00750 /// Return relative icon and text position 00751 FXuint getItemIconPosition(FXint r,FXint c) const; 00752 00753 /** 00754 * Change item borders style. Borders on each side of the item can be turned 00755 * controlled individually using FXTableItem::LBORDER, FXTableItem::RBORDER, 00756 * FXTableItem::TBORDER and FXTableItem::BBORDER. 00757 */ 00758 void setItemBorders(FXint r,FXint c,FXuint borders); 00759 00760 /// Return item border style 00761 FXuint getItemBorders(FXint r,FXint c) const; 00762 00763 /// Change item background stipple style 00764 void setItemStipple(FXint r,FXint c,FXStipplePattern pat); 00765 00766 /// return item background stipple style 00767 FXStipplePattern getItemStipple(FXint r,FXint c) const; 00768 00769 /// Change current item 00770 virtual void setCurrentItem(FXint r,FXint c,FXbool notify=FALSE); 00771 00772 /// Get row number of current item 00773 FXint getCurrentRow() const { return current.row; } 00774 00775 /// Get column number of current item 00776 FXint getCurrentColumn() const { return current.col; } 00777 00778 /// Is item current 00779 FXbool isItemCurrent(FXint r,FXint c) const; 00780 00781 /// Change anchor item 00782 void setAnchorItem(FXint r,FXint c); 00783 00784 /// Get row number of anchor item 00785 FXint getAnchorRow() const { return anchor.row; } 00786 00787 /// Get column number of anchor item 00788 FXint getAnchorColumn() const { return anchor.col; } 00789 00790 /// Get selection start row; returns -1 if no selection 00791 FXint getSelStartRow() const { return selection.fm.row; } 00792 00793 /// Get selection start column; returns -1 if no selection 00794 FXint getSelStartColumn() const { return selection.fm.col; } 00795 00796 /// Get selection end row; returns -1 if no selection 00797 FXint getSelEndRow() const { return selection.to.row; } 00798 00799 /// Get selection end column; returns -1 if no selection 00800 FXint getSelEndColumn() const { return selection.to.col; } 00801 00802 /// Is cell selected 00803 FXbool isItemSelected(FXint r,FXint c) const; 00804 00805 /// Is row of cells selected 00806 FXbool isRowSelected(FXint r) const; 00807 00808 /// Is column selected 00809 FXbool isColumnSelected(FXint c) const; 00810 00811 /// Is anything selected 00812 FXbool isAnythingSelected() const; 00813 00814 /// Select a row 00815 virtual FXbool selectRow(FXint row,FXbool notify=FALSE); 00816 00817 /// Select a column 00818 virtual FXbool selectColumn(FXint col,FXbool notify=FALSE); 00819 00820 /// Select range 00821 virtual FXbool selectRange(FXint startrow,FXint endrow,FXint startcol,FXint endcol,FXbool notify=FALSE); 00822 00823 /// Extend selection 00824 virtual FXbool extendSelection(FXint r,FXint c,FXbool notify=FALSE); 00825 00826 /// Kill selection 00827 virtual FXbool killSelection(FXbool notify=FALSE); 00828 00829 /// Change font 00830 void setFont(FXFont* fnt); 00831 00832 /// Return current font 00833 FXFont* getFont() const { return font; } 00834 00835 /// Obtain colors of various parts 00836 FXColor getTextColor() const { return textColor; } 00837 FXColor getBaseColor() const { return baseColor; } 00838 FXColor getHiliteColor() const { return hiliteColor; } 00839 FXColor getShadowColor() const { return shadowColor; } 00840 FXColor getBorderColor() const { return borderColor; } 00841 FXColor getSelBackColor() const { return selbackColor; } 00842 FXColor getSelTextColor() const { return seltextColor; } 00843 FXColor getGridColor() const { return gridColor; } 00844 FXColor getStippleColor() const { return stippleColor; } 00845 FXColor getCellBorderColor() const { return cellBorderColor; } 00846 00847 /// Change colors of various parts 00848 void setTextColor(FXColor clr); 00849 void setBaseColor(FXColor clr); 00850 void setHiliteColor(FXColor clr); 00851 void setShadowColor(FXColor clr); 00852 void setBorderColor(FXColor clr); 00853 void setSelBackColor(FXColor clr); 00854 void setSelTextColor(FXColor clr); 00855 void setGridColor(FXColor clr); 00856 void setStippleColor(FXColor clr); 00857 void setCellBorderColor(FXColor clr); 00858 00859 /// Change cell background color for even/odd rows/columns 00860 void setCellColor(FXint r,FXint c,FXColor clr); 00861 00862 /// Obtain cell background color for even/odd rows/columns 00863 FXColor getCellColor(FXint r,FXint c) const; 00864 00865 /// Change cell border width 00866 void setCellBorderWidth(FXint borderwidth); 00867 00868 /// Return cell border width 00869 FXint getCellBorderWidth() const { return cellBorderWidth; } 00870 00871 /// Change table style 00872 void setTableStyle(FXuint style); 00873 00874 /// Return table style 00875 FXuint getTableStyle() const; 00876 00877 /// Change help text 00878 void setHelpText(const FXString& text){ help=text; } 00879 const FXString& getHelpText() const { return help; } 00880 00881 /// Serialize 00882 virtual void save(FXStream& store) const; 00883 virtual void load(FXStream& store); 00884 00885 virtual ~FXTable(); 00886 }; 00887 00888 } 00889 00890 #endif

Copyright © 1997-2005 Jeroen van der Zijp