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

FXListBox.h

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

Copyright © 1997-2005 Jeroen van der Zijp