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