]> git.lyx.org Git - lyx.git/blob - src/insets/InsetHFill.cpp
do what the FIXME suggested
[lyx.git] / src / insets / InsetHFill.cpp
1 /**
2  * \file InsetHFill.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 "InsetHFill.h"
14
15 #include "MetricsInfo.h"
16
17 #include "frontends/Painter.h"
18
19 #include "support/gettext.h"
20
21 #include <ostream>
22
23 using namespace std;
24
25 namespace lyx {
26
27
28 InsetHFill::InsetHFill()
29         : InsetCommand(InsetCommandParams(HFILL_CODE), string())
30 {}
31
32
33 ParamInfo const & InsetHFill::findInfo(string const & /* cmdName */)
34 {
35         static ParamInfo param_info_;
36         return param_info_;
37 }
38
39
40 void InsetHFill::metrics(MetricsInfo &, Dimension & dim) const
41 {
42         // The metrics for this inset are calculated externally in
43         // \c TextMetrics::computeRowMetrics. Those are dummy value:
44         dim = Dimension(10, 10, 10);
45 }
46
47
48 void InsetHFill::draw(PainterInfo & pi, int x, int y) const
49 {
50         Dimension const dim = Inset::dimension(*pi.base.bv);
51         int const x0 = x + 1;
52         int const x1 = x + dim.wid - 2;
53         int const y0 = y + dim.des - 1;
54         int const y1 = y - dim.asc + 1;
55
56         pi.pain.line(x0, y1, x0, y0, Color_added_space);
57         pi.pain.line(x0, y, x1, y, Color_added_space,
58                 frontend::Painter::line_onoffdash);
59         pi.pain.line(x1, y1, x1, y0, Color_added_space);
60 }
61
62
63 docstring InsetHFill::screenLabel() const
64 {
65         return _("Horizontal Fill");
66 }
67
68
69 int InsetHFill::plaintext(odocstream & os, OutputParams const &) const
70 {
71         os << "     ";
72         return 5;
73 }
74
75
76 int InsetHFill::docbook(odocstream & os, OutputParams const &) const
77 {
78         os << '\n';
79         return 0;
80 }
81
82
83 void InsetHFill::write(ostream & os) const
84 {
85         os << "\n\\hfill\n";
86 }
87
88
89 bool InsetHFill::isSpace() const
90 {
91         return true;
92 }
93
94
95 } // namespace lyx