Crazy Eddies GUI System  0.6.0
CEGUIItemListbox.h
1 /************************************************************************
2  filename: CEGUIItemListbox.h
3  created: Tue Sep 27 2005
4  author: Tomas Lindquist Olsen
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIItemListbox_h_
29 #define _CEGUIItemListbox_h_
30 
31 #include "elements/CEGUIScrolledItemListBase.h"
32 #include "elements/CEGUIItemListboxProperties.h"
33 
34 #if defined(_MSC_VER)
35 # pragma warning(push)
36 # pragma warning(disable : 4251)
37 #endif
38 
39 // begin CEGUI namespace
40 namespace CEGUI
41 {
42 
47 class CEGUIEXPORT ItemListbox : public ScrolledItemListBase
48 {
49 public:
50  static const String EventNamespace;
51  static const String WidgetTypeName;
52 
53  /************************************************************************
54  Constants
55  *************************************************************************/
58 
59  /************************************************************************
60  Accessors
61  *************************************************************************/
66  size_t getSelectedCount(void) const;
67 
75  ItemEntry* getLastSelectedItem(void) const {return d_lastSelected;}
76 
95  ItemEntry* getFirstSelectedItem(size_t start_index=0) const;
96 
115  ItemEntry* getNextSelectedItem(void) const;
116 
126  ItemEntry* getNextSelectedItemAfter(const ItemEntry* start_item) const;
127 
132  bool isMultiSelectEnabled(void) const {return d_multiSelect;}
133 
138  bool isItemSelected(size_t index) const;
139 
140  /************************************************************************
141  Manipulators
142  *************************************************************************/
147  void setMultiSelectEnabled(bool state);
148 
153  void clearAllSelections(void);
154 
165  void selectRange(size_t a, size_t z);
166 
172  void selectAllItems(void);
173 
174  /************************************************************************
175  Object Construction and Destruction
176  *************************************************************************/
181  ItemListbox(const String& type, const String& name);
182 
187  virtual ~ItemListbox(void) {}
188 
189  /************************************************************************
190  Implementation functions
191  ************************************************************************/
196  virtual void layoutItemWidgets();
197 
202  virtual Size getContentSize() const;
203 
215  virtual bool testClassName_impl(const String& class_name) const
216  {
217  if (class_name=="ItemListbox")
218  {
219  return true;
220  }
221  return ScrolledItemListBase::testClassName_impl(class_name);
222  }
223 
229  virtual void notifyItemClicked(ItemEntry* li);
230 
236  virtual void notifyItemSelectState(ItemEntry* li, bool state);
237 
238 protected:
239  /************************************************************************
240  Protected implementation functions
241  ************************************************************************/
259  ItemEntry* findSelectedItem(size_t start_index) const;
260 
261  /************************************************************************
262  New event handlers
263  ************************************************************************/
264  virtual void onSelectionChanged(WindowEventArgs& e);
265  virtual void onMultiSelectModeChanged(WindowEventArgs& e);
266 
267  /************************************************************************
268  Overridden event handlers
269  ************************************************************************/
270  virtual void onKeyDown(KeyEventArgs& e);
271 
272  /************************************************************************
273  Static Properties for this class
274  ************************************************************************/
275  static ItemListboxProperties::MultiSelect d_multiSelectProperty;
276 
277  /************************************************************************
278  Implementation data
279  ************************************************************************/
280  bool d_multiSelect;
282  mutable size_t d_nextSelectionIndex;
283 
284 private:
285  void addItemListboxProperties(void);
286  void addItemListboxEvents(void);
287 };
288 
289 } // end CEGUI namespace
290 
291 #if defined(_MSC_VER)
292 # pragma warning(pop)
293 #endif
294 
295 #endif // end of guard _CEGUIItemListbox_h_