]> git.lyx.org Git - lyx.git/blob - src/insets/insetnewline.C
delete unneeded BufferView.h declaration.
[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/font_metrics.h"
23 #include "frontends/Painter.h"
24
25 using std::endl;
26 using std::ostream;
27
28
29 void InsetNewline::read(Buffer const &, LyXLex &)
30 {
31         /* Nothing to read */
32 }
33
34
35 void InsetNewline::write(Buffer const &, ostream & os) const
36 {
37         os << "\n\\newline\n";
38 }
39
40
41 void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
42 {
43         LyXFont & font = mi.base.font;
44         dim.asc = font_metrics::maxAscent(font);
45         dim.des = font_metrics::maxDescent(font);
46         dim.wid = font_metrics::width('n', font);
47         dim_ = dim;
48 }
49
50
51 int InsetNewline::latex(Buffer const &, ostream &,
52                         OutputParams const &) const
53 {
54         lyxerr << "Eek, calling InsetNewline::latex !" << endl;
55         return 0;
56 }
57
58
59 int InsetNewline::plaintext(Buffer const &, ostream & os,
60                         OutputParams const &) const
61 {
62         os << '\n';
63         return 0;
64 }
65
66
67 int InsetNewline::docbook(Buffer const &, std::ostream & 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         int const wid = font_metrics::width('n', pi.base.font);
78         int const asc = font_metrics::maxAscent(pi.base.font);
79
80         int xp[3];
81         int yp[3];
82
83         yp[0] = int(y - 0.875 * asc * 0.75);
84         yp[1] = int(y - 0.500 * asc * 0.75);
85         yp[2] = int(y - 0.125 * asc * 0.75);
86
87         if (pi.ltr_pos) {
88                 xp[0] = int(x + wid * 0.375);
89                 xp[1] = int(x);
90                 xp[2] = int(x + wid * 0.375);
91         } else {
92                 xp[0] = int(x + wid * 0.625);
93                 xp[1] = int(x + wid);
94                 xp[2] = int(x + wid * 0.625);
95         }
96
97         pi.pain.lines(xp, yp, 3, LColor::eolmarker);
98
99         yp[0] = int(y - 0.500 * asc * 0.75);
100         yp[1] = int(y - 0.500 * asc * 0.75);
101         yp[2] = int(y - asc * 0.75);
102
103         if (pi.ltr_pos) {
104                 xp[0] = int(x);
105                 xp[1] = int(x + wid);
106                 xp[2] = int(x + wid);
107         } else {
108                 xp[0] = int(x + wid);
109                 xp[1] = int(x);
110                 xp[2] = int(x);
111         }
112
113         pi.pain.lines(xp, yp, 3, LColor::eolmarker);
114 }
115
116
117 bool InsetNewline::isSpace() const
118 {
119         return true;
120 }