]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_funcinset.C
enable direct input of #1...#9; some whitespace changes
[lyx.git] / src / mathed / math_funcinset.C
index c2e7f61df3c2edf925512a3efa3da5a7a3f80b50..b7dedc3cc3c41521e5b7944daf9053f8e978b499 100644 (file)
@@ -5,23 +5,19 @@
 #endif
 
 #include "math_funcinset.h"
-#include "lyxfont.h"
 #include "font.h"
 #include "Painter.h"
-#include "mathed/support.h"
-#include "support/LOstream.h"
+#include "math_support.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
 
 
-using std::ostream;
-
 extern LyXFont WhichFont(short type, int size);
 
 
-MathFuncInset::MathFuncInset(string const & nm, MathInsetTypes ot)
-       : MathInset(0, nm, ot)
-{
-       lims_ = (GetType() == LM_OT_FUNCLIM);
-}
+MathFuncInset::MathFuncInset(string const & nm)
+       : name_(nm)
+{}
 
 
 MathInset * MathFuncInset::clone() const
@@ -30,44 +26,63 @@ MathInset * MathFuncInset::clone() const
 }
 
 
-void MathFuncInset::draw(Painter & pain, int x, int y)
+string const & MathFuncInset::name() const
+{
+       return name_;
+}
+
+
+void MathFuncInset::setName(string const & n)
+{
+       name_ = n;
+}
+
+
+void MathFuncInset::metrics(MathMetricsInfo const & mi) const 
+{
+       mi_ = mi;
+       mathed_string_dim(LM_TC_TEXTRM, mi_, name_, ascent_, descent_, width_);
+}
+
+
+void MathFuncInset::draw(Painter & pain, int x, int y) const
 { 
-       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);
-       }
+       drawStr(pain, LM_TC_TEXTRM, mi_, x, y, name_);
 }
 
 
-void MathFuncInset::Write(std::ostream & os, bool /* fragile */) const
+bool MathFuncInset::match(MathInset * p) const
 {
-       os << "\\" << name_ << ' ';
+       MathFuncInset const * q = p->asFuncInset();
+       return q && name_ == q->name_;
 }
 
 
-void MathFuncInset::WriteNormal(std::ostream & os) const
+void MathFuncInset::maplize(MapleStream & os) const
 {
-       os << "[" << name_ << "] ";
+       os << ' ' << name_;
 }
 
 
-void MathFuncInset::Metrics(MathStyles st, int, int) 
+void MathFuncInset::mathmlize(MathMLStream & os) 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_);
-       }
+       os << MTag("mi") << name_ << ETag("mi");
+}
+
+
+void MathFuncInset::octavize(OctaveStream & os) const
+{
+       os << ' ' << name_;
+}
+
+
+void MathFuncInset::normalize(NormalStream & os) const
+{
+       os << "[func " << name_ << ']';
+}
+
+
+void MathFuncInset::write(WriteStream & os) const
+{
+       os << "\\" << name_ << ' ';
 }