source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreOverlayElementFactory.h @ 1812

Revision 1812, 4.2 KB checked in by gumbau, 18 years ago (diff)
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef __OverlayElementFactory_H__
26#define __OverlayElementFactory_H__
27
28#include "OgrePrerequisites.h"
29#include "OgreOverlayElement.h"
30#include "OgrePanelOverlayElement.h"
31#include "OgreBorderPanelOverlayElement.h"
32#include "OgreTextAreaOverlayElement.h"
33
34namespace Ogre {
35
36    /** Defines the interface which all components wishing to
37        supply OverlayElement subclasses must implement.
38    @remarks
39        To allow the OverlayElement types available for inclusion on
40        overlays to be extended, OGRE allows external apps or plugins
41        to register their ability to create custom OverlayElements with
42        the OverlayManager, using the addOverlayElementFactory method. Classes
43        wanting to do this must implement this interface.
44    @par
45        Each OverlayElementFactory creates a single type of OverlayElement,
46        identified by a 'type name' which must be unique.
47    */
48    class _OgreExport OverlayElementFactory
49    {
50    public:
51        /** Creates a new OverlayElement instance with the name supplied. */
52        virtual OverlayElement* createOverlayElement(const String& instanceName) = 0;
53        /** Destroys a OverlayElement which this factory created previously. */
54        virtual void destroyOverlayElement(OverlayElement* pElement) { delete pElement; };
55        /** Gets the string uniquely identifying the type of element this factory creates. */
56        virtual const String& getTypeName(void) const = 0;
57    };
58
59
60    /** Factory for creating PanelOverlayElement instances. */
61    class _OgreExport PanelOverlayElementFactory: public OverlayElementFactory
62    {
63    public:
64        /** See OverlayElementFactory */
65        OverlayElement* createOverlayElement(const String& instanceName)
66        {
67            return new PanelOverlayElement(instanceName);
68        }
69        /** See OverlayElementFactory */
70        const String& getTypeName(void) const
71        {
72            static String name = "Panel";
73            return name;
74        }
75    };
76
77    /** Factory for creating BorderPanelOverlayElement instances. */
78    class _OgreExport BorderPanelOverlayElementFactory: public OverlayElementFactory
79    {
80    public:
81        /** See OverlayElementFactory */
82        OverlayElement* createOverlayElement(const String& instanceName)
83        {
84            return new BorderPanelOverlayElement(instanceName);
85        }
86        /** See OverlayElementFactory */
87        const String& getTypeName(void) const
88        {
89            static String name = "BorderPanel";
90            return name;
91        }
92    };
93
94    /** Factory for creating TextAreaOverlayElement instances. */
95    class _OgreExport TextAreaOverlayElementFactory: public OverlayElementFactory
96    {
97    public:
98        /** See OverlayElementFactory */
99        OverlayElement* createOverlayElement(const String& instanceName)
100        {
101            return new TextAreaOverlayElement(instanceName);
102        }
103        /** See OverlayElementFactory */
104        const String& getTypeName(void) const
105        {
106            static String name = "TextArea";
107            return name;
108        }
109    };
110
111}
112
113
114
115#endif
Note: See TracBrowser for help on using the repository browser.