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