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

FXListBox.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                        L i s t   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 *********************************************************************************
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.19 2002/02/27 05:12:45 fox Exp $                         *
00023 ********************************************************************************/
00024 #ifndef FXLISTBOX_H
00025 #define FXLISTBOX_H
00026 
00027 #ifndef FXPACKER_H
00028 #include "FXPacker.h"
00029 #endif
00030 
00031 
00032 
00033 /// List Box styles
00034 enum {
00035   LISTBOX_NORMAL         = 0          // Normal style
00036   };
00037 
00038 
00039 class FXButton;
00040 class FXMenuButton;
00041 class FXList;
00042 class FXPopup;
00043 
00044 
00045 /// List Box
00046 class FXAPI FXListBox : public FXPacker {
00047   FXDECLARE(FXListBox)
00048 protected:
00049   FXButton      *field;
00050   FXMenuButton  *button;
00051   FXList        *list;
00052   FXPopup       *pane;
00053 protected:
00054   FXListBox(){}
00055   virtual void layout();
00056 private:
00057   FXListBox(const FXListBox&);
00058   FXListBox &operator=(const FXListBox&);
00059 public:
00060   long onFocusUp(FXObject*,FXSelector,void*);
00061   long onFocusDown(FXObject*,FXSelector,void*);
00062   long onFieldButton(FXObject*,FXSelector,void*);
00063   long onListUpdate(FXObject*,FXSelector,void*);
00064   long onListChanged(FXObject*,FXSelector,void*);
00065   long onListClicked(FXObject*,FXSelector,void*);
00066   long onCmdSetValue(FXObject*,FXSelector,void*);
00067   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00068   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00069 public:
00070   enum {
00071     ID_LIST=FXPacker::ID_LAST,
00072     ID_FIELD,
00073     ID_LAST
00074     };
00075 public:
00076 
00077   /// Constructor
00078   FXListBox(FXComposite *p,FXint nvis,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);
00079 
00080   /// Create server-side resources
00081   virtual void create();
00082 
00083   /// Detach server-side resources
00084   virtual void detach();
00085 
00086   /// Destroy server-side resources
00087   virtual void destroy();
00088 
00089   /// Enable drive box
00090   virtual void enable();
00091 
00092   /// Disable drive box
00093   virtual void disable();
00094 
00095   /// Return default width
00096   virtual FXint getDefaultWidth();
00097 
00098   /// Return default height
00099   virtual FXint getDefaultHeight();
00100 
00101   /// Return the number of items in the list
00102   FXint getNumItems() const;
00103 
00104   /// Return the number of visible items
00105   FXint getNumVisible() const;
00106 
00107   /// Set the number of visible items
00108   void setNumVisible(FXint nvis);
00109 
00110   /// Return true if current item
00111   FXbool isItemCurrent(FXint index) const;
00112 
00113   /// Set the current item (index is zero-based)
00114   void setCurrentItem(FXint index);
00115 
00116   /// Get the current item's index
00117   FXint getCurrentItem() const;
00118 
00119   /// Return the item at the given index
00120   FXString retrieveItem(FXint index) const;
00121 
00122   /// Replace the item at index
00123   void replaceItem(FXint index,const FXString& text,FXIcon* icon=NULL,void* ptr=NULL);
00124 
00125   /// Insert a new item at index
00126   void insertItem(FXint index,const FXString& text,FXIcon* icon=NULL,void* ptr=NULL);
00127 
00128   /// Add an item to the end of the list
00129   void appendItem(const FXString& text,FXIcon* icon=NULL,void* ptr=NULL);
00130 
00131   /// Prepend an item to the list
00132   void prependItem(const FXString& text,FXIcon* icon=NULL,void* ptr=NULL);
00133 
00134   /// Remove this item from the list
00135   void removeItem(FXint index);
00136 
00137   /// Remove all items from the list
00138   void clearItems();
00139 
00140   /**
00141   * Search items for item by name, starting from start item; the
00142   * flags argument controls the search direction, and case sensitivity.
00143   */
00144   FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
00145 
00146   /// Set text for specified item
00147   void setItemText(FXint index,const FXString& text);
00148 
00149   /// Get text for specified item
00150   FXString getItemText(FXint index) const;
00151 
00152   /// Change item icon
00153   void setItemIcon(FXint index,FXIcon* icon);
00154 
00155   /// Return icon of item at index
00156   FXIcon* getItemIcon(FXint index) const;
00157 
00158   /// Set data pointer for specified item
00159   void setItemData(FXint index,void* ptr) const;
00160 
00161   /// Get data pointer for specified item
00162   void* getItemData(FXint index) const;
00163 
00164   /// Is the pane shown
00165   FXbool isPaneShown() const;
00166 
00167   /// Sort items using current sort function
00168   void sortItems();
00169 
00170   /// Set text font
00171   void setFont(FXFont* fnt);
00172 
00173   /// Get text font
00174   FXFont* getFont() const;
00175 
00176   /// Set window background color
00177   virtual void setBackColor(FXColor clr);
00178 
00179   /// Get background color
00180   FXColor getBackColor() const;
00181 
00182   /// Change text color
00183   void setTextColor(FXColor clr);
00184 
00185   /// Return text color
00186   FXColor getTextColor() const;
00187 
00188   /// Change selected background color
00189   void setSelBackColor(FXColor clr);
00190 
00191   /// Return selected background color
00192   FXColor getSelBackColor() const;
00193 
00194   /// Change selected text color
00195   void setSelTextColor(FXColor clr);
00196 
00197   /// Return selected text color
00198   FXColor getSelTextColor() const;
00199 
00200   /// Return sort function
00201   FXListSortFunc getSortFunc() const;
00202 
00203   /// Change sort function
00204   void setSortFunc(FXListSortFunc func);
00205 
00206   /// Set the combobox help text
00207   void setHelpText(const FXString& txt);
00208 
00209   /// Get the combobox help text
00210   FXString getHelpText() const;
00211 
00212   /// Set the tool tip message for this combobox
00213   void setTipText(const FXString& txt);
00214 
00215   /// Get the tool tip message for this combobox
00216   FXString getTipText() const;
00217 
00218   /// Save combobox to a stream
00219   virtual void save(FXStream& store) const;
00220 
00221   /// Load combobox from a stream
00222   virtual void load(FXStream& store);
00223 
00224   /// Destructor
00225   virtual ~FXListBox();
00226   };
00227 
00228 
00229 
00230 #endif