• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

CEGUIMenuItem.h

00001 /***********************************************************************
00002         filename:       CEGUIMenuItem.h
00003         created:        2/4/2005
00004         author:         Tomas Lindquist Olsen (based on code by Paul D Turner)
00005         
00006         purpose:        Interface to base class for MenuItem 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 _CEGUIMenuItem_h_
00031 #define _CEGUIMenuItem_h_
00032 
00033 #include "../CEGUIBase.h"
00034 #include "../CEGUIWindow.h"
00035 #include "CEGUIItemEntry.h"
00036 
00037 // Start of CEGUI namespace section
00038 namespace CEGUI
00039 {
00040 
00045 class CEGUIEXPORT MenuItem : public ItemEntry
00046 {
00047 public:
00048         static const String EventNamespace;                             
00049     static const String WidgetTypeName;             
00050 
00051         /*************************************************************************
00052                 Event name constants
00053         *************************************************************************/
00054         // generated internally by Window
00059         static const String EventClicked;
00060 
00061 
00062         /*************************************************************************
00063                 Accessor type functions
00064         *************************************************************************/
00072         bool    isHovering(void) const                  {return d_hovering;}
00073 
00074 
00082         bool    isPushed(void) const                    {return d_pushed;}
00083 
00084 
00089     bool    isOpened(void) const            {return d_opened;}
00090 
00091 
00099         PopupMenu*      getPopupMenu(void) const                        {return d_popup;}
00100 
00101 
00102         /*************************************************************************
00103                 Manipulators
00104         *************************************************************************/
00115         void    setPopupMenu(PopupMenu* popup);
00116 
00117 
00125         void    openPopupMenu(bool notify=true);
00126 
00127 
00138         void    closePopupMenu(bool notify=true);
00139 
00140 
00148         bool    togglePopupMenu(void);
00149 
00150 
00151         /*************************************************************************
00152                 Construction and Destruction
00153         *************************************************************************/
00158         MenuItem(const String& type, const String& name);
00159 
00160 
00165         virtual ~MenuItem(void);
00166 
00167 
00168 protected:
00169         /*************************************************************************
00170                 New Event Handlers
00171         *************************************************************************/
00176         virtual void    onClicked(WindowEventArgs& e);
00177 
00178 
00179         /*************************************************************************
00180                 Overridden event handlers
00181         *************************************************************************/
00182         virtual void    onMouseMove(MouseEventArgs& e);
00183         virtual void    onMouseButtonDown(MouseEventArgs& e);
00184         virtual void    onMouseButtonUp(MouseEventArgs& e);
00185         virtual void    onCaptureLost(WindowEventArgs& e);
00186         virtual void    onMouseLeaves(MouseEventArgs& e);
00187         virtual void    onTextChanged(WindowEventArgs& e);
00188 
00189 
00190         /*************************************************************************
00191                 Implementation Functions
00192         *************************************************************************/
00203         void    updateInternalState(const Point& mouse_pos);
00204 
00205 
00213         void    closeAllMenuItemPopups();
00214 
00215 
00226         void    setPopupMenu_impl(PopupMenu* popup,bool add_as_child=true);
00227 
00228 
00239         virtual bool    testClassName_impl(const String& class_name) const
00240         {
00241                 if (class_name=="MenuItem")     return true;
00242                 return ItemEntry::testClassName_impl(class_name);
00243         }
00244 
00245 
00246         /*************************************************************************
00247                 Implementation Data
00248         *************************************************************************/
00249         bool d_pushed;                  
00250         bool d_hovering;                
00251         bool d_opened;                  
00252 
00253         PopupMenu*  d_popup;    
00254 
00255         bool d_popupWasClosed;  
00256 
00257 
00258 private:
00259     /*************************************************************************
00260                 Private methods
00261         *************************************************************************/
00262         void addMenuItemProperties(void);
00263 
00264 
00269         virtual void    addChild_impl(Window* wnd);
00270 };
00271 
00272 } // End of  CEGUI namespace section
00273 
00274 #endif  // end of guard _CEGUIMenuItem_h_

Generated on Sat Sep 25 2010 02:10:34 for Crazy Eddies GUI System by  doxygen 1.7.1