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     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 _CEGUIMenuItem_h_
00027 #define _CEGUIMenuItem_h_
00028 
00029 #include "CEGUIBase.h"
00030 #include "CEGUIWindow.h"
00031 #include "elements/CEGUITextItem.h"
00032 #include "elements/CEGUIMenuItemProperties.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 MenuItem : public TextItem
00050 {
00051 public:
00052         static const String EventNamespace;                             
00053 
00054         /*************************************************************************
00055                 Constants
00056         *************************************************************************/
00057         // default colours for rendering
00058         
00059         static const colour             DefaultHoverColour;                     
00060         static const colour             DefaultPushedColour;            
00061         static const colour             DefaultOpenedColour;            
00062         static const colour             DefaultNormalTextColour;        
00063         static const colour             DefaultDisabledTextColour;      
00064 
00065 
00066         /*************************************************************************
00067                 Event name constants
00068         *************************************************************************/
00069         // generated internally by Window
00070         static const String EventClicked;                                       
00071 
00072 
00073         /*************************************************************************
00074                 Accessor type functions
00075         *************************************************************************/
00083         bool    isHovering(void) const                  {return d_hovering;}
00084 
00085 
00093         bool    isPushed(void) const                    {return d_pushed;}
00094 
00095 
00103         colour  getHoverColour(void) const                      {return d_hoverColour;}
00104 
00105 
00113         colour  getPushedColour(void) const                     {return d_pushedColour;}
00114 
00115 
00123         colour  getOpenedColour(void) const                     {return d_openedColour;}
00124 
00125 
00133         colour  getNormalTextColour(void) const                 {return d_normalTextColour;}
00134 
00135 
00143         colour  getDisabledTextColour(void) const               {return d_disabledTextColour;}
00144 
00145 
00153         PopupMenu*      getPopupMenu(void) const                        {return d_popup;}
00154 
00155 
00156         /*************************************************************************
00157                 Manipulators
00158         *************************************************************************/
00169         void    setHoverColour(const colour& colour);
00170 
00171 
00182         void    setPushedColour(const colour& colour);
00183 
00184 
00195         void    setOpenedColour(const colour& colour);
00196 
00197 
00208         void    setNormalTextColour(const colour& colour);
00209 
00210 
00221         void    setDisabledTextColour(const colour& colour);
00222 
00223 
00234         void    setPopupMenu(PopupMenu* popup);
00235 
00236 
00241         void    openPopupMenu(void);
00242 
00243 
00254         void    closePopupMenu(bool notify=true);
00255 
00256 
00264         bool    togglePopupMenu(void);
00265 
00266 
00267         /*************************************************************************
00268                 Construction and Destruction
00269         *************************************************************************/
00274         MenuItem(const String& type, const String& name);
00275 
00276 
00281         virtual ~MenuItem(void);
00282 
00283 
00284 protected:
00285         /*************************************************************************
00286                 New Event Handlers
00287         *************************************************************************/
00292         virtual void    onClicked(WindowEventArgs& e);
00293 
00294 
00295         /*************************************************************************
00296                 Overridden event handlers
00297         *************************************************************************/
00298         virtual void    onMouseMove(MouseEventArgs& e);
00299         virtual void    onMouseButtonDown(MouseEventArgs& e);
00300         virtual void    onMouseButtonUp(MouseEventArgs& e);
00301         virtual void    onCaptureLost(WindowEventArgs& e);
00302         virtual void    onMouseLeaves(MouseEventArgs& e);
00303 
00304 
00305         /*************************************************************************
00306                 Implementation Functions
00307         *************************************************************************/
00318         void    updateInternalState(const Point& mouse_pos);
00319 
00320 
00325         void    addMenuItemEvents(void);
00326 
00327 
00335         void    closeAllMenuItemPopups();
00336 
00337 
00348         virtual bool    testClassName_impl(const String& class_name) const
00349         {
00350                 if (class_name==(const utf8*)"MenuItem")        return true;
00351                 return TextItem::testClassName_impl(class_name);
00352         }
00353 
00354 
00355         /*************************************************************************
00356                 Implementation Rendering Functions
00357         *************************************************************************/
00358 
00359         /*************************************************************************
00360                 Implementation Data
00361         *************************************************************************/
00362         bool    d_pushed;                       
00363         bool    d_hovering;                     
00364         bool    d_opened;                       
00365 
00366         // common rendering setting data
00367         colour  d_hoverColour;                                  
00368         colour  d_pushedColour;                                 
00369         colour  d_openedColour;                                 
00370         colour  d_normalTextColour;                             
00371         colour  d_disabledTextColour;                   
00372 
00373         PopupMenu* d_popup;                                             
00374 
00375         bool    d_popupWasClosed;                               
00376 
00377 private:
00378         /*************************************************************************
00379                 Static Properties for this class
00380         *************************************************************************/
00381         static MenuItemProperties::HoverColour                  d_hoverColourProperty;
00382         static MenuItemProperties::PushedColour                 d_pushedColourProperty;
00383         static MenuItemProperties::OpenedColour                 d_openedColourProperty;
00384         static MenuItemProperties::NormalTextColour             d_normalTextColourProperty;
00385         static MenuItemProperties::DisabledTextColour   d_disabledTextColourProperty;
00386 
00387 
00388         /*************************************************************************
00389                 Private methods
00390         *************************************************************************/
00391         void addMenuItemProperties(void);
00392 
00393 
00398         virtual void    addChild_impl(Window* wnd);
00399 };
00400 
00401 } // End of  CEGUI namespace section
00402 
00403 
00404 #if defined(_MSC_VER)
00405 #       pragma warning(pop)
00406 #endif
00407 
00408 
00409 #endif  // end of guard _CEGUIMenuItem_h_

Generated on Sat Nov 26 10:09:54 2005 for Crazy Eddies GUI System by  doxygen 1.4.5