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

FXBasketListBox.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 *                                                                              *
00003 *                    B a s k e t   L i s t   B o x   O b j e c t               *
00004 *                                                                              *
00005 ********************************************************************************
00006 * Copyright (C) 2002 by Bryan W. Headley.  All Rights Reserved.                *
00007 *                                                                              *
00008 * Based on FOX Toolkit, Copyright (C) 1997,2002 Jeroen van der Zijp.           *
00009 ********************************************************************************
00010 * This library is free software; you can redistribute it and/or                *
00011 * modify it under the terms of the GNU Lesser General Public                   *
00012 * License as published by the Free Software Foundation; either                 *
00013 * version 2.1 of the License, or (at your option) any later version.           *
00014 *                                                                              *
00015 * This library is distributed in the hope that it will be useful,              *
00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of               *
00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU            *
00018 * Lesser General Public License for more details.                              *
00019 *                                                                              *
00020 * You should have received a copy of the GNU Lesser General Public             *
00021 * License along with this library; if not, write to the Free Software          *
00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.   *
00023 ********************************************************************************
00024 * $Id: FXBasketListBox.h,v 0.00 2002/08/07 00:00:00 bwheadley Exp $            *
00025 *******************************************************************************/
00026 #ifndef FXBASKETLISTBOX_H
00027 #define FXBASKETLISTBOX_H
00028 
00029 #ifndef FXPACKER_H
00030 #include <fox/FXPacker.h>
00031 using namespace FX;
00032 #endif
00033 namespace FXEX {
00034 
00035 /// List Box styles
00036 enum {
00037   BASKETLISTBOX_ORIENT_HORIZONTAL= 0x10000000,
00038   BASKETLISTBOX_ORIENT_VERTICAL  = 0x20000000,
00039   BASKETLISTBOX_NORMAL           = (FRAME_SUNKEN|FRAME_THICK|BASKETLISTBOX_ORIENT_HORIZONTAL),
00040   };
00041 
00042 /// List Box
00043 class FXAPI FXBasketListBox : public FXPacker {
00044   FXDECLARE(FXBasketListBox)
00045 protected:
00046   FXIcon*            basketIcon;
00047   FXButton*          field;
00048   FXMenuButton*      button;
00049   FXList*            basketList;
00050   FXList*            selectionList;
00051   FXPopup*           pane;
00052   FXButton*          doneButton;
00053   FXVerticalFrame*   vframe;
00054   FXHorizontalFrame* hframe;
00055   FXVerticalFrame*   vframe1;
00056   FXVerticalFrame*   vframe2;
00057   FXLabel*           label1;
00058   FXLabel*           label2;
00059   FXuint             options;
00060 
00061 protected:
00062   FXBasketListBox(){}
00063   virtual void layout();
00064 
00065 private:
00066   FXBasketListBox(const FXBasketListBox&);
00067   FXBasketListBox &operator=(const FXBasketListBox&);
00068 
00069 public:
00070   // Available callbacks on the basketList
00071   long onBasketListFocusUp(FXObject*,FXSelector,void*);
00072   long onBasketListFocusDown(FXObject*,FXSelector,void*);
00073   long onBasketListUpdate(FXObject*,FXSelector,void*);
00074   long onBasketListChanged(FXObject*,FXSelector,void*);
00075   long onBasketListClicked(FXObject*,FXSelector,void*);
00076 
00077   // Available callbacks on the selectionList
00078   long onSelectionListFocusUp(FXObject*,FXSelector,void*);
00079   long onSelectionListFocusDown(FXObject*,FXSelector,void*);
00080   long onSelectionListUpdate(FXObject*,FXSelector,void*);
00081   long onSelectionListChanged(FXObject*,FXSelector,void*);
00082   long onSelectionListClicked(FXObject*,FXSelector,void*);
00083 
00084   long onFocusSelf(FXObject*,FXSelector,void*);
00085   long onFieldButton(FXObject*,FXSelector,void*);
00086   long onDoneButton(FXObject*,FXSelector,void*);
00087   long onCmdGetValue(FXObject*,FXSelector,void*);
00088   long onCmdSetValue(FXObject*,FXSelector,void*);
00089   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00090   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00091 
00092 public:
00093   enum {
00094     ID_SELECTIONLIST=FXPacker::ID_LAST,
00095     ID_BASKETLIST,
00096     ID_FIELD,
00097     ID_DONE,
00098     ID_LAST
00099     };
00100 public:
00101 
00102   /// Specify the number of visible items
00103   FXBasketListBox(FXComposite *p,FXint nvis,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=BASKETLISTBOX_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);
00104 
00105   /// Create server-side resources
00106   virtual void create();
00107 
00108   /// Detach server-side resources
00109   virtual void detach();
00110 
00111   /// Destroy server-side resources
00112   virtual void destroy();
00113 
00114   /// Enable drive box
00115   virtual void enable();
00116 
00117   /// Disable drive box
00118   virtual void disable();
00119 
00120   /// Return default width
00121   virtual FXint getDefaultWidth();
00122 
00123   /// Return default height
00124   virtual FXint getDefaultHeight();
00125 
00126   /// Set values for the widget.
00127   void setValues(const FXStringList& list);
00128 
00129   /// Get values for the widget.
00130   FXStringList getValues() const;
00131 
00132   // I'm trying to implement a "like" API to FXListBox and FXComboBox,
00133   // two similar widgets. To do that, I assume that the first parameter
00134   // to these methods, the FXList*, points to the selection FXList.
00135   // For the above two widgets, that's the only FXList*; the FXBasketListBox
00136   // has two. Yes, I could have done the same with a series of inlines,
00137   // but opted against namespace pollution. Sometimes, below, I had no
00138   // choice but to implement pass-thru's. I am so ashamed :-)
00139 
00140   /**
00141    * Return the number of items in the list.
00142    * If list is not specified, use the selection list.
00143    */
00144   FXint getNumItems(FXList* list=NULL) const;
00145 
00146   /**
00147    * Return the number of visible items.
00148    * If list is not specified, use the selection list.
00149    */
00150   FXint getNumVisible(FXList* list=NULL) const;
00151 
00152   /**
00153    * Set the number of visible items.
00154    * If list is not specified, use the selection list.
00155    */
00156   void setNumVisible(FXint nvis,FXList* list=NULL);
00157 
00158   /**
00159    * Return true if current item.
00160    * If list is not specified, use the selection list.
00161    */
00162   FXbool isItemCurrent(FXint index,FXList* list=NULL) const;
00163 
00164   /**
00165    * Set the current item (index is zero-based).
00166    * If list is not specified, use the selection list.
00167    */
00168   void setCurrentItem(FXint index,FXList* list=NULL);
00169 
00170   /**
00171    * Get the current item's index.
00172    * If list is not specified, use the selection list.
00173    */
00174   FXint getCurrentItem(FXList* list=NULL) const;
00175 
00176   /**
00177    * Return the item at the given index.
00178    * If list is not specified, use the selection list.
00179    */
00180   FXString getItem(FXint index,FXList* list=NULL) const;
00181 
00182   /**
00183    * Replace the item at index.
00184    * If list is not specified, use the selection list.
00185    */
00186   void setItem(FXint index,const FXString& text,FXIcon* icon=NULL,void* ptr=NULL,FXList* list=NULL);
00187 
00188   /** 
00189    * Insert a new item at index.
00190    * If list is not specified, use the selection list.
00191    */
00192   void insertItem(FXint index,const FXString& text,FXIcon* icon=NULL,void* ptr=NULL,FXList* list=NULL);
00193 
00194   /**
00195    * Add an item to the end of the list.
00196    * If list is not specified, use the selection list.
00197    */
00198   void appendItem(const FXString& text,FXIcon* icon=NULL,void* ptr=NULL,FXList* list=NULL);
00199 
00200   /**
00201    * Prepend an item to the list.
00202    * If list is not specified, use the selection list.
00203    */
00204   void prependItem(const FXString& text,FXIcon* icon=NULL,void* ptr=NULL,FXList* list=NULL);
00205 
00206   /**
00207    * Remove this item from the list.
00208    * If list is not specified, use the selection list.
00209    */
00210   void removeItem(FXint index,FXList* list=NULL);
00211 
00212   /**
00213    * Remove all items from the list.
00214    * If list is not specified, use the selection list.
00215    */
00216   void clearItems(FXList* list=NULL);
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    * If list is not specified, use the selection list.
00222    */
00223   FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP,FXList* list=NULL) const;
00224 
00225   /**
00226    * Set text for specified item
00227    * If list is not specified, use the selection list.
00228    */
00229   void setItemText(FXint index,const FXString& text,FXList* list=NULL);
00230 
00231   /**
00232    * Get text for specified item
00233    * If list is not specified, use the selection list.
00234    */
00235   FXString getItemText(FXint index,FXList* list=NULL) const;
00236 
00237   /**
00238    * Change item icon
00239    * If list is not specified, use the selection list.
00240    */
00241   void setItemIcon(FXint index,FXIcon* icon,FXList* list=NULL);
00242 
00243   /**
00244    * Return icon of item at index
00245    * If list is not specified, use the selection list.
00246    */
00247   FXIcon* getItemIcon(FXint index,FXList* list=NULL) const;
00248 
00249   /**
00250    * Set data pointer for specified item
00251    * If list is not specified, use the selection list.
00252    */
00253   void setItemData(FXint index,void* ptr,FXList* list=NULL) const;
00254 
00255   /**
00256    * Get data pointer for specified item
00257    * If list is not specified, use the selection list.
00258    */
00259   void* getItemData(FXint index,FXList* list=NULL) const;
00260 
00261   /**
00262    * Is the pane shown
00263    * If list is not specified, use the selection list.
00264    */
00265   FXbool isPaneShown(FXList* list=NULL) const;
00266 
00267   /**
00268    * Sort items using current sort function
00269    * If list is not specified, use the selection list.
00270    */
00271   void sortItems(FXList* list=NULL);
00272 
00273   /**
00274    * Set text font
00275    * If list is not specified, use the selection list.
00276    */
00277   void setFont(FXFont* fnt,FXList* list=NULL);
00278 
00279   /**
00280    * Get text font
00281    * If list is not specified, use the selection list.
00282    */
00283   FXFont* getFont(FXList* list=NULL) const;
00284 
00285   /**
00286    * Set window background color
00287    * If list is not specified, use the selection list.
00288    */
00289   void setBackColor(FXColor clr,FXList* list=NULL);
00290 
00291   /**
00292    * Get background color
00293    * If list is not specified, use the selection list.
00294    */
00295   FXColor getBackColor(FXList* list=NULL) const;
00296 
00297   /**
00298    * Change text color
00299    * If list is not specified, use the selection list.
00300    */
00301   void setTextColor(FXColor clr,FXList* list=NULL);
00302 
00303   /**
00304    * Return text color
00305    * If list is not specified, use the selection list.
00306    */
00307   FXColor getTextColor(FXList* list=NULL) const;
00308 
00309   /**
00310    * Change selected background color
00311    * If list is not specified, use the selection list.
00312    */
00313   void setSelBackColor(FXColor clr,FXList* list=NULL);
00314 
00315   /**
00316    * Return selected background color
00317    * If list is not specified, use the selection list.
00318    */
00319   FXColor getSelBackColor(FXList* list=NULL) const;
00320 
00321   /**
00322    * Change selected text color
00323    * If list is not specified, use the selection list.
00324    */
00325   void setSelTextColor(FXColor clr,FXList* list=NULL);
00326 
00327   /**
00328    * Return selected text color
00329    * If list is not specified, use the selection list.
00330    */
00331   FXColor getSelTextColor(FXList* list=NULL) const;
00332 
00333   /**
00334    * Return sort function
00335    * If list is not specified, use the selection list.
00336    */
00337   FXListSortFunc getSortFunc(FXList* list=NULL) const;
00338 
00339   /**
00340    * Change sort function
00341    * If list is not specified, use the selection list.
00342    */
00343   void setSortFunc(FXListSortFunc func,FXList* list=NULL);
00344 
00345   /// get access to basket list
00346   FXList* getBasketList() { return basketList; }
00347 
00348   /// get access to selected list
00349   FXList* getSelectionList() { return selectionList; }
00350 
00351   /// Set the combobox help text
00352   void setHelpText(const FXString& txt);
00353 
00354   /// Get the combobox help text
00355   FXString getHelpText() const;
00356 
00357   /// Set the tool tip message for this combobox
00358   void setTipText(const FXString& txt);
00359 
00360   /// Get the tool tip message for this combobox
00361   FXString getTipText() const;
00362 
00363   /// Save object to a stream
00364   virtual void save(FXStream& store) const;
00365 
00366   /// Load object from a stream
00367   virtual void load(FXStream& store);
00368 
00369   /// Destructor
00370   virtual ~FXBasketListBox();
00371   };
00372 
00373 } // namespace FXEX
00374 #endif // FXBASKETLISTBOX_H