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