2 * \file InsetNewpage.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 "InsetNewpage.h"
16 #include "MetricsInfo.h"
17 #include "OutputParams.h"
18 #include "TextMetrics.h"
20 #include "frontends/FontMetrics.h"
21 #include "frontends/Painter.h"
23 #include "support/debug.h"
24 #include "support/docstring.h"
25 #include "support/docstream.h"
26 #include "support/gettext.h"
32 void InsetNewpage::read(Buffer const &, Lexer &)
38 void InsetNewpage::write(Buffer const &, ostream & os) const
40 os << "\n" << getCmdName() << '\n';
44 void InsetNewpage::metrics(MetricsInfo & mi, Dimension & dim) const
46 dim.asc = defaultRowHeight();
47 dim.des = defaultRowHeight();
48 dim.wid = mi.base.textwidth;
49 // Cache the inset dimension.
54 void InsetNewpage::draw(PainterInfo & pi, int x, int y) const
56 using frontend::Painter;
59 font.setColor(ColorName());
62 Dimension const dim = dimension(*pi.base.bv);
67 theFontMetrics(font).rectText(insetLabel(), w, a, d);
69 int const text_start = int(x + (dim.wid - w) / 2);
70 int const text_end = text_start + w;
72 pi.pain.rectText(text_start, y + d, insetLabel(), font,
73 Color_none, Color_none);
75 pi.pain.line(x, y, text_start, y,
76 ColorName(), Painter::line_onoffdash);
77 pi.pain.line(text_end, y, int(x + dim.wid), y,
78 ColorName(), Painter::line_onoffdash);
82 int InsetNewpage::latex(Buffer const &, odocstream & os,
83 OutputParams const &) const
85 os << from_ascii(getCmdName()) << "{}";
90 int InsetNewpage::plaintext(Buffer const &, odocstream & os,
91 OutputParams const &) const
94 return PLAINTEXT_NEWLINE;
98 int InsetNewpage::docbook(Buffer const &, odocstream & os,
99 OutputParams const &) const