Crazy Eddie's GUI System  0.8.3
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
widgets/ItemListbox.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 "./ScrolledItemListBase.h"
32 
33 #if defined(_MSC_VER)
34 # pragma warning(push)
35 # pragma warning(disable : 4251)
36 #endif
37 
38 // begin CEGUI namespace
39 namespace CEGUI
40 {
41 
46 class CEGUIEXPORT ItemListbox : public ScrolledItemListBase
47 {
48 public:
49  static const String EventNamespace;
50  static const String WidgetTypeName;
51 
52  /************************************************************************
53  Constants
54  *************************************************************************/
67 
68  /************************************************************************
69  Accessors
70  *************************************************************************/
75  size_t getSelectedCount(void) const;
76 
84  ItemEntry* getLastSelectedItem(void) const {return d_lastSelected;}
85 
104  ItemEntry* getFirstSelectedItem(size_t start_index=0) const;
105 
124  ItemEntry* getNextSelectedItem(void) const;
125 
135  ItemEntry* getNextSelectedItemAfter(const ItemEntry* start_item) const;
136 
141  bool isMultiSelectEnabled(void) const {return d_multiSelect;}
142 
147  bool isItemSelected(size_t index) const;
148 
149  /************************************************************************
150  Manipulators
151  *************************************************************************/
156  void setMultiSelectEnabled(bool state);
157 
162  void clearAllSelections(void);
163 
174  void selectRange(size_t a, size_t z);
175 
181  void selectAllItems(void);
182 
183  /************************************************************************
184  Object Construction and Destruction
185  *************************************************************************/
190  ItemListbox(const String& type, const String& name);
191 
196  virtual ~ItemListbox(void) {}
197 
198  /************************************************************************
199  Implementation functions
200  ************************************************************************/
205  virtual void layoutItemWidgets();
206 
211  virtual Sizef getContentSize() const;
212 
218  virtual void notifyItemClicked(ItemEntry* li);
219 
225  virtual void notifyItemSelectState(ItemEntry* li, bool state);
226 
227 protected:
228  /************************************************************************
229  Protected implementation functions
230  ************************************************************************/
248  ItemEntry* findSelectedItem(size_t start_index) const;
249 
250  // overridden from ItemListBase
251  bool handle_PaneChildRemoved(const EventArgs& e);
252 
253  /************************************************************************
254  New event handlers
255  ************************************************************************/
256  virtual void onSelectionChanged(WindowEventArgs& e);
257  virtual void onMultiSelectModeChanged(WindowEventArgs& e);
258 
259  /************************************************************************
260  Overridden event handlers
261  ************************************************************************/
262  virtual void onKeyDown(KeyEventArgs& e);
263 
264  /************************************************************************
265  Implementation data
266  ************************************************************************/
267  bool d_multiSelect;
269  mutable size_t d_nextSelectionIndex;
270 
271 private:
272  void addItemListboxProperties(void);
273 };
274 
275 } // end CEGUI namespace
276 
277 #if defined(_MSC_VER)
278 # pragma warning(pop)
279 #endif
280 
281 #endif // end of guard _CEGUIItemListbox_h_