Crazy Eddies GUI System: CEGUIItemListbox.h Source File

Crazy Eddies GUI System 0.7.6

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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 "CEGUIScrolledItemListBase.h"
    00032 #include "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     *************************************************************************/
    00061     static const String EventSelectionChanged;
    00067     static const String EventMultiSelectModeChanged;
    00068
    00069     /************************************************************************
    00070         Accessors
    00071     *************************************************************************/
    00076     size_t getSelectedCount(void) const;
    00077
    00085     ItemEntry* getLastSelectedItem(void) const      {return d_lastSelected;}
    00086
    00105     ItemEntry* getFirstSelectedItem(size_t start_index=0) const;
    00106
    00125     ItemEntry* getNextSelectedItem(void) const;
    00126
    00136     ItemEntry* getNextSelectedItemAfter(const ItemEntry* start_item) const;
    00137
    00142     bool isMultiSelectEnabled(void) const   {return d_multiSelect;}
    00143
    00148     bool isItemSelected(size_t index) const;
    00149
    00150     /************************************************************************
    00151         Manipulators
    00152     *************************************************************************/
    00153     // Overridden from base class
    00154     virtual void initialiseComponents(void);
    00155
    00160     void setMultiSelectEnabled(bool state);
    00161
    00166     void clearAllSelections(void);
    00167
    00178     void selectRange(size_t a, size_t z);
    00179
    00185     void selectAllItems(void);
    00186
    00187     /************************************************************************
    00188         Object Construction and Destruction
    00189     *************************************************************************/
    00194     ItemListbox(const String& type, const String& name);
    00195
    00200     virtual ~ItemListbox(void) {}
    00201
    00202     /************************************************************************
    00203         Implementation functions
    00204     ************************************************************************/
    00209     virtual void layoutItemWidgets();
    00210
    00215     virtual Size getContentSize() const;
    00216
    00228     virtual bool testClassName_impl(const String& class_name) const
    00229     {
    00230         if (class_name=="ItemListbox")
    00231         {
    00232             return true;
    00233         }
    00234         return ScrolledItemListBase::testClassName_impl(class_name);
    00235     }
    00236
    00242     virtual void notifyItemClicked(ItemEntry* li);
    00243
    00249     virtual void notifyItemSelectState(ItemEntry* li, bool state);
    00250
    00251 protected:
    00252     /************************************************************************
    00253         Protected implementation functions
    00254     ************************************************************************/
    00272     ItemEntry* findSelectedItem(size_t start_index) const;
    00273
    00274     /************************************************************************
    00275         New event handlers
    00276     ************************************************************************/
    00277     virtual void onSelectionChanged(WindowEventArgs& e);
    00278     virtual void onMultiSelectModeChanged(WindowEventArgs& e);
    00279
    00280     /************************************************************************
    00281         Overridden event handlers
    00282     ************************************************************************/
    00283     virtual void onKeyDown(KeyEventArgs& e);
    00284
    00285     /************************************************************************
    00286         Static Properties for this class
    00287     ************************************************************************/
    00288     static ItemListboxProperties::MultiSelect d_multiSelectProperty;
    00289
    00290     /************************************************************************
    00291         Implementation data
    00292     ************************************************************************/
    00293     bool d_multiSelect;
    00294     ItemEntry* d_lastSelected;
    00295     mutable size_t d_nextSelectionIndex;
    00296
    00297 private:
    00298     void addItemListboxProperties(void);
    00299     void addItemListboxEvents(void);
    00301     bool handle_PaneChildRemoved(const EventArgs& e);
    00302 };
    00303
    00304 } // end CEGUI namespace
    00305
    00306 #if defined(_MSC_VER)
    00307 #       pragma warning(pop)
    00308 #endif
    00309
    00310 #endif // end of guard _CEGUIItemListbox_h_