Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SDLFont.h

Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2001-2005 Stephane Magnenat & Luc-Olivier de Charrière
00003   for any question or comment contact us at nct@ysagoon.com or nuage@ysagoon.com
00004 
00005   This program is free software; you can redistribute it and/or modify
00006   it under the terms of the GNU General Public License as published by
00007   the Free Software Foundation; either version 2 of the License, or
00008   (at your option) any later version.
00009 
00010   This program is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013   GNU General Public License for more details.
00014 
00015   You should have received a copy of the GNU General Public License
00016   along with this program; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00018 */
00019 
00020 #ifndef __SDLFONT_H
00021 #define __SDLFONT_H
00022 
00023 #include "GAGSys.h"
00024 #include "GraphicContext.h"
00025 #include "SDL_ttf.h"
00026 #include <stack>
00027 
00032 namespace GAG
00033 {
00036     class SDLFont : public Font
00037     {
00038     private:
00039         friend class SDLGraphicContext;
00041         SDLFont();
00042     
00043     public:
00045         virtual ~SDLFont();
00047         bool load(const char *filename, unsigned size);
00048         
00050         int getStringWidth(const char *string) const;
00052         int getStringHeight(const char *string) const;
00054         bool printable(char c) const;
00055         
00056         virtual void setColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = DrawableSurface::ALPHA_OPAQUE);
00057         virtual void pushColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = DrawableSurface::ALPHA_OPAQUE);
00058         virtual void popColor(void);
00059         virtual void getColor(Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) const;
00060         
00061         virtual void setStyle(unsigned style);
00062         virtual void pushStyle(unsigned style);
00063         virtual void popStyle(void);
00064         virtual unsigned getStyle(void) const;
00065         
00066     protected:
00067         friend class SDLDrawableSurface;
00068         
00070         void drawString(SDL_Surface *Surface, int x, int y, int w, const char *text, SDL_Rect *clip=NULL) const;
00071         
00072     protected:
00073         TTF_Font *font; 
00074         
00075         std::stack<unsigned> styleStack; 
00076         std::stack<SDL_Color> colorStack; 
00077     };
00078 }
00079 
00080 #endif

Generated on Mon Oct 24 17:38:25 2005 for Teem by  doxygen 1.4.2