Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
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_