4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Alejandro Aguilar Sierra
10 * Full author contact details are available in file CREDITS.
16 #include "InsetMathNest.h"
18 #include "InsetMathNest.h"
19 #include "MacroTable.h"
25 /// This class contains the data for a macro.
26 class MathMacro : public InsetMathNest {
28 /// A macro can be built from an existing template
29 MathMacro(docstring const & name, int numargs);
31 void draw(PainterInfo & pi, int x, int y) const;
33 void drawExpanded(PainterInfo & pi, int x, int y) const;
34 /// draw selection background
35 void drawSelection(PainterInfo & pi, int x, int y) const;
37 void drawDecoration(PainterInfo & pi, int x, int y) const
38 { drawMarkers2(pi, x, y); }
40 bool metrics(MetricsInfo & mi, Dimension & dim) const;
41 /// get cursor position
42 void cursorPos(BufferView const & bv, CursorSlice const & sl,
43 bool boundary, int & x, int & y) const;
45 Inset * editXY(Cursor & cur, int x, int y);
46 /// target pos when we enter the inset from the left by pressing "Right"
47 bool idxFirst(Cursor &) const;
48 /// target pos when we enter the inset from the right by pressing "Left"
49 bool idxLast(Cursor &) const;
51 bool idxUpDown(Cursor & cur, bool up) const;
53 virtual bool notifyCursorLeaves(Cursor &);
55 docstring name() const;
57 int kerning() const { return kerning_; }
59 void setExpansion(MathData const & exp, MathData const & args) const;
62 void validate(LaTeXFeatures &) const;
65 void maple(MapleStream &) const;
67 void mathmlize(MathStream &) const;
69 void octave(OctaveStream &) const;
71 void infoize(odocstream &) const;
73 void infoize2(odocstream &) const;
76 virtual std::auto_ptr<Inset> doClone() const;
78 void updateExpansion() const;
82 /// the unexpanded macro defintition
83 mutable MathData tmpl_;
84 /// the macro substituted with our args
85 mutable MathData expanded_;
87 mutable MacroData macroBackup_;
89 mutable bool editing_;