2 * \file InsetMathSqrt.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathSqrt.h"
15 #include "MathStream.h"
16 #include "TextPainter.h"
17 #include "frontends/Painter.h"
22 InsetMathSqrt::InsetMathSqrt(Buffer
* buf
)
23 : InsetMathNest(buf
, 1)
27 Inset
* InsetMathSqrt::clone() const
29 return new InsetMathSqrt(*this);
33 void InsetMathSqrt::metrics(MetricsInfo
& mi
, Dimension
& dim
) const
35 cell(0).metrics(mi
, dim
);
43 void InsetMathSqrt::draw(PainterInfo
& pi
, int x
, int y
) const
45 cell(0).draw(pi
, x
+ 10, y
);
46 Dimension
const dim
= dimension(*pi
.base
.bv
);
47 int const a
= dim
.ascent();
48 int const d
= dim
.descent();
51 pi
.pain
.line(x
+ dim
.width(), y
- a
+ 1,
52 x
+ 8, y
- a
+ 1, Color_math
);
53 xp
[0] = x
+ 8; yp
[0] = y
- a
+ 1;
54 xp
[1] = x
+ 5; yp
[1] = y
+ d
- 1;
55 xp
[2] = x
; yp
[2] = y
+ (d
- a
)/2;
56 pi
.pain
.lines(xp
, yp
, 3, Color_math
);
57 drawMarkers(pi
, x
, y
);
61 void InsetMathSqrt::metricsT(TextMetricsInfo
const & mi
, Dimension
& dim
) const
63 cell(0).metricsT(mi
, dim
);
69 void InsetMathSqrt::drawT(TextPainter
& /*pain*/, int /*x*/, int /*y*/) const
72 cell(0).drawT(pain, x + 2, y);
73 Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
74 pain.horizontalLine(x + 2, y - dim0.ascent(), dim0.width(), '_');
75 pain.verticalLine (x + 1, y - dim0.ascent() + 1, dim0.height());
76 pain.draw(x, y + dim0.descent(), '\\');
81 void InsetMathSqrt::write(WriteStream
& os
) const
83 MathEnsurer
ensurer(os
);
84 os
<< "\\sqrt{" << cell(0) << '}';
88 void InsetMathSqrt::normalize(NormalStream
& os
) const
90 os
<< "[sqrt " << cell(0) << ']';
93 void InsetMathSqrt::maple(MapleStream
& os
) const
95 os
<< "sqrt(" << cell(0) << ')';
98 void InsetMathSqrt::mathematica(MathematicaStream
& os
) const
100 os
<< "Sqrt[" << cell(0) << ']';
104 void InsetMathSqrt::octave(OctaveStream
& os
) const
106 os
<< "sqrt(" << cell(0) << ')';
110 void InsetMathSqrt::mathmlize(MathStream
& os
) const
112 os
<< MTag("msqrt") << cell(0) << ETag("msqrt");