X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fformulamacro.C;h=39ab9325401bde56f23a94e7d151e9f8f2577d76;hb=7338f3b980d4dc5793ff80be814b7a74e1c72274;hp=42f8f19755e823b5f1b3c689b02d14fabd38517c;hpb=285952e13002efe5d69a890e6e2a924b0c294808;p=lyx.git diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 42f8f19755..39ab932540 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -1,14 +1,12 @@ -/* - * 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 @@ -36,7 +34,10 @@ #include "lyxtext.h" #include "Lsstream.h" +using namespace lyx::support; + using std::ostream; +using std::auto_ptr; extern MathCursor * mathcursor; @@ -48,10 +49,11 @@ InsetFormulaMacro::InsetFormulaMacro() } -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))); } @@ -62,18 +64,12 @@ InsetFormulaMacro::InsetFormulaMacro(string const & s) } -Inset * InsetFormulaMacro::clone(Buffer const &) const +auto_ptr InsetFormulaMacro::clone() const { - return new InsetFormulaMacro(*this); + return auto_ptr(new InsetFormulaMacro(*this)); } -// Inset * InsetFormulaMacro::clone(Buffer const &, bool) const -// { -// return new InsetFormulaMacro(*this); -// } - - void InsetFormulaMacro::write(Buffer const *, ostream & os) const { os << "FormulaMacro "; @@ -132,9 +128,8 @@ string InsetFormulaMacro::prefix() const } -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; @@ -155,9 +150,9 @@ MathAtom & InsetFormulaMacro::par() } -Inset::Code InsetFormulaMacro::lyxCode() const +InsetOld::Code InsetFormulaMacro::lyxCode() const { - return Inset::MATHMACRO_CODE; + return InsetOld::MATHMACRO_CODE; } @@ -171,15 +166,9 @@ void InsetFormulaMacro::draw(PainterInfo & p, int x, int y) const 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);