A bit more re-organization.
[lyx.git] / src / mathed / TextPainter.cpp
blob7ff8368d6b0eacdf7224eda5d99db8e3f0ac29a5
1 /**
2 * \file TextPainter.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author André Pönitz
8 * Full author contact details are available in file CREDITS.
9 */
11 #include <config.h>
13 #include "TextPainter.h"
16 namespace lyx {
19 TextPainter::TextPainter(int xmax, int ymax)
20 : xmax_(xmax), ymax_(ymax), data_(xmax_ * (ymax_ + 1), ' ')
24 char_type & TextPainter::at(int x, int y)
26 return data_[y * xmax_ + x];
30 char_type TextPainter::at(int x, int y) const
32 return data_[y * xmax_ + x];
36 void TextPainter::draw(int x, int y, char_type const * str)
38 //cerr << "drawing string '" << str << "' at " << x << ',' << y << endl;
39 for (int i = 0; *str && x + i < xmax_; ++i, ++str)
40 at(x + i, y) = *str;
41 //show();
45 void TextPainter::horizontalLine(int x, int y, int n, char_type c)
47 for (int i = 0; i < n && i + x < xmax_; ++i)
48 at(x + i, y) = c;
52 void TextPainter::verticalLine(int x, int y, int n, char_type c)
54 for (int i = 0; i < n && i + y < ymax_; ++i)
55 at(x, y + i) = c;
59 void TextPainter::draw(int x, int y, char_type c)
61 //cerr << "drawing char '" << c << "' at " << x << ',' << y << endl;
62 at(x, y) = c;
63 //show();
67 void TextPainter::show(odocstream & os, int offset) const
69 os << '\n';
70 for (int j = 0; j <= ymax_; ++j) {
71 for (int i = 0; i < offset; ++i)
72 os << ' ';
73 for (int i = 0; i < xmax_; ++i)
74 os << at(i, j);
75 os << '\n';
80 } // namespace lyx