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