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