]> git.lyx.org Git - lyx.git/blob - src/mathed/textpainter.C
fix the <...> delimiters
[lyx.git] / src / mathed / textpainter.C
1 #include <iostream>
2 #include "textpainter.h"
3
4
5 TextPainter::TextPainter(int xmax, int ymax)
6         : xmax_(xmax), ymax_(ymax), data_(xmax_ * (ymax_ + 1), ' ')
7 {}
8
9
10 char & TextPainter::at(int x, int y)
11 {
12         return data_[y * xmax_ + x];
13 }
14
15
16 char TextPainter::at(int x, int y) const
17 {
18         return data_[y * xmax_ + x];
19 }
20
21
22 void TextPainter::draw(int x, int y, char const * str)
23 {
24         //cerr << "drawing string '" << str << "' at " << x << "," << y << "\n";
25         for (int i = 0; *str && x + i < xmax_; ++i, ++str)
26                 at(x + i, y) = *str;
27         //show();
28 }
29
30
31 void TextPainter::horizontalLine(int x, int y, int n, char c)
32 {
33         for (int i = 0; i < n && i + x < xmax_; ++i)
34                 at(x + i, y) = c;
35 }
36
37
38 void TextPainter::verticalLine(int x, int y, int n, char c)
39 {
40         for (int i = 0; i < n && i + y < ymax_; ++i)
41                 at(x, y + i) = c;
42 }
43
44
45 void TextPainter::draw(int x, int y, char c)
46 {
47         //cerr << "drawing char '" << c << "' at " << x << "," << y << "\n";
48         at(x, y) = c;
49         //show();
50 }
51
52
53 void TextPainter::show(std::ostream & os) const
54 {
55         os << '\n';
56         for (int j = 0; j <= ymax_; ++j) {
57                 for (int i = 0; i < xmax_; ++i)
58                         os << at(i, j);
59                 os << '\n';
60         }
61 }