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

FXComboBoxEx.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *             E x t e n d e d   C o m b o   B o x   W i d g e t                 *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2002 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 * Modified      2002,2003 by Johan Meijdam,         VORtech Computing.          *
00008 *********************************************************************************
00009 * This library is free software; you can redistribute it and/or                 *
00010 * modify it under the terms of the GNU Lesser General Public                    *
00011 * License as published by the Free Software Foundation; either                  *
00012 * version 2.1 of the License, or (at your option) any later version.            *
00013 *                                                                               *
00014 * This library is distributed in the hope that it will be useful,               *
00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00017 * Lesser General Public License for more details.                               *
00018 *                                                                               *
00019 * You should have received a copy of the GNU Lesser General Public              *
00020 * License along with this library; if not, write to the Free Software           *
00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00022 ********************************************************************************/
00023 #ifndef FXCOMBOBOXEX_H
00024 #define FXCOMBOBOXEX_H
00025 
00026 #ifndef FXPACKER_H
00027 #include <fox/FXPacker.h>
00028 using namespace FX;
00029 #endif
00030 namespace FXEX {
00031 
00032 /**
00033  * The ComboBoxEx widget is very similar to the normal FOX ComboBox widget.  It differs in
00034  * that the dropdown list entries use an FXIconList rather than an FXList.  This allows the
00035  * combobox to optionally show icons next to each list entry, rather than a bland text based
00036  * list.
00037  *
00038  * ComboBoxEx styles are the same styles used in FXComboxBox - look there for the definitions.
00039  */
00040 class FXAPI FXComboBoxEx : public FXPacker {
00041   FXDECLARE(FXComboBoxEx)
00042 protected:
00043   FXTextField   *field;
00044   FXMenuButton  *button;
00045   FXIconList    *list;
00046   FXPopup       *pane;
00047 
00048   FXint         numvisible;  
00049 private:
00050   /// Return the text from the given string until the first tab character, or the whole string
00051   static FXString getTextUntilFirstTab(const FXString& in);
00052 protected:
00053   FXComboBoxEx(){}
00054   virtual void layout();
00055 private:
00056   FXComboBoxEx(const FXComboBoxEx&);
00057   FXComboBoxEx &operator=(const FXComboBoxEx&);
00058 public:
00059   long onFocusUp(FXObject*,FXSelector,void*);
00060   long onFocusDown(FXObject*,FXSelector,void*);
00061   long onFocusSelf(FXObject*,FXSelector,void*);
00062   long onTextButton(FXObject*,FXSelector,void*);
00063   long onTextChanged(FXObject*,FXSelector,void*);
00064   long onTextCommand(FXObject*,FXSelector,void*);
00065   long onListClicked(FXObject*,FXSelector,void*);
00066   long onFwdToText(FXObject*,FXSelector,void*);
00067   long onUpdFmText(FXObject*,FXSelector,void*);
00068 public:
00069   enum {
00070     ID_LIST=FXPacker::ID_LAST,
00071     ID_TEXT,
00072     ID_LAST
00073     };
00074 public:
00075 
00076   /// Constructor
00077   FXComboBoxEx(FXComposite *p,FXint cols,FXint nvis,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=COMBOBOX_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);
00078 
00079   /// Create server-side resources
00080   virtual void create();
00081 
00082   /// Detach server-side resources
00083   virtual void detach();
00084 
00085   /// Destroy server-side resources
00086   virtual void destroy();
00087 
00088   /// Enable combo box
00089   virtual void enable();
00090 
00091   /// Disable combo box
00092   virtual void disable();
00093 
00094   /// Return default width
00095   virtual FXint getDefaultWidth();
00096 
00097   /// Return default height
00098   virtual FXint getDefaultHeight();
00099 
00100   /// Return true if combobox is editable
00101   FXbool isEditable() const;
00102 
00103   /// Set editable state
00104   void setEditable(FXbool edit=TRUE);
00105 
00106   /// Set the text
00107   void setText(const FXString& text);
00108 
00109   /// Get the text
00110   FXString getText() const;
00111 
00112   /// Set the number of columns
00113   void setNumColumns(FXint cols);
00114 
00115   /// Get the number of columns
00116   FXint getNumColumns() const;
00117 
00118   /// Return the number of items in the list
00119   FXint getNumItems() const;
00120 
00121   /// Return the number of visible items
00122   FXint getNumVisible() const;
00123 
00124   /// TO DO:
00125   /// Set the number of visible items
00126   void setNumVisible(FXint nvis);
00127 
00128   /// Return true if current item
00129   FXbool isItemCurrent(FXint index) const;
00130 
00131   /// Set the current item (index is zero-based)
00132   void setCurrentItem(FXint indexz);
00133 
00134   /// Get the current item's index
00135   FXint getCurrentItem() const;
00136 
00137   /// Return the item at the given index
00138   FXString getItem(FXint index) const;
00139 
00140   /// Replace the item at index
00141   void setItem(FXint index,const FXString& text,void* ptr=NULL);
00142 
00143   /// Insert a new item at index
00144   void insertItem(FXint index,const FXString& text,void* ptr=NULL);
00145 
00146   /// Append an item to the list
00147   void appendItem(const FXString& text,void* ptr=NULL);
00148 
00149   /// Prepend an item to the list
00150   void prependItem(const FXString& text,void* ptr=NULL);
00151 
00152   /// Replace the item at index
00153   void setItem(FXint index,FXIconItem* item);
00154 
00155   /// Insert a new item at index
00156   void insertItem(FXint index,FXIconItem* item);
00157 
00158   /// Append an item to the list
00159   void appendItem(FXIconItem* item);
00160 
00161   /// Prepend an item to the list
00162   void prependItem(FXIconItem* item);
00163 
00164   /// Remove this item from the list
00165   void removeItem(FXint index);
00166 
00167   /// Remove all items from the list
00168   void clearItems();
00169 
00170   /// Append header with given text and optional icon
00171   void appendHeader(const FXString& text,FXIcon *icon,FXint size) {
00172     list->appendHeader(text,icon,size);
00173     recalc();
00174     }
00175 
00176   /// Remove header at index
00177   void removeHeader(FXint index) {
00178     list->removeHeader(index);
00179     recalc();
00180     }
00181 
00182   /// Change text of header at index
00183   void setHeaderText(FXint index,const FXString& text) {
00184     list->setHeaderText(index, text);
00185     }
00186 
00187   /// Return text of header at index
00188   FXString getHeaderText(FXint index) const {
00189     return list->getHeaderText(index);
00190     }
00191 
00192   /// Change icon of header at index
00193   void setHeaderIcon(FXint index,FXIcon *icon) {
00194     list->setHeaderIcon(index,icon);
00195     }
00196 
00197   /// Return icon of header at index
00198   FXIcon* getHeaderIcon(FXint index) const {
00199     return list->getHeaderIcon(index);
00200     }   
00201 
00202   /// Change size of header at index
00203   void setHeaderSize(FXint index,FXint size) {
00204     list->setHeaderSize(index,size);
00205     recalc();
00206     }
00207 
00208   /// Return width of header at index
00209   FXint getHeaderSize(FXint index) const {
00210     return list->getHeaderSize(index);
00211     }
00212 
00213   /// Return number of headers
00214   FXint getNumHeaders() const {
00215     return list->getNumHeaders();
00216     }
00217 
00218   /**
00219   * Search items for item by name, starting from start item; the
00220   * flags argument controls the search direction, and case sensitivity.
00221   */
00222   FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00223 
00224   /// Set text for specified item
00225   void setItemText(FXint index,const FXString& text);
00226 
00227   /// Get text for specified item
00228   FXString getItemText(FXint index) const;
00229 
00230   /// Set data pointer for specified item
00231   void setItemData(FXint index,void* ptr) const;
00232 
00233   /// Get data pointer for specified item
00234   void* getItemData(FXint index) const;
00235 
00236   /// Is the pane shown
00237   FXbool isPaneShown() const;
00238 
00239   /// Sort items using current sort function
00240   void sortItems();
00241 
00242   /// Set text font
00243   void setFont(FXFont* fnt);
00244 
00245   /// Get text font
00246   FXFont* getFont() const;
00247 
00248   /// Set the combobox style.
00249   void setComboStyle(FXuint mode);
00250 
00251   /// Get the combobox style.
00252   FXuint getComboStyle() const;
00253 
00254   /// Set window background color
00255   virtual void setBackColor(FXColor clr);
00256 
00257   /// Get background color
00258   FXColor getBackColor() const;
00259 
00260   /// Change text color
00261   void setTextColor(FXColor clr);
00262 
00263   /// Return text color
00264   FXColor getTextColor() const;
00265 
00266   /// Change selected background color
00267   void setSelBackColor(FXColor clr);
00268 
00269   /// Return selected background color
00270   FXColor getSelBackColor() const;
00271 
00272   /// Change selected text color
00273   void setSelTextColor(FXColor clr);
00274 
00275   /// Return selected text color
00276   FXColor getSelTextColor() const;
00277 
00278   /// Return sort function
00279   FXIconListSortFunc getSortFunc() const;
00280 
00281   /// Change sort function
00282   void setSortFunc(FXIconListSortFunc func);
00283 
00284   /// Set the combobox help text
00285   void setHelpText(const FXString& txt);
00286 
00287   /// Get the combobox help text
00288   FXString getHelpText() const;
00289 
00290   /// Set the tool tip message for this combobox
00291   void setTipText(const FXString& txt);
00292 
00293   /// Get the tool tip message for this combobox
00294   FXString getTipText() const;
00295 
00296   /// Save combobox to a stream
00297   virtual void save(FXStream& store) const;
00298 
00299   /// Load combobox from a stream
00300   virtual void load(FXStream& store);
00301 
00302   /// Destructor
00303   virtual ~FXComboBoxEx();
00304   };
00305 }
00306 
00307 #endif