2 * \file math_decorationinset.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alejandro Aguilar Sierra
9 * Full author contact details are available in file CREDITS.
14 #include "math_decorationinset.h"
15 #include "math_data.h"
16 #include "math_support.h"
17 #include "math_parser.h"
18 #include "math_mathmlstream.h"
19 #include "math_streamstr.h"
23 #include "support/std_ostream.h"
28 MathDecorationInset::MathDecorationInset(latexkeys const * key)
29 : MathNestInset(1), key_(key)
33 auto_ptr<InsetBase> MathDecorationInset::clone() const
35 return auto_ptr<InsetBase>(new MathDecorationInset(*this));
39 bool MathDecorationInset::upper() const
41 return key_->name.substr(0, 5) != "under";
45 bool MathDecorationInset::isScriptable() const
48 key_->name == "overbrace" ||
49 key_->name == "underbrace" ||
50 key_->name == "overleftarrow" ||
51 key_->name == "overrightarrow" ||
52 key_->name == "overleftrightarrow" ||
53 key_->name == "underleftarrow" ||
54 key_->name == "underrightarrow" ||
55 key_->name == "underleftrightarrow";
59 bool MathDecorationInset::protect() const
62 key_->name == "overbrace" ||
63 key_->name == "underbrace" ||
64 key_->name == "overleftarrow" ||
65 key_->name == "overrightarrow" ||
66 key_->name == "overleftrightarrow" ||
67 key_->name == "underleftarrow" ||
68 key_->name == "underrightarrow" ||
69 key_->name == "underleftrightarrow";
73 bool MathDecorationInset::wide() const
76 key_->name == "overline" ||
77 key_->name == "underline" ||
78 key_->name == "overbrace" ||
79 key_->name == "underbrace" ||
80 key_->name == "overleftarrow" ||
81 key_->name == "overrightarrow" ||
82 key_->name == "overleftrightarrow" ||
83 key_->name == "widehat" ||
84 key_->name == "widetilde" ||
85 key_->name == "underleftarrow" ||
86 key_->name == "underrightarrow" ||
87 key_->name == "underleftrightarrow";
91 void MathDecorationInset::metrics(MetricsInfo & mi, Dimension & dim) const
93 cell(0).metrics(mi, dim);
95 dh_ = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
96 dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
111 void MathDecorationInset::draw(PainterInfo & pi, int x, int y) const
113 lyxerr << "MathDecorationInset::draw: x: " << x << std::endl;
114 cell(0).draw(pi, x + 1, y);
116 mathed_draw_deco(pi, x + 1, y + dy_, cell(0).width(), dh_, key_->name);
118 mathed_draw_deco(pi, x + 1 + (cell(0).width() - dw_) / 2,
119 y + dy_, dw_, dh_, key_->name);
120 drawMarkers(pi, x, y);
124 void MathDecorationInset::write(WriteStream & os) const
126 if (os.fragile() && protect())
128 os << '\\' << key_->name << '{' << cell(0) << '}';
132 void MathDecorationInset::normalize(NormalStream & os) const
134 os << "[deco " << key_->name << ' ' << cell(0) << ']';
138 void MathDecorationInset::infoize(std::ostream & os) const
140 os << "Deco: " << key_->name;