]> git.lyx.org Git - lyx.git/blob - src/mathed/MathMacro.h
* up/down jumps between macro parameters
[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         bool idxUpDown(Cursor & cur, bool up) const;
52         ///
53         virtual bool notifyCursorLeaves(Cursor &);
54         ///
55         docstring name() const;
56         ///
57         void setExpansion(MathData const & exp, MathData const & args) const;
58
59         ///
60         void validate(LaTeXFeatures &) const;
61
62         ///
63         void maple(MapleStream &) const;
64         ///
65         void mathmlize(MathStream &) const;
66         ///
67         void octave(OctaveStream &) const;
68         ///
69         void infoize(odocstream &) const;
70         ///
71         void infoize2(odocstream &) const;
72
73 private:
74         virtual std::auto_ptr<Inset> doClone() const;
75         ///
76         void updateExpansion() const;
77
78         /// name of macro
79         docstring name_;
80         /// the unexpanded macro defintition
81         mutable MathData tmpl_;
82         /// the macro substituted with our args
83         mutable MathData expanded_;
84         ///
85         mutable MacroData macroBackup_;
86         ///
87         mutable bool editing_;
88 };
89
90
91
92
93 } // namespace lyx
94 #endif