3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "insetnewline.h"
15 #include "BufferView.h"
17 #include "dimension.h"
18 #include "paragraph.h"
20 #include "metricsinfo.h"
21 #include "paragraph_funcs.h"
23 #include "support/LOstream.h"
25 #include "frontends/Painter.h"
26 #include "frontends/font_metrics.h"
32 void InsetNewline::read(Buffer const *, LyXLex &)
38 void InsetNewline::write(Buffer const *, ostream & os) const
40 os << "\n\\newline \n";
44 void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
46 LyXFont & font = mi.base.font;
47 dim.asc = font_metrics::maxAscent(font);
48 dim.des = font_metrics::maxDescent(font);
49 dim.wid = font_metrics::width('n', font);
54 int InsetNewline::latex(Buffer const *, ostream &,
55 LatexRunParams const &) const
57 lyxerr << "Eek, calling InsetNewline::latex !" << endl;
62 int InsetNewline::ascii(Buffer const *, ostream & os, int) const
69 int InsetNewline::linuxdoc(Buffer const *, std::ostream & os) const
76 int InsetNewline::docbook(Buffer const *, std::ostream & os, bool) const
83 void InsetNewline::draw(PainterInfo & pi, int x, int y) const
85 int const wid = font_metrics::width('n', pi.base.font);
86 int const asc = font_metrics::maxAscent(pi.base.font);
88 // hack, and highly dubious
89 lyx::pos_type pos = ownerPar(*pi.base.bv->buffer(), this)
90 .getPositionOfInset(this);
91 bool const ltr_pos = (pi.base.bv->text->bidi_level(pos) % 2 == 0);
96 yp[0] = int(y - 0.875 * asc * 0.75);
97 yp[1] = int(y - 0.500 * asc * 0.75);
98 yp[2] = int(y - 0.125 * asc * 0.75);
101 xp[0] = int(x + wid * 0.375);
103 xp[2] = int(x + wid * 0.375);
105 xp[0] = int(x + wid * 0.625);
106 xp[1] = int(x + wid);
107 xp[2] = int(x + wid * 0.625);
110 pi.pain.lines(xp, yp, 3, LColor::eolmarker);
112 yp[0] = int(y - 0.500 * asc * 0.75);
113 yp[1] = int(y - 0.500 * asc * 0.75);
114 yp[2] = int(y - asc * 0.75);
118 xp[1] = int(x + wid);
119 xp[2] = int(x + wid);
121 xp[0] = int(x + wid);
126 pi.pain.lines(xp, yp, 3, LColor::eolmarker);