]> git.lyx.org Git - lyx.git/blob - src/mathed/TextPainter.cpp
g-brief loads babel internally. So don't load it ourselves.
[lyx.git] / src / mathed / TextPainter.cpp
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.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "TextPainter.h"
14
15
16 namespace lyx {
17
18
19 TextPainter::TextPainter(int xmax, int ymax)
20         : xmax_(xmax), ymax_(ymax), data_(xmax_ * (ymax_ + 1), ' ')
21 {}
22
23
24 char_type & TextPainter::at(int x, int y)
25 {
26         return data_[y * xmax_ + x];
27 }
28
29
30 char_type TextPainter::at(int x, int y) const
31 {
32         return data_[y * xmax_ + x];
33 }
34
35
36 void TextPainter::draw(int x, int y, char_type const * str)
37 {
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();
42 }
43
44
45 void TextPainter::horizontalLine(int x, int y, int len, char_type c)
46 {
47         for (int i = 0; i < len && i + x < xmax_; ++i)
48                 at(x + i, y) = c;
49 }
50
51
52 void TextPainter::verticalLine(int x, int y, int len, char_type c)
53 {
54         for (int i = 0; i < len && i + y < ymax_; ++i)
55                 at(x, y + i) = c;
56 }
57
58
59 void TextPainter::draw(int x, int y, char_type c)
60 {
61         //cerr << "drawing char '" << c << "' at " << x << ',' << y << endl;
62         at(x, y) = c;
63         //show();
64 }
65
66
67 void TextPainter::show(odocstream & os, int offset) const
68 {
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';
76         }
77 }
78
79
80 } // namespace lyx