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