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"
27 MathRootInset::MathRootInset(short st)
31 uroot = new MathParInset(LM_ST_TEXT);
35 MathRootInset::~MathRootInset()
41 MathedInset * MathRootInset::Clone()
43 MathRootInset * p = new MathRootInset(GetStyle());
44 MathedIter it(array), itr(uroot->GetData());
45 p->SetData(it.Copy());
47 p->SetData(itr.Copy());
53 void MathRootInset::SetData(LyxArrayBase * d)
56 MathParInset::SetData(d);
63 bool MathRootInset::setArgumentIdx(int i)
65 if (i == 0 || i == 1) {
73 void MathRootInset::GetXY(int & x, int & y) const
76 MathParInset::GetXY(x, y);
82 LyxArrayBase * MathRootInset::GetData()
87 return uroot->GetData();
91 bool MathRootInset::Inside(int x, int y)
93 return (uroot->Inside(x, y) || MathSqrtInset::Inside(x, y));
97 void MathRootInset::Metrics()
102 MathSqrtInset::Metrics();
104 wroot = uroot->Width();
107 // if (uroot->Ascent() > dh)
108 if (uroot->Height() > dh)
109 ascent += uroot->Height() - dh;
110 dh -= descent - uroot->Descent();
115 void MathRootInset::draw(Painter & pain, int x, int y)
120 uroot->draw(pain, x, y - dh);
121 MathSqrtInset::draw(pain, x + wroot, y);
126 void MathRootInset::SetStyle(short st)
128 MathSqrtInset::SetStyle(st);
130 uroot->SetStyle((size<LM_ST_SCRIPTSCRIPT) ? size+1: size);
134 void MathRootInset::SetFocus(int x, int)
136 idx = (x > xo + wroot) ? 1: 0;
140 void MathRootInset::Write(ostream & os, bool fragile)
142 os << '\\' << name << '[';
143 uroot->Write(os, fragile);
145 MathParInset::Write(os, fragile);