2001-02-26 12:53:35 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
#include "math_deliminset.h"
|
|
|
|
#include "math_parser.h"
|
|
|
|
#include "Painter.h"
|
|
|
|
#include "mathed/support.h"
|
2001-02-14 15:00:50 +00:00
|
|
|
#include "support/LOstream.h"
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
MathDelimInset::MathDelimInset(int l, int r)
|
2001-07-09 10:19:50 +00:00
|
|
|
: MathInset(1), left_(l), right_(r)
|
2001-06-25 00:06:33 +00:00
|
|
|
{}
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
MathInset * MathDelimInset::clone() const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-02-20 10:49:48 +00:00
|
|
|
return new MathDelimInset(*this);
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
void MathDelimInset::Write(std::ostream & os, bool fragile) const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-02-16 09:25:43 +00:00
|
|
|
latexkeys const * l = (left_ != '|') ?
|
|
|
|
lm_get_key_by_id(left_, LM_TK_SYM) : 0;
|
|
|
|
latexkeys const * r = (right_ != '|') ?
|
|
|
|
lm_get_key_by_id(right_, LM_TK_SYM) : 0;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
os << "\\left";
|
2001-06-25 00:06:33 +00:00
|
|
|
if (l)
|
2001-02-13 13:28:32 +00:00
|
|
|
os << '\\' << l->name << ' ';
|
2001-06-25 00:06:33 +00:00
|
|
|
else {
|
|
|
|
if (left_ == '{' || left_ == '}')
|
2001-02-16 09:25:43 +00:00
|
|
|
os << '\\' << char(left_) << ' ';
|
2001-06-25 00:06:33 +00:00
|
|
|
else
|
2001-02-16 09:25:43 +00:00
|
|
|
os << char(left_) << ' ';
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
cell(0).Write(os, fragile);
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
os << "\\right";
|
2001-06-25 00:06:33 +00:00
|
|
|
if (r)
|
2001-02-13 13:28:32 +00:00
|
|
|
os << '\\' << r->name << ' ';
|
2001-06-25 00:06:33 +00:00
|
|
|
else {
|
|
|
|
if (right_ == '{' || right_ == '}')
|
2001-02-16 09:25:43 +00:00
|
|
|
os << '\\' << char(right_) << ' ';
|
2001-06-25 00:06:33 +00:00
|
|
|
else
|
2001-02-16 09:25:43 +00:00
|
|
|
os << char(right_) << ' ';
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 15:43:57 +00:00
|
|
|
void MathDelimInset::draw(Painter & pain, int x, int y)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-02-15 12:22:01 +00:00
|
|
|
xo(x);
|
|
|
|
yo(y);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
int w = dw();
|
|
|
|
xcell(0).draw(pain, x + w, y);
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
if (left_ == '.') {
|
2001-06-25 00:06:33 +00:00
|
|
|
pain.line(x + 4, yo() - ascent_, x + 4, yo() + descent_,
|
2001-02-13 13:28:32 +00:00
|
|
|
LColor::mathcursor, Painter::line_onoffdash);
|
|
|
|
} else
|
2001-06-25 00:06:33 +00:00
|
|
|
mathed_draw_deco(pain, x, y - ascent_, w, height(), left_);
|
|
|
|
|
|
|
|
x += width() - w - 2;
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
if (right_ == '.') {
|
2001-06-25 00:06:33 +00:00
|
|
|
pain.line(x + 4, yo() - ascent_, x + 4, yo() + descent_,
|
2001-02-13 13:28:32 +00:00
|
|
|
LColor::mathcursor, Painter::line_onoffdash);
|
|
|
|
} else
|
2001-06-25 00:06:33 +00:00
|
|
|
mathed_draw_deco(pain, x, y - ascent_, w, height(), right_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MathDelimInset::dw() const
|
|
|
|
{
|
|
|
|
int w = height()/5;
|
|
|
|
if (w > 15)
|
|
|
|
w = 15;
|
|
|
|
if (w < 6)
|
|
|
|
w = 6;
|
|
|
|
return w;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-26 06:46:50 +00:00
|
|
|
void MathDelimInset::Metrics(MathStyles st)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
xcell(0).Metrics(st);
|
|
|
|
size_ = st;
|
|
|
|
ascent_ = xcell(0).ascent() + 2;
|
|
|
|
descent_ = xcell(0).descent() + 2;
|
|
|
|
width_ = xcell(0).width() + 2 * dw() + 4;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|