]> git.lyx.org Git - lyx.git/blob - src/insets/insetnewline.C
This commit cleans up everything related to singleton. The other important change...
[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/FontMetrics.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         lyx::frontend::FontMetrics const & fm 
44                 =       theFontMetrics(mi.base.font);
45         dim.asc = fm.maxAscent();
46         dim.des = fm.maxDescent();
47         dim.wid = fm.width('n');
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         lyx::frontend::FontMetrics const & fm =
79                 theFontMetrics(pi.base.font);
80         int const wid = fm.width('n');
81         int const asc = fm.maxAscent();
82
83         int xp[3];
84         int yp[3];
85
86         yp[0] = int(y - 0.875 * asc * 0.75);
87         yp[1] = int(y - 0.500 * asc * 0.75);
88         yp[2] = int(y - 0.125 * asc * 0.75);
89
90         if (pi.ltr_pos) {
91                 xp[0] = int(x + wid * 0.375);
92                 xp[1] = int(x);
93                 xp[2] = int(x + wid * 0.375);
94         } else {
95                 xp[0] = int(x + wid * 0.625);
96                 xp[1] = int(x + wid);
97                 xp[2] = int(x + wid * 0.625);
98         }
99
100         pi.pain.lines(xp, yp, 3, LColor::eolmarker);
101
102         yp[0] = int(y - 0.500 * asc * 0.75);
103         yp[1] = int(y - 0.500 * asc * 0.75);
104         yp[2] = int(y - asc * 0.75);
105
106         if (pi.ltr_pos) {
107                 xp[0] = int(x);
108                 xp[1] = int(x + wid);
109                 xp[2] = int(x + wid);
110         } else {
111                 xp[0] = int(x + wid);
112                 xp[1] = int(x);
113                 xp[2] = int(x);
114         }
115
116         pi.pain.lines(xp, yp, 3, LColor::eolmarker);
117 }
118
119
120 bool InsetNewline::isSpace() const
121 {
122         return true;
123 }