]> git.lyx.org Git - lyx.git/blob - src/insets/InsetLine.cpp
4ff27b12c9b1d4fae5c3be53f02f140365cd89f1
[lyx.git] / src / insets / InsetLine.cpp
1 /**
2  * \file InsetLine.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 "InsetLine.h"
14
15 #include "debug.h"
16 #include "Color.h"
17 #include "Text.h"
18 #include "MetricsInfo.h"
19 #include "LaTeXFeatures.h"
20 #include "OutputParams.h"
21
22 #include "frontends/Painter.h"
23
24
25 namespace lyx {
26
27 using frontend::Painter;
28
29 using std::ostream;
30
31
32 void InsetLine::read(Buffer const &, Lexer &)
33 {
34         /* Nothing to read */
35 }
36
37
38 void InsetLine::write(Buffer const &, ostream & os) const
39 {
40         os << "\n\\lyxline\n";
41 }
42
43
44 bool InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const
45 {
46         dim.asc = 3;
47         dim.des = 3;
48         dim.wid = mi.base.textwidth;
49         bool const changed = dim_ != dim;
50         dim_ = dim;
51         return changed;
52 }
53
54
55 void InsetLine::draw(PainterInfo & pi, int x, int y) const
56 {
57         pi.pain.line(x, y, x + dim_.wid, y, Color::topline, Painter::line_solid,
58                         Painter::line_thick);
59 }
60
61
62 int InsetLine::latex(Buffer const &, odocstream & os,
63                      OutputParams const & runparams) const
64 {
65         os << "\\lyxline{\\"
66            << from_ascii(runparams.local_font->latexSize()) << '}';
67         return 0;
68 }
69
70
71 int InsetLine::plaintext(Buffer const &, odocstream & os,
72                          OutputParams const &) const
73 {
74         os << "\n-------------------------------------------\n";
75         return PLAINTEXT_NEWLINE;
76 }
77
78
79 int InsetLine::docbook(Buffer const &, odocstream & os,
80                        OutputParams const &) const
81 {
82         os << '\n';
83         return 0;
84 }
85
86
87 void InsetLine::validate(LaTeXFeatures & features) const
88 {
89         features.require("lyxline");
90 }
91
92
93 } // namespace lyx