* Created: January 1999
* Description: Root math object
*
- * Copyright: (c) 1999 Alejandro Aguilar Sierra
+ * Copyright: 1999 Alejandro Aguilar Sierra
*
* You are free to use and modify this code under the terms of
* the GNU General Public Licence version 2 or later.
#include "math_iter.h"
#include "math_root.h"
+#include "support/LOstream.h"
-MathRootInset::MathRootInset(short st): MathSqrtInset(st)
+using std::ostream;
+
+MathRootInset::MathRootInset(short st)
+ : MathSqrtInset(st)
{
- idx = 1;
- uroot = new MathParInset(LM_ST_TEXT);
+ idx_ = 1;
+ uroot_ = new MathParInset(LM_ST_TEXT);
}
MathRootInset::~MathRootInset()
{
- delete uroot;
+ delete uroot_;
}
MathedInset * MathRootInset::Clone()
{
- MathRootInset * p = new MathRootInset(GetStyle());
- MathedIter it(array), itr(uroot->GetData());
- p->SetData(it.Copy());
- p->setArgumentIdx(0);
- p->SetData(itr.Copy());
-
- return p;
+ MathRootInset * p = new MathRootInset(GetStyle());
+ MathedIter it(array);
+ MathedIter itr(uroot_->GetData());
+ p->setData(it.Copy());
+ p->setArgumentIdx(0);
+ p->setData(itr.Copy());
+
+ return p;
}
-void MathRootInset::SetData(LyxArrayBase * d)
+void MathRootInset::setData(MathedArray * d)
{
- if (idx == 1)
- MathParInset::SetData(d);
- else {
- uroot->SetData(d);
- }
+ if (idx_ == 1)
+ MathParInset::setData(d);
+ else {
+ uroot_->setData(d);
+ }
}
bool MathRootInset::setArgumentIdx(int i)
{
- if (i == 0 || i == 1) {
- idx = i;
- return true;
- } else
- return false;
+ if (i == 0 || i == 1) {
+ idx_ = i;
+ return true;
+ } else
+ return false;
}
void MathRootInset::GetXY(int & x, int & y) const
{
- if (idx == 1)
- MathParInset::GetXY(x, y);
- else
- uroot->GetXY(x, y);
+ if (idx_ == 1)
+ MathParInset::GetXY(x, y);
+ else
+ uroot_->GetXY(x, y);
}
-LyxArrayBase * MathRootInset::GetData()
+MathedArray * MathRootInset::GetData()
{
- if (idx == 1)
- return array;
- else
- return uroot->GetData();
+ if (idx_ == 1)
+ return array;
+ else
+ return uroot_->GetData();
}
bool MathRootInset::Inside(int x, int y)
{
- return (uroot->Inside(x, y) || MathSqrtInset::Inside(x, y));
+ return (uroot_->Inside(x, y) || MathSqrtInset::Inside(x, y));
}
void MathRootInset::Metrics()
{
- int idxp = idx;
-
- idx = 1;
- MathSqrtInset::Metrics();
- uroot->Metrics();
- wroot = uroot->Width();
- dh = Height()/2;
- width += wroot;
- // if (uroot->Ascent() > dh)
- if (uroot->Height() > dh)
- ascent += uroot->Height() - dh;
- dh -= descent - uroot->Descent();
- idx = idxp;
+ int idxp = idx_;
+
+ idx_ = 1;
+ MathSqrtInset::Metrics();
+ uroot_->Metrics();
+ wroot_ = uroot_->Width();
+ dh_ = Height()/2;
+ width += wroot_;
+ // if (uroot->Ascent() > dh)
+ if (uroot_->Height() > dh_)
+ ascent += uroot_->Height() - dh_;
+ dh_ -= descent - uroot_->Descent();
+ idx_ = idxp;
}
void MathRootInset::draw(Painter & pain, int x, int y)
{
- int idxp = idx;
-
- idx = 1;
- uroot->draw(pain, x, y - dh);
- MathSqrtInset::draw(pain, x + wroot, y);
- idx = idxp;
+ int idxp = idx_;
+
+ idx_ = 1;
+ uroot_->draw(pain, x, y - dh_);
+ MathSqrtInset::draw(pain, x + wroot_, y);
+ idx_ = idxp;
}
void MathRootInset::SetStyle(short st)
{
- MathSqrtInset::SetStyle(st);
-
- uroot->SetStyle((size<LM_ST_SCRIPTSCRIPT) ? size+1: size);
+ MathSqrtInset::SetStyle(st);
+
+ uroot_->SetStyle((size() < LM_ST_SCRIPTSCRIPT) ? size() + 1 : size());
}
void MathRootInset::SetFocus(int x, int)
{
- idx = (x > xo + wroot) ? 1: 0;
+ idx_ = (x > xo() + wroot_) ? 1: 0;
}
-void MathRootInset::Write(ostream & os)
+void MathRootInset::Write(ostream & os, bool fragile)
{
-#ifdef USE_OSTREAM_ONLY
os << '\\' << name << '[';
- uroot->Write(os);
+ uroot_->Write(os, fragile);
os << "]{";
- MathParInset::Write(os);
+ MathParInset::Write(os, fragile);
os << '}';
-#else
- string output;
- MathRootInset::Write(output);
- os << output;
-#endif
}
-
-
-#ifndef USE_OSTREAM_ONLY
-void MathRootInset::Write(string & outf)
-{
- outf += '\\';
- outf += name;
- outf += '[';
- uroot->Write(outf);
- outf += "]{";
- MathParInset::Write(outf);
- outf += '}';
-}
-#endif