-
-
-inline
-char *strnew(char const* s)
-{
- char *s1 = new char[strlen(s)+1];
- return strcpy(s1, s);
-}
-
-
-MathedInset::MathedInset(MathedInset* inset)
-{
- if (inset) {
- name = inset->GetName();
- objtype = inset->GetType();
- size = inset->GetStyle();
- width = inset->Width();
- ascent = inset->Ascent();
- descent = inset->Descent();
- } else {
- objtype = LM_OT_UNDEF;
- size = LM_ST_TEXT;
- width = ascent = descent = 0;
- name = 0;
- }
-}
-
-
-MathFuncInset::MathFuncInset(char const *nm, short ot, short st):
- MathedInset("", ot, st)
-{
- ln = 0;
- lims = (GetType()==LM_OT_FUNCLIM);
- if (GetType()==LM_OT_UNDEF) {
- fname = strnew(nm);
- SetName(fname);
- } else {
- fname = 0;
- SetName(nm);
- }
-}
-
-MathedInset *MathFuncInset::Clone()
-{
- MathedInset *l = new MathFuncInset(name, GetType(), GetStyle());
- return l;
-}
-
-MathSpaceInset::MathSpaceInset(int sp, short ot, short st):
- MathedInset("", ot, st), space(sp)
-{
-}
-
-MathedInset *MathSpaceInset::Clone()
-{
- MathedInset *l = new MathSpaceInset(space, GetType(), GetStyle());
- return l;
-}
-
-MathParInset::MathParInset(short st, char const *nm, short ot):
- MathedInset(nm, ot, st)
-{
- array = 0;
- ascent = 8;
- width = 4;
- descent = 0;
- flag = 1;
- if (objtype==LM_OT_SCRIPT)
- flag |= LMPF_SCRIPT;
-}
-
-MathParInset::MathParInset(MathParInset* p): MathedInset(p)
-{
- flag = p->flag;
- p->setArgumentIdx(0);
- MathedIter it(p->GetData());
- SetData(it.Copy());
-}
-
-
-MathParInset::~MathParInset()
-{
- if (array) {
- MathedIter it(array);
- it.Clear();
- delete array;
- }
-}
-
-
-MathedInset *MathParInset::Clone()
-{
- MathParInset* p = new MathParInset(this);
- return p;
+#include "lyxfont.h"
+#include "mathed/support.h"
+#include "Painter.h"
+
+
+// Initialize some static class variables.
+int MathedInset::df_asc;
+int MathedInset::df_des;
+int MathedInset::df_width;
+int MathedInset::workWidth;
+
+
+MathedInset::MathedInset(string const & nm, short ot, short st)
+ : name(nm), objtype(ot), width(0), ascent(0), descent(0),
+ size_(st)
+{}
+
+
+// In a near future maybe we use a better fonts renderer
+void MathedInset::drawStr(Painter & pain, short type, int siz,
+ int x, int y, string const & s)
+{
+ string st;
+ if (MathIsBinary(type))
+ for (string::const_iterator it = s.begin();
+ it != s.end(); ++it) {
+ st += ' ';
+ st += *it;
+ st += ' ';
+ }
+ else
+ st = s;
+
+ LyXFont const mf = mathed_get_font(type, siz);
+ pain.text(x, y, st, mf);