]> git.lyx.org Git - lyx.git/blob - src/mathed/MathMacroTemplate.h
cf46734618f290d0abce49e90add8e0cd82482c1
[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 "MathMacroTable.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                 MathArray const & = MathArray(),
34                 MathArray const & = MathArray());
35         ///
36         explicit MathMacroTemplate(const docstring & str);
37         ///
38         void edit(LCursor & cur, bool left);
39         ///
40         EDITABLE editable() const { return HIGHLY_EDITABLE; }
41         ///
42         void read(Buffer const &, LyXLex & 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 & os,
49                         OutputParams const &) const
50         { os << "[math macro]"; return 12; }
51
52         /// Number of arguments
53         int numargs() const;
54         ///
55         void numargs(int);
56         ///
57         docstring name() const;
58         ///
59         MacroData asMacroData() const;
60         ///
61         void draw(PainterInfo & pi, int x, int y) const;
62         ///
63         bool metrics(MetricsInfo & mi, Dimension & dim) const;
64         /// identifies macro templates
65         MathMacroTemplate * asMacroTemplate() { return this; }
66         /// identifies macro templates
67         MathMacroTemplate const * asMacroTemplate() const { return this; }
68         ///
69         InsetBase::Code lyxCode() const { return MATHMACRO_CODE; }
70
71 private:
72         virtual std::auto_ptr<InsetBase> doClone() const;
73         /// prefix in inset
74         docstring prefix() const;
75
76         ///
77         int numargs_;
78         ///
79         docstring name_;
80         /// newcommand or renewcommand or def
81         docstring type_;
82 };
83
84
85 } // namespace lyx
86
87 #endif