2 * \file InsetMathPhantom.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 "InsetMathPhantom.h"
15 #include "MathStream.h"
16 #include "frontends/Painter.h"
21 InsetMathPhantom::InsetMathPhantom(Kind k)
22 : InsetMathNest(1), kind_(k)
26 Inset * InsetMathPhantom::clone() const
28 return new InsetMathPhantom(*this);
32 void InsetMathPhantom::metrics(MetricsInfo & mi, Dimension & dim) const
34 cell(0).metrics(mi, dim);
39 void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const
41 static int const arrow_size = 4;
43 // We first draw the text and then an arrow
44 ColorCode const origcol = pi.base.font.color();
45 pi.base.font.setColor(Color_special);
46 cell(0).draw(pi, x + 1, y);
47 pi.base.font.setColor(origcol);
48 Dimension const dim = dimension(*pi.base.bv);
50 if (kind_ == phantom || kind_ == vphantom) {
63 int const x2 = x + dim.wid / 2;
64 int const x1 = x2 - arrow_size;
65 int const x3 = x2 + arrow_size;
67 int const y1 = y - dim.asc;
68 int const y2 = y1 + arrow_size;
69 int const y4 = y + dim.des;
70 int const y3 = y4 - arrow_size;
73 pi.pain.line(x2, y1, x1, y2, Color_added_space);
74 pi.pain.line(x2, y1, x3, y2, Color_added_space);
77 pi.pain.line(x2, y4, x1, y3, Color_added_space);
78 pi.pain.line(x2, y4, x3, y3, Color_added_space);
81 pi.pain.line(x2, y1, x2, y4, Color_added_space);
84 if (kind_ == phantom || kind_ == hphantom) {
87 // y2--- <---------------->
94 int const x2 = x + arrow_size;
95 int const x4 = x + dim.wid;
96 int const x3 = x4 - arrow_size;
98 int const y2 = y + (dim.des - dim.asc) / 2;
99 int const y1 = y2 - arrow_size;
100 int const y3 = y2 + arrow_size;
103 pi.pain.line(x1, y2, x2, y3, Color_added_space);
104 pi.pain.line(x1, y2, x2, y1, Color_added_space);
107 pi.pain.line(x4, y2, x3, y3, Color_added_space);
108 pi.pain.line(x4, y2, x3, y1, Color_added_space);
111 pi.pain.line(x1, y2, x4, y2, Color_added_space);
114 drawMarkers(pi, x, y);
118 void InsetMathPhantom::write(WriteStream & os) const
131 os << cell(0) << '}';
135 void InsetMathPhantom::normalize(NormalStream & os) const
148 os << cell(0) << ']';
152 void InsetMathPhantom::infoize(odocstream & os) const