-/*
- * File: formulamacro.C
- * Purpose: Implementation of the formula macro LyX inset
- * Author: André Pönitz, based on ideas of Alejandro Aguilar Sierra
- * Created: March 2001
- * Description: Allows the edition of math macros inside Lyx.
+/**
+ * \file formulamacro.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * Copyright: 2001 The LyX Project
+ * \author Alejandro Aguilar Sierra
+ * \author André Pönitz
*
- * You are free to use and modify this code under the terms of
- * the GNU General Public Licence version 2 or later.
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "lyxtext.h"
#include "Lsstream.h"
+using namespace lyx::support;
+
using std::ostream;
+using std::auto_ptr;
extern MathCursor * mathcursor;
}
-InsetFormulaMacro::InsetFormulaMacro(string const & name, int nargs)
+InsetFormulaMacro::InsetFormulaMacro
+ (string const & name, int nargs, string const & type)
{
setInsetName(name);
- MathMacroTable::create(MathAtom(new MathMacroTemplate(name, nargs)));
+ MathMacroTable::create(MathAtom(new MathMacroTemplate(name, nargs, type)));
}
}
-Inset * InsetFormulaMacro::clone(Buffer const &) const
+auto_ptr<InsetBase> InsetFormulaMacro::clone() const
{
- return new InsetFormulaMacro(*this);
+ return auto_ptr<InsetBase>(new InsetFormulaMacro(*this));
}
-// Inset * InsetFormulaMacro::clone(Buffer const &, bool) const
-// {
-// return new InsetFormulaMacro(*this);
-// }
-
-
void InsetFormulaMacro::write(Buffer const *, ostream & os) const
{
os << "FormulaMacro ";
}
-void InsetFormulaMacro::metrics(MetricsInfo & m, Dimension & dim) const
+void InsetFormulaMacro::metrics(MetricsInfo & mi, Dimension & dim) const
{
- MetricsInfo mi = m;
par()->metrics(mi, dim_);
dim_.asc += 5;
dim_.des += 5;
}
-Inset::Code InsetFormulaMacro::lyxCode() const
+InsetOld::Code InsetFormulaMacro::lyxCode() const
{
- return Inset::MATHMACRO_CODE;
+ return InsetOld::MATHMACRO_CODE;
}
pi.base.style = LM_ST_TEXT;
pi.base.font = font;
- Dimension dim;
- MetricsInfo mi;
- mi.base.bv = pi.base.bv;
- mi.base.font = pi.base.font;
- metrics(mi, dim);
- dim_ = dim;
- int const a = y - dim.asc + 1;
- int const w = dim.wid - 2;
- int const h = dim.height() - 2;
+ int const a = y - dim_.asc + 1;
+ int const w = dim_.wid - 2;
+ int const h = dim_.height() - 2;
// LColor::mathbg used to be "AntiqueWhite" but is "linen" now, too
pi.pain.fillRectangle(x, a, w, h, LColor::mathmacrobg);