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

FXListBox.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * L i s t B o x W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXListBox.h,v 1.43 2006/01/22 17:58:05 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXLISTBOX_H
25 #define FXLISTBOX_H
26 
27 #ifndef FXPACKER_H
28 #include "FXPacker.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// List Box styles
35 enum {
36  LISTBOX_NORMAL = 0 // Normal style
37  };
38 
39 
40 class FXButton;
41 class FXMenuButton;
42 class FXList;
43 class FXPopup;
44 
45 
46 /**
47 * The List Box is a control to select one of a list of options. It looks
48 * similar to a Combo Box except that List Box yields integer numbers only.
49 * When an option is selected, List Box will send an SEL_COMMAND with the
50 * index of the opton. While manipulating the list, it may send SEL_CHANGED
51 * messages to indicate which option the cursor is hovering over.
52 * The List Box is able to receive ID_GETINTVALUE and ID_SETINTVALUE which
53 * will retrieve the current option or change the selected option.
54 */
55 class FXAPI FXListBox : public FXPacker {
57 protected:
58  FXButton *field;
59  FXMenuButton *button;
60  FXList *list;
61  FXPopup *pane;
62 protected:
63  FXListBox(){}
64 private:
65  FXListBox(const FXListBox&);
66  FXListBox &operator=(const FXListBox&);
67 public:
68  long onFocusUp(FXObject*,FXSelector,void*);
69  long onFocusDown(FXObject*,FXSelector,void*);
70  long onFocusSelf(FXObject*,FXSelector,void*);
71  long onMouseWheel(FXObject*,FXSelector,void*);
72  long onFieldButton(FXObject*,FXSelector,void*);
73  long onListUpdate(FXObject*,FXSelector,void*);
74  long onListClicked(FXObject*,FXSelector,void*);
75  long onListChanged(FXObject*,FXSelector,void*);
76  long onCmdSetValue(FXObject*,FXSelector,void*);
77  long onCmdGetIntValue(FXObject*,FXSelector,void*);
78  long onCmdSetIntValue(FXObject*,FXSelector,void*);
79 public:
80  enum {
81  ID_LIST=FXPacker::ID_LAST,
82  ID_FIELD,
83  ID_LAST
84  };
85 public:
86 
87  /// Constructor
88  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);
89 
90  /// Create server-side resources
91  virtual void create();
92 
93  /// Detach server-side resources
94  virtual void detach();
95 
96  /// Destroy server-side resources
97  virtual void destroy();
98 
99  /// Perform layout
100  virtual void layout();
101 
102  /// Enable drive box
103  virtual void enable();
104 
105  /// Disable drive box
106  virtual void disable();
107 
108  /// Return default width
109  virtual FXint getDefaultWidth();
110 
111  /// Return default height
112  virtual FXint getDefaultHeight();
113 
114  /// Return the number of items in the list
115  FXint getNumItems() const;
116 
117  /// Return the number of visible items
118  FXint getNumVisible() const;
119 
120  /// Set the number of visible items
121  void setNumVisible(FXint nvis);
122 
123  /// Return true if current item
124  FXbool isItemCurrent(FXint index) const;
125 
126  /// Set the current item (index is zero-based)
127  virtual void setCurrentItem(FXint index,FXbool notify=FALSE);
128 
129  /// Get the current item's index
130  FXint getCurrentItem() const;
131 
132  /// Return the item at the given index
133  FXString getItem(FXint index) const;
134 
135  /// Replace the item at index
136  FXint setItem(FXint index,const FXString& text,FXIcon* icon=NULL,void* ptr=NULL);
137 
138  /// Fill list box by appending items from array of strings
139  FXint fillItems(const FXchar** strings,FXIcon* icon=NULL,void* ptr=NULL);
140 
141  /// Fill list box by appending items from newline separated strings
142  FXint fillItems(const FXString& strings,FXIcon* icon=NULL,void* ptr=NULL);
143 
144  /// Insert a new item at index
145  FXint insertItem(FXint index,const FXString& text,FXIcon* icon=NULL,void* ptr=NULL);
146 
147  /// Add an item to the end of the list
148  FXint appendItem(const FXString& text,FXIcon* icon=NULL,void* ptr=NULL);
149 
150  /// Prepend an item to the list
151  FXint prependItem(const FXString& text,FXIcon* icon=NULL,void* ptr=NULL);
152 
153  /// Move item from oldindex to newindex
154  FXint moveItem(FXint newindex,FXint oldindex);
155 
156  /// Extract item from list
157  FXListItem* extractItem(FXint index);
158 
159  /// Remove this item from the list
160  void removeItem(FXint index);
161 
162  /// Remove all items from the list
163  void clearItems();
164 
165  /**
166  * Search items by name, beginning from item start. If the start
167  * item is -1 the search will start at the first item in the list.
168  * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the
169  * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP
170  * to control whether the search wraps at the start or end of the list.
171  * The option SEARCH_IGNORECASE causes a case-insensitive match. Finally,
172  * passing SEARCH_PREFIX causes searching for a prefix of the item name.
173  * Return -1 if no matching item is found.
174  */
175  FXint findItem(const FXString& text,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
176 
177  /**
178  * Search items by associated user data, beginning from item start. If the
179  * start item is -1 the search will start at the first item in the list.
180  * Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the
181  * search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP
182  * to control whether the search wraps at the start or end of the list.
183  */
184  FXint findItemByData(const void *ptr,FXint start=-1,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP) const;
185 
186  /// Set text for specified item
187  void setItemText(FXint index,const FXString& text);
188 
189  /// Get text for specified item
190  FXString getItemText(FXint index) const;
191 
192  /// Change item icon, deleting old one if it was owned
193  void setItemIcon(FXint index,FXIcon* icon,FXbool owned=FALSE);
194 
195  /// Return icon of item at index
196  FXIcon* getItemIcon(FXint index) const;
197 
198  /// Set data pointer for specified item
199  void setItemData(FXint index,void* ptr) const;
200 
201  /// Get data pointer for specified item
202  void* getItemData(FXint index) const;
203 
204  /// Is the pane shown
205  FXbool isPaneShown() const;
206 
207  /// Sort items using current sort function
208  void sortItems();
209 
210  /// Set text font
211  void setFont(FXFont* fnt);
212 
213  /// Get text font
214  FXFont* getFont() const;
215 
216  /// Set window background color
217  virtual void setBackColor(FXColor clr);
218 
219  /// Get background color
220  FXColor getBackColor() const;
221 
222  /// Change text color
223  void setTextColor(FXColor clr);
224 
225  /// Return text color
226  FXColor getTextColor() const;
227 
228  /// Change selected background color
229  void setSelBackColor(FXColor clr);
230 
231  /// Return selected background color
232  FXColor getSelBackColor() const;
233 
234  /// Change selected text color
235  void setSelTextColor(FXColor clr);
236 
237  /// Return selected text color
238  FXColor getSelTextColor() const;
239 
240  /// Return sort function
241  FXListSortFunc getSortFunc() const;
242 
243  /// Change sort function
244  void setSortFunc(FXListSortFunc func);
245 
246  /// Set the combobox help text
247  void setHelpText(const FXString& txt);
248 
249  /// Get the combobox help text
250  const FXString& getHelpText() const;
251 
252  /// Set the tool tip message for this combobox
253  void setTipText(const FXString& txt);
254 
255  /// Get the tool tip message for this combobox
256  const FXString& getTipText() const;
257 
258  /// Save combobox to a stream
259  virtual void save(FXStream& store) const;
260 
261  /// Load combobox from a stream
262  virtual void load(FXStream& store);
263 
264  /// Destructor
265  virtual ~FXListBox();
266  };
267 
268 }
269 
270 #endif
FXint(* FXListSortFunc)(const FXListItem *, const FXListItem *)
List item collate function.
Definition: FXList.h:144
A menu button posts a popup menu when clicked.
Definition: FXMenuButton.h:79
Search forward (default)
Definition: fxdefs.h:363
char FXchar
Definition: fxdefs.h:380
Definition: FXWindow.h:241
unsigned int FXuint
Definition: fxdefs.h:389
Popup window.
Definition: FXPopup.h:52
Definition: FXFrame.h:56
FXuint FXSelector
Association key.
Definition: FXObject.h:53
A button provides a push button, with optional icon and/or text label.
Definition: FXButton.h:85
#define FXAPI
Definition: fxdefs.h:122
The List Box is a control to select one of a list of options.
Definition: FXListBox.h:62
FXuchar FXbool
Definition: fxdefs.h:386
Sunken border.
Definition: FXWindow.h:76
#define NULL
Definition: fxdefs.h:41
FXuint FXColor
Definition: fxdefs.h:447
A List Widget displays a list of items, each with a text and optional icon.
Definition: FXList.h:167
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:390
Packer is a layout manager which automatically places child windows inside its area against the left...
Definition: FXPacker.h:58
#define FALSE
Definition: fxdefs.h:35
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
Thick border.
Definition: FXWindow.h:78
Wrap around to start.
Definition: fxdefs.h:366
Normal style.
Definition: FXListBox.h:39
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92

Copyright © 1997-2005 Jeroen van der Zijp