]> git.lyx.org Git - features.git/blob - src/insets/InsetNewpage.cpp
Move debug.{cpp,h}, Messages.{cpp,h} and gettext.{cpp,h} to support/.
[features.git] / src / insets / InsetNewpage.cpp
1 /**
2  * \file InsetNewpage.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetNewpage.h"
14
15 #include "support/debug.h"
16 #include "support/gettext.h"
17 #include "Text.h"
18 #include "MetricsInfo.h"
19 #include "OutputParams.h"
20 #include "TextMetrics.h"
21
22 #include "frontends/FontMetrics.h"
23 #include "frontends/Painter.h"
24
25 #include "support/docstring.h"
26 #include "support/docstream.h"
27
28
29 namespace lyx {
30
31 void InsetNewpage::read(Buffer const &, Lexer &)
32 {
33         /* Nothing to read */
34 }
35
36
37 void InsetNewpage::write(Buffer const &, std::ostream & os) const
38 {
39         os << "\n" << getCmdName() << '\n';
40 }
41
42
43 void InsetNewpage::metrics(MetricsInfo & mi, Dimension & dim) const
44 {
45         dim.asc = defaultRowHeight();
46         dim.des = defaultRowHeight();
47         dim.wid = mi.base.textwidth;
48         // Cache the inset dimension. 
49         setDimCache(mi, dim);
50 }
51
52
53 void InsetNewpage::draw(PainterInfo & pi, int x, int y) const
54 {
55         using frontend::Painter;
56
57         FontInfo font;
58         font.setColor(ColorName());
59         font.decSize();
60
61         Dimension const dim = dimension(*pi.base.bv);
62
63         int w = 0;
64         int a = 0;
65         int d = 0;
66         theFontMetrics(font).rectText(insetLabel(), w, a, d);
67
68         int const text_start = int(x + (dim.wid - w) / 2);
69         int const text_end = text_start + w;
70
71         pi.pain.rectText(text_start, y + d, insetLabel(), font,
72                 Color_none, Color_none);
73
74         pi.pain.line(x, y, text_start, y,
75                    ColorName(), Painter::line_onoffdash);
76         pi.pain.line(text_end, y, int(x + dim.wid), y,
77                    ColorName(), Painter::line_onoffdash);
78 }
79
80
81 int InsetNewpage::latex(Buffer const &, odocstream & os,
82                           OutputParams const &) const
83 {
84         os << from_ascii(getCmdName()) << "{}";
85         return 0;
86 }
87
88
89 int InsetNewpage::plaintext(Buffer const &, odocstream & os,
90                               OutputParams const &) const
91 {
92         os << '\n';
93         return PLAINTEXT_NEWLINE;
94 }
95
96
97 int InsetNewpage::docbook(Buffer const &, odocstream & os,
98                             OutputParams const &) const
99 {
100         os << '\n';
101         return 0;
102 }
103
104
105 } // namespace lyx