X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fformulamacro.C;h=39ab9325401bde56f23a94e7d151e9f8f2577d76;hb=7338f3b980d4dc5793ff80be814b7a74e1c72274;hp=6eeb17968f60190f8be2cc13b0ca177fe5da3b59;hpb=d60684fd075f46ddce27ab06cb950b1b02d1036a;p=lyx.git diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 6eeb17968f..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 @@ -29,17 +27,17 @@ #include "frontends/Painter.h" #include "frontends/font_metrics.h" #include "support/lyxlib.h" +#include "support/lstrings.h" #include "support/LOstream.h" #include "debug.h" #include "lyxlex.h" #include "lyxtext.h" -#include "lyxfont.h" - #include "Lsstream.h" -#include "support/BoostFormat.h" +using namespace lyx::support; using std::ostream; +using std::auto_ptr; extern MathCursor * mathcursor; @@ -51,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))); } @@ -65,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 "; @@ -125,31 +118,23 @@ void InsetFormulaMacro::read(std::istream & is) MathMacroTemplate * p = new MathMacroTemplate(is); setInsetName(p->name()); MathMacroTable::create(MathAtom(p)); - metrics(); + //metrics(); } string InsetFormulaMacro::prefix() const { -#if USE_BOOST_FORMAT - return STRCONV(boost::io::str(boost::format(_(" Macro: %s: ")) % - STRCONV(getInsetName()))); -#else - return _(" Macro: ") + getInsetName() + ": "; -#endif + return bformat(_(" Macro: %s: "), getInsetName()); } -void InsetFormulaMacro::dimension(BufferView * bv, LyXFont const & font, - Dimension & dim) const +void InsetFormulaMacro::metrics(MetricsInfo & mi, Dimension & dim) const { - MetricsInfo mi; - mi.base.bv = bv; - mi.base.font = font; - dim = par()->metrics(mi); - dim.asc += 5; - dim.des += 5; - dim.wid += 10 + font_metrics::width(prefix(), font); + par()->metrics(mi, dim_); + dim_.asc += 5; + dim_.des += 5; + dim_.wid += 10 + font_metrics::width(prefix(), mi.base.font); + dim = dim_; } @@ -165,9 +150,9 @@ MathAtom & InsetFormulaMacro::par() } -Inset::Code InsetFormulaMacro::lyxCode() const +InsetOld::Code InsetFormulaMacro::lyxCode() const { - return Inset::MATHMACRO_CODE; + return InsetOld::MATHMACRO_CODE; } @@ -181,11 +166,9 @@ void InsetFormulaMacro::draw(PainterInfo & p, int x, int y) const pi.base.style = LM_ST_TEXT; pi.base.font = font; - Dimension dim; - dimension(pi.base.bv, font, 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);