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 "LColor.h"
|
|
|
|
#include "Painter.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
|
|
|
MathSqrtInset::MathSqrtInset()
|
2001-08-03 17:10:22 +00:00
|
|
|
: MathNestInset(1)
|
2001-06-25 00:06:33 +00:00
|
|
|
{}
|
2001-02-26 12:53:35 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
MathInset * MathSqrtInset::clone() const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-02-20 10:49:48 +00:00
|
|
|
return new MathSqrtInset(*this);
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-22 15:37:49 +00:00
|
|
|
void MathSqrtInset::metrics(MathMetricsInfo const & mi) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-10-22 15:37:49 +00:00
|
|
|
xcell(0).metrics(mi);
|
2001-06-25 00:06:33 +00:00
|
|
|
ascent_ = xcell(0).ascent() + 4;
|
|
|
|
descent_ = xcell(0).descent() + 2;
|
|
|
|
width_ = xcell(0).width() + 12;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-06 17:20:26 +00:00
|
|
|
void MathSqrtInset::draw(Painter & pain, int x, int y) const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
xcell(0).draw(pain, x + 10, y);
|
|
|
|
int const a = ascent_;
|
|
|
|
int const d = descent_;
|
2001-02-16 09:25:43 +00:00
|
|
|
int xp[4];
|
|
|
|
int yp[4];
|
2001-06-25 00:06:33 +00:00
|
|
|
xp[0] = x + width_; yp[0] = y - a + 1;
|
|
|
|
xp[1] = x + 8; yp[1] = y - a + 1;
|
|
|
|
xp[2] = x + 5; yp[2] = y + d - 1;
|
|
|
|
xp[3] = x; yp[3] = y + (d - a)/2;
|
2001-02-13 13:28:32 +00:00
|
|
|
pain.lines(xp, yp, 4, LColor::mathline);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-19 11:25:48 +00:00
|
|
|
void MathSqrtInset::write(MathWriteInfo & os) const
|
2001-02-28 11:56:36 +00:00
|
|
|
{
|
2001-10-19 11:25:48 +00:00
|
|
|
os << "\\sqrt{" << cell(0) << '}';
|
2001-02-28 11:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathSqrtInset::writeNormal(std::ostream & os) const
|
2001-04-25 15:43:57 +00:00
|
|
|
{
|
2001-04-27 12:35:55 +00:00
|
|
|
os << "[sqrt ";
|
2001-07-26 06:56:43 +00:00
|
|
|
cell(0).writeNormal(os);
|
2001-10-24 16:10:38 +00:00
|
|
|
os << "]";
|
2001-04-25 15:43:57 +00:00
|
|
|
}
|