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_sqrtinset.h"
|
|
|
|
#include "math_iter.h"
|
|
|
|
#include "LColor.h"
|
|
|
|
#include "Painter.h"
|
|
|
|
#include "support.h"
|
2001-02-14 15:00:50 +00:00
|
|
|
#include "support/LOstream.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-02-14 15:00:50 +00:00
|
|
|
using std::ostream;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-02-26 12:53:35 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
MathSqrtInset::MathSqrtInset(short st)
|
|
|
|
: MathParInset(st, "sqrt", LM_OT_SQRT) {}
|
|
|
|
|
|
|
|
|
|
|
|
MathedInset * MathSqrtInset::Clone()
|
|
|
|
{
|
2001-02-20 10:49:48 +00:00
|
|
|
return new MathSqrtInset(*this);
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
void MathSqrtInset::draw(Painter & pain, int x, int y)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-02-16 09:25:43 +00:00
|
|
|
MathParInset::draw(pain, x + hmax_ + 2, y);
|
|
|
|
int const h = ascent;
|
|
|
|
int const d = descent;
|
|
|
|
int const h2 = Height() / 2;
|
|
|
|
int const w2 = (Height() > 4 * hmax_) ? hmax_ : hmax_ / 2;
|
|
|
|
int xp[4];
|
|
|
|
int yp[4];
|
|
|
|
xp[0] = x + hmax_ + wbody_; yp[0] = y - h;
|
|
|
|
xp[1] = x + hmax_; yp[1] = y - h;
|
|
|
|
xp[2] = x + w2; yp[2] = y + d;
|
|
|
|
xp[3] = x; yp[3] = y + d - h2;
|
2001-02-13 13:28:32 +00:00
|
|
|
pain.lines(xp, yp, 4, LColor::mathline);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-28 11:56:36 +00:00
|
|
|
void MathSqrtInset::Write(ostream & os, bool fragile)
|
|
|
|
{
|
|
|
|
os << '\\' << name << '{';
|
|
|
|
MathParInset::Write(os, fragile);
|
|
|
|
os << '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 15:43:57 +00:00
|
|
|
void MathSqrtInset::WriteNormal(ostream & os)
|
|
|
|
{
|
|
|
|
os << "{sqrt ";
|
|
|
|
MathParInset::WriteNormal(os);
|
|
|
|
os << "} ";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
void MathSqrtInset::Metrics()
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
|
|
|
MathParInset::Metrics();
|
2001-04-24 16:13:38 +00:00
|
|
|
ascent += 4;
|
2001-02-13 13:28:32 +00:00
|
|
|
descent += 2;
|
2001-02-16 09:25:43 +00:00
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
hmax_ = mathed_char_height(LM_TC_VAR, size(), 'I', a, b);
|
2001-04-24 16:13:38 +00:00
|
|
|
if (hmax_ < 10)
|
|
|
|
hmax_ = 10;
|
2001-02-16 09:25:43 +00:00
|
|
|
wbody_ = width + 4;
|
|
|
|
width += hmax_ + 4;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-28 11:56:36 +00:00
|
|
|
bool MathSqrtInset::Inside(int x, int y)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-02-28 11:56:36 +00:00
|
|
|
return x >= xo() - hmax_
|
|
|
|
&& x <= xo() + width - hmax_
|
|
|
|
&& y <= yo() + descent
|
|
|
|
&& y >= yo() - ascent;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|