| 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-2006 Torus Knot Software Ltd |
|---|
| 8 | Also see acknowledgements in Readme.html |
|---|
| 9 | |
|---|
| 10 | This program is free software; you can redistribute it and/or modify it under |
|---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software |
|---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later |
|---|
| 13 | version. |
|---|
| 14 | |
|---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
|---|
| 18 | |
|---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with |
|---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
|---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
|---|
| 22 | http://www.gnu.org/copyleft/lesser.txt. |
|---|
| 23 | |
|---|
| 24 | You may alternatively use this source under the terms of a specific version of |
|---|
| 25 | the OGRE Unrestricted License provided you have obtained such a license from |
|---|
| 26 | Torus Knot Software Ltd. |
|---|
| 27 | ----------------------------------------------------------------------------- |
|---|
| 28 | */ |
|---|
| 29 | |
|---|
| 30 | #ifndef __OverlayContainer_H__ |
|---|
| 31 | #define __OverlayContainer_H__ |
|---|
| 32 | |
|---|
| 33 | #include "OgrePrerequisites.h" |
|---|
| 34 | #include "OgreOverlayElement.h" |
|---|
| 35 | #include "OgreIteratorWrappers.h" |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | namespace Ogre { |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | /** A 2D element which contains other OverlayElement instances. |
|---|
| 42 | @remarks |
|---|
| 43 | This is a specialisation of OverlayElement for 2D elements that contain other |
|---|
| 44 | elements. These are also the smallest elements that can be attached directly |
|---|
| 45 | to an Overlay. |
|---|
| 46 | @remarks |
|---|
| 47 | OverlayContainers should be managed using OverlayManager. This class is responsible for |
|---|
| 48 | instantiating / deleting elements, and also for accepting new types of element |
|---|
| 49 | from plugins etc. |
|---|
| 50 | */ |
|---|
| 51 | class _OgreExport OverlayContainer : public OverlayElement |
|---|
| 52 | { |
|---|
| 53 | public: |
|---|
| 54 | typedef std::map<String, OverlayElement*> ChildMap; |
|---|
| 55 | typedef MapIterator<ChildMap> ChildIterator; |
|---|
| 56 | typedef std::map<String, OverlayContainer*> ChildContainerMap; |
|---|
| 57 | typedef MapIterator<ChildContainerMap> ChildContainerIterator; |
|---|
| 58 | protected: |
|---|
| 59 | // Map of all children |
|---|
| 60 | ChildMap mChildren; |
|---|
| 61 | // Map of container children (subset of mChildren) |
|---|
| 62 | ChildContainerMap mChildContainers; |
|---|
| 63 | |
|---|
| 64 | bool mChildrenProcessEvents; |
|---|
| 65 | |
|---|
| 66 | public: |
|---|
| 67 | /// Constructor: do not call direct, use OverlayManager::createOverlayElement |
|---|
| 68 | OverlayContainer(const String& name); |
|---|
| 69 | virtual ~OverlayContainer(); |
|---|
| 70 | |
|---|
| 71 | /** Adds another OverlayElement to this container. */ |
|---|
| 72 | virtual void addChild(OverlayElement* elem); |
|---|
| 73 | /** Adds another OverlayElement to this container. */ |
|---|
| 74 | virtual void addChildImpl(OverlayElement* elem); |
|---|
| 75 | /** Add a nested container to this container. */ |
|---|
| 76 | virtual void addChildImpl(OverlayContainer* cont); |
|---|
| 77 | /** Removes a named element from this container. */ |
|---|
| 78 | virtual void removeChild(const String& name); |
|---|
| 79 | /** Gets the named child of this container. */ |
|---|
| 80 | virtual OverlayElement* getChild(const String& name); |
|---|
| 81 | |
|---|
| 82 | /** @copydoc OverlayElement::initialise */ |
|---|
| 83 | void initialise(void); |
|---|
| 84 | |
|---|
| 85 | void _addChild(OverlayElement* elem); |
|---|
| 86 | void _removeChild(OverlayElement* elem) { _removeChild(elem->getName()); } |
|---|
| 87 | void _removeChild(const String& name); |
|---|
| 88 | |
|---|
| 89 | /** Gets an object for iterating over all the children of this object. */ |
|---|
| 90 | virtual ChildIterator getChildIterator(void); |
|---|
| 91 | |
|---|
| 92 | /** Gets an iterator for just the container children of this object. |
|---|
| 93 | @remarks |
|---|
| 94 | Good for cascading updates without having to use RTTI |
|---|
| 95 | */ |
|---|
| 96 | virtual ChildContainerIterator getChildContainerIterator(void); |
|---|
| 97 | |
|---|
| 98 | /** Tell the object and its children to recalculate */ |
|---|
| 99 | virtual void _positionsOutOfDate(void); |
|---|
| 100 | |
|---|
| 101 | /** Overridden from OverlayElement. */ |
|---|
| 102 | virtual void _update(void); |
|---|
| 103 | |
|---|
| 104 | /** Overridden from OverlayElement. */ |
|---|
| 105 | virtual void _notifyZOrder(ushort newZOrder); |
|---|
| 106 | |
|---|
| 107 | /** Overridden from OverlayElement. */ |
|---|
| 108 | virtual void _notifyViewport(); |
|---|
| 109 | |
|---|
| 110 | /** Overridden from OverlayElement. */ |
|---|
| 111 | virtual void _notifyWorldTransforms(const Matrix4& xform); |
|---|
| 112 | |
|---|
| 113 | /** Overridden from OverlayElement. */ |
|---|
| 114 | virtual void _notifyParent(OverlayContainer* parent, Overlay* overlay); |
|---|
| 115 | |
|---|
| 116 | /** Overridden from OverlayElement. */ |
|---|
| 117 | virtual void _updateRenderQueue(RenderQueue* queue); |
|---|
| 118 | |
|---|
| 119 | /** Overridden from OverlayElement. */ |
|---|
| 120 | inline bool isContainer() const |
|---|
| 121 | { return true; } |
|---|
| 122 | |
|---|
| 123 | /** Should this container pass events to their children */ |
|---|
| 124 | virtual inline bool isChildrenProcessEvents() const |
|---|
| 125 | { return true; } |
|---|
| 126 | |
|---|
| 127 | /** Should this container pass events to their children */ |
|---|
| 128 | virtual inline void setChildrenProcessEvents(bool val) |
|---|
| 129 | { mChildrenProcessEvents = val; } |
|---|
| 130 | |
|---|
| 131 | /** This returns a OverlayElement at position x,y. */ |
|---|
| 132 | virtual OverlayElement* findElementAt(Real x, Real y); // relative to parent |
|---|
| 133 | |
|---|
| 134 | void copyFromTemplate(OverlayElement* templateOverlay); |
|---|
| 135 | virtual OverlayElement* clone(const String& instanceName); |
|---|
| 136 | |
|---|
| 137 | }; |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | |
|---|
| 144 | #endif |
|---|
| 145 | |
|---|