# 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     Crazy Eddie's GUI System (http://www.cegui.org.uk)
    00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
    00011
    00012     This library is free software; you can redistribute it and/or
    00013     modify it under the terms of the GNU Lesser General Public
    00014     License as published by the Free Software Foundation; either
    00015     version 2.1 of the License, or (at your option) any later version.
    00016
    00017     This library is distributed in the hope that it will be useful,
    00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00020     Lesser General Public License for more details.
    00021
    00022     You should have received a copy of the GNU Lesser General Public
    00023     License along with this library; if not, write to the Free Software
    00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00025 *************************************************************************/
    00026 #ifndef _CEGUIMenuBase_h_
    00027 #define _CEGUIMenuBase_h_
    00028
    00029 #include "CEGUIBase.h"
    00030 #include "CEGUIWindow.h"
    00031 #include "elements/CEGUIMenuBaseProperties.h"
    00032 #include "elements/CEGUIItemListBase.h"
    00033
    00034
    00035 #if defined(_MSC_VER)
    00036 #       pragma warning(push)
    00037 #       pragma warning(disable : 4251)
    00038 #endif
    00039
    00040
    00041 // Start of CEGUI namespace section
    00042 namespace CEGUI
    00043 {
    00044
    00049 class CEGUIEXPORT MenuBase : public ItemListBase
    00050 {
    00051 public:
    00052         static const String EventNamespace;
    00053
    00054         /*************************************************************************
    00055                 Constants
    00056         *************************************************************************/
    00057         static const colour DefaultBackgroundColour;
    00058
    00059
    00060         /*************************************************************************
    00061                 Event name constants
    00062         *************************************************************************/
    00063         // generated internally by Window
    00064         static const String EventPopupOpened;
    00065         static const String EventPopupClosed;
    00066
    00067
    00068         /*************************************************************************
    00069                 Accessor type functions
    00070         *************************************************************************/
    00078         float   getItemSpacing(void) const                                      {return d_itemSpacing;}
    00079
    00080
    00088         float   getHorzPadding(void) const                                      {return d_horzPadding;}
    00089
    00090
    00098         float   getVertPadding(void) const                                      {return d_vertPadding;}
    00099
    00100
    00108         float   getBorderWidth(void) const                                      {return d_borderWidth;}
    00109
    00110
    00118         const ColourRect&       getBackgroundColours(void) const        {return d_backgroundColours;}
    00119
    00120
    00128         bool    isMultiplePopupsAllowed(void) const                     {return d_allowMultiplePopups;}
    00129
    00130
    00138         MenuItem*       getPopupMenuItem(void) const                            {return d_popup;}
    00139
    00140
    00141         /*************************************************************************
    00142                 Manipulators
    00143         *************************************************************************/
    00148         void    setItemSpacing(float spacing)                           {d_itemSpacing=spacing;handleUpdatedItemData();}
    00149
    00150
    00155         void    setHorzPadding(float padding)                           {d_horzPadding=padding;handleUpdatedItemData();}
    00156
    00157
    00162         void    setVertPadding(float padding)                           {d_vertPadding=padding;handleUpdatedItemData();}
    00163
    00164
    00169         void    setBorderWidth(float border)                            {d_borderWidth=border;handleUpdatedItemData();}
    00170
    00171
    00176         void    setBackgroundColours(const ColourRect& cr)      {d_backgroundColours=cr;}
    00177
    00178
    00186         void    changePopupMenuItem(MenuItem* item);
    00187
    00188
    00193         void    setAllowMultiplePopups(bool setting)            {d_allowMultiplePopups=setting;}
    00194
    00195
    00196         /*************************************************************************
    00197                 Construction and Destruction
    00198         *************************************************************************/
    00203         MenuBase(const String& type, const String& name);
    00204
    00205
    00210         virtual ~MenuBase(void);
    00211
    00212
    00213 protected:
    00214         /*************************************************************************
    00215                 New Event Handlers
    00216         *************************************************************************/
    00221         virtual void    onPopupOpened(WindowEventArgs& e);
    00222
    00223
    00228         virtual void    onPopupClosed(WindowEventArgs& e);
    00229
    00230
    00231         /*************************************************************************
    00232                 Implementation Functions
    00233         *************************************************************************/
    00238         void    addMenuBaseEvents(void);
    00239
    00240
    00251         virtual bool    testClassName_impl(const String& class_name) const
    00252         {
    00253                 if (class_name==(const utf8*)"MenuBase")        return true;
    00254                 return ItemListBase::testClassName_impl(class_name);
    00255         }
    00256
    00257
    00258         /*************************************************************************
    00259                 Implementation Data
    00260         *************************************************************************/
    00261         float d_itemSpacing;
    00262         float d_horzPadding;
    00263         float d_vertPadding;
    00264         float d_borderWidth;
    00265
    00266         ColourRect d_backgroundColours;
    00267
    00268         MenuItem* d_popup;
    00269         bool d_allowMultiplePopups;
    00270
    00271
    00272 private:
    00273         /*************************************************************************
    00274         Static Properties for this class
    00275         *************************************************************************/
    00276         static MenuBaseProperties::ItemSpacing                  d_itemSpacingProperty;
    00277         static MenuBaseProperties::HorzPadding                  d_horzPaddingProperty;
    00278         static MenuBaseProperties::VertPadding                  d_vertPaddingProperty;
    00279         static MenuBaseProperties::BorderWidth                  d_borderWidthProperty;
    00280         static MenuBaseProperties::BackgroundColours    d_backgroundColoursProperty;
    00281         static MenuBaseProperties::AllowMultiplePopups  d_allowMultiplePopupsProperty;
    00282
    00283         /*************************************************************************
    00284         Private methods
    00285         *************************************************************************/
    00286         void    addMenuBaseProperties(void);
    00287 };
    00288
    00289 } // End of  CEGUI namespace section
    00290
    00291
    00292 #if defined(_MSC_VER)
    00293 #       pragma warning(pop)
    00294 #endif
    00295
    00296 #endif  // end of guard _CEGUIMenuBase_h_