]> git.lyx.org Git - lyx.git/blob - src/insets/insetnewline.C
Free BufferView from LyXView!
[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 "BufferView.h"
16 #include "debug.h"
17 #include "LColor.h"
18 #include "lyxtext.h"
19 #include "metricsinfo.h"
20 #include "paragraph.h"
21 #include "paragraph_funcs.h"
22
23 #include "frontends/font_metrics.h"
24 #include "frontends/Painter.h"
25
26 using std::endl;
27 using std::ostream;
28
29
30 void InsetNewline::read(Buffer const &, LyXLex &)
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         LyXFont & font = mi.base.font;
45         dim.asc = font_metrics::maxAscent(font);
46         dim.des = font_metrics::maxDescent(font);
47         dim.wid = font_metrics::width('n', font);
48         dim_ = dim;
49 }
50
51
52 int InsetNewline::latex(Buffer const &, ostream &,
53                         OutputParams const &) const
54 {
55         lyxerr << "Eek, calling InsetNewline::latex !" << endl;
56         return 0;
57 }
58
59
60 int InsetNewline::plaintext(Buffer const &, ostream & os,
61                         OutputParams const &) const
62 {
63         os << '\n';
64         return 0;
65 }
66
67
68 int InsetNewline::docbook(Buffer const &, std::ostream & os,
69                           OutputParams const &) const
70 {
71         os << '\n';
72         return 0;
73 }
74
75
76 void InsetNewline::draw(PainterInfo & pi, int x, int y) const
77 {
78         int const wid = font_metrics::width('n', pi.base.font);
79         int const asc = font_metrics::maxAscent(pi.base.font);
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, LColor::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, LColor::eolmarker);
115 }
116
117
118 bool InsetNewline::isSpace() const
119 {
120         return true;
121 }