]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_funcinset.C
use stream-like syntax for LaTeX output
[lyx.git] / src / mathed / math_funcinset.C
index 2f56e9fefb90021c68899788d6d774aa39210da6..b5651b9df79b9488eb277d4b18972e80b6824aff 100644 (file)
@@ -1,11 +1,8 @@
-#include <config.h>
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
 #include "math_funcinset.h"
-#include "lyxfont.h"
 #include "font.h"
 #include "Painter.h"
 #include "mathed/support.h"
@@ -17,63 +14,51 @@ using std::ostream;
 extern LyXFont WhichFont(short type, int size);
 
 
-MathFuncInset::MathFuncInset(string const & nm, MathInsetTypes ot)
-       : MathInset(nm, ot)
+MathFuncInset::MathFuncInset(string const & nm)
+       : name_(nm)
+{}
+
+
+MathInset * MathFuncInset::clone() const
 {
-       lims_ = (GetType() == LM_OT_FUNCLIM);
+       return new MathFuncInset(*this);
 }
 
 
-MathInset * MathFuncInset::Clone() const
+string const & MathFuncInset::name() const
 {
-       return new MathFuncInset(*this);
+       return name_;
 }
 
 
-void MathFuncInset::draw(Painter & pain, int x, int y)
-{ 
-       if (!name_.empty() && name_[0] > ' ') {
-               LyXFont font = WhichFont(LM_TC_TEXTRM, size());
-#ifndef NO_LATEX
-               font.setLatex(LyXFont::ON);
-#endif
-               x += (lyxfont::width('I', font) + 3) / 4;
-               pain.text(x, y, name_, font);
-       }
+void MathFuncInset::setName(string const & n)
+{
+       name_ = n;
 }
 
 
-void MathFuncInset::Write(std::ostream & os, bool /* fragile */) const
+void MathFuncInset::write(MathWriteInfo & os) const
 {
        os << "\\" << name_ << ' ';
 }
 
 
-void MathFuncInset::WriteNormal(std::ostream & os) const
+void MathFuncInset::writeNormal(std::ostream & os) const
 {
        os << "[" << name_ << "] ";
 }
 
 
-void MathFuncInset::Metrics(MathStyles st) 
+void MathFuncInset::metrics(MathMetricsInfo const & st) const 
 {
-       LyXFont font = WhichFont(LM_TC_TEXTRM, size());
-#ifndef NO_LATEX
-       font.setLatex(LyXFont::ON);
-#endif
        size_ = st;
-       if (name_.empty()) {
-               width_   = lyxfont::width('M', font);
-               ascent_  = lyxfont::ascent('M', font);
-               descent_ = 0;
-       } else {
-               width_ = lyxfont::width(name_, font) + lyxfont::width('I', font) / 2;
-               mathed_string_height(LM_TC_TEXTRM, size_, name_, ascent_, descent_);
-       }
+       mathed_string_dim(LM_TC_TEX, size_.size, name_, ascent_, descent_, width_);
 }
 
 
-bool MathFuncInset::GetLimits() const 
-{  
-       return lims_ && (size() == LM_ST_DISPLAY); 
-} 
+void MathFuncInset::draw(Painter & pain, int x, int y) const
+{ 
+       xo(x);
+       yo(y);
+       drawStr(pain, LM_TC_TEX, size_.size, x, y, name_);
+}