2001-12-05 08:04:20 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2001-02-26 12:53:35 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
#include "math_decorationinset.h"
|
2001-11-08 12:15:12 +00:00
|
|
|
#include "math_support.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
#include "math_parser.h"
|
2001-11-08 12:06:56 +00:00
|
|
|
#include "math_mathmlstream.h"
|
2001-12-05 08:04:20 +00:00
|
|
|
#include "math_streamstr.h"
|
2002-06-25 03:56:30 +00:00
|
|
|
#include "support/LOstream.h"
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2002-07-17 10:25:33 +00:00
|
|
|
MathDecorationInset::MathDecorationInset(latexkeys const * key)
|
|
|
|
: MathNestInset(1), key_(key)
|
2001-09-03 15:22:55 +00:00
|
|
|
{}
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
MathInset * MathDecorationInset::clone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2001-02-20 10:49:48 +00:00
|
|
|
return new MathDecorationInset(*this);
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-15 06:53:25 +00:00
|
|
|
bool MathDecorationInset::upper() const
|
|
|
|
{
|
2002-07-17 10:25:33 +00:00
|
|
|
return key_->name.substr(0, 5) != "under";
|
2001-08-15 06:53:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-11 10:58:17 +00:00
|
|
|
bool MathDecorationInset::isScriptable() const
|
|
|
|
{
|
2001-09-12 13:23:39 +00:00
|
|
|
return
|
2002-07-17 10:25:33 +00:00
|
|
|
key_->name == "overbrace" ||
|
|
|
|
key_->name == "underbrace" ||
|
|
|
|
key_->name == "overleftarrow" ||
|
|
|
|
key_->name == "overrightarrow" ||
|
|
|
|
key_->name == "overleftrightarrow" ||
|
|
|
|
key_->name == "underleftarrow" ||
|
|
|
|
key_->name == "underrightarrow" ||
|
|
|
|
key_->name == "underleftrightarrow";
|
2001-09-11 10:58:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-15 06:53:25 +00:00
|
|
|
bool MathDecorationInset::protect() const
|
|
|
|
{
|
|
|
|
return
|
2002-07-17 10:25:33 +00:00
|
|
|
key_->name == "overbrace" ||
|
|
|
|
key_->name == "underbrace" ||
|
|
|
|
key_->name == "overleftarrow" ||
|
|
|
|
key_->name == "overrightarrow" ||
|
|
|
|
key_->name == "overleftrightarrow" ||
|
|
|
|
key_->name == "underleftarrow" ||
|
|
|
|
key_->name == "underrightarrow" ||
|
|
|
|
key_->name == "underleftrightarrow";
|
2001-08-15 06:53:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-09-12 15:56:09 +00:00
|
|
|
bool MathDecorationInset::wide() const
|
|
|
|
{
|
|
|
|
return
|
2002-07-17 10:25:33 +00:00
|
|
|
key_->name == "overline" ||
|
|
|
|
key_->name == "underline" ||
|
|
|
|
key_->name == "overbrace" ||
|
|
|
|
key_->name == "underbrace" ||
|
|
|
|
key_->name == "overleftarrow" ||
|
|
|
|
key_->name == "overrightarrow" ||
|
|
|
|
key_->name == "overleftrightarrow" ||
|
|
|
|
key_->name == "widehat" ||
|
|
|
|
key_->name == "widetilde" ||
|
|
|
|
key_->name == "underleftarrow" ||
|
|
|
|
key_->name == "underrightarrow" ||
|
|
|
|
key_->name == "underleftrightarrow";
|
2001-09-12 15:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-28 13:22:36 +00:00
|
|
|
Dimension MathDecorationInset::metrics(MetricsInfo & mi) const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
cell(0).metrics(mi);
|
|
|
|
dim_ = cell(0).dim();
|
2003-05-28 13:22:36 +00:00
|
|
|
|
2002-07-11 11:27:24 +00:00
|
|
|
dh_ = 6; //mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);
|
|
|
|
dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-08-15 06:53:25 +00:00
|
|
|
if (upper()) {
|
2003-05-27 13:55:03 +00:00
|
|
|
dy_ = -dim_.asc - dh_;
|
|
|
|
dim_.asc += dh_ + 1;
|
2001-02-13 13:28:32 +00:00
|
|
|
} else {
|
2003-05-27 13:55:03 +00:00
|
|
|
dy_ = dim_.des + 1;
|
|
|
|
dim_.des += dh_ + 2;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
2002-06-24 15:37:14 +00:00
|
|
|
|
2002-07-11 11:27:24 +00:00
|
|
|
metricsMarkers();
|
2003-05-28 13:22:36 +00:00
|
|
|
return dim_;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
2001-09-03 15:22:55 +00:00
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
void MathDecorationInset::draw(PainterInfo & pi, int x, int y) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
cell(0).draw(pi, x + 1, y);
|
2002-03-21 17:42:56 +00:00
|
|
|
if (wide())
|
2003-05-28 13:22:36 +00:00
|
|
|
mathed_draw_deco(pi, x + 1, y + dy_, pi.width, dh_, key_->name);
|
2002-03-19 16:55:58 +00:00
|
|
|
else
|
2003-05-28 13:22:36 +00:00
|
|
|
mathed_draw_deco(pi, x + 1 + (pi.width - dw_) / 2,
|
|
|
|
y + dy_, dw_, dh_, key_->name);
|
2002-06-24 15:37:14 +00:00
|
|
|
drawMarkers(pi, x, y);
|
2001-07-05 14:48:45 +00:00
|
|
|
}
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
void MathDecorationInset::write(WriteStream & os) const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
if (os.fragile() && protect())
|
2001-02-13 13:28:32 +00:00
|
|
|
os << "\\protect";
|
2002-07-17 10:25:33 +00:00
|
|
|
os << '\\' << key_->name << '{' << cell(0) << '}';
|
2001-07-13 07:55:55 +00:00
|
|
|
}
|
|
|
|
|
2001-08-15 06:53:25 +00:00
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
void MathDecorationInset::normalize(NormalStream & os) const
|
2001-07-13 07:55:55 +00:00
|
|
|
{
|
2002-07-17 10:25:33 +00:00
|
|
|
os << "[deco " << key_->name << ' ' << cell(0) << ']';
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
2002-06-24 15:37:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
void MathDecorationInset::infoize(std::ostream & os) const
|
|
|
|
{
|
2002-07-17 10:25:33 +00:00
|
|
|
os << "Deco: " << key_->name;
|
2002-06-24 15:37:14 +00:00
|
|
|
}
|