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

FXComboBox.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                       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 *********************************************************************************
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: FXComboBox.h,v 1.26 2002/09/30 13:06:55 fox Exp $                        *
00023 ********************************************************************************/
00024 #ifndef FXCOMBOBOX_H
00025 #define FXCOMBOBOX_H
00026 
00027 #ifndef FXPACKER_H
00028 #include "FXPacker.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 // ComboBox styles
00035 enum {
00036   COMBOBOX_NO_REPLACE     = 0,                  // Leave the list the same
00037   COMBOBOX_REPLACE        = 0x00020000,         // Replace current item with typed text
00038   COMBOBOX_INSERT_BEFORE  = 0x00040000,         // Typed text inserted before current
00039   COMBOBOX_INSERT_AFTER   = 0x00060000,         // Typed text inserted after current
00040   COMBOBOX_INSERT_FIRST   = 0x00080000,         // Typed text inserted at begin of list
00041   COMBOBOX_INSERT_LAST    = 0x00090000,         // Typed text inserted at end of list
00042   COMBOBOX_STATIC         = 0x00100000,         // Unchangable text box
00043   COMBOBOX_NORMAL         = 0                   // Can type text but list is not changed
00044   };
00045 
00046 
00047 class FXTextField;
00048 class FXMenuButton;
00049 class FXList;
00050 class FXPopup;
00051 
00052 
00053 /// Combobox
00054 class FXAPI FXComboBox : public FXPacker {
00055   FXDECLARE(FXComboBox)
00056 protected:
00057   FXTextField   *field;
00058   FXMenuButton  *button;
00059   FXList        *list;
00060   FXPopup       *pane;
00061 protected:
00062   FXComboBox(){}
00063   virtual void layout();
00064 private:
00065   FXComboBox(const FXComboBox&);
00066   FXComboBox &operator=(const FXComboBox&);
00067 public:
00068   long onFocusUp(FXObject*,FXSelector,void*);
00069   long onFocusDown(FXObject*,FXSelector,void*);
00070   long onFocusSelf(FXObject*,FXSelector,void*);
00071   long onTextButton(FXObject*,FXSelector,void*);
00072   long onTextChanged(FXObject*,FXSelector,void*);
00073   long onTextCommand(FXObject*,FXSelector,void*);
00074   long onListClicked(FXObject*,FXSelector,void*);
00075   long onFwdToText(FXObject*,FXSelector,void*);
00076   long onUpdFmText(FXObject*,FXSelector,void*);
00077 public:
00078   enum {
00079     ID_LIST=FXPacker::ID_LAST,
00080     ID_TEXT,
00081     ID_LAST
00082     };
00083 public:
00084 
00085   /// Constructor
00086   FXComboBox(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);
00087 
00088   /// Create server-side resources
00089   virtual void create();
00090 
00091   /// Detach server-side resources
00092   virtual void detach();
00093 
00094   /// Destroy server-side resources
00095   virtual void destroy();
00096 
00097   /// Enable combo box
00098   virtual void enable();
00099 
00100   /// Disable combo box
00101   virtual void disable();
00102 
00103   /// Return default width
00104   virtual FXint getDefaultWidth();
00105 
00106   /// Return default height
00107   virtual FXint getDefaultHeight();
00108 
00109   /// Return true if combobox is editable
00110   FXbool isEditable() const;
00111 
00112   /// Set editable state
00113   void setEditable(FXbool edit=TRUE);
00114 
00115   /// Set the text
00116   void setText(const FXString& text);
00117 
00118   /// Get the text
00119   FXString getText() const;
00120 
00121   /// Set the number of columns
00122   void setNumColumns(FXint cols);
00123 
00124   /// Get the number of columns
00125   FXint getNumColumns() const;
00126 
00127   /// Return the number of items in the list
00128   FXint getNumItems() const;
00129 
00130   /// Return the number of visible items
00131   FXint getNumVisible() const;
00132 
00133   /// Set the number of visible items
00134   void setNumVisible(FXint nvis);
00135 
00136   /// Return true if current item
00137   FXbool isItemCurrent(FXint index) const;
00138 
00139   /// Set the current item (index is zero-based)
00140   void setCurrentItem(FXint indexz);
00141 
00142   /// Get the current item's index
00143   FXint getCurrentItem() const;
00144 
00145   /// Return the item at the given index
00146   FXString getItem(FXint index) const;
00147 
00148   /// Replace the item at index
00149   void setItem(FXint index,const FXString& text,void* ptr=NULL);
00150 
00151   /// Insert a new item at index
00152   void insertItem(FXint index,const FXString& text,void* ptr=NULL);
00153 
00154   /// Append an item to the list
00155   void appendItem(const FXString& text,void* ptr=NULL);
00156 
00157   /// Prepend an item to the list
00158   void prependItem(const FXString& text,void* ptr=NULL);
00159 
00160   /// Remove this item from the list
00161   void removeItem(FXint index);
00162 
00163   /// Remove all items from the list
00164   void clearItems();
00165 
00166   /// Set text for specified item
00167   void setItemText(FXint index,const FXString& text);
00168 
00169   /// Get text for specified item
00170   FXString getItemText(FXint index) const;
00171 
00172   /// Set data pointer for specified item
00173   void setItemData(FXint index,void* ptr) const;
00174 
00175   /// Get data pointer for specified item
00176   void* getItemData(FXint index) const;
00177 
00178   /// Is the pane shown
00179   FXbool isPaneShown() const;
00180 
00181   /// Sort items using current sort function
00182   void sortItems();
00183 
00184   /// Set text font
00185   void setFont(FXFont* fnt);
00186 
00187   /// Get text font
00188   FXFont* getFont() const;
00189 
00190   /// Set the combobox style.
00191   void setComboStyle(FXuint mode);
00192 
00193   /// Get the combobox style.
00194   FXuint getComboStyle() const;
00195 
00196   /// Set window background color
00197   virtual void setBackColor(FXColor clr);
00198 
00199   /// Get background color
00200   FXColor getBackColor() const;
00201 
00202   /// Change text color
00203   void setTextColor(FXColor clr);
00204 
00205   /// Return text color
00206   FXColor getTextColor() const;
00207 
00208   /// Change selected background color
00209   void setSelBackColor(FXColor clr);
00210 
00211   /// Return selected background color
00212   FXColor getSelBackColor() const;
00213 
00214   /// Change selected text color
00215   void setSelTextColor(FXColor clr);
00216 
00217   /// Return selected text color
00218   FXColor getSelTextColor() const;
00219 
00220   /// Return sort function
00221   FXListSortFunc getSortFunc() const;
00222 
00223   /// Change sort function
00224   void setSortFunc(FXListSortFunc func);
00225 
00226   /// Set the combobox help text
00227   void setHelpText(const FXString& txt);
00228 
00229   /// Get the combobox help text
00230   const FXString& getHelpText() const;
00231 
00232   /// Set the tool tip message for this combobox
00233   void setTipText(const FXString& txt);
00234 
00235   /// Get the tool tip message for this combobox
00236   const FXString& getTipText() const;
00237 
00238   /// Save combobox to a stream
00239   virtual void save(FXStream& store) const;
00240 
00241   /// Load combobox from a stream
00242   virtual void load(FXStream& store);
00243 
00244   /// Destructor
00245   virtual ~FXComboBox();
00246   };
00247 
00248 }
00249 
00250 #endif