00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __FRENDERER_H_
00021 #define __FRENDERER_H_
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include "config.h"
00025 #endif
00026
00027 #ifdef DEBUG
00028 # ifndef NO_DEBUG_FONT_RENDERER
00029 # define DEBUG_FONT_RENDERER
00030 # endif
00031 #else
00032 # ifdef DEBUG_FONT_RENDERER
00033 # error DEBUG_FONT_RENDERER defined without DEBUG
00034 # endif
00035 #endif
00036
00037 #include <vector>
00038 #include <string>
00039 #include <stdexcept>
00040 #include "brenderer.h"
00041 #include "rect.h"
00042 #include "blitter.h"
00043
00054 class font_renderer : public base_renderer {
00055 private:
00056 int _nb_frames;
00057 int _color;
00058 bool _original;
00059 std::vector<std::pair<int, int> > _sizes;
00060 std::vector<char *> _chars;
00061 public:
00066 font_renderer(bool use_original_colors = false) throw();
00067 virtual ~font_renderer() throw();
00068 virtual bool wait(int ms) throw() { return true; };
00069 protected:
00070 virtual void save(int frame = -1);
00077 int char_width(int c) const throw(std::exception);
00084 int string_width(const std::string & str) const throw(std::exception);
00091 int char_height(int c) const throw(std::exception);
00098 int string_height(const std::string & str) const throw(std::exception);
00111 int draw_char(char * buffer, const point & size, int x, int y, int c) const throw(std::exception);
00122 void draw_substring(const std::string & str, char * buffer, const point & size, int x, int y) const throw(std::exception);
00123 public:
00130 bool set_color(int c) throw() { _color = c; return true; }
00150 bool draw_string_centered(const std::string & str, char * buffer, const point & size, int y, int xmin, int width, int offset) const throw(std::exception);
00161 bool draw_string_absolute(const std::string & str, char * buffer, const point & size, int x, int y) const throw(std::exception);
00162 };
00163
00164 #endif