4 * Purpose: Implementation of the root object
5 * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
6 * Created: January 1999
7 * Description: Root math object
9 * Copyright: 1999 Alejandro Aguilar Sierra
11 * You are free to use and modify this code under the terms of
12 * the GNU General Public Licence version 2 or later.
16 #include FORMS_H_LOCATION
19 #pragma implementation
22 #include "math_iter.h"
23 #include "math_root.h"
24 #include "support/LOstream.h"
28 MathRootInset::MathRootInset(short st)
32 uroot_ = new MathParInset(LM_ST_TEXT);
36 MathRootInset::~MathRootInset()
42 MathedInset * MathRootInset::Clone()
44 MathRootInset * p = new MathRootInset(*this);
45 p->uroot_ = (MathParInset *) p->uroot_->Clone();
51 void MathRootInset::setData(MathedArray * d)
54 MathParInset::setData(d);
61 bool MathRootInset::setArgumentIdx(int i)
63 if (i == 0 || i == 1) {
71 void MathRootInset::GetXY(int & x, int & y) const
74 MathParInset::GetXY(x, y);
80 MathedArray * MathRootInset::GetData()
85 return uroot_->GetData();
89 bool MathRootInset::Inside(int x, int y)
91 return (uroot_->Inside(x, y) || MathSqrtInset::Inside(x, y));
95 void MathRootInset::Metrics()
100 MathSqrtInset::Metrics();
102 wroot_ = uroot_->Width();
105 // if (uroot->Ascent() > dh)
106 if (uroot_->Height() > dh_)
107 ascent += uroot_->Height() - dh_;
108 dh_ -= descent - uroot_->Descent();
113 void MathRootInset::draw(Painter & pain, int x, int y)
118 uroot_->draw(pain, x, y - dh_);
119 MathSqrtInset::draw(pain, x + wroot_, y);
124 void MathRootInset::SetStyle(short st)
126 MathSqrtInset::SetStyle(st);
128 uroot_->SetStyle((size() < LM_ST_SCRIPTSCRIPT) ? size() + 1 : size());
132 void MathRootInset::SetFocus(int x, int)
134 idx_ = (x > xo() + wroot_) ? 1: 0;
138 void MathRootInset::Write(ostream & os, bool fragile)
140 os << '\\' << name << '[';
141 uroot_->Write(os, fragile);
143 MathParInset::Write(os, fragile);