]> git.lyx.org Git - features.git/blob - src/insets/InsetNewline.cpp
cosmetics. mainly replace #include "dostring.h" by #include "strfwd.h"
[features.git] / src / insets / InsetNewline.cpp
1 /**
2  * \file InsetNewline.cpp
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 "Dimension.h"
17 #include "MetricsInfo.h"
18 #include "OutputParams.h"
19
20 #include "frontends/FontMetrics.h"
21 #include "frontends/Painter.h"
22
23
24 namespace lyx {
25
26 using std::endl;
27 using std::ostream;
28
29
30 void InsetNewline::read(Buffer const &, Lexer &)
31 {
32         /* Nothing to read */
33 }
34
35
36 void InsetNewline::write(Buffer const &, ostream & os) const
37 {
38         os << "\n\\newline\n";
39 }
40
41
42 void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
43 {
44         frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
45         dim.asc = fm.maxAscent();
46         dim.des = fm.maxDescent();
47         dim.wid = fm.width('n');
48 }
49
50
51 int InsetNewline::latex(Buffer const &, odocstream &,
52                         OutputParams const &) const
53 {
54         lyxerr << "Eek, calling InsetNewline::latex !" << endl;
55         return 0;
56 }
57
58
59 int InsetNewline::plaintext(Buffer const &, odocstream & os,
60                             OutputParams const &) const
61 {
62         os << '\n';
63         return PLAINTEXT_NEWLINE;
64 }
65
66
67 int InsetNewline::docbook(Buffer const &, odocstream & os,
68                           OutputParams const &) const
69 {
70         os << '\n';
71         return 0;
72 }
73
74
75 void InsetNewline::draw(PainterInfo & pi, int x, int y) const
76 {
77         frontend::FontMetrics const & fm = theFontMetrics(pi.base.font);
78         int const wid = fm.width('n');
79         int const asc = fm.maxAscent();
80
81         int xp[3];
82         int yp[3];
83
84         yp[0] = int(y - 0.875 * asc * 0.75);
85         yp[1] = int(y - 0.500 * asc * 0.75);
86         yp[2] = int(y - 0.125 * asc * 0.75);
87
88         if (pi.ltr_pos) {
89                 xp[0] = int(x + wid * 0.375);
90                 xp[1] = int(x);
91                 xp[2] = int(x + wid * 0.375);
92         } else {
93                 xp[0] = int(x + wid * 0.625);
94                 xp[1] = int(x + wid);
95                 xp[2] = int(x + wid * 0.625);
96         }
97
98         pi.pain.lines(xp, yp, 3, Color_eolmarker);
99
100         yp[0] = int(y - 0.500 * asc * 0.75);
101         yp[1] = int(y - 0.500 * asc * 0.75);
102         yp[2] = int(y - asc * 0.75);
103
104         if (pi.ltr_pos) {
105                 xp[0] = int(x);
106                 xp[1] = int(x + wid);
107                 xp[2] = int(x + wid);
108         } else {
109                 xp[0] = int(x + wid);
110                 xp[1] = int(x);
111                 xp[2] = int(x);
112         }
113
114         pi.pain.lines(xp, yp, 3, Color_eolmarker);
115 }
116
117
118 bool InsetNewline::isSpace() const
119 {
120         return true;
121 }
122
123
124 } // namespace lyx