]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathSqrt.C
cursor is no more damaging the background. L-shaped cursor is broken right now....
[lyx.git] / src / mathed / InsetMathSqrt.C
1 /**
2  * \file InsetMathSqrt.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 "InsetMathSqrt.h"
14 #include "MathData.h"
15 #include "MathStream.h"
16 #include "TextPainter.h"
17 #include "LColor.h"
18 #include "frontends/Painter.h"
19
20
21 namespace lyx {
22
23 using std::auto_ptr;
24
25
26 InsetMathSqrt::InsetMathSqrt()
27         : InsetMathNest(1)
28 {}
29
30
31 auto_ptr<InsetBase> InsetMathSqrt::doClone() const
32 {
33         return auto_ptr<InsetBase>(new InsetMathSqrt(*this));
34 }
35
36
37 void InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & dim) const
38 {
39         cell(0).metrics(mi, dim);
40         dim.asc += 4;
41         dim.des += 2;
42         dim.wid += 12;
43         metricsMarkers(dim);
44         dim_ = dim;
45 }
46
47
48 void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
49 {
50         cell(0).draw(pi, x + 10, y);
51         int const a = dim_.ascent();
52         int const d = dim_.descent();
53         int xp[4];
54         int yp[4];
55         xp[0] = x + dim_.width(); yp[0] = y - a + 1;
56         xp[1] = x + 8;            yp[1] = y - a + 1;
57         xp[2] = x + 5;            yp[2] = y + d - 1;
58         xp[3] = x;                yp[3] = y + (d - a)/2;
59         pi.pain.lines(xp, yp, 4, LColor::math);
60         drawMarkers(pi, x, y);
61 }
62
63
64 void InsetMathSqrt::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
65 {
66         cell(0).metricsT(mi, dim);
67         dim.asc += 1;
68         dim.wid += 2;
69 }
70
71
72 void InsetMathSqrt::drawT(TextPainter & pain, int x, int y) const
73 {
74         cell(0).drawT(pain, x + 2, y);
75         pain.horizontalLine(x + 2, y - cell(0).ascent(), cell(0).width(), '_');
76         pain.verticalLine  (x + 1, y - cell(0).ascent() + 1, cell(0).height());
77         pain.draw(x, y + cell(0).descent(), '\\');
78 }
79
80
81 void InsetMathSqrt::write(WriteStream & os) const
82 {
83         os << "\\sqrt{" << cell(0) << '}';
84 }
85
86
87 void InsetMathSqrt::normalize(NormalStream & os) const
88 {
89         os << "[sqrt " << cell(0) << ']';
90 }
91
92 void InsetMathSqrt::maple(MapleStream & os) const
93 {
94         os << "sqrt(" << cell(0) << ')';
95 }
96
97 void InsetMathSqrt::mathematica(MathematicaStream & os) const
98 {
99         os << "Sqrt[" << cell(0) << ']';
100 }
101
102
103 void InsetMathSqrt::octave(OctaveStream & os) const
104 {
105         os << "sqrt(" << cell(0) << ')';
106 }
107
108
109 void InsetMathSqrt::mathmlize(MathStream & os) const
110 {
111         os << MTag("msqrt") << cell(0) << ETag("msqrt");
112 }
113
114
115 } // namespace lyx