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

FXTableBox.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                       T a b l e   B o x   W i d g e t                         *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2001 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 * contributor Hakki Dogusan dogusanh@tr.net  http://home.tr.net/dogusanh        *
00023 ********************************************************************************/
00024 #ifndef FXTABLEBOX_H
00025 #define FXTABLEBOX_H
00026 
00027 #ifndef FXPACKER_H
00028 #include <fox/FXPacker.h>
00029 using namespace FX;
00030 #endif
00031 namespace FXEX {
00032 
00033 // TableBox styles
00034 enum {
00035   TABLEBOX_NO_REPLACE     = 0,                  // Leave the list the same
00036   TABLEBOX_REPLACE        = 0x00020000,         // Replace current item with typed text
00037   TABLEBOX_INSERT_BEFORE  = 0x00040000,         // Typed text inserted before current
00038   TABLEBOX_INSERT_AFTER   = 0x00060000,         // Typed text inserted after current
00039   TABLEBOX_INSERT_FIRST   = 0x00080000,         // Typed text inserted at begin of list
00040   TABLEBOX_INSERT_LAST    = 0x00090000,         // Typed text inserted at end of list
00041   TABLEBOX_STATIC         = 0x00100000,         // Unchangable text box
00042   TABLEBOX_NORMAL         = 0                   // Can type text but list is not changed
00043   };
00044 
00045 /**
00046  * Tablebox is a table in a combobox (I think?)
00047  */
00048 class FXAPI FXTableBox : public FXPacker {
00049   FXDECLARE(FXTableBox)
00050 
00051 protected:
00052   FXTextField   *text;
00053   FXMenuButton  *button;
00054   FXIconList    *list;
00055   FXPopup       *pane;
00056   FXint          visible;
00057   FXint          boundcol;
00058 
00059 protected:
00060   FXTableBox(){}
00061 
00062   virtual void layout();
00063 
00064 private:
00065   FXTableBox(const FXTableBox&);
00066   FXTableBox &operator=(const FXTableBox&);
00067 
00068 public:
00069   long onFocusUp(FXObject*,FXSelector,void*);
00070   long onFocusDown(FXObject*,FXSelector,void*);
00071   long onChanged(FXObject*,FXSelector,void*);
00072   long onCommand(FXObject*,FXSelector,void*);
00073   long onTextButton(FXObject*,FXSelector,void*);
00074   long onTextChanged(FXObject*,FXSelector,void*);
00075   long onTextCommand(FXObject*,FXSelector,void*);
00076   long onListClicked(FXObject*,FXSelector,void*);
00077   long onFwdToText(FXObject*,FXSelector,void*);
00078   long onUpdFmText(FXObject*,FXSelector,void*);
00079 
00080 public:
00081   enum {
00082     ID_LIST=FXPacker::ID_LAST,
00083     ID_TEXT,
00084     ID_LAST
00085     };
00086 
00087 public:
00088 
00089   /// Constructor
00090   FXTableBox(FXComposite *p,FXint cols,FXint nvis,FXint bcol,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=TABLEBOX_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD);
00091 
00092   /// Create server-side resources
00093   virtual void create();
00094 
00095   /// Detach server-side resources
00096   virtual void detach();
00097 
00098   /// Destroy server-side resources
00099   virtual void destroy();
00100 
00101   /// Enable combo box
00102   virtual void enable();
00103 
00104   /// Disable combo box
00105   virtual void disable();
00106 
00107   /// Return default width
00108   virtual FXint getDefaultWidth();
00109 
00110   /// Return default height
00111   virtual FXint getDefaultHeight();
00112 
00113   /// Return true if combobox is editable
00114   FXbool isEditable() const;
00115 
00116   /// Set editable state
00117   void setEditable(FXbool edit=TRUE);
00118 
00119   /// Set the text
00120   void setText(const FXString& txt);
00121 
00122   /// Get the text
00123   FXString getText() const;
00124 
00125   /// Set the number of text columns
00126   void setTextNumCols(FXint cols);
00127 
00128   /// Get the number of text columns
00129   FXint getTextNumCols() const;
00130 
00131   /// Return the number of visible items
00132   FXint getNumVisible() const;
00133 
00134   /// Set the number of visible items
00135   void setNumVisible(FXint nvis);
00136 
00137   /// Set the combobox style.
00138   void setComboStyle(FXuint mode);
00139 
00140   /// Get the combobox style.
00141   FXuint getComboStyle() const;
00142 
00143   /// Return the bound column
00144   FXint getBoundCol() const;
00145 
00146   /// Set the bound column
00147   void setBoundCol(FXint bcol);
00148 
00149   /// Return number of rows
00150   FXint getNumRows() const;
00151 
00152   /// Return number of list columns
00153   FXint getNumCols() const;
00154 
00155   /// Return header control
00156   FXHeader* getHeader() const;
00157 
00158   /// Append header with given text and optional icon
00159   void appendHeader(const FXString& text,FXIcon *icon=NULL,FXint size=1);
00160 
00161   /// Remove header at index
00162   void removeHeader(FXint index);
00163 
00164   /// Change text of header at index
00165   void setHeaderText(FXint index,const FXString& text);
00166 
00167   /// Return text of header at index
00168   FXString getHeaderText(FXint index) const;
00169 
00170   /// Change icon of header at index
00171   void setHeaderIcon(FXint index,FXIcon *icon);
00172 
00173   /// Return icon of header at index
00174   FXIcon* getHeaderIcon(FXint index) const;
00175 
00176   /// Change size of header at index
00177   void setHeaderSize(FXint index,FXint size);
00178 
00179   /// Return width of header at index
00180   FXint getHeaderSize(FXint index) const;
00181 
00182   /// Return number of headers
00183   FXint getNumHeaders() const;
00184 
00185   /// Return the item at the given index
00186   //hd FXString retrieveItem(FXint index) const;
00187   /// Return the item at the given index
00188   FXIconItem *getItem(FXint index) const;
00189 
00190   /// Replace the item at index
00191   //hd void replaceItem(FXint index,const FXString& text,void* ptr=NULL);
00192   /// Replace the item with a [possibly subclassed] item
00193   FXint setItem(FXint index,FXIconItem* item);
00194 
00195   /// Replace items text, icons, and user-data pointer
00196   FXint setItem(FXint index,const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL);
00197 
00198   /// Insert a new item at index
00199   //hd void insertItem(FXint index,const FXString& text,void* ptr=NULL);
00200   /// Insert a new [possibly subclassed] item at the give index
00201   FXint insertItem(FXint index,FXIconItem* item);
00202 
00203   /// Insert item at index with given text, icons, and user-data pointer
00204   FXint insertItem(FXint index,const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL);
00205 
00206   /// Append an item to the list
00207   //hd void appendItem(const FXString& text,void* ptr=NULL);
00208   /// Append a [possibly subclassed] item to the end of the list
00209   FXint appendItem(FXIconItem* item);
00210 
00211   /// Append new item with given text and optional icons, and user-data pointer
00212   FXint appendItem(const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL);
00213 
00214   /// Prepend an item to the list
00215   //hd void prependItem(const FXString& text,void* ptr=NULL);
00216   /// Append a [possibly subclassed] item to the end of the list
00217   FXint prependItem(FXIconItem* item);
00218 
00219   /// Append new item with given text and optional icons, and user-data pointer
00220   FXint prependItem(const FXString& text,FXIcon *big=NULL,FXIcon* mini=NULL,void* ptr=NULL);
00221 
00222   /// Remove item from list
00223   void removeItem(FXint index);
00224 
00225   /// Remove all items from list
00226   void clearItems();
00227 
00228   /// Return item width
00229   FXint getItemWidth() const;
00230 
00231   /// Return item height
00232   FXint getItemHeight() const;
00233 
00234   /// Return index of item at x,y, or -1 if none
00235   //hd FXint getItemAt(FXint x,FXint y) const;
00236 
00237   /**
00238   * Search items for item by name, starting from start item; the
00239   * flags argument controls the search direction, and case sensitivity.
00240   */
00241   FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00242 
00243   /// Scroll to make item at index visible
00244   void makeItemVisible(FXint index);
00245 
00246   /// Change item text
00247   void setItemText(FXint index,const FXString& text);
00248 
00249   /// Return item text
00250   FXString getItemText(FXint index) const;
00251 
00252   /// Change item's column text; col==-1=>use boundcol
00253   void setItemColText(FXint index,const FXString& text,FXint col=-1);
00254 
00255   /// Return item's column text; col==-1=> use boundcol
00256   FXString getItemColText(FXint index,FXint col=-1) const;
00257 
00258   /// Change item big icon
00259   void setItemBigIcon(FXint index,FXIcon* icon);
00260 
00261   /// Return big icon of item at index
00262   FXIcon* getItemBigIcon(FXint index) const;
00263 
00264   /// Change item mini icon
00265   void setItemMiniIcon(FXint index,FXIcon* icon);
00266 
00267   /// Return mini icon of item at index
00268   FXIcon* getItemMiniIcon(FXint index) const;
00269 
00270   /// Change item user-data pointer
00271   void setItemData(FXint index,void* ptr);
00272 
00273   /// Return item user-data pointer
00274   void* getItemData(FXint index) const;
00275 
00276   /// Return TRUE if item at index is selected
00277   FXbool isItemSelected(FXint index) const;
00278 
00279   /// Return TRUE if item at index is current
00280   FXbool isItemCurrent(FXint index) const;
00281 
00282   /// Return TRUE if item at index is visible
00283   FXbool isItemVisible(FXint index) const;
00284 
00285   /// Return TRUE if item at index is enabled
00286   FXbool isItemEnabled(FXint index) const;
00287 
00288   /// Return item hit code: 0 outside, 1 icon, 2 text
00289   FXint hitItem(FXint index,FXint x,FXint y,FXint ww=1,FXint hh=1) const;
00290 
00291   /// Repaint item at index
00292   void updateItem(FXint index);
00293 
00294   /// Select items in rectangle
00295   FXbool selectInRectangle(FXint x,FXint y,FXint w,FXint h);
00296 
00297   /// Enable item at index
00298   FXbool enableItem(FXint index);
00299 
00300   /// Disable item at index
00301   FXbool disableItem(FXint index);
00302 
00303   /// Select item at index
00304   FXbool selectItem(FXint index);
00305 
00306   /// Deselect item at index
00307   FXbool deselectItem(FXint index);
00308 
00309   /// Toggle item at index
00310   FXbool toggleItem(FXint index);
00311 
00312   /// Change current item index
00313   void setCurrentItem(FXint index);
00314 
00315   /// Return current item index, or -1 if none
00316   FXint getCurrentItem() const;
00317 
00318   /// Change anchor item index
00319   void setAnchorItem(FXint index);
00320 
00321   /// Return anchor item index, or -1 if none
00322   FXint getAnchorItem() const;
00323 
00324   /// Return index of item under cursor, or -1 if none
00325   FXint getCursorItem() const;
00326 
00327   /// Extend selection from anchor index to index
00328   FXbool extendSelection(FXint index);
00329 
00330   /// Deselect all items
00331   FXbool killSelection();
00332 
00333   /// Sort items
00334   void sortItems();
00335 
00336   /// Change maximum item space for each item
00337   void setItemSpace(FXint s);
00338 
00339   /// Return maximum item space
00340   FXint getItemSpace() const;
00341 
00342   /// Return sort function
00343   FXIconListSortFunc getSortFunc() const;
00344 
00345   /// Change sort function
00346   void setSortFunc(FXIconListSortFunc func);
00347 
00348   /// Get the current icon list style
00349   FXuint getListStyle() const;
00350 
00351   /// Set the current icon list style.
00352   void setListStyle(FXuint style);
00353 
00354   /// Change text font
00355   void setFont(FXFont* fnt);
00356 
00357   /// Return text font
00358   FXFont* getFont() const;
00359 
00360   /// Set window background color
00361   void setBackColor(FXColor clr);
00362 
00363   /// Get background color
00364   FXColor getBackColor() const;
00365 
00366   /// Return normal text color
00367   FXColor getTextColor() const;
00368 
00369   /// Change normal text color
00370   void setTextColor(FXColor clr);
00371 
00372   /// Return selected text background
00373   FXColor getSelBackColor() const;
00374 
00375   /// Change selected text background
00376   void setSelBackColor(FXColor clr);
00377 
00378   /// Return selected text color
00379   FXColor getSelTextColor() const;
00380 
00381   /// Change selected text color
00382   void setSelTextColor(FXColor clr);
00383 
00384   /// Set the combobox help text
00385   void setHelpText(const FXString& txt);
00386 
00387   /// Get the combobox help text
00388   FXString getHelpText() const;
00389 
00390   /// Set the tool tip message for this combobox
00391   void setTipText(const FXString& txt);
00392 
00393   /// Get the tool tip message for this combobox
00394   FXString getTipText() const;
00395 
00396   /// Save combobox to a stream
00397   virtual void save(FXStream& store) const;
00398 
00399   /// Load combobox from a stream
00400   virtual void load(FXStream& store);
00401 
00402   /// Destructor
00403   virtual ~FXTableBox();
00404   };
00405 
00406 } // namespace FXEX
00407 #endif // FXTABLEBOX_H