]> git.lyx.org Git - lyx.git/blob - src/mathed/MathMacroArgument.C
Fix some unicode conversion problems, more work needed.
[lyx.git] / src / mathed / MathMacroArgument.C
1 /**
2  * \file MathMacroArgument.C
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 "MathMacroArgument.h"
15 #include "InsetMathMacro.h"
16 #include "MathMLStream.h"
17 #include "MathSupport.h"
18 #include "debug.h"
19
20
21 namespace lyx {
22
23 using std::endl;
24 using std::auto_ptr;
25 using std::size_t;
26 using std::vector;
27
28
29 MathMacroArgument::MathMacroArgument(size_t n)
30         : number_(n)
31 {
32         if (n < 1 || n > 9) {
33                 lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
34                         << n << endl;
35         }
36         str_[0] = '#';
37         str_[1] = static_cast<unsigned char>('0' + n);
38         str_[2] = '\0';
39 }
40
41
42 auto_ptr<InsetBase> MathMacroArgument::doClone() const
43 {
44         return auto_ptr<InsetBase>(new MathMacroArgument(*this));
45 }
46
47
48 void MathMacroArgument::write(WriteStream & os) const
49 {
50         os << str_;
51 }
52
53
54 void MathMacroArgument::metrics(MetricsInfo & mi, Dimension & dim) const
55 {
56         vector<char_type> n(str_, str_ + 3);
57         mathed_string_dim(mi.base.font, n, dim_);
58         dim = dim_;
59 }
60
61
62 void MathMacroArgument::draw(PainterInfo & pi, int x, int y) const
63 {
64         // FIXME UNICODE
65         drawStrRed(pi, x, y, from_utf8(str_));
66         setPosCache(pi, x, y);
67 }
68
69
70 void MathMacroArgument::normalize(NormalStream & os) const
71 {
72         os << "[macroarg " << str_ << "] ";
73 }
74
75
76 } // namespace lyx