]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_funcinset.C
fix pullArg when pressing <Delete> at the end of an cell
[lyx.git] / src / mathed / math_funcinset.C
index d7e3598de0e9854912ffee84065703ed6b4b24a4..a75ba7360cc7efe63629e5f3039766d9340e08d2 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,55 +14,47 @@ using std::ostream;
 extern LyXFont WhichFont(short type, int size);
 
 
-MathFuncInset::MathFuncInset(string const & nm, short ot, short st)
-       : MathedInset(nm, ot, st)
+MathFuncInset::MathFuncInset(string const & nm, MathInsetTypes ot)
+       : MathInset(0, nm, ot)
 {
        lims_ = (GetType() == LM_OT_FUNCLIM);
 }
 
 
-MathedInset * MathFuncInset::Clone()
+MathInset * MathFuncInset::clone() const
 {
-       return new MathFuncInset(name, GetType(), GetStyle());
+       return new MathFuncInset(*this);
 }
 
 
-void
-MathFuncInset::draw(Painter & pain, int x, int y)
-{ 
-       if (!name.empty() && name[0] > ' ') {
-               LyXFont font = WhichFont(LM_TC_TEXTRM, size());
-               font.setLatex(LyXFont::ON);
-               x += (lyxfont::width('I', font) + 3) / 4;
-               pain.text(x, y, name, font);
-       }
+void MathFuncInset::Write(std::ostream & os, bool /* fragile */) const
+{
+       os << "\\" << name_ << ' ';
 }
 
 
-void MathFuncInset::Write(std::ostream & os, bool /* fragile */)
+void MathFuncInset::WriteNormal(std::ostream & os) const
 {
-       os << "\\" << name << ' ';
+       os << "[" << name_ << "] ";
 }
 
 
-void MathFuncInset::Metrics() 
+void MathFuncInset::Metrics(MathStyles st, int, int
 {
-       LyXFont font = WhichFont(LM_TC_TEXTRM, size());
-       font.setLatex(LyXFont::ON);
-       if (name.empty()) {
-               width = df_width;
-               descent = df_des;
-               ascent = df_asc;
-       } else {
-               width = lyxfont::width(name, font)
-                       + lyxfont::width('I', font) / 2;
-               mathed_string_height(LM_TC_TEXTRM, size(),
-                                    name, ascent, descent);
-       }
+       size_ = st;
+       if (name_.empty()) 
+               mathed_char_dim(LM_TC_TEXTRM, size_, 'I', ascent_, descent_, width_);
+       else 
+               mathed_string_dim(LM_TC_TEXTRM, size_, name_, ascent_, descent_, width_);
 }
 
 
-bool MathFuncInset::GetLimits() const 
-{  
-       return bool(lims_ && (GetStyle() == LM_ST_DISPLAY)); 
-} 
+void MathFuncInset::draw(Painter & pain, int x, int y)
+{ 
+       xo(x);
+       yo(y);
+       if (name_.empty()) 
+               drawChar(pain, LM_TC_TEXTRM, size_, x, y, ' ');
+       else
+               drawStr(pain, LM_TC_TEXTRM, size_, x, y, name_);
+}