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 | #ifndef __OverlayElementFactory_H__ |
---|
29 | #define __OverlayElementFactory_H__ |
---|
30 | |
---|
31 | #include "OgreOverlayPrerequisites.h" |
---|
32 | #include "OgreOverlayElement.h" |
---|
33 | #include "OgrePanelOverlayElement.h" |
---|
34 | #include "OgreBorderPanelOverlayElement.h" |
---|
35 | #include "OgreTextAreaOverlayElement.h" |
---|
36 | |
---|
37 | namespace Ogre { |
---|
38 | |
---|
39 | /** \addtogroup Core |
---|
40 | * @{ |
---|
41 | */ |
---|
42 | /** \addtogroup Overlays |
---|
43 | * @{ |
---|
44 | */ |
---|
45 | /** Defines the interface which all components wishing to |
---|
46 | supply OverlayElement subclasses must implement. |
---|
47 | @remarks |
---|
48 | To allow the OverlayElement types available for inclusion on |
---|
49 | overlays to be extended, OGRE allows external apps or plugins |
---|
50 | to register their ability to create custom OverlayElements with |
---|
51 | the OverlayManager, using the addOverlayElementFactory method. Classes |
---|
52 | wanting to do this must implement this interface. |
---|
53 | @par |
---|
54 | Each OverlayElementFactory creates a single type of OverlayElement, |
---|
55 | identified by a 'type name' which must be unique. |
---|
56 | */ |
---|
57 | class _OgreOverlayExport OverlayElementFactory : public OverlayAlloc |
---|
58 | { |
---|
59 | public: |
---|
60 | /** Destroy the overlay element factory */ |
---|
61 | virtual ~OverlayElementFactory () {} |
---|
62 | /** Creates a new OverlayElement instance with the name supplied. */ |
---|
63 | virtual OverlayElement* createOverlayElement(const String& instanceName) = 0; |
---|
64 | /** Destroys a OverlayElement which this factory created previously. */ |
---|
65 | virtual void destroyOverlayElement(OverlayElement* pElement) { delete pElement; } |
---|
66 | /** Gets the string uniquely identifying the type of element this factory creates. */ |
---|
67 | virtual const String& getTypeName(void) const = 0; |
---|
68 | }; |
---|
69 | |
---|
70 | |
---|
71 | /** Factory for creating PanelOverlayElement instances. */ |
---|
72 | class _OgreOverlayExport PanelOverlayElementFactory: public OverlayElementFactory |
---|
73 | { |
---|
74 | public: |
---|
75 | /** See OverlayElementFactory */ |
---|
76 | OverlayElement* createOverlayElement(const String& instanceName) |
---|
77 | { |
---|
78 | return OGRE_NEW PanelOverlayElement(instanceName); |
---|
79 | } |
---|
80 | /** See OverlayElementFactory */ |
---|
81 | virtual const String& getTypeName(void) const; |
---|
82 | }; |
---|
83 | |
---|
84 | /** Factory for creating BorderPanelOverlayElement instances. */ |
---|
85 | class _OgreOverlayExport BorderPanelOverlayElementFactory: public OverlayElementFactory |
---|
86 | { |
---|
87 | public: |
---|
88 | /** See OverlayElementFactory */ |
---|
89 | OverlayElement* createOverlayElement(const String& instanceName) |
---|
90 | { |
---|
91 | return OGRE_NEW BorderPanelOverlayElement(instanceName); |
---|
92 | } |
---|
93 | /** See OverlayElementFactory */ |
---|
94 | virtual const String& getTypeName(void) const; |
---|
95 | }; |
---|
96 | |
---|
97 | /** Factory for creating TextAreaOverlayElement instances. */ |
---|
98 | class _OgreOverlayExport TextAreaOverlayElementFactory: public OverlayElementFactory |
---|
99 | { |
---|
100 | public: |
---|
101 | /** See OverlayElementFactory */ |
---|
102 | OverlayElement* createOverlayElement(const String& instanceName) |
---|
103 | { |
---|
104 | return OGRE_NEW TextAreaOverlayElement(instanceName); |
---|
105 | } |
---|
106 | /** See OverlayElementFactory */ |
---|
107 | virtual const String& getTypeName(void) const; |
---|
108 | }; |
---|
109 | /** @} */ |
---|
110 | /** @} */ |
---|
111 | |
---|
112 | } |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | #endif |
---|