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,2005 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.41 2005/01/16 16:06:06 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 /** 00054 * A Combo Box provides a way to select a string from a list of strings. 00055 * Unless COMBOBOX_STATIC is passed, it also allows the user to enter a new 00056 * string into the text field, for example if the desired entry is not in the 00057 * list of strings. Passing COMBOBOX_REPLACE, COMBOBOX_INSERT_BEFORE, COMBOBOX_INSERT_AFTER, 00058 * COMBOBOX_INSERT_FIRST, or COMBOBOX_INSERT_LAST causes a newly entered text to replace the 00059 * current one in the list, or be added before or after the current entry, or to be added at 00060 * the beginning or end of the list. 00061 * Combo Box is intended to enter text; if you need to enter a choice from a list of 00062 * options, it is recommended that the List Box widget is used instead. 00063 * When the text in the field is changed, a SEL_COMMAND will be send to the target. 00064 * The Combo Box can also receive ID_GETSTRINGVALUE and ID_SETSTRINGVALUE and so 00065 * on, which will behave similar to Text Field in that they will retrieve or update 00066 * the value of the field. 00067 */ 00068 class FXAPI FXComboBox : public FXPacker { 00069 FXDECLARE(FXComboBox) 00070 protected: 00071 FXTextField *field; 00072 FXMenuButton *button; 00073 FXList *list; 00074 FXPopup *pane; 00075 protected: 00076 FXComboBox(){} 00077 private: 00078 FXComboBox(const FXComboBox&); 00079 FXComboBox &operator=(const FXComboBox&); 00080 public: 00081 long onFocusUp(FXObject*,FXSelector,void*); 00082 long onFocusDown(FXObject*,FXSelector,void*); 00083 long onFocusSelf(FXObject*,FXSelector,void*); 00084 long onTextButton(FXObject*,FXSelector,void*); 00085 long onTextChanged(FXObject*,FXSelector,void*); 00086 long onTextCommand(FXObject*,FXSelector,void*); 00087 long onListClicked(FXObject*,FXSelector,void*); 00088 long onFwdToText(FXObject*,FXSelector,void*); 00089 long onUpdFmText(FXObject*,FXSelector,void*); 00090 public: 00091 enum { 00092 ID_LIST=FXPacker::ID_LAST, 00093 ID_TEXT, 00094 ID_LAST 00095 }; 00096 public: 00097 00098 /// Construct a Combo Box widget with room to display cols columns of text 00099 FXComboBox(FXComposite *p,FXint cols,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); 00100 00101 /// Create server-side resources 00102 virtual void create(); 00103 00104 /// Detach server-side resources 00105 virtual void detach(); 00106 00107 /// Destroy server-side resources 00108 virtual void destroy(); 00109 00110 /// Enable combo box 00111 virtual void enable(); 00112 00113 /// Disable combo box 00114 virtual void disable(); 00115 00116 /// Return default width 00117 virtual FXint getDefaultWidth(); 00118 00119 /// Return default height 00120 virtual FXint getDefaultHeight(); 00121 00122 /// Perform layout 00123 virtual void layout(); 00124 00125 /// Return true if combobox is editable 00126 FXbool isEditable() const; 00127 00128 /// Set editable state 00129 void setEditable(FXbool edit=TRUE); 00130 00131 /// Set the text 00132 void setText(const FXString& text); 00133 00134 /// Get the text 00135 FXString getText() const; 00136 00137 /// Set the number of columns 00138 void setNumColumns(FXint cols); 00139 00140 /// Get the number of columns 00141 FXint getNumColumns() const; 00142 00143 /// Return the number of items in the list 00144 FXint getNumItems() const; 00145 00146 /// Return the number of visible items 00147 FXint getNumVisible() const; 00148 00149 /// Set the number of visible items in the drop down list 00150 void setNumVisible(FXint nvis); 00151 00152 /// Return true if current item 00153 FXbool isItemCurrent(FXint index) const; 00154 00155 /// Set the current item (index is zero-based) 00156 void setCurrentItem(FXint index); 00157 00158 /// Get the current item's index 00159 FXint getCurrentItem() const; 00160 00161 /// Return the item at the given index 00162 FXString getItem(FXint index) const; 00163 00164 /// Replace the item at index 00165 FXint setItem(FXint index,const FXString& text,void* ptr=NULL); 00166 00167 /// Fill combo box by appending items from array of strings 00168 FXint fillItems(const FXchar** strings); 00169 00170 /// Fill combo box by appending items from newline separated strings 00171 FXint fillItems(const FXString& strings); 00172 00173 /// Insert a new item at index 00174 FXint insertItem(FXint index,const FXString& text,void* ptr=NULL); 00175 00176 /// Append an item to the list 00177 FXint appendItem(const FXString& text,void* ptr=NULL); 00178 00179 /// Prepend an item to the list 00180 FXint prependItem(const FXString& text,void* ptr=NULL); 00181 00182 /// Move item from oldindex to newindex 00183 FXint moveItem(FXint newindex,FXint oldindex); 00184 00185 /// Remove this item from the list 00186 void removeItem(FXint index); 00187 00188 /// Remove all items from the list 00189 void clearItems(); 00190 00191 /** 00192 * Search items by name, beginning from item start. If the start item 00193 * is -1 the search will start at the first item in the list. Flags 00194 * may be SEARCH_FORWARD or SEARCH_BACKWARD to control the search 00195 * direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP 00196 * to control whether the search wraps at the start or end of the list. 00197 * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, 00198 * passing SEARCH_PREFIX causes searching for a prefix of the item name. 00199 * Return -1 if no matching item is found. 00200 */ 00201 FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; 00202 00203 /** 00204 * Search items by associated user data, beginning from item start. If the 00205 * start item is -1 the search will start at the first item in the list. 00206 * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the 00207 * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP 00208 * to control whether the search wraps at the start or end of the list. 00209 * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, 00210 * passing SEARCH_PREFIX causes searching for a prefix of the item name. 00211 * Return -1 if no matching item is found. 00212 */ 00213 FXint findItemByData(const void *ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; 00214 00215 /// Set text for specified item 00216 void setItemText(FXint index,const FXString& text); 00217 00218 /// Get text for specified item 00219 FXString getItemText(FXint index) const; 00220 00221 /// Set data pointer for specified item 00222 void setItemData(FXint index,void* ptr) const; 00223 00224 /// Get data pointer for specified item 00225 void* getItemData(FXint index) const; 00226 00227 /// Is the pane shown 00228 FXbool isPaneShown() const; 00229 00230 /// Sort items using current sort function 00231 void sortItems(); 00232 00233 /// Set text font 00234 void setFont(FXFont* fnt); 00235 00236 /// Get text font 00237 FXFont* getFont() const; 00238 00239 /// Set the combobox style. 00240 void setComboStyle(FXuint mode); 00241 00242 /// Get the combobox style. 00243 FXuint getComboStyle() const; 00244 00245 /// Set window background color 00246 virtual void setBackColor(FXColor clr); 00247 00248 /// Get background color 00249 FXColor getBackColor() const; 00250 00251 /// Change text color 00252 void setTextColor(FXColor clr); 00253 00254 /// Return text color 00255 FXColor getTextColor() const; 00256 00257 /// Change selected background color 00258 void setSelBackColor(FXColor clr); 00259 00260 /// Return selected background color 00261 FXColor getSelBackColor() const; 00262 00263 /// Change selected text color 00264 void setSelTextColor(FXColor clr); 00265 00266 /// Return selected text color 00267 FXColor getSelTextColor() const; 00268 00269 /// Return sort function 00270 FXListSortFunc getSortFunc() const; 00271 00272 /// Change sort function 00273 void setSortFunc(FXListSortFunc func); 00274 00275 /// Set the combobox help text 00276 void setHelpText(const FXString& txt); 00277 00278 /// Get the combobox help text 00279 const FXString& getHelpText() const; 00280 00281 /// Set the tool tip message for this combobox 00282 void setTipText(const FXString& txt); 00283 00284 /// Get the tool tip message for this combobox 00285 const FXString& getTipText() const; 00286 00287 /// Save combobox to a stream 00288 virtual void save(FXStream& store) const; 00289 00290 /// Load combobox from a stream 00291 virtual void load(FXStream& store); 00292 00293 /// Destructor 00294 virtual ~FXComboBox(); 00295 }; 00296 00297 } 00298 00299 #endif

Copyright © 1997-2005 Jeroen van der Zijp