]> git.lyx.org Git - lyx.git/blob - src/insets/insetnewline.C
Rename LatexRunParams::fragile as moving_arg.
[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 "dimension.h"
18 #include "paragraph.h"
19 #include "lyxtext.h"
20 #include "support/LOstream.h"
21 #include "frontends/Painter.h"
22 #include "frontends/font_metrics.h"
23
24 using std::ostream;
25 using std::endl;
26
27
28 void InsetNewline::read(Buffer const *, LyXLex &)
29 {
30         /* Nothing to read */
31 }
32
33
34 void InsetNewline::write(Buffer const *, ostream & os) const
35 {
36         os << "\n\\newline \n";
37 }
38
39
40 void InsetNewline::dimension(BufferView *, LyXFont const & font,
41         Dimension & dim) const
42 {
43         dim.a = font_metrics::maxAscent(font);
44         dim.d = font_metrics::maxDescent(font);
45         dim.w = font_metrics::width('n', font);
46 }
47
48
49 int InsetNewline::latex(Buffer const *, ostream &,
50                         LatexRunParams const &) const
51 {
52         lyxerr << "Eek, calling InsetNewline::latex !" << endl;
53         return 0;
54 }
55
56
57 int InsetNewline::ascii(Buffer const *, ostream & os, int) const
58 {
59         os << '\n';
60         return 0;
61 }
62
63
64 int InsetNewline::linuxdoc(Buffer const *, std::ostream &) const
65 {
66         /* FIXME */
67         return 0;
68 }
69
70
71 int InsetNewline::docbook(Buffer const *, std::ostream &, bool) const
72 {
73         /* FIXME */
74         return 0;
75 }
76
77
78 void InsetNewline::draw(BufferView * bv, LyXFont const & font,
79                         int baseline, float & x) const
80 {
81         Painter & pain(bv->painter());
82
83         int const wid = font_metrics::width('n', font);
84         int const asc = font_metrics::maxAscent(font);
85         int const y = baseline;
86
87         // hack, and highly dubious
88         lyx::pos_type pos = parOwner()->getPositionOfInset(this);
89         bool const ltr_pos = (bv->text->bidi_level(pos) % 2 == 0);
90
91         int xp[3];
92         int yp[3];
93
94         yp[0] = int(y - 0.875 * asc * 0.75);
95         yp[1] = int(y - 0.500 * asc * 0.75);
96         yp[2] = int(y - 0.125 * asc * 0.75);
97
98         if (ltr_pos) {
99                 xp[0] = int(x + wid * 0.375);
100                 xp[1] = int(x);
101                 xp[2] = int(x + wid * 0.375);
102         } else {
103                 xp[0] = int(x + wid * 0.625);
104                 xp[1] = int(x + wid);
105                 xp[2] = int(x + wid * 0.625);
106         }
107
108         pain.lines(xp, yp, 3, LColor::eolmarker);
109
110         yp[0] = int(y - 0.500 * asc * 0.75);
111         yp[1] = int(y - 0.500 * asc * 0.75);
112         yp[2] = int(y - asc * 0.75);
113
114         if (ltr_pos) {
115                 xp[0] = int(x);
116                 xp[1] = int(x + wid);
117                 xp[2] = int(x + wid);
118         } else {
119                 xp[0] = int(x + wid);
120                 xp[1] = int(x);
121                 xp[2] = int(x);
122         }
123
124         pain.lines(xp, yp, 3, LColor::eolmarker);
125
126         x += wid;
127 }