00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __NEFONT_H
00028 #define __NEFONT_H
00029
00030
00031 #include "base.h"
00032 #include "loadableentity.h"
00033 #include "texture.h"
00034 #include "material.h"
00035 #include "pointer.h"
00036
00037
00043 namespace NeoEngine
00044 {
00045
00046
00047
00048 class RenderDevice;
00049
00050
00051
00056 class NEOENGINE_API FontCharacter
00057 {
00058 public:
00059
00061 float m_fU;
00062
00064 float m_fV;
00065
00067 float m_fUWidth;
00068
00070 float m_fVHeight;
00071
00073 int m_iX;
00074
00076 int m_iY;
00077
00079 int m_iWidth;
00080
00082 int m_iHeight;
00083 };
00084
00085
00086
00087
00088
00093 class NEOENGINE_API Font : public RefCounter, public LoadableEntity
00094 {
00095 friend class FontManager;
00096
00097 public:
00098
00103 enum FONTALIGN
00104 {
00105 LEFT,
00106 RIGHT
00107 };
00108
00113 enum FONTLINEWRAP
00114 {
00115 NOWRAP,
00116 WORDWRAP
00117 };
00118
00119
00120
00121 protected:
00122
00124 MaterialPtr m_pkMaterial;
00125
00127 FontCharacter m_akCharacters[256];
00128
00130 int m_iSpacing;
00131
00133 int m_iLineHeight;
00134
00136 int m_iSpaceWidth;
00137
00139 int m_iClipX;
00140
00142 int m_iClipY;
00143
00145 int m_iClipWidth;
00146
00148 int m_iClipHeight;
00149
00151 FONTLINEWRAP m_eLineWrap;
00152
00154 std::string m_strName;
00155
00157 FontManager *m_pkFontManager;
00158
00160 std::string m_strWordSeparators;
00161
00163 FONTALIGN m_eHorizontalAlign;
00164
00166 Color m_kColor;
00167
00168
00174 bool LoadNode( unsigned int uiFlags );
00175
00176
00181 Font( FontManager *pkFontManager );
00182
00183
00184 public:
00185
00187 static NE_STATIC float s_fSubPixelOffset;
00188
00191 virtual ~Font();
00192
00200 int Printf( int iX, int iY, const char *pszFormat, ... );
00201
00209 int Printf( float fX, float fY, const char *pszFormat, ... );
00210
00218 void SetClipBox( int iX, int iY, int iWidth, int iHeight );
00219
00227 void GetClipBox( int *piX, int *piY, int *piWidth, int *piHeight );
00228
00232 void ResetClipBox();
00233
00239 FONTLINEWRAP SetLineWrap( FONTLINEWRAP eWrap ) { FONTLINEWRAP eRet = m_eLineWrap; m_eLineWrap = eWrap; return eRet; }
00240
00244 FONTLINEWRAP GetLineWrap() const { return m_eLineWrap; }
00245
00249 int GetLineHeight() const { return m_iLineHeight; }
00250
00255 int GetStringLength( const std::string &rstrString );
00256
00262 int GetStringHeight( const std::string &rstrString, int iX );
00263
00267 const std::string &GetName() const { return m_strName; }
00268
00272 const Color &GetColor() const;
00273
00278 Color SetColor( const Color &rkColor );
00279
00284 void SetWordSeparators( const std::string &rstrSeparators );
00285
00291 FONTALIGN SetHorizontalAlign( FONTALIGN eAlign );
00292
00296 FONTALIGN GetHorizontalAlign();
00297
00306 std::string ClipLine( const std::string &rstrLine, int iX, int iY, int *piLines = 0 );
00307 };
00308
00309
00310 #ifndef __NESMARTPOINTER_FONT
00311
00312 SmartPointer(Font);
00313 # define __NESMARTPOINTER_FONT
00314 #endif
00315
00316
00317 #ifdef WIN32
00318 # ifndef __HAVE_VECTOR_NEFONT
00319 # ifdef _MSC_VER
00320 # pragma warning( disable : 4231 )
00321 # endif
00322 UDTVectorEXPIMP( class Font* );
00323 # define __HAVE_VECTOR_NEFONT
00324 # endif
00325 #endif
00326
00327
00328
00329
00334 class NEOENGINE_API FontManager
00335 {
00336 friend class Font;
00337
00338 protected:
00339
00341 std::vector< Font* > m_vpkFonts;
00342
00347 void DeregisterFont( Font *pkFont );
00348
00349
00350 public:
00351
00354 FontManager();
00355
00358 ~FontManager();
00359
00366 FontPtr CreateFont( const std::string &rstrName, bool bLoad = true );
00367
00373 FontPtr FindFont( const std::string &rstrName );
00374 };
00375
00376
00377 };
00378
00379
00380 #endif