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: (c) 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"
25 MathRootInset::MathRootInset(short st): MathSqrtInset(st)
28 uroot = new MathParInset(LM_ST_TEXT);
32 MathRootInset::~MathRootInset()
38 MathedInset * MathRootInset::Clone()
40 MathRootInset * p = new MathRootInset(GetStyle());
41 MathedIter it(array), itr(uroot->GetData());
42 p->SetData(it.Copy());
44 p->SetData(itr.Copy());
50 void MathRootInset::SetData(LyxArrayBase * d)
53 MathParInset::SetData(d);
60 bool MathRootInset::setArgumentIdx(int i)
62 if (i == 0 || i == 1) {
70 void MathRootInset::GetXY(int & x, int & y) const
73 MathParInset::GetXY(x, y);
79 LyxArrayBase * MathRootInset::GetData()
84 return uroot->GetData();
88 bool MathRootInset::Inside(int x, int y)
90 return (uroot->Inside(x, y) || MathSqrtInset::Inside(x, y));
94 void MathRootInset::Metrics()
99 MathSqrtInset::Metrics();
101 wroot = uroot->Width();
104 // if (uroot->Ascent() > dh)
105 if (uroot->Height() > dh)
106 ascent += uroot->Height() - dh;
107 dh -= descent - uroot->Descent();
112 void MathRootInset::draw(Painter & pain, int x, int y)
117 uroot->draw(pain, x, y - dh);
118 MathSqrtInset::draw(pain, x + wroot, y);
123 void MathRootInset::SetStyle(short st)
125 MathSqrtInset::SetStyle(st);
127 uroot->SetStyle((size<LM_ST_SCRIPTSCRIPT) ? size+1: size);
131 void MathRootInset::SetFocus(int x, int)
133 idx = (x > xo + wroot) ? 1: 0;
137 void MathRootInset::Write(ostream & os)
140 MathRootInset::Write(output);
145 void MathRootInset::Write(string &outf)
152 MathParInset::Write(outf);