Panda3D
dynamicTextPage.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file dynamicTextPage.h
10  * @author drose
11  * @date 2002-02-09
12  */
13 
14 #ifndef DYNAMICTEXTPAGE_H
15 #define DYNAMICTEXTPAGE_H
16 
17 #include "pandabase.h"
18 
19 #ifdef HAVE_FREETYPE
20 
21 #include "texture.h"
22 #include "dynamicTextGlyph.h"
23 #include "pointerTo.h"
24 #include "pvector.h"
25 
26 class DynamicTextFont;
27 
28 /**
29  * A single "page" of a DynamicTextFont. This is a single texture that holds
30  * a number of glyphs for rendering. The font starts out with one page, and
31  * will add more as it needs them.
32  */
33 class EXPCL_PANDA_TEXT DynamicTextPage : public Texture {
34 public:
35  DynamicTextPage(DynamicTextFont *font, int page_number);
36 
37  DynamicTextGlyph *slot_glyph(int character, int x_size, int y_size,
38  int margin, PN_stdfloat advance);
39 
40 PUBLISHED:
41  INLINE const LVecBase2i &get_size() const;
42  INLINE int get_x_size() const;
43  INLINE int get_y_size() const;
44 
45  INLINE bool is_empty() const;
46 
47 public:
48  void fill_region(int x, int y, int x_size, int y_size, const LColor &color);
49 
50 private:
51  int garbage_collect(DynamicTextFont *font);
52 
53  bool find_hole(int &x, int &y, int x_size, int y_size) const;
54  DynamicTextGlyph *find_overlap(int x, int y, int x_size, int y_size) const;
55 
56  typedef pvector< PT(DynamicTextGlyph) > Glyphs;
57  Glyphs _glyphs;
58 
59  LVecBase2i _size;
60 
61  DynamicTextFont *_font;
62 
63 public:
64  static TypeHandle get_class_type() {
65  return _type_handle;
66  }
67  static void init_type() {
68  Texture::init_type();
69  register_type(_type_handle, "DynamicTextPage",
70  Texture::get_class_type());
71  }
72  virtual TypeHandle get_type() const {
73  return get_class_type();
74  }
75  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
76 
77 private:
78  static TypeHandle _type_handle;
79 
80  friend class DynamicTextFont;
81 };
82 
83 #include "dynamicTextPage.I"
84 
85 #endif // HAVE_FREETYPE
86 
87 #endif
pvector
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
Texture
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
Texture::get_x_size
get_x_size
Returns the width of the texture image in texels.
Definition: texture.h:334
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
dynamicTextPage.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
texture.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dynamicTextGlyph.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Texture::get_y_size
get_y_size
Returns the height of the texture image in texels.
Definition: texture.h:338
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.