]> git.lyx.org Git - lyx.git/blob - src/insets/insetnewline.C
This commit is a big rework of the FontLoader/FontMetrics interaction. Only Qt4 for...
[lyx.git] / src / insets / insetnewline.C
1 /**
2  * \file insetnewline.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "insetnewline.h"
14
15 #include "debug.h"
16 #include "LColor.h"
17 #include "lyxtext.h"
18 #include "metricsinfo.h"
19 #include "paragraph.h"
20 #include "paragraph_funcs.h"
21
22 #include "frontends/Application.h"
23 #include "frontends/FontLoader.h"
24 #include "frontends/FontMetrics.h"
25 #include "frontends/Painter.h"
26
27 using std::endl;
28 using std::ostream;
29
30
31 void InsetNewline::read(Buffer const &, LyXLex &)
32 {
33         /* Nothing to read */
34 }
35
36
37 void InsetNewline::write(Buffer const &, ostream & os) const
38 {
39         os << "\n\\newline\n";
40 }
41
42
43 void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
44 {
45         lyx::frontend::FontMetrics const & fm =
46                 theApp->fontLoader().metrics(mi.base.font);
47         dim.asc = fm.maxAscent();
48         dim.des = fm.maxDescent();
49         dim.wid = fm.width('n');
50         dim_ = dim;
51 }
52
53
54 int InsetNewline::latex(Buffer const &, ostream &,
55                         OutputParams const &) const
56 {
57         lyxerr << "Eek, calling InsetNewline::latex !" << endl;
58         return 0;
59 }
60
61
62 int InsetNewline::plaintext(Buffer const &, ostream & os,
63                         OutputParams const &) const
64 {
65         os << '\n';
66         return 0;
67 }
68
69
70 int InsetNewline::docbook(Buffer const &, std::ostream & os,
71                           OutputParams const &) const
72 {
73         os << '\n';
74         return 0;
75 }
76
77
78 void InsetNewline::draw(PainterInfo & pi, int x, int y) const
79 {
80         lyx::frontend::FontMetrics const & fm =
81                 theApp->fontLoader().metrics(pi.base.font);
82         int const wid = fm.width('n');
83         int const asc = fm.maxAscent();
84
85         int xp[3];
86         int yp[3];
87
88         yp[0] = int(y - 0.875 * asc * 0.75);
89         yp[1] = int(y - 0.500 * asc * 0.75);
90         yp[2] = int(y - 0.125 * asc * 0.75);
91
92         if (pi.ltr_pos) {
93                 xp[0] = int(x + wid * 0.375);
94                 xp[1] = int(x);
95                 xp[2] = int(x + wid * 0.375);
96         } else {
97                 xp[0] = int(x + wid * 0.625);
98                 xp[1] = int(x + wid);
99                 xp[2] = int(x + wid * 0.625);
100         }
101
102         pi.pain.lines(xp, yp, 3, LColor::eolmarker);
103
104         yp[0] = int(y - 0.500 * asc * 0.75);
105         yp[1] = int(y - 0.500 * asc * 0.75);
106         yp[2] = int(y - asc * 0.75);
107
108         if (pi.ltr_pos) {
109                 xp[0] = int(x);
110                 xp[1] = int(x + wid);
111                 xp[2] = int(x + wid);
112         } else {
113                 xp[0] = int(x + wid);
114                 xp[1] = int(x);
115                 xp[2] = int(x);
116         }
117
118         pi.pain.lines(xp, yp, 3, LColor::eolmarker);
119 }
120
121
122 bool InsetNewline::isSpace() const
123 {
124         return true;
125 }