Panda3D

geomTextGlyph.h

00001 // Filename: geomTextGlyph.h
00002 // Created by:  drose (31Mar05)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef GEOMTEXTGLYPH_H
00016 #define GEOMTEXTGLYPH_H
00017 
00018 #include "pandabase.h"
00019 #include "geom.h"
00020 
00021 #ifdef HAVE_FREETYPE
00022 
00023 #include "dynamicTextGlyph.h"
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : GeomTextGlyph
00027 // Description : This is a specialization on Geom for containing a
00028 //               primitive intended to represent a DynamicTextGlyph.
00029 //               Its sole purpose is to maintain the geom count on the
00030 //               glyph, so we can determine the actual usage count on
00031 //               a dynamic glyph (and thus know when it is safe to
00032 //               recycle the glyph).
00033 ////////////////////////////////////////////////////////////////////
00034 class EXPCL_PANDA_TEXT GeomTextGlyph : public Geom {
00035 public:
00036   GeomTextGlyph(DynamicTextGlyph *glyph,
00037                 const GeomVertexData *data);
00038   GeomTextGlyph(const GeomVertexData *data);
00039   GeomTextGlyph(const GeomTextGlyph &copy);
00040   void operator = (const GeomTextGlyph &copy);
00041   virtual ~GeomTextGlyph();
00042   ALLOC_DELETED_CHAIN(GeomTextGlyph);
00043 
00044   virtual Geom *make_copy() const;
00045   virtual bool copy_primitives_from(const Geom *other);
00046   void count_geom(const Geom *other);
00047 
00048   virtual void output(ostream &out) const;
00049   virtual void write(ostream &out, int indent_level = 0) const;
00050 
00051 private:
00052   typedef pvector< PT(DynamicTextGlyph) > Glyphs;
00053   Glyphs _glyphs;
00054 
00055 public:
00056   static void register_with_read_factory();
00057   static TypedWritable *make_GeomTextGlyph(const FactoryParams &params);
00058 
00059 PUBLISHED:
00060   static TypeHandle get_class_type() {
00061     return _type_handle;
00062   }
00063 public:
00064   static void init_type() {
00065     Geom::init_type();
00066     register_type(_type_handle, "GeomTextGlyph",
00067                   Geom::get_class_type());
00068   }
00069   virtual TypeHandle get_type() const {
00070     return get_class_type();
00071   }
00072   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00073 
00074 private:
00075   static TypeHandle _type_handle;
00076 };
00077 
00078 #include "geomTextGlyph.I"
00079 
00080 #else  // HAVE_FREETYPE
00081 
00082 // Without Freetype, a GeomTextGlyph is really just an ordinary Geom.
00083 typedef Geom GeomTextGlyph;
00084 
00085 #endif  // HAVE_FREETYPE
00086 
00087 #endif // GEOMTEXTGLYPH_H
 All Classes Functions Variables Enumerations