SDL_ttf++
C++wrapperfortheSDL_ttflibrary.

ttf/RenderModes.h

Go to the documentation of this file.
00001 
00021 #ifndef SDL_TTF_RENDERMODES_H
00022 #define SDL_TTF_RENDERMODES_H
00023 
00024 #include <SDL_ttf.h>
00025 
00026 #include "sdlpp/video/Surface.h"
00027 #include "sdlpp/misc/Color.h"
00028 #include "sdlpp_ttf/ttf/Font.h"
00029 
00030 namespace sdl {
00031 namespace ttf {
00032     using namespace std;
00033     using namespace misc;
00034     using namespace video;
00035 
00040     struct Solid {
00046         Solid (const Color& color) : color_ (color) {};
00047 
00056         Surface render (const Font& font, char c) const {
00057             return Surface (TTF_RenderGlyph_Solid (*font, c, **color_));
00058         };
00059 
00070         template<int Encoding>
00071         Surface render (const Font& font, const string& text) const {
00072             return Surface (TTF_RenderText_Solid (*font, text.c_str (), **color_));
00073         };
00074 
00075         private:
00079             Color color_;
00080     }; //Solid
00081 
00082     template<>
00083     Surface Solid::render<TEXT> (const Font& font, const string& text) const {
00084         return Surface (TTF_RenderText_Solid (*font, text.c_str (), **color_));
00085     };
00086 
00087     //UTF8 specialization
00088     template<>
00089     Surface Solid::render<UTF8> (const Font& font, const string& text) const {
00090         return Surface (TTF_RenderUTF8_Solid (*font, text.c_str (), **color_));
00091     };
00092 
00093     //UNICODE specialization
00094     template<>
00095     Surface Solid::render<UNICODE> (const Font& font, const string& text) const {
00096         return Surface ();//TTF_RenderUNICODE_Solid (*font, text.c_str (), **color_));
00097     };
00098 
00103     struct Shaded {
00110         Shaded (const Color& fg, const Color& bg) : fg_ (fg), bg_ (bg) {};
00111 
00120         Surface render (const Font& font, char c) const {
00121             return TTF_RenderGlyph_Shaded (*font, c, **fg_, **bg_);
00122         };
00123 
00134         template<int Encoding>
00135         Surface render (const Font& font, const string& text) const {
00136             return Surface (TTF_RenderText_Shaded (*font, text.c_str (), **fg_, **bg_));
00137         };
00138 
00139         private:
00143             Color fg_;
00144 
00148             Color bg_;
00149     }; //Shaded
00150 
00151     //TEXT specialization
00152     template<>
00153     Surface Shaded::render<TEXT> (const Font& font, const string& text) const {
00154         return Surface (TTF_RenderText_Shaded (*font, text.c_str (), **fg_, **bg_));
00155     };
00156 
00157     //UTF8 specialization
00158     template<>
00159     Surface Shaded::render<UTF8> (const Font& font, const string& text) const {
00160         return Surface (TTF_RenderUTF8_Shaded (*font, text.c_str (), **fg_, **bg_));
00161     };
00162 
00163     //UNICODE specialization
00164     template<>
00165     Surface Shaded::render<UNICODE> (const Font& font, const string& text) const {
00166         return Surface ();//TTF_RenderUNICODE_Shaded (*font, text.c_str (), **fg_, **bg_));
00167     };
00168 
00173     struct Blended {
00179         Blended (const Color& color) : color_ (color) {};
00180 
00189         Surface render (const Font& font, char c) const {
00190             return Surface (TTF_RenderGlyph_Blended (*font, c, **color_));
00191         };
00192 
00203         template<int Encoding>
00204         Surface render (const Font& font, const string& text) const {
00205             return Surface (TTF_RenderText_Blended (*font, text.c_str (), **color_));
00206         };
00207 
00208         private:
00212             Color color_;
00213     }; //Blended
00214 
00215     //TEXT specialization
00216     template<>
00217     Surface Blended::render<TEXT> (const Font& font, const string& text) const {
00218         return Surface (TTF_RenderText_Blended (*font, text.c_str (), **color_));
00219     };
00220 
00221     //UTF8 specialization
00222     template<>
00223     Surface Blended::render<UTF8> (const Font& font, const string& text) const {
00224         return Surface (TTF_RenderUTF8_Blended (*font, text.c_str (), **color_));
00225     };
00226 
00227     //UNICODE specialization
00228     template<>
00229     Surface Blended::render<UNICODE> (const Font& font, const string& text) const {
00230         return Surface ();//TTF_RenderUNICODE_Blended (*font, text.c_str (), **color_));
00231     };
00232 }; //ttf
00233 }; //sdl
00234 
00235 #endif //SDL_TTF_RENDERMODES_H
00236 
 All Classes Namespaces Files Functions Enumerations Enumerator