]> git.lyx.org Git - lyx.git/blob - src/mathed/math_biginset.C
Fix reading of math macros
[lyx.git] / src / mathed / math_biginset.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "math_biginset.h"
8 #include "math_support.h"
9 #include "math_parser.h"
10 #include "math_mathmlstream.h"
11 #include "math_streamstr.h"
12
13
14 MathBigInset::MathBigInset(string const & name, string const & delim)
15         : name_(name), delim_(delim)
16 {}
17
18
19 MathInset * MathBigInset::clone() const
20 {
21         return new MathBigInset(*this);
22 }
23
24
25 MathBigInset::size_type MathBigInset::size() const
26 {
27         return name_.size() - 4;
28 }
29
30
31 double MathBigInset::increase() const
32 {
33         switch (size()) {
34                 case 1:  return 0.2;
35                 case 2:  return 0.44;
36                 case 3:  return 0.7;
37                 default: return 0.0;
38         }
39         return 0.0;
40 }
41
42
43 void MathBigInset::metrics(MathMetricsInfo & mi) const
44 {
45         double const h = mathed_char_ascent(mi.base.font, 'I');
46         double const f = increase();
47         dim_.w = 6;
48         dim_.a = int(h + f * h);
49         dim_.d = int(f * h);
50 }
51
52
53 void MathBigInset::draw(MathPainterInfo & pi, int x, int y) const
54 {
55         mathed_draw_deco(pi, x + 1, y - ascent(), 4, height(), delim_);
56 }
57
58
59 void MathBigInset::write(WriteStream & os) const
60 {
61         os << '\\' << name_ << ' ' << delim_;
62 }
63
64
65 void MathBigInset::normalize(NormalStream & os) const
66 {
67         os << '[' << name_ << ' ' <<  delim_ << ']';
68 }