2 * \file InsetNewline.cpp
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"
16 #include "Dimension.h"
17 #include "MetricsInfo.h"
18 #include "OutputParams.h"
20 #include "frontends/FontMetrics.h"
21 #include "frontends/Painter.h"
23 #include "support/docstring.h"
32 void InsetNewline::read(Buffer const &, Lexer &)
38 void InsetNewline::write(Buffer const &, ostream & os) const
40 os << "\n" << getLyXName() << '\n';
44 void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
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');
53 int InsetNewline::latex(Buffer const &, odocstream & os,
54 OutputParams const &) const
56 os << from_ascii(getCmdName()) << '\n';
61 int InsetNewline::plaintext(Buffer const &, odocstream & os,
62 OutputParams const &) const
65 return PLAINTEXT_NEWLINE;
69 int InsetNewline::docbook(Buffer const &, odocstream & os,
70 OutputParams const &) const
77 void InsetNewline::draw(PainterInfo & pi, int x, int y) const
80 font.setColor(ColorName());
82 frontend::FontMetrics const & fm = theFontMetrics(pi.base.font);
83 int const wid = fm.width('n');
84 int const asc = fm.maxAscent();
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);
94 xp[0] = int(x + wid * 0.375);
96 xp[2] = int(x + wid * 0.375);
98 xp[0] = int(x + wid * 0.625);
100 xp[2] = int(x + wid * 0.625);
103 pi.pain.lines(xp, yp, 3, ColorName());
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);
111 xp[1] = int(x + wid);
112 xp[2] = int(x + wid);
114 xp[0] = int(x + wid);
119 pi.pain.lines(xp, yp, 3, ColorName());
121 // add label text behind the newline marker to divide from \newline
125 theFontMetrics(font).rectText(insetLabel(), w, a, d);
127 int const text_start = int(x + 2 * wid);
129 pi.pain.rectText(text_start, yp[0] + d, insetLabel(), font,
130 Color_none, Color_none);
134 bool InsetNewline::isSpace() const