]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathCommand.cpp
MathML: remove redundant mrow in InsetMathScript.
[lyx.git] / src / mathed / InsetMathCommand.cpp
1 /**
2  * \file InsetMathCommand.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathCommand.h"
14 #include "MathData.h"
15 #include "MathStream.h"
16 #include "DispatchResult.h"
17
18 #include <sstream>
19
20 using namespace std;
21
22 namespace lyx {
23
24
25 InsetMathCommand::InsetMathCommand(Buffer * buf, docstring const & name, bool needs_math_mode)
26         : InsetMathNest(buf, 2), name_(name), needs_math_mode_(needs_math_mode),
27           set_label_(false)
28 {
29         lock_ = true;
30 }
31
32
33 Inset * InsetMathCommand::clone() const
34 {
35         return new InsetMathCommand(*this);
36 }
37
38
39 void InsetMathCommand::metrics(MetricsInfo & mi, Dimension & dim) const
40 {
41         if (!set_label_) {
42                 set_label_ = true;
43                 button_.update(screenLabel(), true, false);
44         }
45         button_.metrics(mi, dim);
46 }
47
48
49 Inset * InsetMathCommand::editXY(Cursor & cur, int /*x*/, int /*y*/)
50 {
51         edit(cur, true);
52         return this;
53 }
54
55
56 void InsetMathCommand::draw(PainterInfo & pi, int x, int y) const
57 {
58         button_.draw(pi, x, y);
59 }
60
61
62 void InsetMathCommand::write(TeXMathStream & os) const
63 {
64         ModeSpecifier specifier(os, currentMode(), lockedMode(), asciiOnly());
65         MathEnsurer ensurer(os, needs_math_mode_);
66         os << '\\' << name_;
67         if (!cell(1).empty())
68                 os << '[' << cell(1) << ']';
69         os << '{' << cell(0) << '}';
70 }
71
72
73 docstring const InsetMathCommand::screenLabel() const
74 {
75         return name_;
76 }
77
78 } // namespace lyx