]> git.lyx.org Git - lyx.git/blob - src/insets/insetpagebreak.C
* lfuns.h: new LFUN_REPEAT, LFUN_INSERT_LINE, LFUN_INSERT_PAGEBREAK
[lyx.git] / src / insets / insetpagebreak.C
1 /**
2  * \file insetline.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         pi.pain.line(x, y, x + dim_.wid, y, LColor::topline, Painter::line_solid,
53                         Painter::line_thick);
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                         LatexRunParams const &) const
79 {
80         os << "\\newpage{}";
81         return 0;
82 }
83
84
85 int InsetPagebreak::ascii(Buffer const &, ostream & os, int) const
86 {
87         os << "-------------------------------------------";
88         return 0;
89 }
90
91
92 int InsetPagebreak::linuxdoc(Buffer const &, std::ostream & os) const
93 {
94         os << '\n';
95         return 0;
96 }
97
98
99 int InsetPagebreak::docbook(Buffer const &, std::ostream & os, bool) const
100 {
101         os << '\n';
102         return 0;
103 }