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

FXTable.h

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

Copyright © 1997-2005 Jeroen van der Zijp