]> git.lyx.org Git - lyx.git/blob - src/mathed/MathMacro.h
* do not lookup the same macro all the time
[lyx.git] / src / mathed / MathMacro.h
1 // -*- C++ -*-
2 /**
3  * \file MathMacro.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alejandro Aguilar Sierra
8  * \author André Pönitz
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef MATH_MACRO_H
14 #define MATH_MACRO_H
15
16 #include "InsetMathNest.h"
17 #include "MathData.h"
18 #include "InsetMathNest.h"
19 #include "MacroTable.h"
20
21
22 namespace lyx {
23
24
25 /// This class contains the data for a macro.
26 class MathMacro : public InsetMathNest {
27 public:
28         /// A macro can be built from an existing template
29         MathMacro(docstring const & name, int numargs);
30         ///
31         void draw(PainterInfo & pi, int x, int y) const;
32         ///
33         void drawExpanded(PainterInfo & pi, int x, int y) const;
34         /// draw selection background
35         void drawSelection(PainterInfo & pi, int x, int y) const;
36         /// draw decorations.
37         void drawDecoration(PainterInfo & pi, int x, int y) const
38         { drawMarkers2(pi, x, y); }
39         ///
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;
44         ///
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;
50         ///
51         virtual bool notifyCursorLeaves(Cursor &);
52         ///
53         docstring name() const;
54         ///
55         void setExpansion(MathData const & exp, MathData const & args) const;
56
57         ///
58         void validate(LaTeXFeatures &) const;
59
60         ///
61         void maple(MapleStream &) const;
62         ///
63         void mathmlize(MathStream &) const;
64         ///
65         void octave(OctaveStream &) const;
66         ///
67         void infoize(odocstream &) const;
68         ///
69         void infoize2(odocstream &) const;
70
71 private:
72         virtual std::auto_ptr<Inset> doClone() const;
73         ///
74         void updateExpansion() const;
75
76         /// name of macro
77         docstring name_;
78         /// the unexpanded macro defintition
79         mutable MathData tmpl_;
80         /// the macro substituted with our args
81         mutable MathData expanded_;
82         ///
83         mutable MacroData macroBackup_;
84         ///
85         mutable bool editing_;
86 };
87
88
89
90
91 } // namespace lyx
92 #endif