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