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"
19 #include "frontends/Painter.h"
21 #include "support/std_ostream.h"
27 InsetMathPhantom::InsetMathPhantom(Kind k)
28 : InsetMathNest(1), kind_(k)
32 std::auto_ptr<InsetBase> InsetMathPhantom::doClone() const
34 return std::auto_ptr<InsetBase>(new InsetMathPhantom(*this));
38 bool InsetMathPhantom::metrics(MetricsInfo & mi, Dimension & dim) const
40 cell(0).metrics(mi, dim);
49 void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const
51 static int const arrow_size = 4;
53 // We first draw the text and then an arrow
54 Color_color const origcol = pi.base.font.color();
55 pi.base.font.setColor(Color::special);
56 cell(0).draw(pi, x + 1, y);
57 pi.base.font.setColor(origcol);
59 if (kind_ == phantom || kind_ == vphantom) {
72 int const x2 = x + dim_.wid / 2;
73 int const x1 = x2 - arrow_size;
74 int const x3 = x2 + arrow_size;
76 int const y1 = y - dim_.asc;
77 int const y2 = y1 + arrow_size;
78 int const y4 = y + dim_.des;
79 int const y3 = y4 - arrow_size;
82 pi.pain.line(x2, y1, x1, y2, Color::added_space);
83 pi.pain.line(x2, y1, x3, y2, Color::added_space);
86 pi.pain.line(x2, y4, x1, y3, Color::added_space);
87 pi.pain.line(x2, y4, x3, y3, Color::added_space);
90 pi.pain.line(x2, y1, x2, y4, Color::added_space);
93 if (kind_ == phantom || kind_ == hphantom) {
96 // y2--- <---------------->
103 int const x2 = x + arrow_size;
104 int const x4 = x + dim_.wid;
105 int const x3 = x4 - arrow_size;
107 int const y2 = y + (dim_.des - dim_.asc) / 2;
108 int const y1 = y2 - arrow_size;
109 int const y3 = y2 + arrow_size;
112 pi.pain.line(x1, y2, x2, y3, Color::added_space);
113 pi.pain.line(x1, y2, x2, y1, Color::added_space);
116 pi.pain.line(x4, y2, x3, y3, Color::added_space);
117 pi.pain.line(x4, y2, x3, y1, Color::added_space);
120 pi.pain.line(x1, y2, x4, y2, Color::added_space);
123 drawMarkers(pi, x, y);
127 void InsetMathPhantom::write(WriteStream & os) const
140 os << cell(0) << '}';
144 void InsetMathPhantom::normalize(NormalStream & os) const
157 os << cell(0) << ']';
161 void InsetMathPhantom::infoize(odocstream & os) const