]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathMacro.h
Fix bug 1395 by Stefan Schimanski:
[lyx.git] / src / mathed / InsetMathMacro.h
1 // -*- C++ -*-
2 /**
3  * \file InsetMathMacro.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 "MathMacroTable.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);
30         ///
31         virtual MathMacro * asMacro() { return this; }
32         ///
33         virtual MathMacro const * asMacro() const { return this; }
34         ///
35         void draw(PainterInfo & pi, int x, int y) const;
36         ///
37         void drawExpanded(PainterInfo & pi, int x, int y) const;
38         /// draw selection background
39         void drawSelection(PainterInfo & pi, int x, int y) const;
40         /// draw decorations.
41         void drawDecoration(PainterInfo & pi, int x, int y) const
42         { drawMarkers2(pi, x, y); }
43         ///
44         bool metrics(MetricsInfo & mi, Dimension & dim) const;
45         ///
46         bool metricsExpanded(MetricsInfo & mi, Dimension & dim) const;
47         /// get cursor position
48         void cursorPos(BufferView const & bv, CursorSlice const & sl,
49                 bool boundary, int & x, int & y) const;
50         ///
51         InsetBase * editXY(LCursor & cur, int x, int y);
52         /// target pos when we enter the inset from the left by pressing "Right"
53         bool idxFirst(LCursor &) const;
54         /// target pos when we enter the inset from the right by pressing "Left"
55         bool idxLast(LCursor &) const;
56         ///
57         virtual bool notifyCursorLeaves(LCursor &);
58         ///
59         docstring name() const;
60         ///
61         void detachArguments(std::vector<MathArray> &args);
62         ///
63         void attachArguments(std::vector<MathArray> const &args);
64         
65         ///
66         void validate(LaTeXFeatures &) const;
67
68         ///
69         void maple(MapleStream &) const;
70         ///
71         void mathmlize(MathStream &) const;
72         ///
73         void octave(OctaveStream &) const;
74         ///
75         void infoize(odocstream &) const;
76         ///
77         void infoize2(odocstream &) const;
78
79 private:
80         virtual std::auto_ptr<InsetBase> doClone() const;
81         
82         /// name of macro
83         docstring name_;
84         /// the macro template
85         mutable MathArray tmpl_;
86         /// the macro substituted with our args
87         mutable MathArray expanded_;
88 };
89
90
91
92
93 } // namespace lyx
94 #endif