00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "pent_include.h"
00020 #include "ShapeRenderedText.h"
00021
00022 #include "ShapeFont.h"
00023 #include "RenderSurface.h"
00024
00025 DEFINE_RUNTIME_CLASSTYPE_CODE(ShapeRenderedText,RenderedText);
00026
00027
00028 ShapeRenderedText::ShapeRenderedText(std::list<PositionedText>& lines_,
00029 int width_, int height_, int vlead_,
00030 ShapeFont* font_)
00031 : lines(lines_), font(font_)
00032 {
00033 width = width_;
00034 height = height_;
00035 vlead = vlead_;
00036 }
00037
00038 ShapeRenderedText::~ShapeRenderedText()
00039 {
00040
00041 }
00042
00043 void ShapeRenderedText::draw(RenderSurface* surface, int x, int y, bool )
00044 {
00045
00046
00047 std::list<PositionedText>::iterator iter;
00048
00049 for (iter = lines.begin(); iter != lines.end(); ++iter)
00050 {
00051 int line_x = x + iter->dims.x;
00052 int line_y = y + iter->dims.y;
00053
00054 std::size_t textsize = iter->text.size();
00055
00056 for (std::size_t i = 0; i < textsize; ++i) {
00057 surface->Paint(font, static_cast<unsigned char>(iter->text[i]),
00058 line_x, line_y);
00059
00060 if (i == iter->cursor) {
00061 surface->Fill32(0xFF000000, line_x, line_y-font->getBaseline(),
00062 1, iter->dims.h);
00063 }
00064
00065 line_x += font->getWidth(iter->text[i])-font->getHlead();
00066 }
00067
00068 if (iter->cursor == textsize) {
00069 surface->Fill32(0xFF000000, line_x, line_y-font->getBaseline(),
00070 1, iter->dims.h);
00071 }
00072 }
00073 }
00074
00075 void ShapeRenderedText::drawBlended(RenderSurface* surface, int x, int y,
00076 uint32 col, bool )
00077 {
00078
00079
00080 std::list<PositionedText>::iterator iter;
00081
00082 for (iter = lines.begin(); iter != lines.end(); ++iter)
00083 {
00084 int line_x = x + iter->dims.x;
00085 int line_y = y + iter->dims.y;
00086
00087 std::size_t textsize = iter->text.size();
00088
00089 for (std::size_t i = 0; i < textsize; ++i) {
00090 surface->PaintHighlight(font,
00091 static_cast<unsigned char>(iter->text[i]),
00092 line_x, line_y, false, false, col);
00093 line_x += font->getWidth(iter->text[i])-font->getHlead();
00094 }
00095
00096 }
00097 }