]> git.lyx.org Git - lyx.git/blob - src/mathed/MathMacro.h
* Added the kerning method to a macro to inherit the kerning from the expanded form.
[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         int kerning() const { return kerning_; }
58         ///
59         void setExpansion(MathData const & exp, MathData const & args) const;
60
61         ///
62         void validate(LaTeXFeatures &) const;
63
64         ///
65         void maple(MapleStream &) const;
66         ///
67         void mathmlize(MathStream &) const;
68         ///
69         void octave(OctaveStream &) const;
70         ///
71         void infoize(odocstream &) const;
72         ///
73         void infoize2(odocstream &) const;
74
75 private:
76         virtual std::auto_ptr<Inset> doClone() const;
77         ///
78         void updateExpansion() const;
79
80         /// name of macro
81         docstring name_;
82         /// the unexpanded macro defintition
83         mutable MathData tmpl_;
84         /// the macro substituted with our args
85         mutable MathData expanded_;
86         ///
87         mutable MacroData macroBackup_;
88         ///
89         mutable bool editing_;
90         ///
91         mutable int kerning_;
92 };
93
94
95
96
97 } // namespace lyx
98 #endif