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