]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macro.h
Fix to bug 2362: Deleting superscript also deletes subscript.
[lyx.git] / src / mathed / math_macro.h
index 45fc2c91e9ffd5d16dfb128bde8eb206232690ca..6afbab1b3f620009c3147029d671a5a12c9ebe9d 100644 (file)
 // -*- C++ -*-
-/*
- *  File:        math_macro.h
- *  Purpose:     Declaration of macro class for mathed 
- *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
- *  Created:     November 1996
- *  Description: WYSIWYG math macros
+/**
+ * \file math_macro.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *  Dependencies: Mathed
+ * \author Alejandro Aguilar Sierra
+ * \author André Pönitz
  *
- *  Copyright: 1996, 1997 Alejandro Aguilar Sierra
- *
- *   Version: 0.2, Mathed & Lyx project.
- *
- *   This code is under the GNU General Public Licence version 2 or later.
+ * Full author contact details are available in file CREDITS.
  */
-#ifndef MATH_MACRO
-#define MATH_MACRO
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include <vector>
-#include <iosfwd>
-#include <boost/smart_ptr.hpp>
 
-#include "math_parinset.h"
-#include "math_macroarg.h"
+#ifndef MATH_MACRO_H
+#define MATH_MACRO_H
 
-class MathMacroTemplate;
+#include "math_nestinset.h"
+#include "math_data.h"
+#include "math_nestinset.h"
+#include "math_macrotable.h"
 
 
-/** This class contains the data for a macro
-    \author Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
-    \version November 1996
- */
-class MathMacro : public MathParInset {
+/// This class contains the data for a macro.
+class MathMacro : public MathNestInset {
 public:
        /// A macro can be built from an existing template
-       explicit MathMacro(MathMacroTemplate const &);
-       ///
-       void draw(Painter &, int, int);
-       ///
-       void Metrics();
-       ///
-       MathedInset * Clone();
-       ///
-       void Write(std::ostream &, bool fragile);
-       /// Index 0 is the template, index 1..nargs() are the parameters
-       bool setArgumentIdx(int);
+       MathMacro(std::string const & name, int numargs);
        ///
-       int getArgumentIdx() const;
+       void draw(PainterInfo & pi, int x, int y) const;
        ///
-       int getMaxArgumentIdx() const;
+       void drawExpanded(PainterInfo & pi, int x, int y) const;
+       /// draw selection background
+       void drawSelection(PainterInfo & pi, int x, int y) const;
        ///
-       int nargs() const;
+       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       /// get cursor position
+       void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
        ///
-       int GetColumns() const;
+       InsetBase * editXY(LCursor & cur, int x, int y);
        ///
-       void GetXY(int &, int &) const;
+       std::string name() const;
        ///
-       void SetFocus(int, int);
-       ///
-       MathedArray & GetData();
-       ///
-       MathedArray const & GetData() const;
-       ///
-       void setData(MathedArray const &);
-       ///
-       void setData(MathedArray const &, int);
-       ///
-       MathedTextCodes getTCode() const;
+       void setExpansion(MathArray const & exp, MathArray const & args) const;
+
        ///
-       bool Permit(short) const;
+       void validate(LaTeXFeatures &) const;
+
        ///
-       void expand();
+       void maple(MapleStream &) const;
        ///
-       void dump(ostream & os) const;
+       void mathmlize(MathMLStream &) const;
        ///
-       MathParInset const * arg(int) const;
+       void octave(OctaveStream &) const;
        ///
-       MathParInset * arg(int);
+       void infoize(std::ostream &) const;
        ///
-       MathMacroTemplate * tmplate() const;
+       void infoize2(std::ostream &) const;
+
 private:
+       virtual std::auto_ptr<InsetBase> doClone() const;
        ///
-       MathMacroTemplate * tmplate_;
-       /// our arguments
-       std::vector< boost::shared_ptr<MathParInset> > args_;
-       /// the expanded version fror drawing
-       boost::shared_ptr<MathParInset> expanded_;
+       void updateExpansion() const;
        ///
-       int idx_;
+       void expand() const;
 
-       /// unimplemented
-       void operator=(MathMacro const &);
+       /// name of macro
+       std::string name_;
+       /// the unexpanded macro defintition
+       mutable MathArray tmpl_;
+       /// the macro substituted with our args
+       mutable MathArray expanded_;
 };
 
-inline ostream & operator<<(ostream & os, MathMacro const & m)
-{
-       m.dump(os);
-       return os;
-}
+
 #endif