fixed: let the material fill the override chunk block
[opensg.git] / Source / System / Text / OSGTextFaceFactory.h
blob4f95a7cba1eca484ab949b7912f0bdeb24d92a58
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGTEXTFACEFACTORY_H_
40 #define _OSGTEXTFACEFACTORY_H_
42 #ifdef _MSC_VER
43 # pragma once
44 #endif
47 #include "OSGConfig.h"
48 #include "OSGTextDef.h"
49 #include "OSGBaseTypes.h"
50 #include "OSGSingletonHolder.h"
52 #include "OSGTextFace.h"
53 #include "OSGTextTXFParam.h"
55 #include <map>
56 #include <vector>
57 #include <string>
59 using namespace std;
60 OSG_BEGIN_NAMESPACE
63 class TextBackend;
64 class TextVectorFace;
65 class TextPixmapFace;
66 class TextTXFFace;
68 /*! \ingroup GrpTextFaces
70 typedef RefCountPtr<TextVectorFace,
71 MemObjRefCountPolicy> TextVectorFaceRefPtr;
72 /*! \ingroup GrpTextFaces
74 typedef TransitPtr <TextVectorFace > TextVectorFaceTransitPtr;
76 /*! \ingroup GrpTextFaces
78 typedef RefCountPtr<TextPixmapFace,
79 MemObjRefCountPolicy> TextPixmapFaceRefPtr;
80 /*! \ingroup GrpTextFaces
82 typedef TransitPtr <TextPixmapFace > TextPixmapFaceTransitPtr;
84 /*! \ingroup GrpTextFaces
86 typedef RefCountPtr<TextTXFFace,
87 MemObjRefCountPolicy> TextTXFFaceRefPtr;
88 /*! \ingroup GrpTextFaces
90 typedef TransitPtr <TextTXFFace > TextTXFFaceTransitPtr;
92 /**
93 * A singleton used to create new faces. The %TextFaceFactory
94 * keeps a cache of all currently created faces. When creating
95 * a new face, the factory first searches in the cache if the
96 * face already exists. If yes, it returns that face. If no, it
97 * creates a new face, adds it to the cache, and returns it.
98 * Usually you do not use the %TextFaceFactory singleton directly,
99 * instead you use the create method of the TextFace classes.
100 * @author Patrick D&auml;hne
102 * \ingroup GrpTextFactory
103 * \ingroup GrpLibOSGText
106 class OSG_TEXT_DLLMAPPING TextFaceFactoryBase
108 /*========================== PUBLIC =================================*/
109 public:
112 * Tries to create a vector face.
113 * @param family The font family of the face (Arial, Courier etc.)
114 * @param style The style of the face (bold, italic etc.)
115 * @return The vector face object or 0 in case of an error.
117 TextVectorFaceTransitPtr
118 createVectorFace(const std::string &family,
119 TextFace::Style style = TextFace::STYLE_PLAIN);
122 * Tries to create a pixmap face.
123 * @param family The font family of the face (Arial, Courier etc.)
124 * @param style The style of the face (bold, italic etc.)
125 * @param size The size of the pixmap font in pixels.
126 * @return The pixmap face object or 0 in case of an error.
128 TextPixmapFaceTransitPtr
129 createPixmapFace(const std::string &family,
130 TextFace::Style style = TextFace::STYLE_PLAIN,
131 UInt32 size = 32 );
134 * Tries to create a TXF face.
135 * @param family The font family of the face (Arial, Courier etc.)
136 * @param style The style of the face (bold, italic etc.)
137 * @param param Parameters that affect the creation of the
138 * TXF face.
139 * @return The TXF face object or 0 in case of an error.
141 TextTXFFaceTransitPtr
142 createTXFFace(const std::string &family,
143 TextFace::Style style = TextFace::STYLE_PLAIN,
144 const TextTXFParam &param = TextTXFParam() );
146 /** Removes all faces from the face cache. */
147 void clearCache(void);
150 * Returns the names of all font families available.
151 * @param families A vector that gets filled with the names
152 * of all font families.
154 void getFontFamilies(std::vector<std::string> &families) const;
156 /*========================== PRIVATE ================================*/
157 private:
159 template <class SingletonT>
160 friend class SingletonHolder;
162 /** Default Constructor */
163 TextFaceFactoryBase(void);
165 /** Copy constructor (not implemented!) */
166 TextFaceFactoryBase(const TextFaceFactoryBase &);
168 /** Destroys the %TextFaceFactoryBase object. */
169 ~TextFaceFactoryBase(void);
171 /** Copy operator (not implemented!) */
172 const TextFaceFactoryBase &operator=(const TextFaceFactoryBase &);
174 /** The backend that creates all faces */
175 TextBackend *_backend;
177 /** Defines the map that contains the vector faces */
178 typedef std::multimap<std::string, TextVectorFaceRefPtr> VectorFaceMap;
180 /** The map of vector faces currently instantiated (face cache) */
181 VectorFaceMap _vectorFaceMap;
183 /** Defines the map that contains the pixmap faces */
184 typedef std::multimap<std::string, TextPixmapFaceRefPtr> PixmapFaceMap;
186 /** The map of pixmap faces currently instanciated (face cache) */
187 PixmapFaceMap _pixmapFaceMap;
189 /** Defines the map that contains the TXF faces */
190 typedef std::multimap<std::string, TextTXFFaceRefPtr> TXFFaceMap;
192 /** The map of TXF faces currently instantiated (face cache) */
193 TXFFaceMap _txfFaceMap;
196 #if defined(WIN32)
197 OSG_TEXT_EXPIMP_TMPL
198 template class OSG_TEXT_DLLMAPPING SingletonHolder<TextFaceFactoryBase>;
199 #endif
201 /*! \typedef OSG::SingletonHolder<OSG::TextFaceFactoryBase> TextFaceFactory;
202 \ingroup GrpTextFactory
203 \relatesalso OSG::TextFaceFactoryBase
206 typedef SingletonHolder<TextFaceFactoryBase> TextFaceFactory;
208 OSG_END_NAMESPACE
211 #include "OSGTextFaceFactory.inl"
213 #endif /* _OSGTEXTFACEFACTORY_H_ */