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,2004 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.33 2004/02/08 17:17:33 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 /// Combobox 00054 class FXAPI FXComboBox : public FXPacker { 00055 FXDECLARE(FXComboBox) 00056 protected: 00057 FXTextField *field; 00058 FXMenuButton *button; 00059 FXList *list; 00060 FXPopup *pane; 00061 protected: 00062 FXComboBox(){} 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 onFocusSelf(FXObject*,FXSelector,void*); 00070 long onTextButton(FXObject*,FXSelector,void*); 00071 long onTextChanged(FXObject*,FXSelector,void*); 00072 long onTextCommand(FXObject*,FXSelector,void*); 00073 long onListClicked(FXObject*,FXSelector,void*); 00074 long onFwdToText(FXObject*,FXSelector,void*); 00075 long onUpdFmText(FXObject*,FXSelector,void*); 00076 public: 00077 enum { 00078 ID_LIST=FXPacker::ID_LAST, 00079 ID_TEXT, 00080 ID_LAST 00081 }; 00082 public: 00083 00084 /// Constructor 00085 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); 00086 00087 /// Create server-side resources 00088 virtual void create(); 00089 00090 /// Detach server-side resources 00091 virtual void detach(); 00092 00093 /// Destroy server-side resources 00094 virtual void destroy(); 00095 00096 /// Enable combo box 00097 virtual void enable(); 00098 00099 /// Disable combo box 00100 virtual void disable(); 00101 00102 /// Return default width 00103 virtual FXint getDefaultWidth(); 00104 00105 /// Return default height 00106 virtual FXint getDefaultHeight(); 00107 00108 /// Perform layout 00109 virtual void layout(); 00110 00111 /// Return true if combobox is editable 00112 FXbool isEditable() const; 00113 00114 /// Set editable state 00115 void setEditable(FXbool edit=TRUE); 00116 00117 /// Set the text 00118 void setText(const FXString& text); 00119 00120 /// Get the text 00121 FXString getText() const; 00122 00123 /// Set the number of columns 00124 void setNumColumns(FXint cols); 00125 00126 /// Get the number of columns 00127 FXint getNumColumns() const; 00128 00129 /// Return the number of items in the list 00130 FXint getNumItems() const; 00131 00132 /// Return the number of visible items 00133 FXint getNumVisible() const; 00134 00135 /// Set the number of visible items 00136 void setNumVisible(FXint nvis); 00137 00138 /// Return true if current item 00139 FXbool isItemCurrent(FXint index) const; 00140 00141 /// Set the current item (index is zero-based) 00142 void setCurrentItem(FXint indexz); 00143 00144 /// Get the current item's index 00145 FXint getCurrentItem() const; 00146 00147 /// Return the item at the given index 00148 FXString getItem(FXint index) const; 00149 00150 /// Replace the item at index 00151 FXint setItem(FXint index,const FXString& text,void* ptr=NULL); 00152 00153 /// Insert a new item at index 00154 FXint insertItem(FXint index,const FXString& text,void* ptr=NULL); 00155 00156 /// Append an item to the list 00157 FXint appendItem(const FXString& text,void* ptr=NULL); 00158 00159 /// Prepend an item to the list 00160 FXint prependItem(const FXString& text,void* ptr=NULL); 00161 00162 /// Move item from oldindex to newindex 00163 FXint moveItem(FXint newindex,FXint oldindex); 00164 00165 /// Remove this item from the list 00166 void removeItem(FXint index); 00167 00168 /// Remove all items from the list 00169 void clearItems(); 00170 00171 /** 00172 * Search items for item by name, starting from start item; the 00173 * flags argument controls the search direction, and case sensitivity. 00174 */ 00175 FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const; 00176 00177 /// Set text for specified item 00178 void setItemText(FXint index,const FXString& text); 00179 00180 /// Get text for specified item 00181 FXString getItemText(FXint index) const; 00182 00183 /// Set data pointer for specified item 00184 void setItemData(FXint index,void* ptr) const; 00185 00186 /// Get data pointer for specified item 00187 void* getItemData(FXint index) const; 00188 00189 /// Is the pane shown 00190 FXbool isPaneShown() const; 00191 00192 /// Sort items using current sort function 00193 void sortItems(); 00194 00195 /// Set text font 00196 void setFont(FXFont* fnt); 00197 00198 /// Get text font 00199 FXFont* getFont() const; 00200 00201 /// Set the combobox style. 00202 void setComboStyle(FXuint mode); 00203 00204 /// Get the combobox style. 00205 FXuint getComboStyle() const; 00206 00207 /// Set window background color 00208 virtual void setBackColor(FXColor clr); 00209 00210 /// Get background color 00211 FXColor getBackColor() const; 00212 00213 /// Change text color 00214 void setTextColor(FXColor clr); 00215 00216 /// Return text color 00217 FXColor getTextColor() const; 00218 00219 /// Change selected background color 00220 void setSelBackColor(FXColor clr); 00221 00222 /// Return selected background color 00223 FXColor getSelBackColor() const; 00224 00225 /// Change selected text color 00226 void setSelTextColor(FXColor clr); 00227 00228 /// Return selected text color 00229 FXColor getSelTextColor() const; 00230 00231 /// Return sort function 00232 FXListSortFunc getSortFunc() const; 00233 00234 /// Change sort function 00235 void setSortFunc(FXListSortFunc func); 00236 00237 /// Set the combobox help text 00238 void setHelpText(const FXString& txt); 00239 00240 /// Get the combobox help text 00241 FXString getHelpText() const; 00242 00243 /// Set the tool tip message for this combobox 00244 void setTipText(const FXString& txt); 00245 00246 /// Get the tool tip message for this combobox 00247 FXString getTipText() const; 00248 00249 /// Save combobox to a stream 00250 virtual void save(FXStream& store) const; 00251 00252 /// Load combobox from a stream 00253 virtual void load(FXStream& store); 00254 00255 /// Destructor 00256 virtual ~FXComboBox(); 00257 }; 00258 00259 } 00260 00261 #endif

Copyright © 1997-2004 Jeroen van der Zijp