]> git.lyx.org Git - lyx.git/blob - src/insets/InsetLine.cpp
867f5fbb3a7c224235b7c1f66fa144d75a3ff8e5
[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 "Dimension.h"
16 #include "Font.h"
17 #include "LaTeXFeatures.h"
18 #include "MetricsInfo.h"
19 #include "OutputParams.h"
20 #include "output_xhtml.h"
21 #include "Text.h"
22
23 #include "frontends/Painter.h"
24
25 #include "support/debug.h"
26 #include "support/docstream.h"
27
28
29
30 using namespace std;
31
32 namespace lyx {
33
34 using frontend::Painter;
35
36
37 void InsetLine::read(Lexer &)
38 {
39         /* Nothing to read */
40 }
41
42
43 void InsetLine::write(ostream & os) const
44 {
45         os << "\n\\lyxline\n";
46 }
47
48
49 void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const
50 {
51         dim.asc = 3;
52         dim.des = 3;
53         dim.wid = mi.base.textwidth;
54         // Cache the inset dimension. 
55         setDimCache(mi, dim);
56 }
57
58
59 void InsetLine::draw(PainterInfo & pi, int x, int y) const
60 {
61         Dimension const dim = dimension(*pi.base.bv);
62
63         FontInfo f = pi.base.font;
64         Color Line_color = f.realColor();
65
66         pi.pain.line(x, y, x + dim.wid, y, Line_color,
67                 Painter::line_solid, 1);
68 }
69
70
71 int InsetLine::latex(odocstream & os, OutputParams const & runparams) const
72 {
73         os << "\\lyxline{\\"
74            << from_ascii(runparams.local_font->latexSize()) << '}';
75         return 0;
76 }
77
78
79 int InsetLine::plaintext(odocstream & os, OutputParams const &) const
80 {
81         os << "\n-------------------------------------------\n";
82         return PLAINTEXT_NEWLINE;
83 }
84
85
86 int InsetLine::docbook(odocstream & os, OutputParams const &) const
87 {
88         os << '\n';
89         return 0;
90 }
91
92
93 docstring InsetLine::xhtml(XHTMLStream & xs, OutputParams const &) const
94 {
95         xs << html::CompTag("hr");
96         xs.cr();
97         return docstring();
98 }
99
100
101 void InsetLine::validate(LaTeXFeatures & features) const
102 {
103         features.require("lyxline");
104 }
105
106
107 } // namespace lyx