Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/text/textFont.h

Go to the documentation of this file.
00001 // Filename: textFont.h
00002 // Created by:  drose (08Feb02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef TEXTFONT_H
00020 #define TEXTFONT_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "config_text.h"
00025 #include "typedReferenceCount.h"
00026 #include "namable.h"
00027 #include "pmap.h"
00028 
00029 class Node;
00030 class TextGlyph;
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //       Class : TextFont
00034 // Description : An encapsulation of a font; i.e. a set of glyphs that
00035 //               may be assembled together by a TextNode to represent
00036 //               a string of text.
00037 //
00038 //               This is just an abstract interface; see
00039 //               StaticTextFont or DynamicTextFont for an actual
00040 //               implementation.
00041 ////////////////////////////////////////////////////////////////////
00042 class EXPCL_PANDA TextFont : public TypedReferenceCount, public Namable {
00043 public:
00044   TextFont();
00045 
00046 PUBLISHED:
00047   virtual ~TextFont();
00048 
00049   INLINE bool is_valid() const;
00050   INLINE float get_line_height() const;
00051   INLINE void set_line_height(float line_height);
00052 
00053   INLINE float get_space_advance() const;
00054   INLINE void set_space_advance(float space_advance);
00055 
00056   float calc_width(int character);
00057   float calc_width(const string &line);
00058   string wordwrap_to(const string &text, float wordwrap_width,
00059                      bool preserve_trailing_whitespace);
00060 
00061   virtual void write(ostream &out, int indent_level) const;
00062 
00063 public:
00064   float calc_width(const wstring &line);
00065   wstring wordwrap_to(const wstring &text, float wordwrap_width,
00066                      bool preserve_trailing_whitespace);
00067 
00068   virtual bool get_glyph(int character, const TextGlyph *&glyph)=0;
00069 
00070 protected:
00071   bool _is_valid;
00072   float _line_height;
00073   float _space_advance;
00074 
00075 public:
00076   static TypeHandle get_class_type() {
00077     return _type_handle;
00078   }
00079   static void init_type() {
00080     TypedReferenceCount::init_type();
00081     register_type(_type_handle, "TextFont",
00082                   TypedReferenceCount::get_class_type());
00083   }
00084   virtual TypeHandle get_type() const {
00085     return get_class_type();
00086   }
00087   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00088 
00089 private:
00090   static TypeHandle _type_handle;
00091 };
00092 
00093 #include "textFont.I"
00094 
00095 #endif

Generated on Fri May 2 00:44:19 2003 for Panda by doxygen1.3