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