![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * L i s t 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: FXListBox.h,v 1.54 2009/01/06 13:07:25 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXLISTBOX_H 00024 #define FXLISTBOX_H 00025 00026 #ifndef FXPACKER_H 00027 #include "FXPacker.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 /// List Box styles 00034 enum { 00035 LISTBOX_NORMAL = 0 // Normal style 00036 }; 00037 00038 00039 class FXButton; 00040 class FXMenuButton; 00041 class FXList; 00042 class FXPopup; 00043 00044 00045 /** 00046 * The List Box is a control to select one of a list of options. It looks 00047 * similar to a Combo Box except that List Box yields integer numbers only. 00048 * When an option is selected, List Box will send an SEL_COMMAND with the 00049 * index of the opton. While manipulating the list, it may send SEL_CHANGED 00050 * messages to indicate which option the cursor is hovering over. 00051 * The List Box is able to receive ID_GETINTVALUE and ID_SETINTVALUE which 00052 * will retrieve the current option or change the selected option. 00053 * When items are added, replaced, or removed, the list sends messages of 00054 * the type SEL_INSERTED, SEL_REPLACED, or SEL_DELETED, with the index of 00055 * the affected item as argument. 00056 */ 00057 class FXAPI FXListBox : public FXPacker { 00058 FXDECLARE(FXListBox) 00059 protected: 00060 FXButton *field; 00061 FXMenuButton *button; 00062 FXList *list; 00063 FXPopup *pane; 00064 protected: 00065 FXListBox(){} 00066 private: 00067 FXListBox(const FXListBox&); 00068 FXListBox &operator=(const FXListBox&); 00069 public: 00070 long onFocusUp(FXObject*,FXSelector,void*); 00071 long onFocusDown(FXObject*,FXSelector,void*); 00072 long onFocusSelf(FXObject*,FXSelector,void*); 00073 long onMouseWheel(FXObject*,FXSelector,void*); 00074 long onFieldButton(FXObject*,FXSelector,void*); 00075 long onListUpdate(FXObject*,FXSelector,void*); 00076 long onListClicked(FXObject*,FXSelector,void*); 00077 long onListCommand(FXObject*,FXSelector,void*); 00078 long onListForward(FXObject*,FXSelector,void*); 00079 long onCmdSetValue(FXObject*,FXSelector,void*); 00080 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00081 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00082 public: 00083 enum { 00084 ID_LIST=FXPacker::ID_LAST, 00085 ID_FIELD, 00086 ID_LAST 00087 }; 00088 public: 00089 00090 /// Constructor 00091 FXListBox(FXComposite *p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=FRAME_SUNKEN|FRAME_THICK|LISTBOX_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); 00092 00093 /// Create server-side resources 00094 virtual void create(); 00095 00096 /// Detach server-side resources 00097 virtual void detach(); 00098 00099 /// Destroy server-side resources 00100 virtual void destroy(); 00101 00102 /// Perform layout 00103 virtual void layout(); 00104 00105 /// Enable drive box 00106 virtual void enable(); 00107 00108 /// Disable drive box 00109 virtual void disable(); 00110 00111 /// Return default width 00112 virtual FXint getDefaultWidth(); 00113 00114 /// Return default height 00115 virtual FXint getDefaultHeight(); 00116 00117 /// Return the number of items in the list 00118 FXint getNumItems() const; 00119 00120 /// Return the number of visible items 00121 FXint getNumVisible() const; 00122 00123 /// Set the number of visible items 00124 void setNumVisible(FXint nvis); 00125 00126 /// Return true if current item 00127 FXbool isItemCurrent(FXint index) const; 00128 00129 /// Set the current item (index is zero-based) 00130 virtual void setCurrentItem(FXint index,FXbool notify=false); 00131 00132 /// Get the current item's index 00133 FXint getCurrentItem() const; 00134 00135 /// Return the item at the given index 00136 FXString getItem(FXint index) const; 00137 00138 /// Replace the item at index 00139 FXint setItem(FXint index,const FXString& text,FXIcon* icon=NULL,void* ptr=NULL,FXbool notify=false); 00140 00141 /// Fill list box by appending items from array of strings 00142 FXint fillItems(const FXchar** strings,FXIcon* icon=NULL,void* ptr=NULL,FXbool notify=false); 00143 00144 /// Fill list box by appending items from newline separated strings 00145 FXint fillItems(const FXString& strings,FXIcon* icon=NULL,void* ptr=NULL,FXbool notify=false); 00146 00147 /// Insert a new item at index 00148 FXint insertItem(FXint index,const FXString& text,FXIcon* icon=NULL,void* ptr=NULL,FXbool notify=false); 00149 00150 /// Add an item to the end of the list 00151 FXint appendItem(const FXString& text,FXIcon* icon=NULL,void* ptr=NULL,FXbool notify=false); 00152 00153 /// Prepend an item to the list 00154 FXint prependItem(const FXString& text,FXIcon* icon=NULL,void* ptr=NULL,FXbool notify=false); 00155 00156 /// Move item from oldindex to newindex 00157 FXint moveItem(FXint newindex,FXint oldindex,FXbool notify=false); 00158 00159 /// Extract item from list 00160 FXListItem* extractItem(FXint index,FXbool notify=false); 00161 00162 /// Remove this item from the list 00163 void removeItem(FXint index,FXbool notify=false); 00164 00165 /// Remove all items from the list 00166 void clearItems(FXbool notify=false); 00167 00168 /** 00169 * Search items by name, beginning from item start. If the start 00170 * item is -1 the search will start at the first item in the list. 00171 * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the 00172 * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP 00173 * to control whether the search wraps at the start or end of the list. 00174 * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, 00175 * passing SEARCH_PREFIX causes searching for a prefix of the item name. 00176 * Return -1 if no matching item is found. 00177 */ 00178 FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; 00179 00180 /** 00181 * Search items by associated user data, beginning from item start. If the 00182 * start item is -1 the search will start at the first item in the list. 00183 * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the 00184 * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP 00185 * to control whether the search wraps at the start or end of the list. 00186 */ 00187 FXint findItemByData(const void *ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; 00188 00189 /// Set text for specified item 00190 void setItemText(FXint index,const FXString& text); 00191 00192 /// Get text for specified item 00193 FXString getItemText(FXint index) const; 00194 00195 /// Change item icon, deleting old one if it was owned 00196 void setItemIcon(FXint index,FXIcon* icon,FXbool owned=false); 00197 00198 /// Return icon of item at index 00199 FXIcon* getItemIcon(FXint index) const; 00200 00201 /// Set data pointer for specified item 00202 void setItemData(FXint index,void* ptr) const; 00203 00204 /// Get data pointer for specified item 00205 void* getItemData(FXint index) const; 00206 00207 /// Show or hide menu 00208 void showMenu(FXbool shw); 00209 00210 /// Is the menu pane shown 00211 FXbool isMenuShown() const; 00212 00213 /// Sort items using current sort function 00214 void sortItems(); 00215 00216 /// Set text font 00217 void setFont(FXFont* fnt); 00218 00219 /// Get text font 00220 FXFont* getFont() const; 00221 00222 /// Change popup pane shrinkwrap mode 00223 void setShrinkWrap(FXbool flag); 00224 00225 /// Return popup pane shrinkwrap mode 00226 FXbool getShrinkWrap() const; 00227 00228 /// Set window background color 00229 virtual void setBackColor(FXColor clr); 00230 00231 /// Get background color 00232 FXColor getBackColor() const; 00233 00234 /// Change text color 00235 void setTextColor(FXColor clr); 00236 00237 /// Return text color 00238 FXColor getTextColor() const; 00239 00240 /// Change selected background color 00241 void setSelBackColor(FXColor clr); 00242 00243 /// Return selected background color 00244 FXColor getSelBackColor() const; 00245 00246 /// Change selected text color 00247 void setSelTextColor(FXColor clr); 00248 00249 /// Return selected text color 00250 FXColor getSelTextColor() const; 00251 00252 /// Return sort function 00253 FXListSortFunc getSortFunc() const; 00254 00255 /// Change sort function 00256 void setSortFunc(FXListSortFunc func); 00257 00258 /// Set the combobox help text 00259 void setHelpText(const FXString& txt); 00260 00261 /// Get the combobox help text 00262 const FXString& getHelpText() const; 00263 00264 /// Set the tool tip message for this combobox 00265 void setTipText(const FXString& txt); 00266 00267 /// Get the tool tip message for this combobox 00268 const FXString& getTipText() const; 00269 00270 /// Save combobox to a stream 00271 virtual void save(FXStream& store) const; 00272 00273 /// Load combobox from a stream 00274 virtual void load(FXStream& store); 00275 00276 /// Destructor 00277 virtual ~FXListBox(); 00278 }; 00279 00280 } 00281 00282 #endif
![]() |