]> git.lyx.org Git - lyx.git/blob - src/mathed/MathMacroTemplate.h
* up/down jumps between macro parameters
[lyx.git] / src / mathed / MathMacroTemplate.h
1 // -*- C++ -*-
2 /**
3  * \file math_macrotemplate.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_MACROTEMPLATE_H
14 #define MATH_MACROTEMPLATE_H
15
16 #include "MathData.h"
17 #include "MacroTable.h"
18 #include "InsetMathNest.h"
19
20 #include "support/types.h"
21
22
23 namespace lyx {
24
25 /// This class contains the macro definition.
26 class MathMacroTemplate : public InsetMathNest {
27 public:
28         ///
29         MathMacroTemplate();
30         ///
31         MathMacroTemplate(docstring const & name, int nargs,
32                 docstring const & type,
33                 MathData const & = MathData(),
34                 MathData const & = MathData());
35         ///
36         explicit MathMacroTemplate(const docstring & str);
37         ///
38         void edit(Cursor & cur, bool left);
39         ///
40         EDITABLE editable() const { return HIGHLY_EDITABLE; }
41         ///
42         void read(Buffer const &, Lexer & lex);
43         ///
44         void write(Buffer const &, std::ostream & os) const;
45         ///
46         void write(WriteStream & os) const;
47         ///
48         int plaintext(Buffer const &, odocstream &,
49                       OutputParams const &) const;
50
51         /// Number of arguments
52         int numargs() const;
53         ///
54         void numargs(int);
55         ///
56         docstring name() const;
57         ///
58         MacroData asMacroData() const;
59         ///
60         void draw(PainterInfo & pi, int x, int y) const;
61         ///
62         bool metrics(MetricsInfo & mi, Dimension & dim) const;
63         /// identifies macro templates
64         MathMacroTemplate * asMacroTemplate() { return this; }
65         /// identifies macro templates
66         MathMacroTemplate const * asMacroTemplate() const { return this; }
67         ///
68         Inset::Code lyxCode() const { return MATHMACRO_CODE; }
69
70 private:
71         virtual std::auto_ptr<Inset> doClone() const;
72         /// prefix in inset
73         docstring prefix() const;
74
75         ///
76         int numargs_;
77         ///
78         docstring name_;
79         /// newcommand or renewcommand or def
80         docstring type_;
81 };
82
83
84 } // namespace lyx
85
86 #endif