]> git.lyx.org Git - lyx.git/blob - src/insets/insetpagebreak.C
move everything into namespace lyx
[lyx.git] / src / insets / insetpagebreak.C
1 /**
2  * \file insetpagebreak.C
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 "insetpagebreak.h"
14
15 #include "debug.h"
16 #include "LColor.h"
17 #include "lyxtext.h"
18 #include "metricsinfo.h"
19 #include "gettext.h"
20
21 #include "frontends/FontMetrics.h"
22 #include "frontends/Painter.h"
23
24
25 namespace lyx {
26
27 using frontend::Painter;
28
29 using std::endl;
30 using std::ostream;
31
32
33 void InsetPagebreak::read(Buffer const &, LyXLex &)
34 {
35         /* Nothing to read */
36 }
37
38
39 void InsetPagebreak::write(Buffer const &, ostream & os) const
40 {
41         os << "\n\\newpage\n";
42 }
43
44
45 void InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
46 {
47         dim.asc = defaultRowHeight();
48         dim.des = defaultRowHeight();
49         dim.wid = mi.base.textwidth;
50         dim_ = dim;
51 }
52
53
54 void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
55 {
56         static docstring const label = _("Page Break");
57
58         LyXFont font;
59         font.setColor(LColor::pagebreak);
60         font.decSize();
61
62         int w = 0;
63         int a = 0;
64         int d = 0;
65         theFontMetrics(font).rectText(label, w, a, d);
66
67         int const text_start = int(x + (dim_.wid - w) / 2);
68         int const text_end = text_start + w;
69
70         pi.pain.rectText(text_start, y + d, label, font,
71                 LColor::none, LColor::none);
72
73         pi.pain.line(x, y, text_start, y,
74                    LColor::pagebreak, Painter::line_onoffdash);
75         pi.pain.line(text_end, y, int(x + dim_.wid), y,
76                    LColor::pagebreak, Painter::line_onoffdash);
77 }
78
79
80 int InsetPagebreak::latex(Buffer const &, odocstream & os,
81                           OutputParams const &) const
82 {
83         os << "\\newpage{}";
84         return 0;
85 }
86
87
88 int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
89                           OutputParams const &) const
90 {
91         os << '\n';
92         return 0;
93 }
94
95
96 int InsetPagebreak::docbook(Buffer const &, odocstream & os,
97                             OutputParams const &) const
98 {
99         os << '\n';
100         return 0;
101 }
102
103
104 } // namespace lyx