OpenCMISS-Zinc 3.0.0 Release C++ API Documentation
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Pages
font.hpp
Go to the documentation of this file.
1 
4 /* OpenCMISS-Zinc Library
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #ifndef CMZN_FONT_HPP__
10 #define CMZN_FONT_HPP__
11 
12 #include "zinc/font.h"
13 #include "zinc/context.hpp"
14 
15 namespace OpenCMISS
16 {
17 namespace Zinc
18 {
19 
26 class Font
27 {
28 protected:
29  cmzn_font_id id;
30 
31 public:
32 
33  Font() : id(0)
34  { }
35 
36  // takes ownership of C handle, responsibility for destroying it
37  explicit Font(cmzn_font_id font_id) : id(font_id)
38  { }
39 
40  Font(const Font& font) : id(cmzn_font_access(font.id))
41  { }
42 
43  Font& operator=(const Font& font)
44  {
45  cmzn_font_id temp_id = cmzn_font_access(font.id);
46  cmzn_font_destroy(&id);
47  id = temp_id;
48  return *this;
49  }
50 
51  ~Font()
52  {
53  cmzn_font_destroy(&id);
54  }
55 
60  {
61  RENDER_TYPE_INVALID = CMZN_FONT_RENDER_TYPE_INVALID,
63  RENDER_TYPE_BITMAP = CMZN_FONT_RENDER_TYPE_BITMAP,
66  RENDER_TYPE_PIXMAP = CMZN_FONT_RENDER_TYPE_PIXMAP,
68  RENDER_TYPE_POLYGON = CMZN_FONT_RENDER_TYPE_POLYGON,
70  RENDER_TYPE_OUTLINE = CMZN_FONT_RENDER_TYPE_OUTLINE,
73  RENDER_TYPE_EXTRUDE = CMZN_FONT_RENDER_TYPE_EXTRUDE
75  };
76 
81  {
82  TYPEFACE_TYPE_INVALID = CMZN_FONT_TYPEFACE_TYPE_INVALID,
84  TYPEFACE_TYPE_OPENSANS = CMZN_FONT_TYPEFACE_TYPE_OPENSANS
86  };
87 
93  bool isValid() const
94  {
95  return (0 != id);
96  }
97 
103  cmzn_font_id getId() const
104  {
105  return id;
106  }
107 
115  char *getName()
116  {
117  return cmzn_font_get_name(id);
118  }
119 
127  int setName(const char *name)
128  {
129  return cmzn_font_set_name(id, name);
130  }
131 
137  bool isBold()
138  {
139  return cmzn_font_is_bold(id);
140  }
141 
148  int setBold(bool bold)
149  {
150  return cmzn_font_set_bold(id, bold);
151  }
152 
158  double getDepth()
159  {
160  return cmzn_font_get_depth(id);
161  }
162 
170  int setDepth(double depth)
171  {
172  return cmzn_font_set_depth(id, depth);
173  }
174 
180  bool isItalic()
181  {
182  return cmzn_font_is_italic(id);
183  }
184 
191  int setItalic(bool italic)
192  {
193  return cmzn_font_set_italic(id, italic);
194  }
195 
202  {
203  return cmzn_font_get_point_size(id);
204  }
205 
212  int setPointSize(int size)
213  {
214  return cmzn_font_set_point_size(id, size);
215  }
216 
223  {
224  return static_cast<RenderType>(cmzn_font_get_render_type(id));
225  }
226 
234  int setRenderType(RenderType renderType)
235  {
236  return cmzn_font_set_render_type(id,
237  static_cast<cmzn_font_render_type>(renderType));
238  }
239 
246  {
247  return static_cast<TypefaceType>(cmzn_font_get_typeface_type(id));
248  }
249 
257  int setTypefaceType(TypefaceType typefaceType)
258  {
259  return cmzn_font_set_typeface_type(id, static_cast<cmzn_font_typeface_type>(typefaceType));
260  }
261 };
262 
269 {
270 protected:
271  cmzn_fontmodule_id id;
272 
273 public:
274 
275  Fontmodule() : id(0)
276  { }
277 
278  // takes ownership of C handle, responsibility for destroying it
279  explicit Fontmodule(cmzn_fontmodule_id in_fontmodule_id) :
280  id(in_fontmodule_id)
281  { }
282 
283  Fontmodule(const Fontmodule& fontModule) :
284  id(cmzn_fontmodule_access(fontModule.id))
285  { }
286 
287  Fontmodule& operator=(const Fontmodule& fontModule)
288  {
289  cmzn_fontmodule_id temp_id = cmzn_fontmodule_access(
290  fontModule.id);
291  if (0 != id)
292  {
293  cmzn_fontmodule_destroy(&id);
294  }
295  id = temp_id;
296  return *this;
297  }
298 
299  ~Fontmodule()
300  {
301  if (0 != id)
302  {
303  cmzn_fontmodule_destroy(&id);
304  }
305  }
306 
312  bool isValid() const
313  {
314  return (0 != id);
315  }
316 
322  cmzn_fontmodule_id getId() const
323  {
324  return id;
325  }
326 
334  {
335  return Font(cmzn_fontmodule_create_font(id));
336  }
337 
344  Font findFontByName(const char *name)
345  {
346  return Font(cmzn_fontmodule_find_font_by_name(id, name));
347  }
348 
359  {
360  return cmzn_fontmodule_begin_change(id);
361  }
362 
372  int endChange()
373  {
374  return cmzn_fontmodule_end_change(id);
375  }
376 
383  {
384  return Font(cmzn_fontmodule_get_default_font(id));
385  }
386 
393  int setDefaultFont(const Font& font)
394  {
395  return cmzn_fontmodule_set_default_font(id, font.getId());
396  }
397 };
398 
400 {
401  return Fontmodule(cmzn_context_get_fontmodule(id));
402 }
403 
404 } // namespace Zinc
405 }
406 
407 #endif
cmzn_fontmodule_id getId() const
Definition: font.hpp:322
Fontmodule getFontmodule()
Definition: font.hpp:399
bool isItalic()
Definition: font.hpp:180
Module managing all fonts.
Definition: font.hpp:268
enum RenderType getRenderType()
Definition: font.hpp:222
RenderType
Definition: font.hpp:59
TypefaceType getTypefaceType()
Definition: font.hpp:245
TypefaceType
Definition: font.hpp:80
Font getDefaultFont()
Definition: font.hpp:382
int setDefaultFont(const Font &font)
Definition: font.hpp:393
int beginChange()
Definition: font.hpp:358
char * getName()
Definition: font.hpp:115
int setName(const char *name)
Definition: font.hpp:127
int setPointSize(int size)
Definition: font.hpp:212
double getDepth()
Definition: font.hpp:158
bool isValid() const
Definition: font.hpp:312
int setDepth(double depth)
Definition: font.hpp:170
cmzn_font_id getId() const
Definition: font.hpp:103
bool isValid() const
Definition: font.hpp:93
int setRenderType(RenderType renderType)
Definition: font.hpp:234
int setBold(bool bold)
Definition: font.hpp:148
int getPointSize()
Definition: font.hpp:201
int endChange()
Definition: font.hpp:372
Font createFont()
Definition: font.hpp:333
int setTypefaceType(TypefaceType typefaceType)
Definition: font.hpp:257
bool isBold()
Definition: font.hpp:137
Font object controlling attributes of rendering text.
Definition: font.hpp:26
Font findFontByName(const char *name)
Definition: font.hpp:344
int setItalic(bool italic)
Definition: font.hpp:191