2001-02-26 12:53:35 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
#include "math_decorationinset.h"
|
|
|
|
#include "mathed/support.h"
|
|
|
|
#include "math_parser.h"
|
2001-02-14 15:00:50 +00:00
|
|
|
#include "support/LOstream.h"
|
2001-05-31 02:23:46 +00:00
|
|
|
|
2001-02-14 15:00:50 +00:00
|
|
|
|
|
|
|
using std::ostream;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
|
2001-07-26 16:14:23 +00:00
|
|
|
MathDecorationInset::MathDecorationInset(latexkeys const * key)
|
|
|
|
: MathInset(1), key_(key)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-07-26 16:14:23 +00:00
|
|
|
upper_ = key_->id != LM_underline && key_->id != LM_underbrace;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
MathInset * MathDecorationInset::clone() const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-02-20 10:49:48 +00:00
|
|
|
return new MathDecorationInset(*this);
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathDecorationInset::metrics(MathStyles st)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-07-26 06:56:43 +00:00
|
|
|
xcell(0).metrics(st);
|
2001-07-10 17:21:26 +00:00
|
|
|
size_ = st;
|
2001-06-25 00:06:33 +00:00
|
|
|
width_ = xcell(0).width();
|
|
|
|
ascent_ = xcell(0).ascent();
|
|
|
|
descent_ = xcell(0).descent();
|
|
|
|
|
2001-07-10 17:21:26 +00:00
|
|
|
dh_ = 5; //mathed_char_height(LM_TC_VAR, size(), 'I', ascent_, descent_);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
if (upper_) {
|
2001-07-10 17:21:26 +00:00
|
|
|
dy_ = -ascent_ - dh_;
|
2001-07-06 12:09:32 +00:00
|
|
|
ascent_ += dh_ + 1;
|
2001-02-13 13:28:32 +00:00
|
|
|
} else {
|
2001-07-06 12:09:32 +00:00
|
|
|
dy_ = descent_ + 1;
|
|
|
|
descent_ += dh_ + 2;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
2001-07-13 07:55:55 +00:00
|
|
|
|
2001-07-26 16:14:23 +00:00
|
|
|
if (key_->id == LM_not) {
|
2001-07-13 07:55:55 +00:00
|
|
|
ascent_ += dh_;
|
|
|
|
descent_ += dh_;
|
|
|
|
dh_ = height();
|
|
|
|
dy_ = - ascent_;
|
|
|
|
}
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
2001-07-05 14:48:45 +00:00
|
|
|
void MathDecorationInset::draw(Painter & pain, int x, int y)
|
|
|
|
{
|
|
|
|
xo(x);
|
|
|
|
yo(x);
|
|
|
|
xcell(0).draw(pain, x, y);
|
2001-07-26 16:14:23 +00:00
|
|
|
mathed_draw_deco(pain, x, y + dy_, width_, dh_, key_->id);
|
2001-07-05 14:48:45 +00:00
|
|
|
}
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathDecorationInset::write(ostream & os, bool fragile) const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-07-26 16:14:23 +00:00
|
|
|
string name = key_->name;
|
2001-02-13 13:28:32 +00:00
|
|
|
if (fragile &&
|
2001-07-26 16:14:23 +00:00
|
|
|
(name == "overbrace" ||
|
|
|
|
name == "underbrace" ||
|
|
|
|
name == "overleftarrow" ||
|
|
|
|
name == "overrightarrow"))
|
2001-02-13 13:28:32 +00:00
|
|
|
os << "\\protect";
|
2001-07-26 16:14:23 +00:00
|
|
|
os << '\\' << name;
|
2001-07-13 07:55:55 +00:00
|
|
|
|
2001-07-26 16:14:23 +00:00
|
|
|
if (key_->id == LM_not)
|
2001-07-13 07:55:55 +00:00
|
|
|
os << ' ';
|
|
|
|
else
|
|
|
|
os << '{';
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
cell(0).write(os, fragile);
|
2001-07-13 07:55:55 +00:00
|
|
|
|
2001-07-26 16:14:23 +00:00
|
|
|
if (key_->id != LM_not)
|
2001-07-13 07:55:55 +00:00
|
|
|
os << '}';
|
|
|
|
}
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathDecorationInset::writeNormal(ostream & os) const
|
2001-07-13 07:55:55 +00:00
|
|
|
{
|
2001-07-26 16:14:23 +00:00
|
|
|
os << "[" << key_->name << " ";
|
2001-07-26 06:56:43 +00:00
|
|
|
cell(0).writeNormal(os);
|
2001-07-13 07:55:55 +00:00
|
|
|
os << "] ";
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|