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"
15 #include "Dimension.h"
16 #include "MetricsInfo.h"
17 #include "OutputParams.h"
19 #include "frontends/FontMetrics.h"
20 #include "frontends/Painter.h"
22 #include "support/debug.h"
23 #include "support/docstring.h"
24 #include "support/docstream.h"
31 void InsetNewline::read(Lexer &)
37 void InsetNewline::write(ostream & os) const
39 os << "\n" << getLyXName() << '\n';
43 void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
45 frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
46 dim.asc = fm.maxAscent();
47 dim.des = fm.maxDescent();
48 dim.wid = fm.width('n');
52 int InsetNewline::latex(odocstream & os, OutputParams const &) const
54 os << from_ascii(getCmdName()) << '\n';
59 int InsetNewline::plaintext(odocstream & os, OutputParams const &) const
62 return PLAINTEXT_NEWLINE;
66 int InsetNewline::docbook(odocstream & os, OutputParams const &) const
73 void InsetNewline::draw(PainterInfo & pi, int x, int y) const
76 font.setColor(ColorName());
78 frontend::FontMetrics const & fm = theFontMetrics(pi.base.font);
79 int const wid = fm.width('n');
80 int const asc = fm.maxAscent();
85 yp[0] = int(y - 0.875 * asc * 0.75);
86 yp[1] = int(y - 0.500 * asc * 0.75);
87 yp[2] = int(y - 0.125 * asc * 0.75);
90 xp[0] = int(x + wid * 0.375);
92 xp[2] = int(x + wid * 0.375);
94 xp[0] = int(x + wid * 0.625);
96 xp[2] = int(x + wid * 0.625);
99 pi.pain.lines(xp, yp, 3, ColorName());
101 yp[0] = int(y - 0.500 * asc * 0.75);
102 yp[1] = int(y - 0.500 * asc * 0.75);
103 yp[2] = int(y - asc * 0.75);
107 xp[1] = int(x + wid);
108 xp[2] = int(x + wid);
110 xp[0] = int(x + wid);
115 pi.pain.lines(xp, yp, 3, ColorName());
117 // add label text behind the newline marker to divide from \newline
121 theFontMetrics(font).rectText(insetLabel(), w, a, d);
123 int const text_start = int(x + 2 * wid);
125 pi.pain.rectText(text_start, yp[0] + d, insetLabel(), font,
126 Color_none, Color_none);
130 bool InsetNewline::isSpace() const