SDL_ttf++
C++wrapperfortheSDL_ttflibrary.

subsystem/TTF.h

Go to the documentation of this file.
00001 
00021 #ifndef SDL_SUBSYSTEM_TTF_H
00022 #define SDL_SUBSYSTEM_TTF_H
00023 
00024 #include <stdexcept>
00025 
00026 #include <SDL_ttf.h>
00027 
00028 namespace sdl {
00029 namespace subsystem {
00030     using namespace std;
00031 
00036     struct TTF {
00042         static TTF& instance () {
00043             static TTF instance_;
00044             return instance_;
00045         };
00046 
00052         static bool isOpen () { return TTF_WasInit (); };
00053 
00057         void enableByteSwappedUNICODE () { TTF_ByteSwappedUNICODE (1); };
00058 
00062         void disableByteSwappedUNICODE () { TTF_ByteSwappedUNICODE (0); };
00063 
00064         protected:
00070             bool open () {
00071                 init ();
00072                 return isOpen ();
00073             };
00074 
00080             bool close () {
00081                 quit ();
00082                 return !isOpen ();
00083             };
00084            
00085         private:
00089             void init () {
00090                 if (TTF_Init () == -1) 
00091                     throw runtime_error (TTF_GetError ());
00092             };
00093 
00097             void quit () { TTF_Quit (); };
00098         
00102             TTF () { init (); };
00103 
00107             ~TTF () { quit (); };
00108     }; //TTF
00109 }; //subsystem
00110 }; //sdl
00111 
00112 #endif //SDL_SUBSYSTEM_TTF_H
00113 
 All Classes Namespaces Files Functions Enumerations Enumerator