2 * \file math_phantominset.C
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 "math_phantominset.h"
14 #include "math_mathmlstream.h"
15 #include "math_streamstr.h"
19 #include "frontends/Painter.h"
21 #include "support/std_ostream.h"
24 MathPhantomInset::MathPhantomInset(Kind k)
25 : MathNestInset(1), kind_(k)
29 std::auto_ptr<InsetBase> MathPhantomInset::doClone() const
31 return std::auto_ptr<InsetBase>(new MathPhantomInset(*this));
35 void MathPhantomInset::metrics(MetricsInfo & mi, Dimension & dim) const
37 cell(0).metrics(mi, dim);
43 void MathPhantomInset::draw(PainterInfo & pi, int x, int y) const
45 static int const arrow_size = 4;
47 // We first draw the text and then an arrow
48 LColor_color const origcol = pi.base.font.color();
49 pi.base.font.setColor(LColor::special);
50 cell(0).draw(pi, x + 1, y);
51 pi.base.font.setColor(origcol);
53 if (kind_ == phantom || kind_ == vphantom) {
66 int const x2 = x + dim_.wid / 2;
67 int const x1 = x2 - arrow_size;
68 int const x3 = x2 + arrow_size;
70 int const y1 = y - dim_.asc;
71 int const y2 = y1 + arrow_size;
72 int const y4 = y + dim_.des;
73 int const y3 = y4 - arrow_size;
76 pi.pain.line(x2, y1, x1, y2, LColor::added_space);
77 pi.pain.line(x2, y1, x3, y2, LColor::added_space);
80 pi.pain.line(x2, y4, x1, y3, LColor::added_space);
81 pi.pain.line(x2, y4, x3, y3, LColor::added_space);
84 pi.pain.line(x2, y1, x2, y4, LColor::added_space);
87 if (kind_ == phantom || kind_ == hphantom) {
90 // y2--- <---------------->
97 int const x2 = x + arrow_size;
98 int const x4 = x + dim_.wid;
99 int const x3 = x4 - arrow_size;
101 int const y2 = y + (dim_.des - dim_.asc) / 2;
102 int const y1 = y2 - arrow_size;
103 int const y3 = y2 + arrow_size;
106 pi.pain.line(x1, y2, x2, y3, LColor::added_space);
107 pi.pain.line(x1, y2, x2, y1, LColor::added_space);
110 pi.pain.line(x4, y2, x3, y3, LColor::added_space);
111 pi.pain.line(x4, y2, x3, y1, LColor::added_space);
114 pi.pain.line(x1, y2, x4, y2, LColor::added_space);
117 drawMarkers(pi, x, y);
121 void MathPhantomInset::write(WriteStream & os) const
134 os << cell(0) << '}';
138 void MathPhantomInset::normalize(NormalStream & os) const
151 os << cell(0) << ']';
155 void MathPhantomInset::infoize(std::ostream & os) const