Crazy Eddies GUI System  0.7.2
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 "CEGUIScrolledItemListBase.h"
32 #include "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  *************************************************************************/
68 
69  /************************************************************************
70  Accessors
71  *************************************************************************/
76  size_t getSelectedCount(void) const;
77 
85  ItemEntry* getLastSelectedItem(void) const {return d_lastSelected;}
86 
105  ItemEntry* getFirstSelectedItem(size_t start_index=0) const;
106 
125  ItemEntry* getNextSelectedItem(void) const;
126 
136  ItemEntry* getNextSelectedItemAfter(const ItemEntry* start_item) const;
137 
142  bool isMultiSelectEnabled(void) const {return d_multiSelect;}
143 
148  bool isItemSelected(size_t index) const;
149 
150  /************************************************************************
151  Manipulators
152  *************************************************************************/
153  // Overridden from base class
154  virtual void initialiseComponents(void);
155 
160  void setMultiSelectEnabled(bool state);
161 
166  void clearAllSelections(void);
167 
178  void selectRange(size_t a, size_t z);
179 
185  void selectAllItems(void);
186 
187  /************************************************************************
188  Object Construction and Destruction
189  *************************************************************************/
194  ItemListbox(const String& type, const String& name);
195 
200  virtual ~ItemListbox(void) {}
201 
202  /************************************************************************
203  Implementation functions
204  ************************************************************************/
209  virtual void layoutItemWidgets();
210 
215  virtual Size getContentSize() const;
216 
228  virtual bool testClassName_impl(const String& class_name) const
229  {
230  if (class_name=="ItemListbox")
231  {
232  return true;
233  }
234  return ScrolledItemListBase::testClassName_impl(class_name);
235  }
236 
242  virtual void notifyItemClicked(ItemEntry* li);
243 
249  virtual void notifyItemSelectState(ItemEntry* li, bool state);
250 
251 protected:
252  /************************************************************************
253  Protected implementation functions
254  ************************************************************************/
272  ItemEntry* findSelectedItem(size_t start_index) const;
273 
274  /************************************************************************
275  New event handlers
276  ************************************************************************/
277  virtual void onSelectionChanged(WindowEventArgs& e);
278  virtual void onMultiSelectModeChanged(WindowEventArgs& e);
279 
280  /************************************************************************
281  Overridden event handlers
282  ************************************************************************/
283  virtual void onKeyDown(KeyEventArgs& e);
284 
285  /************************************************************************
286  Static Properties for this class
287  ************************************************************************/
288  static ItemListboxProperties::MultiSelect d_multiSelectProperty;
289 
290  /************************************************************************
291  Implementation data
292  ************************************************************************/
293  bool d_multiSelect;
295  mutable size_t d_nextSelectionIndex;
296 
297 private:
298  void addItemListboxProperties(void);
299  void addItemListboxEvents(void);
301  bool handle_PaneChildRemoved(const EventArgs& e);
302 };
303 
304 } // end CEGUI namespace
305 
306 #if defined(_MSC_VER)
307 # pragma warning(pop)
308 #endif
309 
310 #endif // end of guard _CEGUIItemListbox_h_