]> git.lyx.org Git - lyx.git/blob - src/mathed/math_biginset.C
Fix to bug 2362: Deleting superscript also deletes subscript.
[lyx.git] / src / mathed / math_biginset.C
1 /**
2  * \file math_biginset.C
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 "math_biginset.h"
14 #include "math_support.h"
15 #include "math_mathmlstream.h"
16 #include "math_streamstr.h"
17
18
19 using std::string;
20 using std::auto_ptr;
21
22
23 MathBigInset::MathBigInset(string const & name, string const & delim)
24         : name_(name), delim_(delim)
25 {}
26
27
28 auto_ptr<InsetBase> MathBigInset::doClone() const
29 {
30         return auto_ptr<InsetBase>(new MathBigInset(*this));
31 }
32
33
34 MathBigInset::size_type MathBigInset::size() const
35 {
36         return name_.size() - 4;
37 }
38
39
40 double MathBigInset::increase() const
41 {
42         switch (size()) {
43                 case 1:  return 0.2;
44                 case 2:  return 0.44;
45                 case 3:  return 0.7;
46                 default: return 0.0;
47         }
48 }
49
50
51 void MathBigInset::metrics(MetricsInfo & mi, Dimension & dim) const
52 {
53         double const h = mathed_char_ascent(mi.base.font, 'I');
54         double const f = increase();
55         dim_.wid = 6;
56         dim_.asc = int(h + f * h);
57         dim_.des = int(f * h);
58         dim = dim_;
59 }
60
61
62 void MathBigInset::draw(PainterInfo & pi, int x, int y) const
63 {
64         mathed_draw_deco(pi, x + 1, y - dim_.ascent(), 4, dim_.height(), delim_);
65 }
66
67
68 void MathBigInset::write(WriteStream & os) const
69 {
70         os << '\\' << name_ << ' ' << delim_;
71 }
72
73
74 void MathBigInset::normalize(NormalStream & os) const
75 {
76         os << '[' << name_ << ' ' <<  delim_ << ']';
77 }