// -*- C++ -*-
-/*
- * File: formula.h
- * Purpose: Declaration of formula inset
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
- * Created: January 1996
- * Description: Allows the edition of math paragraphs inside Lyx.
+/**
+ * \file formulamacro.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * Copyright: (c) 1996, Alejandro Aguilar Sierra
+ * \author Alejandro Aguilar Sierra
+ * \author André Pönitz
*
- * Version: 0.4, Lyx project.
- *
- * 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.
*/
-#ifndef _INSET_FORMULA_MACRO_H
-#define _INSET_FORMULA_MACRO_H
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "formula.h"
-
-
+#ifndef INSET_FORMULA_MACRO_H
+#define INSET_FORMULA_MACRO_H
+#include "math_nestinset.h"
class MathMacroTemplate;
+class LyXLex;
+
+// An InsetFormulaMacro only knows its name and asks the global
+// MathMacroTable if it needs to know more.
-///
-class InsetFormulaMacro: public InsetFormula {
+/// Main LyX Inset for defining math macros
+class InsetFormulaMacro : public MathNestInset {
public:
///
InsetFormulaMacro();
+ /// construct a macro hull from its name and the number of arguments
+ InsetFormulaMacro(std::string const & name, int nargs, std::string const & t);
+ /// constructs a mocro from its LaTeX definition
+ explicit InsetFormulaMacro(std::string const & s);
///
- InsetFormulaMacro(LString name, int na=0, bool env=false);
- ///
- ~InsetFormulaMacro();
- ///
- int Ascent(LyXFont const &font) const;
+ void metrics(MetricsInfo & mi, Dimension & dim) const;
///
- int Descent(LyXFont const &font) const;
- ///
- int Width(LyXFont const &font) const;
- ///
- void Draw(LyXFont font, LyXScreen &scr, int baseline, float &x);
- ///
- void Read(LyXLex &lex);
- ///
- void Write(FILE *file);
+ void draw(PainterInfo & pi, int x, int y) const;
+
///
-// void Read(LyXLex &lex);
+ void read(Buffer const &, LyXLex & lex);
///
- int Latex(FILE *file, signed char fragile);
+ void write(Buffer const &, std::ostream & os) const;
///
- int Latex(LString &file, signed char fragile);
+ int plaintext(Buffer const &, std::ostream &,
+ OutputParams const &) const;
///
- int Linuxdoc(LString &file);
+ int latex(Buffer const &, std::ostream & os,
+ OutputParams const &) const;
///
- int DocBook(LString &file);
+ int linuxdoc(Buffer const &, std::ostream & os,
+ OutputParams const &) const;
///
- Inset* Clone();
+ int docbook(Buffer const &, std::ostream &,
+ OutputParams const &) const;
- /// what appears in the minibuffer when opening
- char const* EditMessage() {return "Math macro editor mode";}
///
- void Edit(int x, int y);
+ std::auto_ptr<InsetBase> clone() const;
///
- void InsetUnlock();
-
- bool LocalDispatch(int, char const*);
-
-protected:
- void UpdateLocal();
+ InsetBase::Code lyxCode() const { return MATHMACRO_CODE; }
private:
- bool opened;
- LString name;
- class MathMacroTemplate* tmacro;
-
+ ///
+ void read(std::istream & is);
+ /// prefix in inset
+ std::string prefix() const;
+ ///
+ std::string name_;
};
-
#endif
-