| CEGUIMenuBase.h | | CEGUIMenuBase.h | |
| /*********************************************************************** | | /*********************************************************************** | |
|
| filename: CEGUIMenuBase.h | | filename: CEGUIMenuBase.h | |
| created: 5/4/2005 | | created: 5/4/2005 | |
| author: Tomas Lindquist Olsen (based on code by Paul D Turne | | author: Tomas Lindquist Olsen (based on code by Paul D Turner) | |
| r) | | | |
| | | | |
|
| purpose: Interface to base class for MenuBase widget | | purpose: Interface to base class for MenuBase widget | |
| *************************************************************************/ | | *************************************************************************/ | |
| /**************************************************************************
* | | /**************************************************************************
* | |
| * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team | | * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team | |
| * | | * | |
| * Permission is hereby granted, free of charge, to any person obtaining | | * Permission is hereby granted, free of charge, to any person obtaining | |
| * a copy of this software and associated documentation files (the | | * a copy of this software and associated documentation files (the | |
| * "Software"), to deal in the Software without restriction, including | | * "Software"), to deal in the Software without restriction, including | |
| * without limitation the rights to use, copy, modify, merge, publish, | | * without limitation the rights to use, copy, modify, merge, publish, | |
| * distribute, sublicense, and/or sell copies of the Software, and to | | * distribute, sublicense, and/or sell copies of the Software, and to | |
| * permit persons to whom the Software is furnished to do so, subject to | | * permit persons to whom the Software is furnished to do so, subject to | |
| | | | |
| skipping to change at line 39 | | skipping to change at line 39 | |
| **************************************************************************
*/ | | **************************************************************************
*/ | |
| #ifndef _CEGUIMenuBase_h_ | | #ifndef _CEGUIMenuBase_h_ | |
| #define _CEGUIMenuBase_h_ | | #define _CEGUIMenuBase_h_ | |
| | | | |
| #include "../CEGUIBase.h" | | #include "../CEGUIBase.h" | |
| #include "../CEGUIWindow.h" | | #include "../CEGUIWindow.h" | |
| #include "CEGUIMenuBaseProperties.h" | | #include "CEGUIMenuBaseProperties.h" | |
| #include "CEGUIItemListBase.h" | | #include "CEGUIItemListBase.h" | |
| | | | |
| #if defined(_MSC_VER) | | #if defined(_MSC_VER) | |
|
| # pragma warning(push) | | # pragma warning(push) | |
| # pragma warning(disable : 4251) | | # pragma warning(disable : 4251) | |
| #endif | | #endif | |
| | | | |
| // Start of CEGUI namespace section | | // Start of CEGUI namespace section | |
| namespace CEGUI | | namespace CEGUI | |
| { | | { | |
| | | | |
| /*! | | /*! | |
| \brief | | \brief | |
|
| Abstract base class for menus. | | Abstract base class for menus. | |
| */ | | */ | |
| class CEGUIEXPORT MenuBase : public ItemListBase | | class CEGUIEXPORT MenuBase : public ItemListBase | |
| { | | { | |
| public: | | public: | |
|
| static const String EventNamespace; //!<
Namespace for global events | | static const String EventNamespace; //!< Namespace for glob
al events | |
| | | | |
|
| /******************************************************************* | | /********************************************************************** | |
| ****** | | *** | |
| Event name constants | | Event name constants | |
| ******************************************************************** | | *********************************************************************** | |
| *****/ | | **/ | |
| // generated internally by Window | | // generated internally by Window | |
| /** Event fired when a MenuItem attached to this menu opened a PopupMen
u. | | /** Event fired when a MenuItem attached to this menu opened a PopupMen
u. | |
| * Handlers are passed a const WindowEventArgs reference with | | * Handlers are passed a const WindowEventArgs reference with | |
| * WindowEventArgs::window set to the PopupMenu that was opened. | | * WindowEventArgs::window set to the PopupMenu that was opened. | |
| */ | | */ | |
|
| static const String EventPopupOpened; | | static const String EventPopupOpened; | |
| /** Event fired when a MenuItem attached to this menu closed a PopupMen
u. | | /** Event fired when a MenuItem attached to this menu closed a PopupMen
u. | |
| * Handlers are passed a const WindowEventArgs reference with | | * Handlers are passed a const WindowEventArgs reference with | |
| * WindowEventArgs::window set to the PopupMenu that was closed. | | * WindowEventArgs::window set to the PopupMenu that was closed. | |
| */ | | */ | |
|
| static const String EventPopupClosed; | | static const String EventPopupClosed; | |
| | | | |
|
| /******************************************************************* | | /********************************************************************** | |
| ****** | | *** | |
| Accessor type functions | | Accessor type functions | |
| ******************************************************************** | | *********************************************************************** | |
| *****/ | | **/ | |
| /*! | | /*! | |
| \brief | | \brief | |
| Get the item spacing for this menu. | | Get the item spacing for this menu. | |
| | | | |
|
| \return | | \return | |
| A float value with the current item spacing for this menu | | A float value with the current item spacing for this menu | |
| */ | | */ | |
| float getItemSpacing(void) const | | float getItemSpacing(void) const | |
| {return d_itemSpacing;} | | { | |
| | | return d_itemSpacing; | |
| | | } | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| Return whether this menu allows multiple popup menus to open | | Return whether this menu allows multiple popup menus to open at the | |
| at the same time. | | same time. | |
| | | | |
|
| \return | | \return | |
| true if this menu allows multiple popup menus to be opened s | | true if this menu allows multiple popup menus to be opened simultan | |
| imultaneously. false if not | | eously. false if not | |
| */ | | */ | |
| bool isMultiplePopupsAllowed(void) const {ret | | bool isMultiplePopupsAllowed(void) const | |
| urn d_allowMultiplePopups;} | | { | |
| | | return d_allowMultiplePopups; | |
| | | } | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| Get currently opened MenuItem in this menu. Returns NULL if | | Return whether this menu should close all its open child popups, wh | |
| no menu item is open. | | en it gets hidden | |
| | | | |
|
| \return | | \return | |
| Pointer to the MenuItem currently open. | | true if the menu should close all its open child popups, when it ge | |
| */ | | ts hidden | |
| MenuItem* getPopupMenuItem(void) const | | */ | |
| {return d_popupItem;} | | bool getAutoCloseNestedPopups(void) const | |
| | | { | |
| | | return d_autoCloseNestedPopups; | |
| | | } | |
| | | | |
|
| /******************************************************************* | | /*! | |
| ****** | | \brief | |
| Manipulators | | Get currently opened MenuItem in this menu. Returns NULL if no menu | |
| ******************************************************************** | | item is open. | |
| *****/ | | | |
| /*! | | | |
| \brief | | | |
| Set the item spacing for this menu. | | | |
| */ | | | |
| void setItemSpacing(float spacing) {d_i | | | |
| temSpacing=spacing; handleUpdatedItemData();} | | | |
| | | | |
|
| /*! | | \return | |
| \brief | | Pointer to the MenuItem currently open. | |
| Change the currently open MenuItem in this menu. | | */ | |
| | | MenuItem* getPopupMenuItem(void) const | |
| | | { | |
| | | return d_popupItem; | |
| | | } | |
| | | | |
|
| \param item | | /********************************************************************** | |
| Pointer to a MenuItem to open or NULL to close any opened. | | *** | |
| */ | | Manipulators | |
| void changePopupMenuItem(MenuItem* item); | | *********************************************************************** | |
| | | **/ | |
| | | /*! | |
| | | \brief | |
| | | Set the item spacing for this menu. | |
| | | */ | |
| | | void setItemSpacing(float spacing) | |
| | | { | |
| | | d_itemSpacing = spacing; | |
| | | handleUpdatedItemData(); | |
| | | } | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| Set whether this menu allows multiple popup menus to be open | | Change the currently open MenuItem in this menu. | |
| ed simultaneously. | | | |
| */ | | | |
| void setAllowMultiplePopups(bool setting); | | | |
| | | | |
|
| /******************************************************************* | | \param item | |
| ****** | | Pointer to a MenuItem to open or NULL to close any opened. | |
| Construction and Destruction | | */ | |
| ******************************************************************** | | void changePopupMenuItem(MenuItem* item); | |
| *****/ | | | |
| /*! | | | |
| \brief | | | |
| Constructor for MenuBase objects | | | |
| */ | | | |
| MenuBase(const String& type, const String& name); | | | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| Destructor for MenuBase objects | | Set whether this menu allows multiple popup menus to be opened simu | |
| */ | | ltaneously. | |
| virtual ~MenuBase(void); | | */ | |
| | | void setAllowMultiplePopups(bool setting); | |
| | | | |
| | | /*! | |
| | | \brief | |
| | | Set whether the menu should close all its open child popups, when i | |
| | | t gets hidden | |
| | | */ | |
| | | void setAutoCloseNestedPopups(bool setting) | |
| | | { | |
| | | d_autoCloseNestedPopups = setting; | |
| | | } | |
| | | /*! | |
| | | \brief | |
| | | tells the current popup that it should start its closing timer. | |
| | | */ | |
| | | void setPopupMenuItemClosing(); | |
| | | | |
| | | /********************************************************************** | |
| | | *** | |
| | | Construction and Destruction | |
| | | *********************************************************************** | |
| | | **/ | |
| | | /*! | |
| | | \brief | |
| | | Constructor for MenuBase objects | |
| | | */ | |
| | | MenuBase(const String& type, const String& name); | |
| | | | |
| | | /*! | |
| | | \brief | |
| | | Destructor for MenuBase objects | |
| | | */ | |
| | | virtual ~MenuBase(void); | |
| | | | |
| protected: | | protected: | |
|
| /******************************************************************* | | /********************************************************************** | |
| ****** | | *** | |
| New Event Handlers | | New Event Handlers | |
| ******************************************************************** | | *********************************************************************** | |
| *****/ | | **/ | |
| /*! | | /*! | |
| \brief | | \brief | |
| handler invoked internally when the a MenuItem attached to t | | handler invoked internally when the a MenuItem attached to this men | |
| his menu opens its popup. | | u opens its popup. | |
| */ | | */ | |
| virtual void onPopupOpened(WindowEventArgs& e); | | virtual void onPopupOpened(WindowEventArgs& e); | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| handler invoked internally when the a MenuItem attached to t | | handler invoked internally when the a MenuItem attached to this men | |
| his menu closes its popup. | | u closes its popup. | |
| */ | | */ | |
| virtual void onPopupClosed(WindowEventArgs& e); | | virtual void onPopupClosed(WindowEventArgs& e); | |
| | | | |
| // overridden from base | | // overridden from base | |
| virtual void onChildRemoved(WindowEventArgs& e); | | virtual void onChildRemoved(WindowEventArgs& e); | |
|
| | | virtual void onHidden(WindowEventArgs& e); | |
| | | /********************************************************************** | |
| | | *** | |
| | | Implementation Functions | |
| | | *********************************************************************** | |
| | | **/ | |
| | | /*! | |
| | | \brief | |
| | | Return whether this window was inherited from the given class name | |
| | | at some point in the inheritance hierarchy. | |
| | | | |
|
| /******************************************************************* | | \param class_name | |
| ****** | | The class name that is to be checked. | |
| Implementation Functions | | | |
| ******************************************************************** | | | |
| *****/ | | | |
| /*! | | | |
| \brief | | | |
| Return whether this window was inherited from the given clas | | | |
| s name at some point in the inheritance hierarchy. | | | |
| | | | |
|
| \param class_name | | \return | |
| The class name that is to be checked. | | true if this window was inherited from \a class_name. false if not. | |
| | | */ | |
| | | virtual bool testClassName_impl(const String& class_name) const | |
| | | { | |
| | | if (class_name == "MenuBase") return true; | |
| | | | |
|
| \return | | return ItemListBase::testClassName_impl(class_name); | |
| true if this window was inherited from \a class_name. false | | } | |
| if not. | | | |
| */ | | | |
| virtual bool testClassName_impl(const String& class_name) const | | | |
| { | | | |
| if (class_name=="MenuBase") return true; | | | |
| return ItemListBase::testClassName_impl(class_name); | | | |
| } | | | |
| | | | |
|
| /******************************************************************* | | /********************************************************************** | |
| ****** | | *** | |
| Implementation Data | | Implementation Data | |
| ******************************************************************** | | *********************************************************************** | |
| *****/ | | **/ | |
| float d_itemSpacing; //!< The spacing in pixels between i | | float d_itemSpacing; //!< The spacing in pixels between items. | |
| tems. | | | |
| | | | |
|
| MenuItem* d_popupItem; //!< The currently open MenuItem. NULL i | | MenuItem* d_popupItem; //!< The currently open MenuItem. NULL if n | |
| f no item is open. If multiple popups are allowed, this means nothing. | | o item is open. If multiple popups are allowed, this means nothing. | |
| bool d_allowMultiplePopups; //!< true if multiple popup menus ar | | bool d_allowMultiplePopups; //!< true if multiple popup menus are allow | |
| e allowed simultaneously. false if not. | | ed simultaneously. false if not. | |
| | | bool d_autoCloseNestedPopups; //!< true if the menu should close all it | |
| | | s open child popups, when it gets hidden | |
| | | | |
| private: | | private: | |
|
| /******************************************************************* | | /********************************************************************** | |
| ****** | | *** | |
| Static Properties for this class | | Static Properties for this class | |
| ******************************************************************** | | *********************************************************************** | |
| *****/ | | **/ | |
| static MenuBaseProperties::ItemSpacing d_itemSpacin | | static MenuBaseProperties::ItemSpacing d_itemSpacingProperty; | |
| gProperty; | | static MenuBaseProperties::AllowMultiplePopups d_allowMultiplePopupsPr | |
| static MenuBaseProperties::AllowMultiplePopups d_allowMultiplePopup | | operty; | |
| sProperty; | | static MenuBaseProperties::AutoCloseNestedPopups d_autoCloseNestedPopup | |
| | | sProperty; | |
| | | | |
|
| /******************************************************************* | | /********************************************************************** | |
| ****** | | *** | |
| Private methods | | Private methods | |
| ******************************************************************** | | *********************************************************************** | |
| *****/ | | **/ | |
| void addMenuBaseProperties(void); | | void addMenuBaseProperties(void); | |
| }; | | }; | |
| | | | |
| } // End of CEGUI namespace section | | } // End of CEGUI namespace section | |
| | | | |
| #if defined(_MSC_VER) | | #if defined(_MSC_VER) | |
|
| # pragma warning(pop) | | # pragma warning(pop) | |
| #endif | | #endif | |
| | | | |
|
| #endif // end of guard _CEGUIMenuBase_h_ | | #endif // end of guard _CEGUIMenuBase_h_ | |
| | | | |
End of changes. 32 change blocks. |
| 152 lines changed or deleted | | 191 lines changed or added | |
|
| CEGUIMenuBaseProperties.h | | CEGUIMenuBaseProperties.h | |
| /*********************************************************************** | | /*********************************************************************** | |
|
| filename: CEGUIMenuBaseProperties.h | | filename: CEGUIMenuBaseProperties.h | |
| created: 5/4/2005 | | created: 5/4/2005 | |
| author: Tomas Lindquist Olsen (based on code by Paul D Turne | | author: Tomas Lindquist Olsen (based on code by Paul D Turner) | |
| r) | | | |
| *************************************************************************/ | | *************************************************************************/ | |
| /**************************************************************************
* | | /**************************************************************************
* | |
| * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team | | * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team | |
| * | | * | |
| * Permission is hereby granted, free of charge, to any person obtaining | | * Permission is hereby granted, free of charge, to any person obtaining | |
| * a copy of this software and associated documentation files (the | | * a copy of this software and associated documentation files (the | |
| * "Software"), to deal in the Software without restriction, including | | * "Software"), to deal in the Software without restriction, including | |
| * without limitation the rights to use, copy, modify, merge, publish, | | * without limitation the rights to use, copy, modify, merge, publish, | |
| * distribute, sublicense, and/or sell copies of the Software, and to | | * distribute, sublicense, and/or sell copies of the Software, and to | |
| * permit persons to whom the Software is furnished to do so, subject to | | * permit persons to whom the Software is furnished to do so, subject to | |
| | | | |
| skipping to change at line 42 | | skipping to change at line 42 | |
| | | | |
| // Start of CEGUI namespace section | | // Start of CEGUI namespace section | |
| namespace CEGUI | | namespace CEGUI | |
| { | | { | |
| // Start of ItemListBaseProperties namespace section | | // Start of ItemListBaseProperties namespace section | |
| namespace MenuBaseProperties | | namespace MenuBaseProperties | |
| { | | { | |
| | | | |
| /*! | | /*! | |
| \brief | | \brief | |
|
| Property to access the item spacing of the menu. | | Property to access the item spacing of the menu. | |
| | | | |
|
| \par Usage: | | \par Usage: | |
| - Name: ItemSpacing | | - Name: ItemSpacing | |
| - Format: "[float]". | | - Format: "[float]". | |
| | | | |
|
| \par Where: | | \par Where: | |
| - [float] represents the item spacing of the menu. | | - [float] represents the item spacing of the menu. | |
| */ | | */ | |
| class ItemSpacing : public Property | | class ItemSpacing : public Property | |
| { | | { | |
| public: | | public: | |
|
| ItemSpacing() : Property( | | ItemSpacing() : Property( | |
| "ItemSpacing", | | "ItemSpacing", | |
| "Property to get/set the item spacing of the menu. Value is | | "Property to get/set the item spacing of the menu. Value is a | |
| a float.", | | float.", | |
| "10.000000") | | "10.000000") | |
| {} | | {} | |
| | | | |
|
| String get(const PropertyReceiver* receiver) const; | | String get(const PropertyReceiver* receiver) const; | |
| void set(PropertyReceiver* receiver, const String& value); | | void set(PropertyReceiver* receiver, const String& value); | |
| }; | | }; | |
| | | | |
| /*! | | /*! | |
| \brief | | \brief | |
| Property to access the state of the allow multiple popups setting. | | Property to access the state of the allow multiple popups setting. | |
| | | | |
| \par Usage: | | \par Usage: | |
|
| - Name: AllowMultiplePopups | | - Name: AllowMultiplePopups | |
| - Format: "[text]". | | - Format: "[text]". | |
| | | | |
| \par Where [Text] is: | | \par Where [Text] is: | |
|
| - "True" to indicate that auto resizing is enabled. | | - "True" to indicate that auto resizing is enabled. | |
| - "False" to indicate that auto resizing is disabled. | | - "False" to indicate that auto resizing is disabled. | |
| */ | | */ | |
| class AllowMultiplePopups : public Property | | class AllowMultiplePopups : public Property | |
| { | | { | |
| public: | | public: | |
| AllowMultiplePopups() : Property( | | AllowMultiplePopups() : Property( | |
|
| "AllowMultiplePopups", | | "AllowMultiplePopups", | |
| "Property to get/set the state of the allow multiple popups sett | | "Property to get/set the state of the allow multiple popups set | |
| ing for the menu. Value is either \"True\" or \"False\".", | | ting for the menu. Value is either \"True\" or \"False\".", | |
| "False") | | "False") | |
| {} | | {} | |
| | | | |
|
| String get(const PropertyReceiver* receiver) const; | | String get(const PropertyReceiver* receiver) const; | |
| void set(PropertyReceiver* receiver, const String& value); | | void set(PropertyReceiver* receiver, const String& value); | |
| | | }; | |
| | | | |
| | | /*! | |
| | | \brief | |
| | | Property to set if the menu should close all its open child popups, whe | |
| | | n it gets hidden | |
| | | | |
| | | \par Usage: | |
| | | - Name: AutoCloseNestedPopups | |
| | | - Format: "[text]". | |
| | | | |
| | | \par Where [Text] is: | |
| | | - "True" to indicate that close on hidden is enabled. | |
| | | - "False" to indicate that close on hidden is disabled. | |
| | | */ | |
| | | class AutoCloseNestedPopups : public Property | |
| | | { | |
| | | public: | |
| | | AutoCloseNestedPopups() : Property( | |
| | | "AutoCloseNestedPopups", | |
| | | "Property to set if the menu should close all its open child po | |
| | | pups, when it gets hidden. Value is either \"True\" or \"False\".", | |
| | | "False") | |
| | | {} | |
| | | | |
| | | String get(const PropertyReceiver* receiver) const; | |
| | | void set(PropertyReceiver* receiver, const String& value); | |
| }; | | }; | |
| | | | |
| } // End of MenuBaseProperties namespace section | | } // End of MenuBaseProperties namespace section | |
| } // End of CEGUI namespace section | | } // End of CEGUI namespace section | |
| | | | |
|
| #endif // end of guard _CEGUIMenuBaseProperties_h_ | | #endif // end of guard _CEGUIMenuBaseProperties_h_ | |
| | | | |
End of changes. 11 change blocks. |
| 28 lines changed or deleted | | 54 lines changed or added | |
|
| CEGUIMenuItem.h | | CEGUIMenuItem.h | |
| /*********************************************************************** | | /*********************************************************************** | |
|
| filename: CEGUIMenuItem.h | | filename: CEGUIMenuItem.h | |
| created: 2/4/2005 | | created: 2/4/2005 | |
| author: Tomas Lindquist Olsen (based on code by Paul D Turne | | author: Tomas Lindquist Olsen (based on code by Paul D Turner) | |
| r) | | | |
| | | | |
|
| purpose: Interface to base class for MenuItem widget | | purpose: Interface to base class for MenuItem widget | |
| *************************************************************************/ | | *************************************************************************/ | |
| /**************************************************************************
* | | /**************************************************************************
* | |
| * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team | | * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team | |
| * | | * | |
| * Permission is hereby granted, free of charge, to any person obtaining | | * Permission is hereby granted, free of charge, to any person obtaining | |
| * a copy of this software and associated documentation files (the | | * a copy of this software and associated documentation files (the | |
| * "Software"), to deal in the Software without restriction, including | | * "Software"), to deal in the Software without restriction, including | |
| * without limitation the rights to use, copy, modify, merge, publish, | | * without limitation the rights to use, copy, modify, merge, publish, | |
| * distribute, sublicense, and/or sell copies of the Software, and to | | * distribute, sublicense, and/or sell copies of the Software, and to | |
| * permit persons to whom the Software is furnished to do so, subject to | | * permit persons to whom the Software is furnished to do so, subject to | |
| | | | |
| skipping to change at line 37 | | skipping to change at line 37 | |
| * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
| * OTHER DEALINGS IN THE SOFTWARE. | | * OTHER DEALINGS IN THE SOFTWARE. | |
| **************************************************************************
*/ | | **************************************************************************
*/ | |
| #ifndef _CEGUIMenuItem_h_ | | #ifndef _CEGUIMenuItem_h_ | |
| #define _CEGUIMenuItem_h_ | | #define _CEGUIMenuItem_h_ | |
| | | | |
| #include "../CEGUIBase.h" | | #include "../CEGUIBase.h" | |
| #include "../CEGUIWindow.h" | | #include "../CEGUIWindow.h" | |
| #include "CEGUIItemEntry.h" | | #include "CEGUIItemEntry.h" | |
| | | | |
|
| | | #include "CEGUIMenuItemProperties.h" | |
| | | | |
| | | #if defined(_MSC_VER) | |
| | | # pragma warning(push) | |
| | | # pragma warning(disable : 4251) | |
| | | #endif | |
| | | | |
| // Start of CEGUI namespace section | | // Start of CEGUI namespace section | |
| namespace CEGUI | | namespace CEGUI | |
| { | | { | |
| | | | |
| /*! | | /*! | |
| \brief | | \brief | |
|
| Base class for menu items. | | Base class for menu items. | |
| */ | | */ | |
| class CEGUIEXPORT MenuItem : public ItemEntry | | class CEGUIEXPORT MenuItem : public ItemEntry | |
| { | | { | |
| public: | | public: | |
|
| static const String EventNamespace; //!<
Namespace for global events | | static const String EventNamespace; //!< Namespace for glob
al events | |
| static const String WidgetTypeName; //!< Window factory nam
e | | static const String WidgetTypeName; //!< Window factory nam
e | |
| | | | |
|
| /******************************************************************* | | /********************************************************************** | |
| ****** | | *** | |
| Event name constants | | Event name constants | |
| ******************************************************************** | | *********************************************************************** | |
| *****/ | | **/ | |
| // generated internally by Window | | // generated internally by Window | |
| /** Event fired when the menu item is clicked. | | /** Event fired when the menu item is clicked. | |
| * Handlers are passed a const WindowEventArgs reference with | | * Handlers are passed a const WindowEventArgs reference with | |
| * WindowEventArgs::window set to the MenuItem that was clicked. | | * WindowEventArgs::window set to the MenuItem that was clicked. | |
| */ | | */ | |
|
| static const String EventClicked; | | static const String EventClicked; | |
| | | | |
|
| /******************************************************************* | | /********************************************************************** | |
| ****** | | *** | |
| Accessor type functions | | Accessor type functions | |
| ******************************************************************** | | *********************************************************************** | |
| *****/ | | **/ | |
| /*! | | /*! | |
| \brief | | \brief | |
| return true if user is hovering over this widget (or it's pu | | return true if user is hovering over this widget (or it's pushed an | |
| shed and user is not over it for highlight) | | d user is not over it for highlight) | |
| | | | |
|
| \return | | \return | |
| true if the user is hovering or if the button is pushed and | | true if the user is hovering or if the button is pushed and the mou | |
| the mouse is not over the button. Otherwise return false. | | se is not over the button. Otherwise return false. | |
| */ | | */ | |
| bool isHovering(void) const {return d_hovering;} | | bool isHovering(void) const | |
| | | { | |
| | | return d_hovering; | |
| | | } | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| Return true if the button widget is in the pushed state. | | Return true if the button widget is in the pushed state. | |
| | | | |
|
| \return | | \return | |
| true if the button-type widget is pushed, false if the widge | | true if the button-type widget is pushed, false if the widget is no | |
| t is not pushed. | | t pushed. | |
| */ | | */ | |
| bool isPushed(void) const {return d_pushed;} | | bool isPushed(void) const | |
| | | { | |
| | | return d_pushed; | |
| | | } | |
| | | | |
| /*! | | /*! | |
| \brief | | \brief | |
| Returns true if the popup menu attached to the menu item is open. | | Returns true if the popup menu attached to the menu item is open. | |
| */ | | */ | |
|
| bool isOpened(void) const {return d_opened;} | | bool isOpened(void) const | |
| | | { | |
| | | return d_opened; | |
| | | } | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| Get the PopupMenu that is currently attached to this MenuIte | | Returns true if the menu item popup is closing or not. | |
| m. | | */ | |
| | | bool isPopupClosing(void) const | |
| | | { | |
| | | return d_popupClosing; | |
| | | } | |
| | | | |
|
| \return | | /*! | |
| A pointer to the currently attached PopupMenu. Null is ther | | \brief | |
| e is no PopupMenu attached. | | Returns true if the menu item popup is closed or opened automatical | |
| */ | | ly if hovering with the mouse. | |
| PopupMenu* getPopupMenu(void) const {ret | | */ | |
| urn d_popup;} | | bool hasAutoPopup(void) const | |
| | | { | |
| | | return d_autoPopupTimeout > 0.0f; | |
| | | } | |
| | | | |
|
| /******************************************************************* | | /*! | |
| ****** | | \brief | |
| Manipulators | | Returns the time, which has to elapse before the popup window is op | |
| ******************************************************************** | | ened/closed if the hovering state changes. | |
| *****/ | | */ | |
| /*! | | float getAutoPopupTimeout(void) const | |
| \brief | | { | |
| Set the popup menu for this item. | | return d_autoPopupTimeout; | |
| | | } | |
| | | | |
|
| \param popup | | /*! | |
| popupmenu window to attach to this item | | \brief | |
| | | Sets the time, which has to elapse before the popup window is opene | |
| | | d/closed if the hovering state changes. | |
| | | */ | |
| | | void setAutoPopupTimeout(float time) | |
| | | { | |
| | | d_autoPopupTimeout = time; | |
| | | } | |
| | | | |
|
| \return | | /*! | |
| Nothing. | | \brief | |
| */ | | Get the PopupMenu that is currently attached to this MenuItem. | |
| void setPopupMenu(PopupMenu* popup); | | | |
| | | | |
|
| /*! | | \return | |
| \brief | | A pointer to the currently attached PopupMenu. Null is there is no | |
| Opens the PopupMenu. | | PopupMenu attached. | |
| | | */ | |
| | | PopupMenu* getPopupMenu(void) const | |
| | | { | |
| | | return d_popup; | |
| | | } | |
| | | | |
| | | /*! | |
| | | \brief | |
| | | Returns the current offset for popup placement. | |
| | | */ | |
| | | const UVector2& getPopupOffset(void) const | |
| | | { | |
| | | return d_popupOffset; | |
| | | } | |
| | | | |
| | | /*! | |
| | | \brief | |
| | | sets the current offset for popup placement. | |
| | | */ | |
| | | void setPopupOffset(const UVector2& popupOffset) | |
| | | { | |
| | | d_popupOffset = popupOffset; | |
| | | } | |
| | | | |
| | | /********************************************************************** | |
| | | *** | |
| | | Manipulators | |
| | | *********************************************************************** | |
| | | **/ | |
| | | /*! | |
| | | \brief | |
| | | Set the popup menu for this item. | |
| | | | |
| | | \param popup | |
| | | popupmenu window to attach to this item | |
| | | | |
| | | \return | |
| | | Nothing. | |
| | | */ | |
| | | void setPopupMenu(PopupMenu* popup); | |
| | | | |
| | | /*! | |
| | | \brief | |
| | | Opens the PopupMenu. | |
| | | | |
| \param notify | | \param notify | |
|
| true if the parent menu bar or menu popup (if any) is to han | | true if the parent menu bar or menu popup (if any) is to handle the | |
| dle the open. | | open. | |
| */ | | */ | |
| void openPopupMenu(bool notify=true); | | void openPopupMenu(bool notify = true); | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| Closes the PopupMenu. | | Closes the PopupMenu. | |
| | | | |
|
| \param notify | | \param notify | |
| true if the parent menubar (if any) is to handle the close. | | true if the parent menubar (if any) is to handle the close. | |
| | | | |
|
| \return | | \return | |
| Nothing. | | Nothing. | |
| */ | | */ | |
| void closePopupMenu(bool notify=true); | | void closePopupMenu(bool notify = true); | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| Toggles the PopupMenu. | | Toggles the PopupMenu. | |
| | | | |
|
| \return | | \return | |
| true if the popup was opened. false if it was closed. | | true if the popup was opened. false if it was closed. | |
| */ | | */ | |
| bool togglePopupMenu(void); | | bool togglePopupMenu(void); | |
| | | | |
|
| /******************************************************************* | | /*! | |
| ****** | | \brief | |
| Construction and Destruction | | starts the closing timer for the popup, which will close it if the | |
| ******************************************************************** | | timer is enabled. | |
| *****/ | | */ | |
| /*! | | void startPopupClosing(void); | |
| \brief | | | |
| Constructor for MenuItem objects | | | |
| */ | | | |
| MenuItem(const String& type, const String& name); | | | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| Destructor for MenuItem objects | | starts the opening timer for the popup, which will open it if the t | |
| */ | | imer is enabled. | |
| virtual ~MenuItem(void); | | */ | |
| | | void startPopupOpening(void); | |
| | | /********************************************************************** | |
| | | *** | |
| | | Construction and Destruction | |
| | | *********************************************************************** | |
| | | **/ | |
| | | /*! | |
| | | \brief | |
| | | Constructor for MenuItem objects | |
| | | */ | |
| | | MenuItem(const String& type, const String& name); | |
| | | | |
| | | /*! | |
| | | \brief | |
| | | Destructor for MenuItem objects | |
| | | */ | |
| | | virtual ~MenuItem(void); | |
| | | | |
| protected: | | protected: | |
|
| /******************************************************************* | | /********************************************************************** | |
| ****** | | *** | |
| New Event Handlers | | New Event Handlers | |
| ******************************************************************** | | *********************************************************************** | |
| *****/ | | **/ | |
| /*! | | /*! | |
| \brief | | \brief | |
| handler invoked internally when the MenuItem is clicked. | | handler invoked internally when the MenuItem is clicked. | |
| */ | | */ | |
| virtual void onClicked(WindowEventArgs& e); | | virtual void onClicked(WindowEventArgs& e); | |
| | | | |
|
| /******************************************************************* | | /********************************************************************** | |
| ****** | | *** | |
| Overridden event handlers | | Overridden event handlers | |
| ******************************************************************** | | *********************************************************************** | |
| *****/ | | **/ | |
| virtual void onMouseMove(MouseEventArgs& e); | | virtual void onMouseMove(MouseEventArgs& e); | |
| virtual void onMouseButtonDown(MouseEventArgs& e); | | virtual void onMouseButtonDown(MouseEventArgs& e); | |
| virtual void onMouseButtonUp(MouseEventArgs& e); | | virtual void onMouseButtonUp(MouseEventArgs& e); | |
| virtual void onCaptureLost(WindowEventArgs& e); | | virtual void onCaptureLost(WindowEventArgs& e); | |
| virtual void onMouseLeaves(MouseEventArgs& e); | | virtual void onMouseLeaves(MouseEventArgs& e); | |
| virtual void onTextChanged(WindowEventArgs& e); | | virtual void onTextChanged(WindowEventArgs& e); | |
| | | virtual void updateSelf(float elapsed); | |
| | | | |
|
| /******************************************************************* | | /********************************************************************** | |
| ****** | | *** | |
| Implementation Functions | | Implementation Functions | |
| ******************************************************************** | | *********************************************************************** | |
| *****/ | | **/ | |
| /*! | | /*! | |
| \brief | | \brief | |
| Update the internal state of the widget with the mouse at th | | Update the internal state of the widget with the mouse at the given | |
| e given position. | | position. | |
| | | | |
|
| \param mouse_pos | | \param mouse_pos | |
| Point object describing, in screen pixel co-ordinates, the l | | Point object describing, in screen pixel co-ordinates, the location | |
| ocation of the mouse cursor. | | of the mouse cursor. | |
| | | | |
|
| \return | | \return | |
| Nothing | | Nothing | |
| */ | | */ | |
| void updateInternalState(const Point& mouse_pos); | | void updateInternalState(const Point& mouse_pos); | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| Recursive function that closes all popups down the hierarcy | | Recursive function that closes all popups down the hierarcy startin | |
| starting with this one. | | g with this one. | |
| | | | |
|
| \return | | \return | |
| Nothing. | | Nothing. | |
| */ | | */ | |
| void closeAllMenuItemPopups(); | | void closeAllMenuItemPopups(); | |
| | | | |
| /*! | | /*! | |
|
| \brief | | \brief | |
| Set the popup menu for this item. | | Set the popup menu for this item. | |
| | | | |
|
| \param popup | | \param popup | |
| popupmenu window to attach to this item | | popupmenu window to attach to this item | |
| | | | |
|
| \return | | \return | |
| Nothing. | | Nothing. | |
| */ | | */ | |
| void setPopupMenu_impl(PopupMenu* popup,bool add_as_child=true); | | void setPopupMenu_impl(PopupMenu* popup, bool add_as_child = true); | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| Return whether this window was inherited from the given clas | | Return whether this window was inherited from the given class name | |
| s name at some point in the inheritance hierarchy. | | at some point in the inheritance hierarchy. | |
| | | | |
|
| \param class_name | | \param class_name | |
| The class name that is to be checked. | | The class name that is to be checked. | |
| | | | |
|
| \return | | \return | |
| true if this window was inherited from \a class_name. false | | true if this window was inherited from \a class_name. false if not. | |
| if not. | | */ | |
| */ | | virtual bool testClassName_impl(const String& class_name) const | |
| virtual bool testClassName_impl(const String& class_name) const | | { | |
| { | | if (class_name == "MenuItem") return true; | |
| if (class_name=="MenuItem") return true; | | | |
| return ItemEntry::testClassName_impl(class_name); | | | |
| } | | | |
| | | | |
|
| /******************************************************************* | | return ItemEntry::testClassName_impl(class_name); | |
| ****** | | } | |
| Implementation Data | | | |
| ******************************************************************** | | | |
| *****/ | | | |
| bool d_pushed; //!< true when widget is pushed | | | |
| bool d_hovering; //!< true when the button is in 'hov | | | |
| er' state and requires the hover rendering. | | | |
| bool d_opened; //!< true when the menu item's popup | | | |
| menu is in its opened state. | | | |
| | | | |
|
| PopupMenu* d_popup; //!< PopupMenu that this item displays when | | /********************************************************************** | |
| activated. | | *** | |
| | | Implementation Data | |
| | | *********************************************************************** | |
| | | **/ | |
| | | bool d_pushed; //!< true when widget is pushed | |
| | | bool d_hovering; //!< true when the button is in 'hover' state a | |
| | | nd requires the hover rendering. | |
| | | bool d_opened; //!< true when the menu item's popup menu is in | |
| | | its opened state. | |
| | | bool d_popupClosing; //!< true when the d_popupTimerTimeElapsed time | |
| | | r is running to close the popup (another menu item of our container is hove | |
| | | red) | |
| | | bool d_popupOpening; //!< true when the d_popupTimerTimeElapsed time | |
| | | r is running to open the popup (the menu item is hovered) | |
| | | float d_autoPopupTimeout; //!< the time in seconds, to wait before open | |
| | | ing / closing the popup if the mouse is over the item / over another item i | |
| | | n our container | |
| | | float d_autoPopupTimeElapsed; //!< the current time, which is already | |
| | | elapsed if the timer is running (d_popupClosing or d_popupOpening is true) | |
| | | | |
|
| bool d_popupWasClosed; //!< Used internally to determine if a popup | | PopupMenu* d_popup; //!< PopupMenu that this item displays when act | |
| was just closed on a Clicked event | | ivated. | |
| | | | |
| | | bool d_popupWasClosed; //!< Used internally to determine if a popup wa | |
| | | s just closed on a Clicked event | |
| | | | |
| | | UVector2 d_popupOffset; //!< current offset for popup placement. | |
| | | | |
| private: | | private: | |
|
| | | /********************************************************************** | |
| | | ** | |
| | | Static Properties for this class | |
| | | *********************************************************************** | |
| | | */ | |
| | | static MenuItemProperties::PopupOffset d_popupOffsetProperty; | |
| | | static MenuItemProperties::AutoPopupTimeout d_autoPopupTimeoutProperty; | |
| | | | |
| /**********************************************************************
*** | | /**********************************************************************
*** | |
|
| Private methods | | Private methods | |
| ******************************************************************** | | *********************************************************************** | |
| *****/ | | **/ | |
| void addMenuItemProperties(void); | | void addMenuItemProperties(void); | |
| | | | |
|
| /*! | | /*! | |
| \brief | | \brief | |
| Add given window to child list at an appropriate position | | Add given window to child list at an appropriate position | |
| */ | | */ | |
| virtual void addChild_impl(Window* wnd); | | virtual void addChild_impl(Window* wnd); | |
| }; | | }; | |
| | | | |
| } // End of CEGUI namespace section | | } // End of CEGUI namespace section | |
| | | | |
|
| #endif // end of guard _CEGUIMenuItem_h_ | | #if defined(_MSC_VER) | |
| | | # pragma warning(pop) | |
| | | #endif | |
| | | | |
| | | #endif // end of guard _CEGUIMenuItem_h_ | |
| | | | |
End of changes. 46 change blocks. |
| 190 lines changed or deleted | | 297 lines changed or added | |
|