3 * Purpose: Implementation of the root object
4 * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
5 * Created: January 1999
6 * Description: Root math object
8 * Copyright: 1999 Alejandro Aguilar Sierra
10 * You are free to use and modify this code under the terms of
11 * the GNU General Public Licence version 2 or later.
15 #include FORMS_H_LOCATION
18 #pragma implementation
21 #include "math_root.h"
22 #include "math_iter.h"
23 #include "support/LOstream.h"
27 MathRootInset::MathRootInset(short st)
28 : MathSqrtInset(st), idx_(1), uroot_(LM_ST_TEXT)
32 MathedInset * MathRootInset::Clone()
34 MathRootInset * p = new MathRootInset(*this);
40 void MathRootInset::setData(MathedArray const & d)
43 MathParInset::setData(d);
49 bool MathRootInset::setArgumentIdx(int i)
51 if (i == 0 || i == 1) {
59 int MathRootInset::getArgumentIdx() const
65 int MathRootInset::getMaxArgumentIdx() const
71 void MathRootInset::GetXY(int & x, int & y) const
74 MathParInset::GetXY(x, y);
80 MathedArray & MathRootInset::GetData()
85 return uroot_.GetData();
89 MathedArray const & MathRootInset::GetData() const
94 return uroot_.GetData();
98 bool MathRootInset::Inside(int x, int y)
100 return (uroot_.Inside(x, y) || MathSqrtInset::Inside(x, y));
104 void MathRootInset::Metrics()
106 int const idxp = idx_;
109 MathSqrtInset::Metrics();
111 wroot_ = uroot_.Width();
114 // if (uroot_.Ascent() > dh)
115 if (uroot_.Height() > dh_)
116 ascent += uroot_.Height() - dh_;
117 dh_ -= descent - uroot_.Descent();
122 void MathRootInset::draw(Painter & pain, int x, int y)
124 int const idxp = idx_;
127 uroot_.draw(pain, x, y - dh_);
128 MathSqrtInset::draw(pain, x + wroot_, y);
133 void MathRootInset::SetStyle(short st)
135 MathSqrtInset::SetStyle(st);
137 uroot_.SetStyle((size() < LM_ST_SCRIPTSCRIPT) ? size() + 1 : size());
141 void MathRootInset::SetFocus(int x, int)
143 idx_ = (x > xo() + wroot_) ? 1: 0;
147 void MathRootInset::Write(ostream & os, bool fragile)
149 os << '\\' << name << '[';
150 uroot_.Write(os, fragile);
152 MathParInset::Write(os, fragile);
157 void MathRootInset::WriteNormal(ostream & os)
160 uroot_.WriteNormal(os);
162 MathParInset::WriteNormal(os);