Crazy Eddies GUI System: CEGUIMenuBase.h Source File

Crazy Eddies GUI System 0.7.6

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

- File List

CEGUIMenuBase.h

    00001 /***********************************************************************
    00002     filename:   CEGUIMenuBase.h
    00003     created:    5/4/2005
    00004     author:     Tomas Lindquist Olsen (based on code by Paul D Turner)
    00005
    00006     purpose:    Interface to base class for MenuBase widget
    00007 *************************************************************************/
    00008 /***************************************************************************
    00009  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
    00010  *
    00011  *   Permission is hereby granted, free of charge, to any person obtaining
    00012  *   a copy of this software and associated documentation files (the
    00013  *   "Software"), to deal in the Software without restriction, including
    00014  *   without limitation the rights to use, copy, modify, merge, publish,
    00015  *   distribute, sublicense, and/or sell copies of the Software, and to
    00016  *   permit persons to whom the Software is furnished to do so, subject to
    00017  *   the following conditions:
    00018  *
    00019  *   The above copyright notice and this permission notice shall be
    00020  *   included in all copies or substantial portions of the Software.
    00021  *
    00022  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    00023  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    00024  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    00025  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
    00026  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
    00027  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    00028  *   OTHER DEALINGS IN THE SOFTWARE.
    00029  ***************************************************************************/
    00030 #ifndef _CEGUIMenuBase_h_
    00031 #define _CEGUIMenuBase_h_
    00032
    00033 #include "../CEGUIBase.h"
    00034 #include "../CEGUIWindow.h"
    00035 #include "CEGUIMenuBaseProperties.h"
    00036 #include "CEGUIItemListBase.h"
    00037
    00038
    00039 #if defined(_MSC_VER)
    00040 #   pragma warning(push)
    00041 #   pragma warning(disable : 4251)
    00042 #endif
    00043
    00044
    00045 // Start of CEGUI namespace section
    00046 namespace CEGUI
    00047 {
    00048
    00053 class CEGUIEXPORT MenuBase : public ItemListBase
    00054 {
    00055 public:
    00056     static const String EventNamespace;
    00057
    00058
    00059     /*************************************************************************
    00060         Event name constants
    00061     *************************************************************************/
    00062     // generated internally by Window
    00067     static const String EventPopupOpened;
    00072     static const String EventPopupClosed;
    00073
    00074
    00075     /*************************************************************************
    00076         Accessor type functions
    00077     *************************************************************************/
    00085     float   getItemSpacing(void) const
    00086     {
    00087         return d_itemSpacing;
    00088     }
    00089
    00090
    00098     bool    isMultiplePopupsAllowed(void) const
    00099     {
    00100         return d_allowMultiplePopups;
    00101     }
    00102
    00110     bool    getAutoCloseNestedPopups(void) const
    00111     {
    00112         return d_autoCloseNestedPopups;
    00113     }
    00114
    00122     MenuItem*   getPopupMenuItem(void) const
    00123     {
    00124         return d_popupItem;
    00125     }
    00126
    00127
    00128     /*************************************************************************
    00129         Manipulators
    00130     *************************************************************************/
    00135     void    setItemSpacing(float spacing)
    00136     {
    00137         d_itemSpacing = spacing;
    00138         handleUpdatedItemData();
    00139     }
    00140
    00141
    00149     void    changePopupMenuItem(MenuItem* item);
    00150
    00151
    00156     void    setAllowMultiplePopups(bool setting);
    00157
    00162     void    setAutoCloseNestedPopups(bool setting)
    00163     {
    00164         d_autoCloseNestedPopups = setting;
    00165     }
    00170     void    setPopupMenuItemClosing();
    00171
    00172
    00173     /*************************************************************************
    00174         Construction and Destruction
    00175     *************************************************************************/
    00180     MenuBase(const String& type, const String& name);
    00181
    00182
    00187     virtual ~MenuBase(void);
    00188
    00189
    00190 protected:
    00191     /*************************************************************************
    00192         New Event Handlers
    00193     *************************************************************************/
    00198     virtual void    onPopupOpened(WindowEventArgs& e);
    00199
    00200
    00205     virtual void    onPopupClosed(WindowEventArgs& e);
    00206
    00207     // overridden from base
    00208     virtual void onChildRemoved(WindowEventArgs& e);
    00209     virtual void onHidden(WindowEventArgs& e);
    00210     /*************************************************************************
    00211         Implementation Functions
    00212     *************************************************************************/
    00223     virtual bool    testClassName_impl(const String& class_name) const
    00224     {
    00225         if (class_name == "MenuBase") return true;
    00226
    00227         return ItemListBase::testClassName_impl(class_name);
    00228     }
    00229
    00230
    00231     /*************************************************************************
    00232         Implementation Data
    00233     *************************************************************************/
    00234     float d_itemSpacing;
    00235
    00236     MenuItem* d_popupItem;
    00237     bool d_allowMultiplePopups;
    00238     bool d_autoCloseNestedPopups;
    00239
    00240
    00241 private:
    00242     /*************************************************************************
    00243     Static Properties for this class
    00244     *************************************************************************/
    00245     static MenuBaseProperties::ItemSpacing          d_itemSpacingProperty;
    00246     static MenuBaseProperties::AllowMultiplePopups  d_allowMultiplePopupsProperty;
    00247     static MenuBaseProperties::AutoCloseNestedPopups d_autoCloseNestedPopupsProperty;
    00248
    00249     /*************************************************************************
    00250     Private methods
    00251     *************************************************************************/
    00252     void    addMenuBaseProperties(void);
    00253 };
    00254
    00255 } // End of  CEGUI namespace section
    00256
    00257
    00258 #if defined(_MSC_VER)
    00259 #   pragma warning(pop)
    00260 #endif
    00261
    00262 #endif  // end of guard _CEGUIMenuBase_h_