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