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 2006/02/16 04:08:11 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 /// Table Widget
00250 class FXAPI FXTable : public FXScrollArea {
00251   FXDECLARE(FXTable)
00252 protected:
00253   FXHeader     *colHeader;              // Column header
00254   FXHeader     *rowHeader;              // Row header
00255   FXButton     *cornerButton;           // Corner button
00256   FXTableItem **cells;                  // Cells
00257   FXWindow     *editor;                 // Editor widget
00258   FXFont       *font;                   // Font
00259   FXint         nrows;                  // Number of rows
00260   FXint         ncols;                  // Number of columns
00261   FXint         visiblerows;            // Visible rows
00262   FXint         visiblecols;            // Visible columns
00263   FXint         margintop;              // Margin top
00264   FXint         marginbottom;           // Margin bottom
00265   FXint         marginleft;             // Margin left
00266   FXint         marginright;            // Margin right
00267   FXColor       textColor;              // Normal text color
00268   FXColor       baseColor;              // Base color
00269   FXColor       hiliteColor;            // Highlight color
00270   FXColor       shadowColor;            // Shadow color
00271   FXColor       borderColor;            // Border color
00272   FXColor       selbackColor;           // Select background color
00273   FXColor       seltextColor;           // Select text color
00274   FXColor       gridColor;              // Grid line color
00275   FXColor       stippleColor;           // Stipple color
00276   FXColor       cellBorderColor;        // Cell border color
00277   FXint         cellBorderWidth;        // Cell border width
00278   FXColor       cellBackColor[2][2];    // Row/Column even/odd background color
00279   FXint         defColWidth;            // Default column width [if uniform columns]
00280   FXint         defRowHeight;           // Default row height [if uniform rows]
00281   FXTablePos    current;                // Current position
00282   FXTablePos    anchor;                 // Anchor position
00283   FXTableRange  input;                  // Input cell
00284   FXTableRange  selection;              // Range of selected cells
00285   FXString      clipped;                // Clipped text
00286   FXbool        hgrid;                  // Horizontal grid lines shown
00287   FXbool        vgrid;                  // Vertical grid lines shown
00288   FXuchar       mode;                   // Mode widget is in
00289   FXint         grabx;                  // Grab point x
00290   FXint         graby;                  // Grab point y
00291   FXint         rowcol;                 // Row or column being resized
00292   FXString      help;
00293 public:
00294   static FXDragType csvType;
00295   static const FXchar csvTypeName[];
00296 protected:
00297   FXTable();
00298   FXint startRow(FXint row,FXint col) const;
00299   FXint startCol(FXint row,FXint col) const;
00300   FXint endRow(FXint row,FXint col) const;
00301   FXint endCol(FXint row,FXint col) const;
00302   void spanningRange(FXint& sr,FXint& er,FXint& sc,FXint& ec,FXint anchrow,FXint anchcol,FXint currow,FXint curcol);
00303   virtual void moveContents(FXint x,FXint y);
00304   virtual void drawCell(FXDC& dc,FXint sr,FXint er,FXint sc,FXint ec);
00305   virtual void drawRange(FXDC& dc,FXint rlo,FXint rhi,FXint clo,FXint chi);
00306   virtual void drawHGrid(FXDC& dc,FXint rlo,FXint rhi,FXint clo,FXint chi);
00307   virtual void drawVGrid(FXDC& dc,FXint rlo,FXint rhi,FXint clo,FXint chi);
00308   virtual void drawContents(FXDC& dc,FXint x,FXint y,FXint w,FXint h);
00309   virtual FXTableItem* createItem(const FXString& text,FXIcon* icon,void* ptr);
00310   virtual FXWindow *getControlForItem(FXint r,FXint c);
00311   virtual void setItemFromControl(FXint r,FXint c,FXWindow *control);
00312   virtual void updateColumnNumbers(FXint lo,FXint hi);
00313   virtual void updateRowNumbers(FXint lo,FXint hi);
00314 protected:
00315   enum {
00316     MOUSE_NONE,
00317     MOUSE_SCROLL,
00318     MOUSE_DRAG,
00319     MOUSE_SELECT
00320     };
00321 private:
00322   FXTable(const FXTable&);
00323   FXTable& operator=(const FXTable&);
00324 public:
00325   long onPaint(FXObject*,FXSelector,void*);
00326   long onFocusIn(FXObject*,FXSelector,void*);
00327   long onFocusOut(FXObject*,FXSelector,void*);
00328   long onMotion(FXObject*,FXSelector,void*);
00329   long onKeyPress(FXObject*,FXSelector,void*);
00330   long onKeyRelease(FXObject*,FXSelector,void*);
00331   long onLeftBtnPress(FXObject*,FXSelector,void*);
00332   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00333   long onRightBtnPress(FXObject*,FXSelector,void*);
00334   long onRightBtnRelease(FXObject*,FXSelector,void*);
00335   long onUngrabbed(FXObject*,FXSelector,void*);
00336   long onSelectionLost(FXObject*,FXSelector,void*);
00337   long onSelectionGained(FXObject*,FXSelector,void*);
00338   long onSelectionRequest(FXObject*,FXSelector,void* ptr);
00339   long onClipboardLost(FXObject*,FXSelector,void*);
00340   long onClipboardGained(FXObject*,FXSelector,void*);
00341   long onClipboardRequest(FXObject*,FXSelector,void*);
00342   long onAutoScroll(FXObject*,FXSelector,void*);
00343   long onCommand(FXObject*,FXSelector,void*);
00344   long onClicked(FXObject*,FXSelector,void*);
00345   long onDoubleClicked(FXObject*,FXSelector,void*);
00346   long onTripleClicked(FXObject*,FXSelector,void*);
00347 
00348   long onCmdToggleEditable(FXObject*,FXSelector,void*);
00349   long onUpdToggleEditable(FXObject*,FXSelector,void*);
00350 
00351   // Visual characteristics
00352   long onCmdHorzGrid(FXObject*,FXSelector,void*);
00353   long onUpdHorzGrid(FXObject*,FXSelector,void*);
00354   long onCmdVertGrid(FXObject*,FXSelector,void*);
00355   long onUpdVertGrid(FXObject*,FXSelector,void*);
00356 
00357   // Row/Column manipulations
00358   long onCmdDeleteColumn(FXObject*,FXSelector,void*);
00359   long onUpdDeleteColumn(FXObject*,FXSelector,void*);
00360   long onCmdDeleteRow(FXObject*,FXSelector,void*);
00361   long onUpdDeleteRow(FXObject*,FXSelector,void*);
00362   long onCmdInsertColumn(FXObject*,FXSelector,void*);
00363   long onUpdInsertColumn(FXObject*,FXSelector,void*);
00364   long onCmdInsertRow(FXObject*,FXSelector,void*);
00365   long onUpdInsertRow(FXObject*,FXSelector,void*);
00366 
00367   // Movement
00368   long onCmdMoveRight(FXObject*,FXSelector,void*);
00369   long onCmdMoveLeft(FXObject*,FXSelector,void*);
00370   long onCmdMoveUp(FXObject*,FXSelector,void*);
00371   long onCmdMoveDown(FXObject*,FXSelector,void*);
00372   long onCmdMoveHome(FXObject*,FXSelector,void*);
00373   long onCmdMoveEnd(FXObject*,FXSelector,void*);
00374   long onCmdMoveTop(FXObject*,FXSelector,void*);
00375   long onCmdMoveBottom(FXObject*,FXSelector,void*);
00376   long onCmdMovePageDown(FXObject*,FXSelector,void*);
00377   long onCmdMovePageUp(FXObject*,FXSelector,void*);
00378 
00379   // Mark and extend
00380   long onCmdMark(FXObject*,FXSelector,void*);
00381   long onCmdExtend(FXObject*,FXSelector,void*);
00382 
00383   // Changing Selection
00384   long onUpdSelectCell(FXObject*,FXSelector,void*);
00385   long onCmdSelectCell(FXObject*,FXSelector,void*);
00386   long onUpdSelectRow(FXObject*,FXSelector,void*);
00387   long onCmdSelectRow(FXObject*,FXSelector,void*);
00388   long onUpdSelectColumn(FXObject*,FXSelector,void*);
00389   long onCmdSelectColumn(FXObject*,FXSelector,void*);
00390   long onCmdSelectRowIndex(FXObject*,FXSelector,void*);
00391   long onCmdSelectColumnIndex(FXObject*,FXSelector,void*);
00392   long onUpdSelectAll(FXObject*,FXSelector,void*);
00393   long onCmdSelectAll(FXObject*,FXSelector,void*);
00394   long onUpdDeselectAll(FXObject*,FXSelector,void*);
00395   long onCmdDeselectAll(FXObject*,FXSelector,void*);
00396 
00397   // Manipulation Selection
00398   long onCmdCutSel(FXObject*,FXSelector,void*);
00399   long onCmdCopySel(FXObject*,FXSelector,void*);
00400   long onCmdDeleteSel(FXObject*,FXSelector,void*);
00401   long onCmdPasteSel(FXObject*,FXSelector,void*);
00402   long onUpdHaveSelection(FXObject*,FXSelector,void*);
00403 
00404   // Edit control
00405   long onCmdStartInput(FXObject*,FXSelector,void*);
00406   long onUpdStartInput(FXObject*,FXSelector,void*);
00407   long onCmdAcceptInput(FXObject*,FXSelector,void*);
00408   long onUpdAcceptInput(FXObject*,FXSelector,void*);
00409   long onCmdCancelInput(FXObject*,FXSelector,void*);
00410 public:
00411 
00412   enum {
00413     ID_HORZ_GRID=FXScrollArea::ID_LAST,
00414     ID_VERT_GRID,
00415     ID_TOGGLE_EDITABLE,
00416     ID_DELETE_COLUMN,
00417     ID_DELETE_ROW,
00418     ID_INSERT_COLUMN,
00419     ID_INSERT_ROW,
00420     ID_SELECT_COLUMN_INDEX,
00421     ID_SELECT_ROW_INDEX,
00422     ID_SELECT_COLUMN,
00423     ID_SELECT_ROW,
00424     ID_SELECT_CELL,
00425     ID_SELECT_ALL,
00426     ID_DESELECT_ALL,
00427     ID_MOVE_LEFT,
00428     ID_MOVE_RIGHT,
00429     ID_MOVE_UP,
00430     ID_MOVE_DOWN,
00431     ID_MOVE_HOME,
00432     ID_MOVE_END,
00433     ID_MOVE_TOP,
00434     ID_MOVE_BOTTOM,
00435     ID_MOVE_PAGEDOWN,
00436     ID_MOVE_PAGEUP,
00437     ID_START_INPUT,
00438     ID_CANCEL_INPUT,
00439     ID_ACCEPT_INPUT,
00440     ID_MARK,
00441     ID_EXTEND,
00442     ID_CUT_SEL,
00443     ID_COPY_SEL,
00444     ID_PASTE_SEL,
00445     ID_DELETE_SEL,
00446     ID_LAST
00447     };
00448 
00449 public:
00450 
00451   /**
00452   * Construct a new table.
00453   * The table is initially empty, and reports a default size based on
00454   * the scroll areas's scrollbar placement policy.
00455   */
00456   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);
00457 
00458   /// Return default width
00459   virtual FXint getDefaultWidth();
00460 
00461   /// Return default height
00462   virtual FXint getDefaultHeight();
00463 
00464   /// Computes content width
00465   virtual FXint getContentWidth();
00466 
00467   /// Computes content height
00468   virtual FXint getContentHeight();
00469 
00470   /// Create the server-side resources
00471   virtual void create();
00472 
00473   /// Detach the server-side resources
00474   virtual void detach();
00475 
00476   /// Perform layout
00477   virtual void layout();
00478 
00479   /// Mark this window's layout as dirty
00480   virtual void recalc();
00481 
00482   /// Table widget can receive focus
00483   virtual bool canFocus() const;
00484 
00485   /// Move the focus to this window
00486   virtual void setFocus();
00487 
00488   /// Remove the focus from this window
00489   virtual void killFocus();
00490 
00491   /// Notification that focus moved to new child
00492   virtual void changeFocus(FXWindow *child);
00493 
00494   /// Return button in the top/left corner
00495   FXButton* getCornerButton() const { return cornerButton; }
00496 
00497   /// Return column header control
00498   FXHeader* getColumnHeader() const { return colHeader; }
00499 
00500   /// Return row header control
00501   FXHeader* getRowHeader() const { return rowHeader; }
00502 
00503   /// Change visible rows
00504   void setVisibleRows(FXint nvrows);
00505 
00506   /// return number of visible rows
00507   FXint getVisibleRows() const { return visiblerows; }
00508 
00509   /// Change visible columns
00510   void setVisibleColumns(FXint nvcols);
00511 
00512   /// Return number of visible columns
00513   FXint getVisibleColumns() const { return visiblecols; }
00514 
00515   /// Return TRUE if table is editable
00516   FXbool isEditable() const;
00517 
00518   /// Set editable flag
00519   void setEditable(FXbool edit=TRUE);
00520 
00521   /// Show or hide horizontal grid
00522   void showHorzGrid(FXbool on=TRUE);
00523 
00524   /// Is horizontal grid shown
00525   FXbool isHorzGridShown() const { return hgrid; }
00526 
00527   /// Show or hide vertical grid
00528   void showVertGrid(FXbool on=TRUE);
00529 
00530   /// Is vertical grid shown
00531   FXbool isVertGridShown() const { return vgrid; }
00532 
00533   /// Get number of rows
00534   FXint getNumRows() const { return nrows; }
00535 
00536   /// Get number of columns
00537   FXint getNumColumns() const { return ncols; }
00538 
00539   /// Change top cell margin
00540   void setMarginTop(FXint pt);
00541 
00542   /// Return top cell margin
00543   FXint getMarginTop() const { return margintop; }
00544 
00545   /// Change bottom cell margin
00546   void setMarginBottom(FXint pb);
00547 
00548   /// Return bottom cell margin
00549   FXint getMarginBottom() const { return marginbottom; }
00550 
00551   /// Change left cell margin
00552   void setMarginLeft(FXint pl);
00553 
00554   /// Return left cell margin
00555   FXint getMarginLeft() const { return marginleft; }
00556 
00557   /// Change right cell margin
00558   void setMarginRight(FXint pr);
00559 
00560   /// Return right cell margin
00561   FXint getMarginRight() const { return marginright; }
00562 
00563   /**
00564   * Start input mode for the cell at the given position.
00565   * An input control is created which is used to edit the cell;
00566   * it is filled by the original item's contents if the cell contained
00567   * an item.  You can enter input mode also by sending the table an
00568   * ID_START_INPUT message.
00569   */
00570   virtual void startInput(FXint row,FXint col);
00571 
00572   /**
00573   * Cancel input mode.  The input control is immediately deleted
00574   * and the cell will retain its old value.  You can also cancel
00575   * input mode by sending the table an ID_CANCEL_INPUT message.
00576   */
00577   virtual void cancelInput();
00578 
00579   /**
00580   * End input mode and accept the new value from the control.
00581   * The item in the cell will be set to the value from the control,
00582   * and the control will be deleted.  If TRUE is passed, a SEL_REPLACED
00583   * callback will be generated to signify to the target that this call
00584   * has a new value.  You can also accept the input by sending the table
00585   * an ID_ACCEPT_INPUT message.
00586   */
00587   virtual void acceptInput(FXbool notify=FALSE);
00588 
00589   /**
00590   * Determine column containing x.
00591   * Returns -1 if x left of first column, and ncols if x right of last column;
00592   * otherwise, returns column in table containing x.
00593   */
00594   FXint colAtX(FXint x) const;
00595 
00596   /**
00597   * Determine row containing y.
00598   * Returns -1 if y above first row, and nrows if y below last row;
00599   * otherwise, returns row in table containing y.
00600   */
00601   FXint rowAtY(FXint y) const;
00602 
00603   /// Return the item at the given index
00604   FXTableItem *getItem(FXint row,FXint col) const;
00605 
00606   /// Replace the item with a [possibly subclassed] item
00607   void setItem(FXint row,FXint col,FXTableItem* item,FXbool notify=FALSE);
00608 
00609   /// Set the table size to nr rows and nc columns; all existing items will be removed
00610   virtual void setTableSize(FXint nr,FXint nc,FXbool notify=FALSE);
00611 
00612   /// Insert new row
00613   virtual void insertRows(FXint row,FXint nr=1,FXbool notify=FALSE);
00614 
00615   /// Insert new column
00616   virtual void insertColumns(FXint col,FXint nc=1,FXbool notify=FALSE);
00617 
00618   /// Remove rows of cells
00619   virtual void removeRows(FXint row,FXint nr=1,FXbool notify=FALSE);
00620 
00621   /// Remove column of cells
00622   virtual void removeColumns(FXint col,FXint nc=1,FXbool notify=FALSE);
00623 
00624   /// Extract item from table
00625   virtual FXTableItem* extractItem(FXint row,FXint col,FXbool notify=FALSE);
00626 
00627   /// Clear single cell
00628   virtual void removeItem(FXint row,FXint col,FXbool notify=FALSE);
00629 
00630   /// Clear all cells in the given range
00631   virtual void removeRange(FXint startrow,FXint endrow,FXint startcol,FXint endcol,FXbool notify=FALSE);
00632 
00633   /// Remove all items from table
00634   virtual void clearItems(FXbool notify=FALSE);
00635 
00636   /// Scroll to make cell at r,c fully visible
00637   virtual void makePositionVisible(FXint r,FXint c);
00638 
00639   /// Return TRUE if item partially visible
00640   FXbool isItemVisible(FXint r,FXint c) const;
00641 
00642   /**
00643   * Change column header height mode to fixed or variable.
00644   * In variable height mode, the column header will size to
00645   * fit the contents in it.  In fixed mode, the size is
00646   * explicitly set using setColumnHeaderHeight().
00647   */
00648   void setColumnHeaderMode(FXuint hint=LAYOUT_FIX_HEIGHT);
00649 
00650   /// Return column header height mode
00651   FXuint getColumnHeaderMode() const;
00652 
00653   /**
00654   * Change row header width mode to fixed or variable.
00655   * In variable width mode, the row header will size to
00656   * fit the contents in it.  In fixed mode, the size is
00657   * explicitly set using setRowHeaderWidth().
00658   */
00659   void setRowHeaderMode(FXuint hint=LAYOUT_FIX_WIDTH);
00660 
00661   /// Return row header width mode
00662   FXuint getRowHeaderMode() const;
00663 
00664   /// Set column header font
00665   void setColumnHeaderFont(FXFont* fnt);
00666 
00667   /// Return column header font
00668   FXFont* getColumnHeaderFont() const;
00669 
00670   /// Set row header font
00671   void setRowHeaderFont(FXFont* fnt);
00672 
00673   /// Return row header font
00674   FXFont* getRowHeaderFont() const;
00675 
00676   /// Change column header height
00677   void setColumnHeaderHeight(FXint h);
00678 
00679   /// Return column header height
00680   FXint getColumnHeaderHeight() const;
00681 
00682   /// Change row header width
00683   void setRowHeaderWidth(FXint w);
00684 
00685   /// Return row header width
00686   FXint getRowHeaderWidth() const;
00687 
00688   /// Get X coordinate of column
00689   FXint getColumnX(FXint col) const;
00690 
00691   /// Get Y coordinate of row
00692   FXint getRowY(FXint row) const;
00693 
00694   /// Change column width
00695   virtual void setColumnWidth(FXint col,FXint cwidth);
00696 
00697   /// Get column width
00698   FXint getColumnWidth(FXint col) const;
00699 
00700   /// Change row height
00701   virtual void setRowHeight(FXint row,FXint rheight);
00702 
00703   /// Get row height
00704   FXint getRowHeight(FXint row) const;
00705 
00706   /// Change default column width
00707   void setDefColumnWidth(FXint cwidth);
00708 
00709   /// Get default column width
00710   FXint getDefColumnWidth() const { return defColWidth; }
00711 
00712   /// Change default row height
00713   void setDefRowHeight(FXint rheight);
00714 
00715   /// Get default row height
00716   FXint getDefRowHeight() const { return defRowHeight; }
00717 
00718   /// Return minimum row height
00719   FXint getMinRowHeight(FXint r) const;
00720 
00721   /// Return minimum column width
00722   FXint getMinColumnWidth(FXint c) const;
00723 
00724   /// Fit row heights to contents
00725   void fitRowsToContents(FXint row,FXint nr=1);
00726 
00727   /// Fit column widths to contents
00728   void fitColumnsToContents(FXint col,FXint nc=1);
00729 
00730   /// Change column header text
00731   void setColumnText(FXint index,const FXString& text);
00732 
00733   /// Return text of column header at index
00734   FXString getColumnText(FXint index) const;
00735 
00736   /// Change row header text
00737   void setRowText(FXint index,const FXString& text);
00738 
00739   /// Return text of row header at index
00740   FXString getRowText(FXint index) const;
00741 
00742   /// Change column header icon
00743   void setColumnIcon(FXint index,FXIcon* icon);
00744 
00745   /// Return icon of column header at index
00746   FXIcon* getColumnIcon(FXint index) const;
00747 
00748   /// Change row header icon
00749   void setRowIcon(FXint index,FXIcon* icon);
00750 
00751   /// Return icon of row header at index
00752   FXIcon* getRowIcon(FXint index) const;
00753 
00754   /// Change column header icon position, e.g. FXHeaderItem::BEFORE, etc.
00755   void setColumnIconPosition(FXint index,FXuint mode);
00756 
00757   /// Return icon position of column header at index
00758   FXuint getColumnIconPosition(FXint index) const;
00759 
00760   /// Change row header icon position, e.g. FXHeaderItem::BEFORE, etc.
00761   void setRowIconPosition(FXint index,FXuint mode);
00762 
00763   /// Return icon position of row header at index
00764   FXuint getRowIconPosition(FXint index) const;
00765 
00766   /// Change column header justify, e.g. FXHeaderItem::RIGHT, etc.
00767   void setColumnJustify(FXint index,FXuint justify);
00768 
00769   /// Return justify of column header at index
00770   FXuint getColumnJustify(FXint index) const;
00771 
00772   /// Change row header justify, e.g. FXHeaderItem::RIGHT, etc.
00773   void setRowJustify(FXint index,FXuint justify);
00774 
00775   /// Return justify of row header at index
00776   FXuint getRowJustify(FXint index) const;
00777 
00778   /// Modify cell text
00779   void setItemText(FXint r,FXint c,const FXString& text,FXbool notify=FALSE);
00780 
00781   /// Return cell text
00782   FXString getItemText(FXint r,FXint c) const;
00783 
00784   /// Modify cell icon, deleting the old icon if it was owned
00785   void setItemIcon(FXint r,FXint c,FXIcon* icon,FXbool owned=FALSE,FXbool notify=FALSE);
00786 
00787   /// Return cell icon
00788   FXIcon* getItemIcon(FXint r,FXint c) const;
00789 
00790   /// Modify cell user-data
00791   void setItemData(FXint r,FXint c,void* ptr);
00792   void* getItemData(FXint r,FXint c) const;
00793 
00794   /**
00795   * Extract cells from given range as text, each column separated by a string cs,
00796   * and each row separated by a string rs.
00797   */
00798   void extractText(FXchar*& text,FXint& size,FXint startrow,FXint endrow,FXint startcol,FXint endcol,const FXchar* cs="\t",const FXchar* rs="\n") const;
00799   void extractText(FXString& text,FXint startrow,FXint endrow,FXint startcol,FXint endcol,const FXchar* cs="\t",const FXchar* rs="\n") const;
00800 
00801   /**
00802   * Overlay text over given cell range; the text is interpreted as
00803   * a number of columns separated by a character from the set cs, and
00804   * a number of rows separated by a character from the set rs.
00805   * Cells outside the given cell range are unaffected.
00806   */
00807   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);
00808   void overlayText(FXint startrow,FXint endrow,FXint startcol,FXint endcol,const FXString& text,const FXchar* cs="\t,",const FXchar* rs="\n",FXbool notify=FALSE);
00809 
00810   /**
00811   * Determine the number of rows and columns in a block of text
00812   * where columns are separated by characters from the set cs, and rows
00813   * are separated by characters from the set rs.
00814   */
00815   void countText(FXint& nr,FXint& nc,const FXchar* text,FXint size,const FXchar* cs="\t,",const FXchar* rs="\n") const;
00816   void countText(FXint& nr,FXint& nc,const FXString& text,const FXchar* cs="\t,",const FXchar* rs="\n") const;
00817 
00818   /// Return TRUE if its a spanning cell
00819   FXbool isItemSpanning(FXint r,FXint c) const;
00820 
00821   /// Repaint cells between grid lines sr,er and grid lines sc,ec
00822   void updateRange(FXint sr,FXint er,FXint sc,FXint ec) const;
00823 
00824   /// Repaint cell at r,c
00825   void updateItem(FXint r,FXint c) const;
00826 
00827   /// Enable item
00828   virtual FXbool enableItem(FXint r,FXint c);
00829 
00830   /// Disable item
00831   virtual FXbool disableItem(FXint r,FXint c);
00832 
00833   /// Is item enabled
00834   FXbool isItemEnabled(FXint r,FXint c) const;
00835 
00836   /**
00837   * Change item justification.  Horizontal justification is controlled by passing
00838   * FXTableItem::RIGHT,  FXTableItem::LEFT, or FXTableItem::CENTER_X.
00839   * Vertical justification is controlled by FXTableItem::TOP, FXTableItem::BOTTOM,
00840   * or FXTableItem::CENTER_Y.
00841   * The default is a combination of FXTableItem::RIGHT and FXTableItem::CENTER_Y.
00842   */
00843   void setItemJustify(FXint r,FXint c,FXuint justify);
00844 
00845   /// Return item justification
00846   FXuint getItemJustify(FXint r,FXint c) const;
00847 
00848   /**
00849   * Change relative position of icon and text of item.
00850   * Passing FXTableItem::BEFORE or FXTableItem::AFTER places the icon
00851   * before or after the text, and passing FXTableItem::ABOVE or
00852   * FXTableItem::BELOW places it above or below the text, respectively.
00853   * The default is 0 which places the text on top of the icon.
00854   */
00855   void setItemIconPosition(FXint r,FXint c,FXuint mode);
00856 
00857   /// Return relative icon and text position
00858   FXuint getItemIconPosition(FXint r,FXint c) const;
00859 
00860   /**
00861   * Change item borders style.  Borders on each side of the item can be turned
00862   * controlled individually using FXTableItem::LBORDER, FXTableItem::RBORDER,
00863   * FXTableItem::TBORDER and FXTableItem::BBORDER.
00864   */
00865   void setItemBorders(FXint r,FXint c,FXuint borders);
00866 
00867   /// Return item border style
00868   FXuint getItemBorders(FXint r,FXint c) const;
00869 
00870   /// Change item background stipple style
00871   void setItemStipple(FXint r,FXint c,FXStipplePattern pat);
00872 
00873   /// return item background stipple style
00874   FXStipplePattern getItemStipple(FXint r,FXint c) const;
00875 
00876   /// Change current item
00877   virtual void setCurrentItem(FXint r,FXint c,FXbool notify=FALSE);
00878 
00879   /// Get row number of current item
00880   FXint getCurrentRow() const { return current.row; }
00881 
00882   /// Get column number of current item
00883   FXint getCurrentColumn() const { return current.col; }
00884 
00885   /// Is item current
00886   FXbool isItemCurrent(FXint r,FXint c) const;
00887 
00888   /// Change anchor item
00889   void setAnchorItem(FXint r,FXint c);
00890 
00891   /// Get row number of anchor item
00892   FXint getAnchorRow() const { return anchor.row; }
00893 
00894   /// Get column number of anchor item
00895   FXint getAnchorColumn() const { return anchor.col; }
00896 
00897   /// Get selection start row; returns -1 if no selection
00898   FXint getSelStartRow() const { return selection.fm.row; }
00899 
00900   /// Get selection start column; returns -1 if no selection
00901   FXint getSelStartColumn() const { return selection.fm.col; }
00902 
00903   /// Get selection end row; returns -1 if no selection
00904   FXint getSelEndRow() const { return selection.to.row; }
00905 
00906   /// Get selection end column; returns -1 if no selection
00907   FXint getSelEndColumn() const { return selection.to.col; }
00908 
00909   /// Is cell selected
00910   FXbool isItemSelected(FXint r,FXint c) const;
00911 
00912   /// Is row of cells selected
00913   FXbool isRowSelected(FXint r) const;
00914 
00915   /// Is column selected
00916   FXbool isColumnSelected(FXint c) const;
00917 
00918   /// Is anything selected
00919   FXbool isAnythingSelected() const;
00920 
00921   /// Select a row
00922   virtual FXbool selectRow(FXint row,FXbool notify=FALSE);
00923 
00924   /// Select a column
00925   virtual FXbool selectColumn(FXint col,FXbool notify=FALSE);
00926 
00927   /// Select range
00928   virtual FXbool selectRange(FXint startrow,FXint endrow,FXint startcol,FXint endcol,FXbool notify=FALSE);
00929 
00930   /// Extend selection
00931   virtual FXbool extendSelection(FXint r,FXint c,FXbool notify=FALSE);
00932 
00933   /// Kill selection
00934   virtual FXbool killSelection(FXbool notify=FALSE);
00935 
00936   /// Change font
00937   void setFont(FXFont* fnt);
00938 
00939   /// Return current font
00940   FXFont* getFont() const { return font; }
00941 
00942   /// Obtain colors of various parts
00943   FXColor getTextColor() const { return textColor; }
00944   FXColor getBaseColor() const { return baseColor; }
00945   FXColor getHiliteColor() const { return hiliteColor; }
00946   FXColor getShadowColor() const { return shadowColor; }
00947   FXColor getBorderColor() const { return borderColor; }
00948   FXColor getSelBackColor() const { return selbackColor; }
00949   FXColor getSelTextColor() const { return seltextColor; }
00950   FXColor getGridColor() const { return gridColor; }
00951   FXColor getStippleColor() const { return stippleColor; }
00952   FXColor getCellBorderColor() const { return cellBorderColor; }
00953 
00954   /// Change colors of various parts
00955   void setTextColor(FXColor clr);
00956   void setBaseColor(FXColor clr);
00957   void setHiliteColor(FXColor clr);
00958   void setShadowColor(FXColor clr);
00959   void setBorderColor(FXColor clr);
00960   void setSelBackColor(FXColor clr);
00961   void setSelTextColor(FXColor clr);
00962   void setGridColor(FXColor clr);
00963   void setStippleColor(FXColor clr);
00964   void setCellBorderColor(FXColor clr);
00965 
00966   /// Change cell background color for even/odd rows/columns
00967   void setCellColor(FXint r,FXint c,FXColor clr);
00968 
00969   /// Obtain cell background color for even/odd rows/columns
00970   FXColor getCellColor(FXint r,FXint c) const;
00971 
00972   /// Change cell border width
00973   void setCellBorderWidth(FXint borderwidth);
00974 
00975   /// Return cell border width
00976   FXint getCellBorderWidth() const { return cellBorderWidth; }
00977 
00978   /// Change table style
00979   void setTableStyle(FXuint style);
00980 
00981   /// Return table style
00982   FXuint getTableStyle() const;
00983 
00984   /// Set column renumbering
00985   void setColumnRenumbering(FXbool flag);
00986 
00987   /// Get column renumbering
00988   FXbool getColumnRenumbering() const;
00989 
00990   /// Set row renumbering
00991   void setRowRenumbering(FXbool flag);
00992 
00993   /// Get row renumbering
00994   FXbool getRowRenumbering() const;
00995 
00996   /// Change help text
00997   void setHelpText(const FXString& text){ help=text; }
00998   const FXString& getHelpText() const { return help; }
00999 
01000   /// Serialize
01001   virtual void save(FXStream& store) const;
01002   virtual void load(FXStream& store);
01003 
01004   virtual ~FXTable();
01005   };
01006 
01007 }
01008 
01009 #endif

Copyright © 1997-2005 Jeroen van der Zijp