| 1 | /* |
|---|
| 2 | ----------------------------------------------------------------------------- |
|---|
| 3 | This source file is part of OGRE |
|---|
| 4 | (Object-oriented Graphics Rendering Engine) |
|---|
| 5 | For the latest info, see http://www.ogre3d.org/ |
|---|
| 6 | |
|---|
| 7 | Copyright (c) 2000-2013 Torus Knot Software Ltd |
|---|
| 8 | |
|---|
| 9 | Permission is hereby granted, free of charge, to any person obtaining a copy |
|---|
| 10 | of this software and associated documentation files (the "Software"), to deal |
|---|
| 11 | in the Software without restriction, including without limitation the rights |
|---|
| 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|---|
| 13 | copies of the Software, and to permit persons to whom the Software is |
|---|
| 14 | furnished to do so, subject to the following conditions: |
|---|
| 15 | |
|---|
| 16 | The above copyright notice and this permission notice shall be included in |
|---|
| 17 | all copies or substantial portions of the Software. |
|---|
| 18 | |
|---|
| 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|---|
| 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|---|
| 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|---|
| 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|---|
| 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|---|
| 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|---|
| 25 | THE SOFTWARE. |
|---|
| 26 | ----------------------------------------------------------------------------- |
|---|
| 27 | */ |
|---|
| 28 | |
|---|
| 29 | #ifndef __OverlayContainer_H__ |
|---|
| 30 | #define __OverlayContainer_H__ |
|---|
| 31 | |
|---|
| 32 | #include "OgreOverlayPrerequisites.h" |
|---|
| 33 | #include "OgreOverlayElement.h" |
|---|
| 34 | #include "OgreIteratorWrappers.h" |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | namespace Ogre { |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | /** \addtogroup Core |
|---|
| 41 | * @{ |
|---|
| 42 | */ |
|---|
| 43 | /** \addtogroup Overlays |
|---|
| 44 | * @{ |
|---|
| 45 | */ |
|---|
| 46 | /** A 2D element which contains other OverlayElement instances. |
|---|
| 47 | @remarks |
|---|
| 48 | This is a specialisation of OverlayElement for 2D elements that contain other |
|---|
| 49 | elements. These are also the smallest elements that can be attached directly |
|---|
| 50 | to an Overlay. |
|---|
| 51 | @remarks |
|---|
| 52 | OverlayContainers should be managed using OverlayManager. This class is responsible for |
|---|
| 53 | instantiating / deleting elements, and also for accepting new types of element |
|---|
| 54 | from plugins etc. |
|---|
| 55 | */ |
|---|
| 56 | class _OgreOverlayExport OverlayContainer : public OverlayElement |
|---|
| 57 | { |
|---|
| 58 | public: |
|---|
| 59 | typedef map<String, OverlayElement*>::type ChildMap; |
|---|
| 60 | typedef MapIterator<ChildMap> ChildIterator; |
|---|
| 61 | typedef map<String, OverlayContainer*>::type ChildContainerMap; |
|---|
| 62 | typedef MapIterator<ChildContainerMap> ChildContainerIterator; |
|---|
| 63 | protected: |
|---|
| 64 | /// Map of all children |
|---|
| 65 | ChildMap mChildren; |
|---|
| 66 | /// Map of container children (subset of mChildren) |
|---|
| 67 | ChildContainerMap mChildContainers; |
|---|
| 68 | |
|---|
| 69 | bool mChildrenProcessEvents; |
|---|
| 70 | |
|---|
| 71 | public: |
|---|
| 72 | /// Constructor: do not call direct, use OverlayManager::createOverlayElement |
|---|
| 73 | OverlayContainer(const String& name); |
|---|
| 74 | virtual ~OverlayContainer(); |
|---|
| 75 | |
|---|
| 76 | /** Adds another OverlayElement to this container. */ |
|---|
| 77 | virtual void addChild(OverlayElement* elem); |
|---|
| 78 | /** Adds another OverlayElement to this container. */ |
|---|
| 79 | virtual void addChildImpl(OverlayElement* elem); |
|---|
| 80 | /** Add a nested container to this container. */ |
|---|
| 81 | virtual void addChildImpl(OverlayContainer* cont); |
|---|
| 82 | /** Removes a named element from this container. */ |
|---|
| 83 | virtual void removeChild(const String& name); |
|---|
| 84 | /** Gets the named child of this container. */ |
|---|
| 85 | virtual OverlayElement* getChild(const String& name); |
|---|
| 86 | |
|---|
| 87 | /** @copydoc OverlayElement::initialise */ |
|---|
| 88 | void initialise(void); |
|---|
| 89 | |
|---|
| 90 | void _addChild(OverlayElement* elem); |
|---|
| 91 | void _removeChild(OverlayElement* elem) { _removeChild(elem->getName()); } |
|---|
| 92 | void _removeChild(const String& name); |
|---|
| 93 | |
|---|
| 94 | /** Gets an object for iterating over all the children of this object. */ |
|---|
| 95 | virtual ChildIterator getChildIterator(void); |
|---|
| 96 | |
|---|
| 97 | /** Gets an iterator for just the container children of this object. |
|---|
| 98 | @remarks |
|---|
| 99 | Good for cascading updates without having to use RTTI |
|---|
| 100 | */ |
|---|
| 101 | virtual ChildContainerIterator getChildContainerIterator(void); |
|---|
| 102 | |
|---|
| 103 | /** Tell the object and its children to recalculate */ |
|---|
| 104 | virtual void _positionsOutOfDate(void); |
|---|
| 105 | |
|---|
| 106 | /** Overridden from OverlayElement. */ |
|---|
| 107 | virtual void _update(void); |
|---|
| 108 | |
|---|
| 109 | /** Overridden from OverlayElement. */ |
|---|
| 110 | virtual ushort _notifyZOrder(ushort newZOrder); |
|---|
| 111 | |
|---|
| 112 | /** Overridden from OverlayElement. */ |
|---|
| 113 | virtual void _notifyViewport(); |
|---|
| 114 | |
|---|
| 115 | /** Overridden from OverlayElement. */ |
|---|
| 116 | virtual void _notifyWorldTransforms(const Matrix4& xform); |
|---|
| 117 | |
|---|
| 118 | /** Overridden from OverlayElement. */ |
|---|
| 119 | virtual void _notifyParent(OverlayContainer* parent, Overlay* overlay); |
|---|
| 120 | |
|---|
| 121 | /** Overridden from OverlayElement. */ |
|---|
| 122 | virtual void _updateRenderQueue(RenderQueue* queue); |
|---|
| 123 | |
|---|
| 124 | /** Overridden from OverlayElement. */ |
|---|
| 125 | inline bool isContainer() const |
|---|
| 126 | { return true; } |
|---|
| 127 | |
|---|
| 128 | /** Should this container pass events to their children */ |
|---|
| 129 | virtual inline bool isChildrenProcessEvents() const |
|---|
| 130 | { return true; } |
|---|
| 131 | |
|---|
| 132 | /** Should this container pass events to their children */ |
|---|
| 133 | virtual inline void setChildrenProcessEvents(bool val) |
|---|
| 134 | { mChildrenProcessEvents = val; } |
|---|
| 135 | |
|---|
| 136 | /** This returns a OverlayElement at position x,y. */ |
|---|
| 137 | virtual OverlayElement* findElementAt(Real x, Real y); // relative to parent |
|---|
| 138 | |
|---|
| 139 | void copyFromTemplate(OverlayElement* templateOverlay); |
|---|
| 140 | virtual OverlayElement* clone(const String& instanceName); |
|---|
| 141 | |
|---|
| 142 | }; |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | /** @} */ |
|---|
| 146 | /** @} */ |
|---|
| 147 | |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | #endif |
|---|
| 152 | |
|---|