00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef SDLFONT_H
00023 #define SDLFONT_H
00024
00025 #include "sdlsurfacecontainer.h"
00026 #include "sdlmanager.h"
00027
00046 class DECLSPEC SdlFont
00047 {
00048 public:
00049 DECLSPEC SdlFont();
00050 virtual DECLSPEC ~SdlFont();
00061 DECLSPEC SdlFont( int n, bool light, SdlSurfaceContainer *bmps, const char *l );
00062
00076 DECLSPEC bool create( int n, bool light, SdlSurfaceContainer *bmps, const char *l, Uint32 color = RGB(128,128,128), bool upper = false );
00080 DECLSPEC void destroy();
00082 SdlSurfaceContainer *getBmps() const { return bmps; }
00083
00090 enum VAlign {top, baseline, bottom};
00097 enum HAlign {left, center, right};
00098
00108 DECLSPEC int getCurpos( const char *text, const SDL_Rect &dst, Sint32 xCur, Sint32 yCur, VAlign va = baseline, HAlign ha = center );
00119 DECLSPEC int getCurpos( const char *text, Sint32 dstx, Sint32 dsty, Sint32 xCur, Sint32 yCur, VAlign va = baseline, HAlign ha = center );
00120
00132 DECLSPEC Uint32 write( SdlSurface *surf, const char *text, Sint32 dstx, Sint32 dsty, VAlign va = baseline, HAlign ha = center, const SDL_Rect * clip = 0, int curpos = -1 );
00143 DECLSPEC Uint32 write( SdlSurface *surf, const char *text, const SDL_Rect &dst, VAlign va = baseline, HAlign ha = center, const SDL_Rect * clip = 0, int curpos = -1 );
00144
00146 Uint32 color;
00147
00155 static DECLSPEC SdlFont *get( int n, bool light );
00156
00166 static DECLSPEC const char *strnchr( const char *string, int c, size_t count );
00175 static DECLSPEC const char *strnrchr( const char *string, int c, size_t count );
00182 static DECLSPEC VAlign strToVAlign( const char *s );
00189 static DECLSPEC HAlign strToHAlign( const char *s );
00190 protected:
00192 bool bUpperCase;
00194 SdlSurfaceContainer *bmps;
00196 char *chLetters;
00197
00198 private:
00199 struct FONT
00200 {
00201 SdlFont *f[2];
00202 };
00203 static FONT *lFonts;
00204
00205 static const int nFonts;
00206
00207 void init();
00208
00209 int num;
00210 bool bLight;
00211 };
00212
00213 #endif