Crazy Eddies GUI System  0.7.1
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  *************************************************************************/
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  *************************************************************************/
143  // Overridden from base class
144  virtual void initialiseComponents(void);
145 
150  void setMultiSelectEnabled(bool state);
151 
156  void clearAllSelections(void);
157 
168  void selectRange(size_t a, size_t z);
169 
175  void selectAllItems(void);
176 
177  /************************************************************************
178  Object Construction and Destruction
179  *************************************************************************/
184  ItemListbox(const String& type, const String& name);
185 
190  virtual ~ItemListbox(void) {}
191 
192  /************************************************************************
193  Implementation functions
194  ************************************************************************/
199  virtual void layoutItemWidgets();
200 
205  virtual Size getContentSize() const;
206 
218  virtual bool testClassName_impl(const String& class_name) const
219  {
220  if (class_name=="ItemListbox")
221  {
222  return true;
223  }
224  return ScrolledItemListBase::testClassName_impl(class_name);
225  }
226 
232  virtual void notifyItemClicked(ItemEntry* li);
233 
239  virtual void notifyItemSelectState(ItemEntry* li, bool state);
240 
241 protected:
242  /************************************************************************
243  Protected implementation functions
244  ************************************************************************/
262  ItemEntry* findSelectedItem(size_t start_index) const;
263 
264  /************************************************************************
265  New event handlers
266  ************************************************************************/
267  virtual void onSelectionChanged(WindowEventArgs& e);
268  virtual void onMultiSelectModeChanged(WindowEventArgs& e);
269 
270  /************************************************************************
271  Overridden event handlers
272  ************************************************************************/
273  virtual void onKeyDown(KeyEventArgs& e);
274 
275  /************************************************************************
276  Static Properties for this class
277  ************************************************************************/
278  static ItemListboxProperties::MultiSelect d_multiSelectProperty;
279 
280  /************************************************************************
281  Implementation data
282  ************************************************************************/
283  bool d_multiSelect;
285  mutable size_t d_nextSelectionIndex;
286 
287 private:
288  void addItemListboxProperties(void);
289  void addItemListboxEvents(void);
291  bool handle_PaneChildRemoved(const EventArgs& e);
292 };
293 
294 } // end CEGUI namespace
295 
296 #if defined(_MSC_VER)
297 # pragma warning(pop)
298 #endif
299 
300 #endif // end of guard _CEGUIItemListbox_h_