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_root.h"
23 #include "math_iter.h"
24 #include "support/LOstream.h"
28 MathRootInset::MathRootInset(short st)
29 : MathSqrtInset(st), idx_(1), uroot_(LM_ST_TEXT)
33 MathedInset * MathRootInset::Clone()
35 MathRootInset * p = new MathRootInset(*this);
41 void MathRootInset::setData(MathedArray const & d)
44 MathParInset::setData(d);
50 bool MathRootInset::setArgumentIdx(int i)
52 if (i == 0 || i == 1) {
60 int MathRootInset::getArgumentIdx() const
66 int MathRootInset::getMaxArgumentIdx() const
72 void MathRootInset::GetXY(int & x, int & y) const
75 MathParInset::GetXY(x, y);
81 MathedArray & MathRootInset::GetData()
86 return uroot_.GetData();
90 MathedArray const & MathRootInset::GetData() const
95 return uroot_.GetData();
99 bool MathRootInset::Inside(int x, int y)
101 return (uroot_.Inside(x, y) || MathSqrtInset::Inside(x, y));
105 void MathRootInset::Metrics()
107 int const idxp = idx_;
110 MathSqrtInset::Metrics();
112 wroot_ = uroot_.Width();
115 // if (uroot_.Ascent() > dh)
116 if (uroot_.Height() > dh_)
117 ascent += uroot_.Height() - dh_;
118 dh_ -= descent - uroot_.Descent();
123 void MathRootInset::draw(Painter & pain, int x, int y)
125 int const idxp = idx_;
128 uroot_.draw(pain, x, y - dh_);
129 MathSqrtInset::draw(pain, x + wroot_, y);
134 void MathRootInset::SetStyle(short st)
136 MathSqrtInset::SetStyle(st);
138 uroot_.SetStyle((size() < LM_ST_SCRIPTSCRIPT) ? size() + 1 : size());
142 void MathRootInset::SetFocus(int x, int)
144 idx_ = (x > xo() + wroot_) ? 1: 0;
148 void MathRootInset::Write(ostream & os, bool fragile)
150 os << '\\' << name << '[';
151 uroot_.Write(os, fragile);
153 MathParInset::Write(os, fragile);
158 void MathRootInset::WriteNormal(ostream & os)
161 uroot_.WriteNormal(os);
163 MathParInset::WriteNormal(os);