CEGUIItemListbox.h

00001 /************************************************************************
00002     filename:   CEGUIItemListbox.h
00003     created:    Tue Sep 27 2005
00004     author:     Tomas Lindquist Olsen
00005 *************************************************************************/
00006 /***************************************************************************
00007  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00008  *
00009  *   Permission is hereby granted, free of charge, to any person obtaining
00010  *   a copy of this software and associated documentation files (the
00011  *   "Software"), to deal in the Software without restriction, including
00012  *   without limitation the rights to use, copy, modify, merge, publish,
00013  *   distribute, sublicense, and/or sell copies of the Software, and to
00014  *   permit persons to whom the Software is furnished to do so, subject to
00015  *   the following conditions:
00016  *
00017  *   The above copyright notice and this permission notice shall be
00018  *   included in all copies or substantial portions of the Software.
00019  *
00020  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00023  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00024  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00025  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00026  *   OTHER DEALINGS IN THE SOFTWARE.
00027  ***************************************************************************/
00028 #ifndef _CEGUIItemListbox_h_
00029 #define _CEGUIItemListbox_h_
00030 
00031 #include "elements/CEGUIScrolledItemListBase.h"
00032 #include "elements/CEGUIItemListboxProperties.h"
00033 
00034 #if defined(_MSC_VER)
00035 #       pragma warning(push)
00036 #       pragma warning(disable : 4251)
00037 #endif
00038 
00039 // begin CEGUI namespace
00040 namespace CEGUI
00041 {
00042 
00047 class CEGUIEXPORT ItemListbox : public ScrolledItemListBase
00048 {
00049 public:
00050     static const String EventNamespace; 
00051     static const String WidgetTypeName; 
00052 
00053     /************************************************************************
00054         Constants
00055     *************************************************************************/
00056     static const String EventSelectionChanged; 
00057     static const String EventMultiSelectModeChanged; 
00058 
00059     /************************************************************************
00060         Accessors
00061     *************************************************************************/
00066     size_t getSelectedCount(void) const;
00067 
00075     ItemEntry* getLastSelectedItem(void) const      {return d_lastSelected;}
00076 
00095     ItemEntry* getFirstSelectedItem(size_t start_index=0) const;
00096 
00115     ItemEntry* getNextSelectedItem(void) const;
00116 
00126     ItemEntry* getNextSelectedItemAfter(const ItemEntry* start_item) const;
00127 
00132     bool isMultiSelectEnabled(void) const   {return d_multiSelect;}
00133 
00138     bool isItemSelected(size_t index) const;
00139 
00140     /************************************************************************
00141         Manipulators
00142     *************************************************************************/
00147     void setMultiSelectEnabled(bool state);
00148 
00153     void clearAllSelections(void);
00154 
00165     void selectRange(size_t a, size_t z);
00166 
00172     void selectAllItems(void);
00173 
00174     /************************************************************************
00175         Object Construction and Destruction
00176     *************************************************************************/
00181     ItemListbox(const String& type, const String& name);
00182 
00187     virtual ~ItemListbox(void) {}
00188 
00189     /************************************************************************
00190         Implementation functions
00191     ************************************************************************/
00196     virtual void layoutItemWidgets();
00197 
00202     virtual Size getContentSize() const;
00203 
00215     virtual bool testClassName_impl(const String& class_name) const
00216     {
00217         if (class_name=="ItemListbox")
00218         {
00219             return true;
00220         }
00221         return ScrolledItemListBase::testClassName_impl(class_name);
00222     }
00223 
00229     virtual void notifyItemClicked(ItemEntry* li);
00230 
00236     virtual void notifyItemSelectState(ItemEntry* li, bool state);
00237 
00238 protected:
00239     /************************************************************************
00240         Protected implementation functions
00241     ************************************************************************/
00259     ItemEntry* findSelectedItem(size_t start_index) const;
00260 
00261     /************************************************************************
00262         New event handlers
00263     ************************************************************************/
00264     virtual void onSelectionChanged(WindowEventArgs& e);
00265     virtual void onMultiSelectModeChanged(WindowEventArgs& e);
00266 
00267     /************************************************************************
00268         Overridden event handlers
00269     ************************************************************************/
00270     virtual void onKeyDown(KeyEventArgs& e);
00271 
00272     /************************************************************************
00273         Static Properties for this class
00274     ************************************************************************/
00275     static ItemListboxProperties::MultiSelect d_multiSelectProperty;
00276 
00277     /************************************************************************
00278         Implementation data
00279     ************************************************************************/
00280     bool d_multiSelect; 
00281     ItemEntry* d_lastSelected; 
00282     mutable size_t d_nextSelectionIndex; 
00283 
00284 private:
00285     void addItemListboxProperties(void);
00286     void addItemListboxEvents(void);
00287 };
00288 
00289 } // end CEGUI namespace
00290 
00291 #if defined(_MSC_VER)
00292 #       pragma warning(pop)
00293 #endif
00294 
00295 #endif // end of guard _CEGUIItemListbox_h_

Generated on Sun Nov 5 14:35:28 2006 for Crazy Eddies GUI System by  doxygen 1.4.7