]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macrotemplate.h
Fix to bug 2362: Deleting superscript also deletes subscript.
[lyx.git] / src / mathed / math_macrotemplate.h
index b351a4ff6e0b5df76a88b38e2d1fcffb85b06eed..54ff52f3174f6b04f2c211741d344c8cd99c1fbf 100644 (file)
@@ -1,67 +1,75 @@
 // -*- C++ -*-
-#ifndef MATHMACROTEMPLATE
-#define MATHMACROTEMPLATE
-
-#include <vector>
+/**
+ * \file math_macrotemplate.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
 
-#include "math_parinset.h"
-#include "math_macroarg.h"
+#ifndef MATH_MACROTEMPLATE_H
+#define MATH_MACROTEMPLATE_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
+#include "math_data.h"
+#include "math_macrotable.h"
+#include "math_nestinset.h"
 
-class MathMacro;
 
-/** This class contains the macro definition
-    \author Alejandro Aguilar Sierra
- */
-class MathMacroTemplate : public MathParInset {
+/// This class contains the macro definition.
+class MathMacroTemplate : public MathNestInset {
 public:
-       /// A template constructor needs all the data
-       explicit
-       MathMacroTemplate(string const &, int na = 0, int f = 0);
        ///
-       void draw(Painter &, int, int);
+       MathMacroTemplate();
        ///
-       void Metrics();
+       MathMacroTemplate(std::string const & name, int nargs,
+               std::string const & type,
+               MathArray const & = MathArray(),
+               MathArray const & = MathArray());
        ///
-       void WriteDef(std::ostream &, bool fragile);
-       /// useful for special insets
-       void  setTCode(MathedTextCodes t);
+       explicit MathMacroTemplate(std::istream & is);
        ///
-       MathedTextCodes getTCode() const;
-       /// 
-       void setArgument(MathedArray *, int i= 0);
-       /// Number of arguments
-       int getNoArgs() const;
+       void edit(LCursor & cur, bool left);
        ///
-       void GetMacroXY(int, int &, int &) const;
+       EDITABLE editable() const { return HIGHLY_EDITABLE; }
        ///
-       MathParInset * getMacroPar(int) const;
+       void read(Buffer const &, LyXLex & lex);
        ///
-       void SetMacroFocus(int &, int, int);
+       void write(Buffer const &, std::ostream & os) const;
        ///
-       void setEditMode(bool);
-       
-       /// Replace the appropriate arguments with a specific macro's data
-       void update(MathMacro * m);
+       void write(WriteStream & os) const;
+       /// Number of arguments
+       int numargs() const;
        ///
-       short flags() const;
-private:
+       void numargs(int);
        ///
-       short flags_;
+       std::string name() const;
        ///
-       MathedTextCodes tcode_;
+       MacroData asMacroData() const;
        ///
-       std::vector<MathMacroArgument> args_;
+       void draw(PainterInfo & pi, int x, int y) const;
        ///
-       int nargs_;
-};
+       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       /// identifies macro templates
+       MathMacroTemplate * asMacroTemplate() { return this; }
+       /// identifies macro templates
+       MathMacroTemplate const * asMacroTemplate() const { return this; }
+       ///
+       InsetBase::Code lyxCode() const { return MATHMACRO_CODE; }
+
+private:
+       virtual std::auto_ptr<InsetBase> doClone() const;
+       /// prefix in inset
+       std::string prefix() const;
 
+       ///
+       int numargs_;
+       ///
+       std::string name_;
+       /// newcommand or renewcommand or def
+       std::string type_;
+};
 
-inline
-short MathMacroTemplate::flags() const {
-       return flags_;
-}
 #endif