2001-02-13 13:28:32 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
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
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
2001-02-14 15:00:50 +00:00
|
|
|
|
|
|
|
using std::ostream;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
MathDecorationInset::MathDecorationInset(int d)
|
|
|
|
: MathInset("", LM_OT_DECO, 1), deco_(d)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
upper_ = deco_ != LM_underline && deco_ != LM_underbrace;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
bool MathDecorationInset::GetLimits() const
|
|
|
|
{
|
|
|
|
return deco_ == LM_underbrace || deco_ == LM_overbrace;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +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-06-25 00:06:33 +00:00
|
|
|
void MathDecorationInset::draw(Painter & pain, int x, int y)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
xcell(0).draw(pain, x, y);
|
|
|
|
mathed_draw_deco(pain, x, y + 10, width_, 10, deco_);
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
void MathDecorationInset::Metrics(MathStyles st)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-02-26 12:53:35 +00:00
|
|
|
int const h = 2 * mathed_char_height(LM_TC_VAR, size(), 'I',
|
2001-06-25 00:06:33 +00:00
|
|
|
ascent_, descent_);
|
|
|
|
xcell(0).Metrics(st);
|
|
|
|
width_ = xcell(0).width();
|
|
|
|
ascent_ = xcell(0).ascent();
|
|
|
|
descent_ = xcell(0).descent();
|
|
|
|
|
|
|
|
int w = width() + 4;
|
|
|
|
if (w < 16)
|
|
|
|
w = 16;
|
|
|
|
|
|
|
|
int dh_ = w / 5;
|
|
|
|
if (dh_ > h)
|
|
|
|
dh_ = h;
|
|
|
|
|
|
|
|
int dy_;
|
2001-02-16 09:25:43 +00:00
|
|
|
if (upper_) {
|
2001-06-25 00:06:33 +00:00
|
|
|
ascent_ += dh_ + 2;
|
|
|
|
dy_ = -ascent_;
|
2001-02-13 13:28:32 +00:00
|
|
|
} else {
|
2001-06-25 00:06:33 +00:00
|
|
|
dy_ = descent_ + 2;
|
|
|
|
descent_ += dh_ + 4;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
width_ = w;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
void MathDecorationInset::Write(ostream & os, bool fragile) const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-02-16 09:25:43 +00:00
|
|
|
latexkeys const * l = lm_get_key_by_id(deco_, LM_TK_WIDE);
|
2001-02-13 13:28:32 +00:00
|
|
|
if (fragile &&
|
2001-05-31 02:23:46 +00:00
|
|
|
(compare(l->name, "overbrace") == 0 ||
|
|
|
|
compare(l->name, "underbrace") == 0 ||
|
|
|
|
compare(l->name, "overleftarrow") == 0 ||
|
|
|
|
compare(l->name, "overrightarrow") == 0))
|
2001-02-13 13:28:32 +00:00
|
|
|
os << "\\protect";
|
|
|
|
os << '\\' << l->name << '{';
|
2001-06-25 00:06:33 +00:00
|
|
|
cell(0).Write(os, fragile);
|
2001-02-13 13:28:32 +00:00
|
|
|
os << '}';
|
|
|
|
}
|