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

Revision 1812, 7.8 KB checked in by gumbau, 18 years ago (diff)
Line 
1/************************************************************************
2        filename:       CEGUIImagesetManager.h
3        created:        21/2/2004
4        author:         Paul D Turner
5       
6        purpose:        Defines interface for ImagesetManager object
7*************************************************************************/
8/*************************************************************************
9    Crazy Eddie's GUI System (http://www.cegui.org.uk)
10    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
11
12    This library is free software; you can redistribute it and/or
13    modify it under the terms of the GNU Lesser General Public
14    License as published by the Free Software Foundation; either
15    version 2.1 of the License, or (at your option) any later version.
16
17    This library is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20    Lesser General Public License for more details.
21
22    You should have received a copy of the GNU Lesser General Public
23    License along with this library; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25*************************************************************************/
26#ifndef _CEGUIImagesetManager_h_
27#define _CEGUIImagesetManager_h_
28
29#include "CEGUIBase.h"
30#include "CEGUIString.h"
31#include "CEGUISingleton.h"
32#include "CEGUIIteratorBase.h"
33#include <map>
34
35
36#if defined(_MSC_VER)
37#       pragma warning(push)
38#       pragma warning(disable : 4275)
39#       pragma warning(disable : 4251)
40#endif
41
42
43// Start of CEGUI namespace section
44namespace CEGUI
45{
46/*!
47\brief
48        Class providing a shared library of Imageset objects to the system.
49
50        The ImagesetManager is used to create, access, and destroy Imageset objects.  The idea is that
51        the ImagesetManager will function as a central repository for imagery used within the GUI system,
52        and that such imagery can be accessed, via a unique name, by any interested party within the system.
53*/
54class CEGUIEXPORT ImagesetManager : public Singleton<ImagesetManager>
55{
56public:
57        /*!
58        \brief
59                Constructor for ImagesetManager objects
60        */
61        ImagesetManager(void);
62
63
64        /*!
65        \brief
66                Destructor for ImagesetManager objects
67        */
68        ~ImagesetManager(void);
69
70
71        /*!
72        \brief
73                Return singleton ImagesetManager object
74
75        \return
76                Singleton ImagesetManager object
77        */
78        static  ImagesetManager&        getSingleton(void);
79
80
81        /*!
82        \brief
83                Return pointer to singleton ImagesetManager object
84
85        \return
86                Pointer to singleton ImagesetManager object
87        */
88        static  ImagesetManager*        getSingletonPtr(void);
89
90
91        /*!
92        \brief
93                Create a Imageset object with the given name and Texture
94
95                The created Imageset will be of limited use, and will require one or more images to be defined for the set.
96
97        \param name
98                String object containing the unique name for the Imageset being created.
99
100        \param texture
101                Texture object to be associated with the Imageset
102
103        \return
104                Pointer to the newly created Imageset object
105
106        \exception AlreadyExistsException       Thrown if an Imageset named \a name is already present in the system.
107        */
108        Imageset*       createImageset(const String& name, Texture* texture);
109
110        /*!
111        \brief
112                Create an Imageset object from the specified file
113
114        \param filename
115                String object holding the name of the Imageset definition file which should be used to create the Imageset
116
117    \param resourceGroup
118        Resource group identifier to be passed to the resource manager.  NB: This affects the
119        imageset xml file only, the texture loaded may have its own group specified in the XML file.
120
121        \return
122                Pointer to the newly created Imageset object
123
124        \exception      AlreadyExistsException  Thrown if an Imageset named \a name is already present in the system.
125        \exception      FileIOException                 Thrown if something goes wrong while processing the file \a filename.
126        */
127        Imageset*       createImageset(const String& filename, const String& resourceGroup = "");
128
129
130    /*!
131    \brief
132        Create an Imageset object from the specified image file.  The Imageset will initially have a single
133        image defined named "full_image" which is an image that represents the entire area of the loaded image.
134
135    \param name
136        String object containing the unique name for the Imageset being created.
137
138    \param filename
139        String object holding the name of the image file to be loaded.
140
141    \param resourceGroup
142        Resource group identifier to be passed to the resource manager when loading the image file.
143
144    \return
145        Pointer to the newly created Imageset object
146
147    \exception  AlreadyExistsException  Thrown if an Imageset named \a name is already present in the system.
148    \exception  FileIOException                 Thrown if something goes wrong while reading the image file \a filename.
149    */
150    Imageset* createImagesetFromImageFile(const String& name, const String& filename, const String& resourceGroup = "");
151
152
153        /*!
154        \brief
155                Destroys the Imageset with the specified name
156
157        \param name
158                String object containing the name of the Imageset to be destroyed.  If no such Imageset exists, nothing happens.
159
160        \return
161                Nothing.
162        */
163        void    destroyImageset(const String& name);
164
165        /*!
166        \brief
167                Destroys the given Imageset object
168
169        \param imageset
170                Pointer to the Imageset to be destroyed.  If no such Imageset exists, nothing happens.
171
172        \return
173                Nothing.
174        */
175        void    destroyImageset(Imageset* imageset);
176
177
178        /*!
179        \brief
180                Destroys all Imageset objects registered in the system
181
182        \return
183                Nothing
184        */
185        void    destroyAllImagesets(void);
186
187
188        /*!
189        \brief
190                Returns a pointer to the Imageset object with the specified name
191
192        \param name
193                String object containing the name of the Imageset to return a pointer to
194
195        \return
196                Pointer to the requested Imageset object
197
198        \exception      UnknownObjectException  Thrown if no Imageset named \a name is present in within the system
199        */
200        Imageset*       getImageset(const String& name) const;
201
202
203        /*!
204        \brief
205                Check for the existence of a named Imageset
206
207        \param name
208                String object containing the name of the Imageset to look for
209
210        \return
211                true if an Imageset named \a name is presently loaded in the system, else false.
212        */
213        bool    isImagesetPresent(const String& name) const                     {return d_imagesets.find(name) != d_imagesets.end();}
214
215
216        /*!
217        \brief
218                Notify the ImagesetManager of the current (usually new) display resolution.
219
220        \param size
221                Size object describing the display resolution
222
223        \return
224                Nothing
225        */
226        void    notifyScreenResolution(const Size& size);
227
228
229    /*!
230    \brief
231        Writes a full XML imageset for the specified Imageset to the given OutStream.
232
233    \param imageset
234        String holding the name of the Imageset to be written to the stream.
235
236    \param out_stream
237        OutStream (std::ostream based) object where data is to be sent.
238
239    \return
240        Nothing.
241    */
242    void writeImagesetToStream(const String& imageset, OutStream& out_stream) const;
243
244
245private:
246        /*************************************************************************
247                Implementation Data
248        *************************************************************************/
249        typedef std::map<String, Imageset*>             ImagesetRegistry;
250        ImagesetRegistry        d_imagesets;
251
252public:
253        /*************************************************************************
254                Iterator stuff
255        *************************************************************************/
256        typedef ConstBaseIterator<ImagesetRegistry>     ImagesetIterator;
257
258        /*!
259        \brief
260                Return a ImagesetManager::ImagesetIterator object to iterate over the available Imageset objects.
261        */
262        ImagesetIterator        getIterator(void) const;
263};
264
265} // End of  CEGUI namespace section
266
267#if defined(_MSC_VER)
268#       pragma warning(pop)
269#endif
270
271#endif  // end of guard _CEGUIImageSetManager_h_
Note: See TracBrowser for help on using the repository browser.