2 #include "textpainter.h"
5 TextPainter::TextPainter(int xmax, int ymax)
6 : xmax_(xmax), ymax_(ymax), data_(xmax_ * (ymax_ + 1), ' ')
10 char & TextPainter::at(int x, int y)
12 return data_[y * xmax_ + x];
16 char TextPainter::at(int x, int y) const
18 return data_[y * xmax_ + x];
22 void TextPainter::draw(int x, int y, char const * str)
24 //cerr << "drawing string '" << str << "' at " << x << "," << y << "\n";
25 for (int i = 0; *str && x + i < xmax_; ++i, ++str)
31 void TextPainter::horizontalLine(int x, int y, int n, char c)
33 for (int i = 0; i < n && i + x < xmax_; ++i)
38 void TextPainter::verticalLine(int x, int y, int n, char c)
40 for (int i = 0; i < n && i + y < ymax_; ++i)
45 void TextPainter::draw(int x, int y, char c)
47 //cerr << "drawing char '" << c << "' at " << x << "," << y << "\n";
53 void TextPainter::show(std::ostream & os, int offset) const
56 for (int j = 0; j <= ymax_; ++j) {
57 for (int i = 0; i < offset; ++i)
59 for (int i = 0; i < xmax_; ++i)