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(GetStyle());
46 MathedIter itr(uroot_->GetData());
47 p->setData(it.Copy());
49 p->setData(itr.Copy());
55 void MathRootInset::setData(MathedArray * d)
58 MathParInset::setData(d);
65 bool MathRootInset::setArgumentIdx(int i)
67 if (i == 0 || i == 1) {
75 void MathRootInset::GetXY(int & x, int & y) const
78 MathParInset::GetXY(x, y);
84 MathedArray * MathRootInset::GetData()
89 return uroot_->GetData();
93 bool MathRootInset::Inside(int x, int y)
95 return (uroot_->Inside(x, y) || MathSqrtInset::Inside(x, y));
99 void MathRootInset::Metrics()
104 MathSqrtInset::Metrics();
106 wroot_ = uroot_->Width();
109 // if (uroot->Ascent() > dh)
110 if (uroot_->Height() > dh_)
111 ascent += uroot_->Height() - dh_;
112 dh_ -= descent - uroot_->Descent();
117 void MathRootInset::draw(Painter & pain, int x, int y)
122 uroot_->draw(pain, x, y - dh_);
123 MathSqrtInset::draw(pain, x + wroot_, y);
128 void MathRootInset::SetStyle(short st)
130 MathSqrtInset::SetStyle(st);
132 uroot_->SetStyle((size() < LM_ST_SCRIPTSCRIPT) ? size() + 1 : size());
136 void MathRootInset::SetFocus(int x, int)
138 idx_ = (x > xo() + wroot_) ? 1: 0;
142 void MathRootInset::Write(ostream & os, bool fragile)
144 os << '\\' << name << '[';
145 uroot_->Write(os, fragile);
147 MathParInset::Write(os, fragile);