]> git.lyx.org Git - lyx.git/blob - src/mathed/math_macrotemplate.h
some (yet unfinished) up/down work
[lyx.git] / src / mathed / math_macrotemplate.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 "math_data.h"
17 #include "math_macrotable.h"
18 #include "math_nestinset.h"
19
20
21 /// This class contains the macro definition.
22 class MathMacroTemplate : public MathNestInset {
23 public:
24         ///
25         MathMacroTemplate();
26         ///
27         MathMacroTemplate(std::string const & name, int nargs,
28                 std::string const & type,
29                 MathArray const & = MathArray(),
30                 MathArray const & = MathArray());
31         ///
32         explicit MathMacroTemplate(std::istream & is);
33         ///
34         void edit(LCursor & cur, bool left);
35         ///
36         EDITABLE editable() const { return HIGHLY_EDITABLE; }
37         ///
38         void read(Buffer const &, LyXLex & lex);
39         ///
40         void write(Buffer const &, std::ostream & os) const;
41         ///
42         void write(WriteStream & os) const;
43         /// Number of arguments
44         int numargs() const;
45         ///
46         void numargs(int);
47         ///
48         std::string name() const;
49         ///
50         MacroData asMacroData() const;
51         ///
52         void draw(PainterInfo & pi, int x, int y) const;
53         ///
54         void metrics(MetricsInfo & mi, Dimension & dim) const;
55         /// identifies macro templates
56         MathMacroTemplate * asMacroTemplate() { return this; }
57         /// identifies macro templates
58         MathMacroTemplate const * asMacroTemplate() const { return this; }
59         ///
60         InsetBase::Code lyxCode() const { return MATHMACRO_CODE; }
61
62 private:
63         virtual std::auto_ptr<InsetBase> doClone() const;
64         /// prefix in inset
65         std::string prefix() const;
66
67         ///
68         int numargs_;
69         ///
70         std::string name_;
71         /// newcommand or renewcommand or def
72         std::string type_;
73 };
74
75 #endif