source: OGRE/trunk/ogre_dependencies/Dependencies/include/CEGUI/CEGUIFontManager.h @ 692

Revision 692, 7.8 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1/************************************************************************
2        filename:       CEGUIFontManager.h
3        created:        21/2/2004
4        author:         Paul D Turner
5       
6        purpose:        Defines interface for the FontManager class
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 _CEGUIFontManager_h_
27#define _CEGUIFontManager_h_
28
29#include "CEGUIBase.h"
30#include "CEGUIString.h"
31#include "CEGUISingleton.h"
32#include "CEGUIIteratorBase.h"
33#include <map>
34
35#if defined(_MSC_VER)
36#       pragma warning(push)
37#       pragma warning(disable : 4275)
38#       pragma warning(disable : 4251)
39#endif
40
41
42// Start of CEGUI namespace section
43namespace CEGUI
44{
45/*!
46\brief
47        Class providing a shared library of Font objects to the system.
48
49        The FontManager is used to create, access, and destroy Font objects.  The idea is that the
50        FontManager will function as a central repository for Font objects used within the GUI system,
51        and that those Font objects can be accessed, via a unique name, by any interested party within
52        the system.
53*/
54class CEGUIEXPORT FontManager : public Singleton<FontManager>
55{
56public:
57        /*!
58        \brief
59                Constructor for FontManager objects
60        */
61        FontManager(void);
62
63
64        /*!
65        \brief
66                Destructor for FontManager objects
67        */
68        ~FontManager(void);
69
70
71        /*!
72        \brief
73                Return singleton FontManager object
74
75        \return
76                Singleton FontManager object
77        */
78        static  FontManager&    getSingleton(void);
79
80
81        /*!
82        \brief
83                Return pointer to singleton FontManager object
84
85        \return
86                Pointer to singleton FontManager object
87        */
88        static  FontManager*    getSingletonPtr(void);
89
90
91        /*!
92        \brief
93                Creates a new font from a font definition file, and returns a pointer to the new Font object.
94
95        \param filename
96                String object containing the filename of a 'font definition file' what will be used to create the new font
97
98    \param resourceGroup
99        Resource group identifier to pass to the resource provider when loading the font definition file.
100
101        \return
102                Pointer the the newly created Font object
103
104        \exception      FileIOException                         thrown if there was some problem accessing or parsing the file \a filename
105        \exception      InvalidRequestException         thrown if an invalid filename was provided.
106        \exception      AlreadyExistsException          thrown if a Font already exists with the name specified, or if a font Imageset clashes with one already defined in the system.
107        \exception      GenericException                        thrown if something goes wrong while accessing a true-type font referenced in file \a filename.
108        \exception      RendererException                       thrown if the Renderer can't support a texture large enough to hold the requested glyph imagery.
109        \exception      MemoryException                         thrown if allocation of imagery construction buffer fails.
110        */
111        Font*   createFont(const String& filename, const String& resourceGroup = "");
112
113
114        /*!
115        \brief
116                Creates a new Font based on a true-type font, and returns a pointer to the new Font object.
117
118        \param name
119                String object containing a unique name for the new font.
120
121        \param fontname
122                String object containing the name and path of the true-type font to access.
123
124        \param size
125                Specifies the glyph size (point-size) for the new font.
126
127        \param flags
128                Some combination of FontFlag values to be used for the creation of this font.
129
130    \param resourceGroup
131        Resource group identifier to be passed to the resource provider when loading the font definition file.
132
133        \return
134                Pointer to the newly created Font object.
135
136        \exception      AlreadyExistsException          thrown if a Font already exists with the name specified, or if a font Imageset clashes with one already defined in the system.
137        \exception      GenericException                        thrown if something goes wrong while accessing a true-type font referenced in file \a fontname.
138        \exception      RendererException                       thrown if the Renderer can't support a texture large enough to hold the requested glyph imagery.
139        \exception      MemoryException                         thrown if allocation of imagery construction buffer fails.
140        */
141        Font*   createFont(const String& name, const String& fontname, uint size, uint flags, const String& resourceGroup = "");
142
143
144        /*!
145        \brief
146                Destroy's the font with the given name
147
148        \param name
149                String object containing the name of the font to be destroyed.  If the specified font does not exist, nothing happens.
150
151        \return
152                Nothing
153        */
154        void    destroyFont(const String& name);
155
156
157        /*!
158        \brief
159                Destroys the given Font object
160
161        \param font
162                Pointer to the Font to be destroyed.  If no such Font exists, nothing happens.
163
164        \return
165                Nothing.
166        */
167        void    destroyFont(Font* font);
168
169
170        /*!
171        \brief
172                Destroys all Font objects registered in the system
173
174        \return
175                Nothing
176        */
177        void    destroyAllFonts(void);
178
179
180        /*!
181        \brief
182                Checks the existence of a given font.
183
184        \param name
185                String object holding the name of the Font object to look for.
186
187        \return
188                true if a Font object named \a name exists in the system, false if no such font exists.
189        */
190        bool    isFontPresent(const String& name) const;
191
192
193        /*!
194        \brief
195                Returns a pointer to the font object with the specified name
196
197        \param name
198                String object containing the name of the Font object to be returned
199
200        \return
201                Pointer to the requested Font object
202
203        \exception UnknownObjectException       Thrown if no font with the given name exists.
204        */
205        Font*   getFont(const String& name) const;
206
207
208        /*!
209        \brief
210                Notify the FontManager of the current (usually new) display resolution.
211
212        \param size
213                Size object describing the display resolution
214
215        \return
216                Nothing
217        */
218        void    notifyScreenResolution(const Size& size);
219
220
221    /*!
222    \brief
223        Writes a full XML font file for the specified Font to the given OutStream.
224
225    \param name
226        String holding the name of the Font to be written to the stream.
227
228    \param out_stream
229        OutStream (std::ostream based) object where data is to be sent.
230
231    \return
232        Nothing.
233    */
234    void writeFontToStream(const String& name, OutStream& out_stream) const;
235
236
237private:
238        /*************************************************************************
239                Implementation Data
240        *************************************************************************/
241        typedef std::map<String, Font*>         FontRegistry;
242        FontRegistry            d_fonts;
243
244        struct FontManagerImplData;
245        FontManagerImplData*    d_implData;
246
247
248public:
249        /*************************************************************************
250                Iterator stuff
251        *************************************************************************/
252        typedef ConstBaseIterator<FontRegistry> FontIterator;
253
254        /*!
255        \brief
256                Return a FontManager::FontIterator object to iterate over the available Font objects.
257        */
258        FontIterator    getIterator(void) const;
259};
260
261} // End of  CEGUI namespace section
262
263
264#if defined(_MSC_VER)
265#       pragma warning(pop)
266#endif
267
268#endif  // end of guard _CEGUIFontManager_h_
Note: See TracBrowser for help on using the repository browser.