Crazy Eddie's GUI System  0.8.5
widgets/ItemListbox.h
1 /************************************************************************
2  created: Tue Sep 27 2005
3  author: Tomas Lindquist Olsen
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIItemListbox_h_
28 #define _CEGUIItemListbox_h_
29 
30 #include "./ScrolledItemListBase.h"
31 
32 #if defined(_MSC_VER)
33 # pragma warning(push)
34 # pragma warning(disable : 4251)
35 #endif
36 
37 // begin CEGUI namespace
38 namespace CEGUI
39 {
40 
45 class CEGUIEXPORT ItemListbox : public ScrolledItemListBase
46 {
47 public:
48  static const String EventNamespace;
49  static const String WidgetTypeName;
50 
51  /************************************************************************
52  Constants
53  *************************************************************************/
66 
67  /************************************************************************
68  Accessors
69  *************************************************************************/
74  size_t getSelectedCount(void) const;
75 
83  ItemEntry* getLastSelectedItem(void) const {return d_lastSelected;}
84 
103  ItemEntry* getFirstSelectedItem(size_t start_index=0) const;
104 
123  ItemEntry* getNextSelectedItem(void) const;
124 
134  ItemEntry* getNextSelectedItemAfter(const ItemEntry* start_item) const;
135 
140  bool isMultiSelectEnabled(void) const {return d_multiSelect;}
141 
146  bool isItemSelected(size_t index) const;
147 
148  /************************************************************************
149  Manipulators
150  *************************************************************************/
155  void setMultiSelectEnabled(bool state);
156 
161  void clearAllSelections(void);
162 
173  void selectRange(size_t a, size_t z);
174 
180  void selectAllItems(void);
181 
182  /************************************************************************
183  Object Construction and Destruction
184  *************************************************************************/
189  ItemListbox(const String& type, const String& name);
190 
195  virtual ~ItemListbox(void) {}
196 
197  /************************************************************************
198  Implementation functions
199  ************************************************************************/
204  virtual void layoutItemWidgets();
205 
210  virtual Sizef getContentSize() const;
211 
217  virtual void notifyItemClicked(ItemEntry* li);
218 
224  virtual void notifyItemSelectState(ItemEntry* li, bool state);
225 
226 protected:
227  /************************************************************************
228  Protected implementation functions
229  ************************************************************************/
247  ItemEntry* findSelectedItem(size_t start_index) const;
248 
249  // overridden from ItemListBase
250  bool handle_PaneChildRemoved(const EventArgs& e);
251 
252  /************************************************************************
253  New event handlers
254  ************************************************************************/
255  virtual void onSelectionChanged(WindowEventArgs& e);
256  virtual void onMultiSelectModeChanged(WindowEventArgs& e);
257 
258  /************************************************************************
259  Overridden event handlers
260  ************************************************************************/
261  virtual void onKeyDown(KeyEventArgs& e);
262 
263  /************************************************************************
264  Implementation data
265  ************************************************************************/
266  bool d_multiSelect;
268  mutable size_t d_nextSelectionIndex;
269 
270 private:
271  void addItemListboxProperties(void);
272 };
273 
274 } // end CEGUI namespace
275 
276 #if defined(_MSC_VER)
277 # pragma warning(pop)
278 #endif
279 
280 #endif // end of guard _CEGUIItemListbox_h_
static const String EventMultiSelectModeChanged
Definition: widgets/ItemListbox.h:65
ItemEntry * d_lastSelected
Controls whether multiple items can be selected simultaneously.
Definition: widgets/ItemListbox.h:267
static const String EventSelectionChanged
Definition: widgets/ItemListbox.h:59
bool isMultiSelectEnabled(void) const
Returns 'true' if multiple selections are allowed. 'false' if not.
Definition: widgets/ItemListbox.h:140
static const String EventNamespace
Namespace for global events.
Definition: widgets/ItemListbox.h:48
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
Base class for item type widgets.
Definition: widgets/ItemEntry.h:76
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:49
virtual ~ItemListbox(void)
Destructor for the ItemListbox base class.
Definition: widgets/ItemListbox.h:195
ItemListbox window class.
Definition: widgets/ItemListbox.h:45
EventArgs based class that is used for objects passed to input event handlers concerning keyboard inp...
Definition: InputEvent.h:314
static const String WidgetTypeName
Window factory name.
Definition: widgets/ItemListbox.h:49
size_t d_nextSelectionIndex
The last item that was selected.
Definition: widgets/ItemListbox.h:268
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:251
ScrolledItemListBase window class.
Definition: ScrolledItemListBase.h:45
ItemEntry * getLastSelectedItem(void) const
Returns a pointer to the last selected item.
Definition: widgets/ItemListbox.h:83
String class used within the GUI system.
Definition: String.h:62