]> git.lyx.org Git - lyx.git/blob - src/insets/insetnewline.C
move everything into namespace lyx
[lyx.git] / src / insets / insetnewline.C
1 /**
2  * \file insetnewline.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "insetnewline.h"
14
15 #include "debug.h"
16 #include "LColor.h"
17 #include "lyxtext.h"
18 #include "metricsinfo.h"
19 #include "paragraph.h"
20 #include "paragraph_funcs.h"
21
22 #include "frontends/FontMetrics.h"
23 #include "frontends/Painter.h"
24
25
26 namespace lyx {
27
28 using std::endl;
29 using std::ostream;
30
31
32 void InsetNewline::read(Buffer const &, LyXLex &)
33 {
34         /* Nothing to read */
35 }
36
37
38 void InsetNewline::write(Buffer const &, ostream & os) const
39 {
40         os << "\n\\newline\n";
41 }
42
43
44 void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
45 {
46         frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
47         dim.asc = fm.maxAscent();
48         dim.des = fm.maxDescent();
49         dim.wid = fm.width('n');
50         dim_ = dim;
51 }
52
53
54 int InsetNewline::latex(Buffer const &, odocstream &,
55                         OutputParams const &) const
56 {
57         lyxerr << "Eek, calling InsetNewline::latex !" << endl;
58         return 0;
59 }
60
61
62 int InsetNewline::plaintext(Buffer const &, odocstream & os,
63                         OutputParams const &) const
64 {
65         os << '\n';
66         return 0;
67 }
68
69
70 int InsetNewline::docbook(Buffer const &, odocstream & os,
71                           OutputParams const &) const
72 {
73         os << '\n';
74         return 0;
75 }
76
77
78 void InsetNewline::draw(PainterInfo & pi, int x, int y) const
79 {
80         frontend::FontMetrics const & fm = theFontMetrics(pi.base.font);
81         int const wid = fm.width('n');
82         int const asc = fm.maxAscent();
83
84         int xp[3];
85         int yp[3];
86
87         yp[0] = int(y - 0.875 * asc * 0.75);
88         yp[1] = int(y - 0.500 * asc * 0.75);
89         yp[2] = int(y - 0.125 * asc * 0.75);
90
91         if (pi.ltr_pos) {
92                 xp[0] = int(x + wid * 0.375);
93                 xp[1] = int(x);
94                 xp[2] = int(x + wid * 0.375);
95         } else {
96                 xp[0] = int(x + wid * 0.625);
97                 xp[1] = int(x + wid);
98                 xp[2] = int(x + wid * 0.625);
99         }
100
101         pi.pain.lines(xp, yp, 3, LColor::eolmarker);
102
103         yp[0] = int(y - 0.500 * asc * 0.75);
104         yp[1] = int(y - 0.500 * asc * 0.75);
105         yp[2] = int(y - asc * 0.75);
106
107         if (pi.ltr_pos) {
108                 xp[0] = int(x);
109                 xp[1] = int(x + wid);
110                 xp[2] = int(x + wid);
111         } else {
112                 xp[0] = int(x + wid);
113                 xp[1] = int(x);
114                 xp[2] = int(x);
115         }
116
117         pi.pain.lines(xp, yp, 3, LColor::eolmarker);
118 }
119
120
121 bool InsetNewline::isSpace() const
122 {
123         return true;
124 }
125
126
127 } // namespace lyx