]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macrotemplate.h
Fix math cursor positioning bug
[lyx.git] / src / mathed / math_macrotemplate.h
index bf34520575337c80772ea773fada396d8129b7cb..54ff52f3174f6b04f2c211741d344c8cd99c1fbf 100644 (file)
@@ -1,57 +1,75 @@
 // -*- C++ -*-
-#ifndef MATHMACROTEMPLATE
-#define MATHMACROTEMPLATE
+/**
+ * \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 <vector>
+#ifndef MATH_MACROTEMPLATE_H
+#define MATH_MACROTEMPLATE_H
 
-#include "math_parinset.h"
-#include "math_macroarg.h"
+#include "math_data.h"
+#include "math_macrotable.h"
+#include "math_nestinset.h"
 
-class MathMacro;
 
-/// This class contains the macro definition
-class MathMacroTemplate: public MathParInset {
-  public:
-  /// A template constructor needs all the data
-    explicit
-    MathMacroTemplate(string const &, int na = 0, int f = 0);
-    ///
-    ~MathMacroTemplate();
-    ///
-    void draw(Painter &, int, int);
-    ///
-    void Metrics();
-    ///
-    void WriteDef(std::ostream &, bool fragile);
-    /// useful for special insets
-    void  setTCode(MathedTextCodes t);
-    ///
-    MathedTextCodes getTCode() const;
-    /// 
-    void setArgument(MathedArray *, int i= 0);
-    /// Number of arguments
-    int getNoArgs() const;
-    ///
-    void GetMacroXY(int, int &, int &) const;
-    ///
-    MathParInset * getMacroPar(int) const;
-    ///
-    void SetMacroFocus(int &, int, int);
-    ///
-    void setEditMode(bool);
+/// This class contains the macro definition.
+class MathMacroTemplate : public MathNestInset {
+public:
+       ///
+       MathMacroTemplate();
+       ///
+       MathMacroTemplate(std::string const & name, int nargs,
+               std::string const & type,
+               MathArray const & = MathArray(),
+               MathArray const & = MathArray());
+       ///
+       explicit MathMacroTemplate(std::istream & is);
+       ///
+       void edit(LCursor & cur, bool left);
+       ///
+       EDITABLE editable() const { return HIGHLY_EDITABLE; }
+       ///
+       void read(Buffer const &, LyXLex & lex);
+       ///
+       void write(Buffer const &, std::ostream & os) const;
+       ///
+       void write(WriteStream & os) const;
+       /// Number of arguments
+       int numargs() const;
+       ///
+       void numargs(int);
+       ///
+       std::string name() const;
+       ///
+       MacroData asMacroData() const;
+       ///
+       void draw(PainterInfo & pi, int x, int y) const;
+       ///
+       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; }
 
-    /// Replace the appropriate arguments with a specific macro's data
-    void update(MathMacro * m = 0);
 private:
-    ///
-    short flags;
-    ///
-    MathedTextCodes tcode;
-    ///
-    std::vector<MathMacroArgument> args_;
-    ///
-    int nargs;
-    ///
-    friend class MathMacro;
+       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_;
 };
+
 #endif