-#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"
+#include "support/LOstream.h"
+using std::ostream;
+
extern LyXFont WhichFont(short type, int size);
-MathFuncInset::~MathFuncInset()
+
+MathFuncInset::MathFuncInset(string const & nm)
+ : name_(nm)
{}
-bool MathFuncInset::GetLimits() const
-{
- return bool(lims && (GetStyle() == LM_ST_DISPLAY));
-}
+MathInset * MathFuncInset::clone() const
+{
+ return new MathFuncInset(*this);
+}
-void MathFuncInset::Write(std::ostream & os, bool /* fragile */)
+string const & MathFuncInset::name() const
{
- os << "\\" << name << ' ';
+ return name_;
}
-MathFuncInset::MathFuncInset(string const & nm, short ot, short st)
- : MathedInset("", ot, st)
+void MathFuncInset::setName(string const & n)
{
- ln = 0;
- lims = (GetType() == LM_OT_FUNCLIM);
- if (GetType() == LM_OT_UNDEF) {
- fname = nm;
- SetName(fname);
- } else {
- //fname = 0;
- SetName(nm);
- }
+ name_ = n;
}
-MathedInset * MathFuncInset::Clone()
+void MathFuncInset::write(MathWriteInfo & os) const
{
- return new MathFuncInset(name, GetType(), GetStyle());
+ os << "\\" << name_ << ' ';
}
-
-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::writeNormal(std::ostream & os) const
+{
+ os << "[" << name_ << "] ";
}
-
-void MathFuncInset::Metrics()
+void MathFuncInset::metrics(MathMetricsInfo const & st) const
{
- //ln = (name) ? strlen(name): 0;
- 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;
+ mathed_string_dim(LM_TC_TEX, size_.size, name_, ascent_, descent_, width_);
+}
+
+
+void MathFuncInset::draw(Painter & pain, int x, int y) const
+{
+ xo(x);
+ yo(y);
+ drawStr(pain, LM_TC_TEX, size_.size, x, y, name_);
}