Crazy Eddie's GUI System  0.8.7
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 
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
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_
CEGUI::ItemListbox::setMultiSelectEnabled
void setMultiSelectEnabled(bool state)
Set whether or not multiple selections should be allowed.
CEGUI::ItemListbox::EventNamespace
static const String EventNamespace
Namespace for global events.
Definition: widgets/ItemListbox.h:48
CEGUI::ItemListbox::EventSelectionChanged
static const String EventSelectionChanged
Definition: widgets/ItemListbox.h:59
CEGUI::ItemListbox::notifyItemClicked
virtual void notifyItemClicked(ItemEntry *li)
Notify this ItemListbox that the given ListItem was just clicked. Internal function - not to be used ...
CEGUI::ItemListbox::isMultiSelectEnabled
bool isMultiSelectEnabled(void) const
Returns 'true' if multiple selections are allowed. 'false' if not.
Definition: widgets/ItemListbox.h:140
CEGUI::ItemListbox::~ItemListbox
virtual ~ItemListbox(void)
Destructor for the ItemListbox base class.
Definition: widgets/ItemListbox.h:195
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::ItemListbox::getNextSelectedItem
ItemEntry * getNextSelectedItem(void) const
Returns a pointer to the next seleced item relative to a previous call to getFirstSelectedItem or get...
CEGUI::ItemListbox::EventMultiSelectModeChanged
static const String EventMultiSelectModeChanged
Definition: widgets/ItemListbox.h:65
CEGUI::ItemListbox::getFirstSelectedItem
ItemEntry * getFirstSelectedItem(size_t start_index=0) const
Returns a pointer to the first selected item.
CEGUI::ItemListbox
ItemListbox window class.
Definition: widgets/ItemListbox.h:46
CEGUI::WindowEventArgs
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:252
CEGUI::ItemListbox::d_lastSelected
ItemEntry * d_lastSelected
Controls whether multiple items can be selected simultaneously.
Definition: widgets/ItemListbox.h:267
CEGUI::ScrolledItemListBase
ScrolledItemListBase window class.
Definition: ScrolledItemListBase.h:46
CEGUI::ItemListbox::selectRange
void selectRange(size_t a, size_t z)
Select a range of items.
CEGUI::KeyEventArgs
EventArgs based class that is used for objects passed to input event handlers concerning keyboard inp...
Definition: InputEvent.h:315
CEGUI::ItemListbox::isItemSelected
bool isItemSelected(size_t index) const
Returns 'true' if the item at the given index is selectable and currently selected.
CEGUI::ItemListbox::getNextSelectedItemAfter
ItemEntry * getNextSelectedItemAfter(const ItemEntry *start_item) const
Returns a pointer to the next selected item after the item 'start_item' given.
CEGUI::ItemListbox::WidgetTypeName
static const String WidgetTypeName
Window factory name.
Definition: widgets/ItemListbox.h:49
CEGUI::ItemListbox::onKeyDown
virtual void onKeyDown(KeyEventArgs &e)
Handler called when a key as been depressed while this window has input focus.
CEGUI::ItemListbox::layoutItemWidgets
virtual void layoutItemWidgets()
Setup size and position for the item widgets attached to this ItemListbox.
CEGUI::ItemListbox::getContentSize
virtual Sizef getContentSize() const
Returns the Size in unclipped pixels of the content attached to this ItemListbox.
CEGUI::ItemListbox::d_nextSelectionIndex
size_t d_nextSelectionIndex
The last item that was selected.
Definition: widgets/ItemListbox.h:268
CEGUI::ItemListbox::clearAllSelections
void clearAllSelections(void)
Clears all selections.
CEGUI::ItemListbox::handle_PaneChildRemoved
bool handle_PaneChildRemoved(const EventArgs &e)
Handler to manage items being removed from the content pane. If there is one!
CEGUI::ItemListbox::findSelectedItem
ItemEntry * findSelectedItem(size_t start_index) const
Returns a pointer to the first selected item starting the search from start_index.
CEGUI::Size< float >
CEGUI::ItemListbox::ItemListbox
ItemListbox(const String &type, const String &name)
Constructor for the ItemListbox base class constructor.
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::ItemListbox::selectAllItems
void selectAllItems(void)
Select all items. Does nothing if multiselect is disabled.
CEGUI::ItemListbox::notifyItemSelectState
virtual void notifyItemSelectState(ItemEntry *li, bool state)
Notify this ItemListbox that the given ListItem just changed selection state. Internal function - not...
CEGUI::ItemListbox::getSelectedCount
size_t getSelectedCount(void) const
Returns the number of selected items in this ItemListbox.
CEGUI::ItemEntry
Base class for item type widgets.
Definition: widgets/ItemEntry.h:77
CEGUI::EventArgs
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:51
CEGUI::ItemListbox::getLastSelectedItem
ItemEntry * getLastSelectedItem(void) const
Returns a pointer to the last selected item.
Definition: widgets/ItemListbox.h:83