]> git.lyx.org Git - features.git/blob - src/insets/InsetNewline.cpp
header cleanup.
[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 "Text.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 bool 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         bool const changed = dim_ != dim;
49         dim_ = dim;
50         return changed;
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 PLAINTEXT_NEWLINE;
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, Color::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, Color::eolmarker);
118 }
119
120
121 bool InsetNewline::isSpace() const
122 {
123         return true;
124 }
125
126
127 } // namespace lyx