2001-02-13 13:28:32 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "math_deliminset.h"
|
|
|
|
#include "math_iter.h"
|
|
|
|
#include "math_parser.h"
|
|
|
|
#include "LColor.h"
|
|
|
|
#include "Painter.h"
|
|
|
|
#include "mathed/support.h"
|
2001-02-14 15:00:50 +00:00
|
|
|
#include "support/LOstream.h"
|
|
|
|
|
|
|
|
using std::ostream;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
MathDelimInset::MathDelimInset(int l, int r, short st)
|
2001-02-16 09:25:43 +00:00
|
|
|
: MathParInset(st, "", LM_OT_DELIM), left_(l), right_(r) {}
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
MathedInset * MathDelimInset::Clone()
|
|
|
|
{
|
2001-02-20 10:49:48 +00:00
|
|
|
return new MathDelimInset(*this);
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathDelimInset::Write(ostream & os, bool fragile)
|
|
|
|
{
|
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-02-13 13:28:32 +00:00
|
|
|
os << "\\left";
|
|
|
|
if (l) {
|
|
|
|
os << '\\' << l->name << ' ';
|
|
|
|
} else {
|
2001-02-16 09:25:43 +00:00
|
|
|
if (left_ == '{' || left_ == '}') {
|
|
|
|
os << '\\' << char(left_) << ' ';
|
2001-02-13 13:28:32 +00:00
|
|
|
} else {
|
2001-02-16 09:25:43 +00:00
|
|
|
os << char(left_) << ' ';
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
MathParInset::Write(os, fragile);
|
|
|
|
os << "\\right";
|
|
|
|
if (r) {
|
|
|
|
os << '\\' << r->name << ' ';
|
|
|
|
} else {
|
2001-02-16 09:25:43 +00:00
|
|
|
if (right_ == '{' || right_ == '}') {
|
|
|
|
os << '\\' << char(right_) << ' ';
|
2001-02-13 13:28:32 +00:00
|
|
|
} else {
|
2001-02-16 09:25:43 +00:00
|
|
|
os << char(right_) << ' ';
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
MathDelimInset::draw(Painter & pain, int x, int y)
|
|
|
|
{
|
2001-02-15 12:22:01 +00:00
|
|
|
xo(x);
|
|
|
|
yo(y);
|
2001-02-16 09:25:43 +00:00
|
|
|
MathParInset::draw(pain, x + dw_ + 2, y - dh_);
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
if (left_ == '.') {
|
2001-02-15 12:22:01 +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-02-16 09:25:43 +00:00
|
|
|
mathed_draw_deco(pain, x, y - ascent, dw_, Height(), left_);
|
|
|
|
x += Width() - dw_ - 2;
|
|
|
|
if (right_ == '.') {
|
2001-02-15 12:22:01 +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-02-16 09:25:43 +00:00
|
|
|
mathed_draw_deco(pain, x, y - ascent, dw_, Height(), right_);
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
MathDelimInset::Metrics()
|
|
|
|
{
|
2001-02-15 12:22:01 +00:00
|
|
|
MathParInset::Metrics();
|
|
|
|
int d;
|
|
|
|
|
2001-02-16 09:25:43 +00:00
|
|
|
mathed_char_height(LM_TC_CONST, size(), 'I', d, dh_);
|
|
|
|
dh_ /= 2;
|
|
|
|
ascent += 2 + dh_;
|
|
|
|
descent += 2 - dh_;
|
|
|
|
dw_ = Height()/5;
|
|
|
|
if (dw_ > 15) dw_ = 15;
|
|
|
|
if (dw_ < 6) dw_ = 6;
|
|
|
|
width += 2 * dw_ + 4;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|