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