]> git.lyx.org Git - lyx.git/blob - src/insets/insetpagebreak.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[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 "gettext.h"
17 #include "LColor.h"
18 #include "lyxtext.h"
19 #include "metricsinfo.h"
20 #include "TextMetrics.h"
21
22 #include "frontends/FontMetrics.h"
23 #include "frontends/Painter.h"
24
25
26 namespace lyx {
27
28 using frontend::Painter;
29
30 using std::endl;
31 using std::ostream;
32
33
34 void InsetPagebreak::read(Buffer const &, LyXLex &)
35 {
36         /* Nothing to read */
37 }
38
39
40 void InsetPagebreak::write(Buffer const &, ostream & os) const
41 {
42         os << "\n" << getCmdName() << '\n';
43 }
44
45
46 bool InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
47 {
48         dim.asc = defaultRowHeight();
49         dim.des = defaultRowHeight();
50         dim.wid = mi.base.textwidth;
51         bool const changed = dim_ != dim;
52         dim_ = dim;
53         return changed;
54 }
55
56
57 void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
58 {
59         LyXFont font;
60         font.setColor(LColor::pagebreak);
61         font.decSize();
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                 LColor::none, LColor::none);
73
74         pi.pain.line(x, y, text_start, y,
75                    LColor::pagebreak, Painter::line_onoffdash);
76         pi.pain.line(text_end, y, int(x + dim_.wid), y,
77                    LColor::pagebreak, Painter::line_onoffdash);
78 }
79
80
81 int InsetPagebreak::latex(Buffer const &, odocstream & os,
82                           OutputParams const &) const
83 {
84         os << from_ascii(getCmdName()) << "{}";
85         return 0;
86 }
87
88
89 int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
90                           OutputParams const &) const
91 {
92         os << '\n';
93         return 0;
94 }
95
96
97 int InsetPagebreak::docbook(Buffer const &, odocstream & os,
98                             OutputParams const &) const
99 {
100         os << '\n';
101         return 0;
102 }
103
104
105 } // namespace lyx