sdlfont.h

Go to the documentation of this file.
00001 /********************************************************************************/
00002 /*                                                                              */
00003 /*  Netrinjo-Engine - a library for game-development                            */
00004 /*  Copyright (C) 1999, 2000, 2005 by Tobias Nadler und Georg Schnattinger      */
00005 /*                                                                              */
00006 /*  This library is free software; you can redistribute it and/or               */
00007 /*  modify it under the terms of the GNU Lesser General Public                  */
00008 /*  License as published by the Free Software Foundation; either                */
00009 /*  version 2.1 of the License, or (at your option) any later version.          */
00010 /*                                                                              */
00011 /*  This library is distributed in the hope that it will be useful,             */
00012 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of              */
00013 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU           */
00014 /*  Lesser General Public License for more details.                             */
00015 /*                                                                              */
00016 /*  You should have received a copy of the GNU Lesser General Public            */
00017 /*  License along with this library; if not, write to the Free Software         */
00018 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   */
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     // the maximum number of light fonts or dark fonts allowed
00205     static const int nFonts;
00206 
00207     void init();
00208 
00209     int num;
00210     bool bLight;
00211 };
00212 
00213 #endif

Generated on Wed May 9 17:35:55 2007 for netrinjo by  doxygen 1.5.1