]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_root.C
small cleanup, doxygen, formatting changes
[lyx.git] / src / mathed / math_root.C
index c40f005e2f206fbff57c74476167ec753f2d70c2..13ae9ab97c03e20ec46c7bc6badb4377e0b5737b 100644 (file)
@@ -6,7 +6,7 @@
  *  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
+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(int x, int y)
+void MathRootInset::draw(Painter & pain, int x, int y)
 {
-    int idxp = idx;
-
-    idx = 1;
-    uroot->Draw(x, y - dh);
-    MathSqrtInset::Draw(x+wroot, y);
-    XFlush(fl_display);
-    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(FILE *outf)
-{ 
-   string output;
-   MathRootInset::Write(output);  
-   fprintf(outf, "%s", output.c_str());
-}
-
-
-void MathRootInset::Write(string &outf)
-{ 
-   outf += '\\';
-   outf += name;
-   outf += '[';
-   uroot->Write(outf);  
-   outf += "]{";
-   MathParInset::Write(outf);
-   outf += '}';
+void MathRootInset::Write(ostream & os, bool fragile)
+{
+       os << '\\' << name << '[';
+       uroot_->Write(os, fragile);  
+       os << "]{";
+       MathParInset::Write(os, fragile);
+       os << '}';
 }