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"
14 #include "MathStream.h"
15 #include "MathStream.h"
18 #include "frontends/Painter.h"
20 #include "support/std_ostream.h"
26 InsetMathPhantom::InsetMathPhantom(Kind k)
27 : InsetMathNest(1), kind_(k)
31 Inset * InsetMathPhantom::clone() const
33 return new InsetMathPhantom(*this);
37 void InsetMathPhantom::metrics(MetricsInfo & mi, Dimension & dim) const
39 cell(0).metrics(mi, dim);
41 // Cache the inset dimension.
46 void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const
48 static int const arrow_size = 4;
50 // We first draw the text and then an arrow
51 ColorCode const origcol = pi.base.font.color();
52 pi.base.font.setColor(Color_special);
53 cell(0).draw(pi, x + 1, y);
54 pi.base.font.setColor(origcol);
55 Dimension const dim = dimension(*pi.base.bv);
57 if (kind_ == phantom || kind_ == vphantom) {
70 int const x2 = x + dim.wid / 2;
71 int const x1 = x2 - arrow_size;
72 int const x3 = x2 + arrow_size;
74 int const y1 = y - dim.asc;
75 int const y2 = y1 + arrow_size;
76 int const y4 = y + dim.des;
77 int const y3 = y4 - arrow_size;
80 pi.pain.line(x2, y1, x1, y2, Color_added_space);
81 pi.pain.line(x2, y1, x3, y2, Color_added_space);
84 pi.pain.line(x2, y4, x1, y3, Color_added_space);
85 pi.pain.line(x2, y4, x3, y3, Color_added_space);
88 pi.pain.line(x2, y1, x2, y4, Color_added_space);
91 if (kind_ == phantom || kind_ == hphantom) {
94 // y2--- <---------------->
101 int const x2 = x + arrow_size;
102 int const x4 = x + dim.wid;
103 int const x3 = x4 - arrow_size;
105 int const y2 = y + (dim.des - dim.asc) / 2;
106 int const y1 = y2 - arrow_size;
107 int const y3 = y2 + arrow_size;
110 pi.pain.line(x1, y2, x2, y3, Color_added_space);
111 pi.pain.line(x1, y2, x2, y1, Color_added_space);
114 pi.pain.line(x4, y2, x3, y3, Color_added_space);
115 pi.pain.line(x4, y2, x3, y1, Color_added_space);
118 pi.pain.line(x1, y2, x4, y2, Color_added_space);
121 drawMarkers(pi, x, y);
125 void InsetMathPhantom::write(WriteStream & os) const
138 os << cell(0) << '}';
142 void InsetMathPhantom::normalize(NormalStream & os) const
155 os << cell(0) << ']';
159 void InsetMathPhantom::infoize(odocstream & os) const