TextSurface.hh
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef TEXTSURFACE_HH_
00018 # define TEXTSURFACE_HH_
00019
00020 # include "ResourceCenter.hh"
00021 # include "Surface.hh"
00022
00027 enum eTextRenderMethod {
00028 eTextSolid,
00029 eTextShaded,
00030 eTextBlended,
00031 };
00032
00039 class TextSurface : public Surface
00040 {
00041 public:
00042 TextSurface();
00043 TextSurface(const std::string& font_name, int font_size, int surf_width, int surf_height);
00044 TextSurface(const TextSurface& ts);
00045 TextSurface& operator= (const TextSurface& rhs);
00046 virtual ~TextSurface();
00047
00049 void clearText();
00050
00053 void setText(const std::string& text);
00054
00058 void addText(const std::string& text);
00059
00062 std::string getText() const;
00063
00066 void setAutoWrap(bool enabled);
00067
00070 bool getAutoWrap() const;
00071
00074 void setTextColor(const SDL_Color& fg);
00075
00078 void setBgColor(const SDL_Color& bg);
00079
00082 void setRenderMethod(enum eTextRenderMethod m);
00083
00084 virtual void update();
00085
00086 protected:
00087
00089 virtual void customTextRender(SDL_Surface* surf, int line);
00090
00091 TTF_Font* font_;
00092
00093 private:
00094 Surface surf_font_ref_;
00095 SDL_Color fg_;
00096 SDL_Color bg_;
00097
00098 std::string font_name_;
00099 int font_size_;
00100 int line_skip_;
00101 enum eTextRenderMethod method_;
00102
00103 bool auto_wrap_;
00104
00105 protected:
00106 bool content_changed_;
00107 typedef std::deque<std::string> LineList;
00108 LineList lines_;
00109 std::string text_;
00110 };
00111
00112 #endif