]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathMacroArgument.cpp
g-brief loads babel internally. So don't load it ourselves.
[lyx.git] / src / mathed / InsetMathMacroArgument.cpp
1 /**
2  * \file InsetMathMacroArgument.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "InsetMathMacroArgument.h"
15 #include "MathStream.h"
16 #include "MathSupport.h"
17
18 #include "support/debug.h"
19 #include "support/lassert.h"
20
21
22 namespace lyx {
23
24
25 Inset * InsetMathHash::clone() const
26 {
27         return new InsetMathHash(*this);
28 }
29
30
31 void InsetMathHash::write(TeXMathStream & os) const
32 {
33         os << str_;
34 }
35
36
37 void InsetMathHash::metrics(MetricsInfo & mi, Dimension & dim) const
38 {
39         metricsStrRedBlack(mi, dim, str_);
40 }
41
42
43 void InsetMathHash::draw(PainterInfo & pi, int x, int y) const
44 {
45         drawStrRed(pi, x, y, str_);
46 }
47
48
49 void InsetMathHash::normalize(NormalStream & os) const
50 {
51         os << "[hash " << str_ << "] ";
52 }
53
54
55 InsetMathMacroArgument::InsetMathMacroArgument(int n)
56         : number_(n)
57 {
58         if (n < 1 || n > 9) {
59                 LYXERR0("InsetMathMacroArgument::InsetMathMacroArgument: wrong Argument id: "
60                         << n);
61                 LASSERT(false, n = 1);
62         }
63
64         // The profiler tells us not to use
65         // str_ = '#' + convert<docstring>(n);
66         // so we do the conversion of n to ASCII manually.
67         // This works because 1 <= n <= 9.
68         str_.resize(2);
69         str_[1] = '0' + n;
70 }
71
72
73 Inset * InsetMathMacroArgument::clone() const
74 {
75         return new InsetMathMacroArgument(*this);
76 }
77
78
79 void InsetMathMacroArgument::setNumber(int n)
80 {
81         if (n < 1 || n > 9) {
82                 LYXERR0("InsetMathMacroArgument::setNumber: wrong Argument id: " << n);
83                 LASSERT(false, return);
84         }
85
86         number_ = n;
87         str_[1] = '0' + n;
88 }
89
90
91 void InsetMathMacroArgument::normalize(NormalStream & os) const
92 {
93         os << "[macroarg " << str_ << "] ";
94 }
95
96
97 } // namespace lyx