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

FXListBox.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                        L i s t   B o x   W i d g e t                          *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,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: FXListBox.h,v 1.43 2006/01/22 17:58:05 fox Exp $                         *
00023 ********************************************************************************/
00024 #ifndef FXLISTBOX_H
00025 #define FXLISTBOX_H
00026 
00027 #ifndef FXPACKER_H
00028 #include "FXPacker.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 /// List Box styles
00035 enum {
00036   LISTBOX_NORMAL         = 0          // Normal style
00037   };
00038 
00039 
00040 class FXButton;
00041 class FXMenuButton;
00042 class FXList;
00043 class FXPopup;
00044 
00045 
00046 /**
00047 * The List Box is a control to select one of a list of options.  It looks
00048 * similar to a Combo Box except that List Box yields integer numbers only.
00049 * When an option is selected, List Box will send an SEL_COMMAND with the
00050 * index of the opton.  While manipulating the list, it may send SEL_CHANGED
00051 * messages to indicate which option the cursor is hovering over.
00052 * The List Box is able to receive ID_GETINTVALUE and ID_SETINTVALUE which
00053 * will retrieve the current option or change the selected option.
00054 */
00055 class FXAPI FXListBox : public FXPacker {
00056   FXDECLARE(FXListBox)
00057 protected:
00058   FXButton      *field;
00059   FXMenuButton  *button;
00060   FXList        *list;
00061   FXPopup       *pane;
00062 protected:
00063   FXListBox(){}
00064 private:
00065   FXListBox(const FXListBox&);
00066   FXListBox &operator=(const FXListBox&);
00067 public:
00068   long onFocusUp(FXObject*,FXSelector,void*);
00069   long onFocusDown(FXObject*,FXSelector,void*);
00070   long onFocusSelf(FXObject*,FXSelector,void*);
00071   long onMouseWheel(FXObject*,FXSelector,void*);
00072   long onFieldButton(FXObject*,FXSelector,void*);
00073   long onListUpdate(FXObject*,FXSelector,void*);
00074   long onListClicked(FXObject*,FXSelector,void*);
00075   long onListChanged(FXObject*,FXSelector,void*);
00076   long onCmdSetValue(FXObject*,FXSelector,void*);
00077   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00078   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00079 public:
00080   enum {
00081     ID_LIST=FXPacker::ID_LAST,
00082     ID_FIELD,
00083     ID_LAST
00084     };
00085 public:
00086 
00087   /// Constructor
00088   FXListBox(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=FRAME_SUNKEN|FRAME_THICK|LISTBOX_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);
00089 
00090   /// Create server-side resources
00091   virtual void create();
00092 
00093   /// Detach server-side resources
00094   virtual void detach();
00095 
00096   /// Destroy server-side resources
00097   virtual void destroy();
00098 
00099   /// Perform layout
00100   virtual void layout();
00101 
00102   /// Enable drive box
00103   virtual void enable();
00104 
00105   /// Disable drive box
00106   virtual void disable();
00107 
00108   /// Return default width
00109   virtual FXint getDefaultWidth();
00110 
00111   /// Return default height
00112   virtual FXint getDefaultHeight();
00113 
00114   /// Return the number of items in the list
00115   FXint getNumItems() const;
00116 
00117   /// Return the number of visible items
00118   FXint getNumVisible() const;
00119 
00120   /// Set the number of visible items
00121   void setNumVisible(FXint nvis);
00122 
00123   /// Return true if current item
00124   FXbool isItemCurrent(FXint index) const;
00125 
00126   /// Set the current item (index is zero-based)
00127   virtual void setCurrentItem(FXint index,FXbool notify=FALSE);
00128 
00129   /// Get the current item's index
00130   FXint getCurrentItem() const;
00131 
00132   /// Return the item at the given index
00133   FXString getItem(FXint index) const;
00134 
00135   /// Replace the item at index
00136   FXint setItem(FXint index,const FXString& text,FXIcon* icon=NULL,void* ptr=NULL);
00137 
00138   /// Fill list box by appending items from array of strings
00139   FXint fillItems(const FXchar** strings,FXIcon* icon=NULL,void* ptr=NULL);
00140 
00141   /// Fill list box by appending items from newline separated strings
00142   FXint fillItems(const FXString& strings,FXIcon* icon=NULL,void* ptr=NULL);
00143 
00144   /// Insert a new item at index
00145   FXint insertItem(FXint index,const FXString& text,FXIcon* icon=NULL,void* ptr=NULL);
00146 
00147   /// Add an item to the end of the list
00148   FXint appendItem(const FXString& text,FXIcon* icon=NULL,void* ptr=NULL);
00149 
00150   /// Prepend an item to the list
00151   FXint prependItem(const FXString& text,FXIcon* icon=NULL,void* ptr=NULL);
00152 
00153   /// Move item from oldindex to newindex
00154   FXint moveItem(FXint newindex,FXint oldindex);
00155 
00156   /// Extract item from list
00157   FXListItem* extractItem(FXint index);
00158 
00159   /// Remove this item from the list
00160   void removeItem(FXint index);
00161 
00162   /// Remove all items from the list
00163   void clearItems();
00164 
00165   /**
00166   * Search items by name, beginning from item start.  If the start
00167   * item is -1 the search will start at the first item in the list.
00168   * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the
00169   * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP
00170   * to control whether the search wraps at the start or end of the list.
00171   * The option SEARCH_IGNORECASE causes a case-insensitive match.  Finally,
00172   * passing SEARCH_PREFIX causes searching for a prefix of the item name.
00173   * Return -1 if no matching item is found.
00174   */
00175   FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00176 
00177   /**
00178   * Search items by associated user data, beginning from item start. If the
00179   * start item is -1 the search will start at the first item in the list.
00180   * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the
00181   * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP
00182   * to control whether the search wraps at the start or end of the list.
00183   */
00184   FXint findItemByData(const void *ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00185 
00186   /// Set text for specified item
00187   void setItemText(FXint index,const FXString& text);
00188 
00189   /// Get text for specified item
00190   FXString getItemText(FXint index) const;
00191 
00192   /// Change item icon, deleting old one if it was owned
00193   void setItemIcon(FXint index,FXIcon* icon,FXbool owned=FALSE);
00194 
00195   /// Return icon of item at index
00196   FXIcon* getItemIcon(FXint index) const;
00197 
00198   /// Set data pointer for specified item
00199   void setItemData(FXint index,void* ptr) const;
00200 
00201   /// Get data pointer for specified item
00202   void* getItemData(FXint index) const;
00203 
00204   /// Is the pane shown
00205   FXbool isPaneShown() const;
00206 
00207   /// Sort items using current sort function
00208   void sortItems();
00209 
00210   /// Set text font
00211   void setFont(FXFont* fnt);
00212 
00213   /// Get text font
00214   FXFont* getFont() const;
00215 
00216   /// Set window background color
00217   virtual void setBackColor(FXColor clr);
00218 
00219   /// Get background color
00220   FXColor getBackColor() const;
00221 
00222   /// Change text color
00223   void setTextColor(FXColor clr);
00224 
00225   /// Return text color
00226   FXColor getTextColor() const;
00227 
00228   /// Change selected background color
00229   void setSelBackColor(FXColor clr);
00230 
00231   /// Return selected background color
00232   FXColor getSelBackColor() const;
00233 
00234   /// Change selected text color
00235   void setSelTextColor(FXColor clr);
00236 
00237   /// Return selected text color
00238   FXColor getSelTextColor() const;
00239 
00240   /// Return sort function
00241   FXListSortFunc getSortFunc() const;
00242 
00243   /// Change sort function
00244   void setSortFunc(FXListSortFunc func);
00245 
00246   /// Set the combobox help text
00247   void setHelpText(const FXString& txt);
00248 
00249   /// Get the combobox help text
00250   const FXString& getHelpText() const;
00251 
00252   /// Set the tool tip message for this combobox
00253   void setTipText(const FXString& txt);
00254 
00255   /// Get the tool tip message for this combobox
00256   const FXString& getTipText() const;
00257 
00258   /// Save combobox to a stream
00259   virtual void save(FXStream& store) const;
00260 
00261   /// Load combobox from a stream
00262   virtual void load(FXStream& store);
00263 
00264   /// Destructor
00265   virtual ~FXListBox();
00266   };
00267 
00268 }
00269 
00270 #endif

Copyright © 1997-2005 Jeroen van der Zijp