ttfDraw.h

Go to the documentation of this file.
00001 #ifndef TTF_DRAW_H
00002 #define TTF_DRAW_H
00003 
00013 #include "sdlBase.h"
00014 #include "colors.h"
00015 #ifdef HAVE_CONFIG_H
00016 #include <config.h>
00017 #endif
00018 #if !HAVE_CONFIG_H || HAVE_LIBSDL_TTF
00019 #include <SDL_ttf.h>
00020 #endif
00021 #include <string>
00022 #include <map>
00023 
00024 
00028 class TTF_Draw {
00029   static bool ttf_initialized;
00030 #if !HAVE_CONFIG_H || HAVE_LIBSDL_TTF
00031   std::map<int,TTF_Font*> fonts;
00032 #endif
00033   char* fileName;
00034 
00035   void initTTF(void);
00036   void createFontResource(int pxSize);
00037 public:
00038   TTF_Draw(void);
00039   ~TTF_Draw(void);
00040 
00047   bool load(const char* file);
00048 
00057   SDL_Surface* createText(const unsigned short* text, int pxSize,
00058                           unsigned long color = White,
00059                           unsigned long background = Black);
00060 
00069   SDL_Surface* createText(const char* text, int pxSize,
00070                           unsigned long color = White,
00071                           unsigned long background = Black);
00072 };
00073 
00074 
00078 class TTF_Exception : public std::exception {
00079   std::string error_message;
00080 
00081 public:
00087   TTF_Exception(const char* message) : error_message(message) {}
00088   virtual ~TTF_Exception(void) throw () {}
00089 
00093   virtual const char* what(void) const throw() {
00094     return error_message.c_str();
00095   }
00096 };
00097 
00098 #endif /* !TTF_DRAW_H */
00099 

Generated on Mon Apr 13 22:52:02 2009 by  doxygen 1.5.7.1