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     *************************************************************************/
00143     // Overridden from base class
00144     virtual void initialiseComponents(void);
00145 
00150     void setMultiSelectEnabled(bool state);
00151 
00156     void clearAllSelections(void);
00157 
00168     void selectRange(size_t a, size_t z);
00169 
00175     void selectAllItems(void);
00176 
00177     /************************************************************************
00178         Object Construction and Destruction
00179     *************************************************************************/
00184     ItemListbox(const String& type, const String& name);
00185 
00190     virtual ~ItemListbox(void) {}
00191 
00192     /************************************************************************
00193         Implementation functions
00194     ************************************************************************/
00199     virtual void layoutItemWidgets();
00200 
00205     virtual Size getContentSize() const;
00206 
00218     virtual bool testClassName_impl(const String& class_name) const
00219     {
00220         if (class_name=="ItemListbox")
00221         {
00222             return true;
00223         }
00224         return ScrolledItemListBase::testClassName_impl(class_name);
00225     }
00226 
00232     virtual void notifyItemClicked(ItemEntry* li);
00233 
00239     virtual void notifyItemSelectState(ItemEntry* li, bool state);
00240 
00241 protected:
00242     /************************************************************************
00243         Protected implementation functions
00244     ************************************************************************/
00262     ItemEntry* findSelectedItem(size_t start_index) const;
00263 
00264     /************************************************************************
00265         New event handlers
00266     ************************************************************************/
00267     virtual void onSelectionChanged(WindowEventArgs& e);
00268     virtual void onMultiSelectModeChanged(WindowEventArgs& e);
00269 
00270     /************************************************************************
00271         Overridden event handlers
00272     ************************************************************************/
00273     virtual void onKeyDown(KeyEventArgs& e);
00274 
00275     /************************************************************************
00276         Static Properties for this class
00277     ************************************************************************/
00278     static ItemListboxProperties::MultiSelect d_multiSelectProperty;
00279 
00280     /************************************************************************
00281         Implementation data
00282     ************************************************************************/
00283     bool d_multiSelect; 
00284     ItemEntry* d_lastSelected; 
00285     mutable size_t d_nextSelectionIndex; 
00286 
00287 private:
00288     void addItemListboxProperties(void);
00289     void addItemListboxEvents(void);
00291     bool handle_PaneChildRemoved(const EventArgs& e);
00292 };
00293 
00294 } // end CEGUI namespace
00295 
00296 #if defined(_MSC_VER)
00297 #       pragma warning(pop)
00298 #endif
00299 
00300 #endif // end of guard _CEGUIItemListbox_h_

Generated on Sat Jun 28 14:35:44 2008 for Crazy Eddies GUI System by  doxygen 1.5.4