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)
70 void MathRootInset::GetXY(int& x, int& y) const
73 MathParInset::GetXY(x, y);
78 LyxArrayBase *MathRootInset::GetData()
83 return uroot->GetData();
87 bool MathRootInset::Inside(int x, int y)
89 return (uroot->Inside(x, y) || MathSqrtInset::Inside(x, y));
93 void MathRootInset::Metrics()
98 MathSqrtInset::Metrics();
100 wroot = uroot->Width();
103 // if (uroot->Ascent() > dh)
104 if (uroot->Height() > dh)
105 ascent += uroot->Height() - dh;
106 dh -= descent - uroot->Descent();
111 void MathRootInset::Draw(int x, int y)
116 uroot->Draw(x, y - dh);
117 MathSqrtInset::Draw(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(FILE *outf)
140 MathRootInset::Write(output);
141 fprintf(outf, "%s", output.c_str());
145 void MathRootInset::Write(string &outf)
152 MathParInset::Write(outf);