]> git.lyx.org Git - features.git/blob - src/mathed/math_bigopinset.C
5e5823df73edf47ef74c362daa703855c5c91f7f
[features.git] / src / mathed / math_bigopinset.C
1 #include <config.h>
2
3 #include "math_bigopinset.h"
4 #include "LColor.h"
5 #include "Painter.h"
6 #include "mathed/support.h"
7
8 bool MathBigopInset::GetLimits() const 
9 {  
10         // Default case
11         if (lims < 0) {
12                 return sym != LM_int && sym != LM_oint && GetStyle() == LM_ST_DISPLAY;
13         } 
14         
15         // Custom 
16         return lims > 0;
17
18
19
20 void MathBigopInset::SetLimits(bool ls) 
21 {  
22         lims = ls ? 1 : 0; 
23 }
24
25
26 MathBigopInset::MathBigopInset(string const & nam, int id, short st)
27         : MathedInset(nam, LM_OT_BIGOP, st), sym(id)
28 {
29         lims = -1;
30 }
31
32
33 MathedInset * MathBigopInset::Clone()
34 {
35         return new MathBigopInset(name, sym, GetStyle());
36 }
37
38
39 void
40 MathBigopInset::draw(Painter & pain, int x, int y)
41 {
42         string s;
43         short t;
44         
45         if (sym < 256 || sym == LM_oint) {
46                 s += (sym == LM_oint) ? LM_int : sym;
47                 t = LM_TC_BSYM;
48         } else {
49                 s = name;
50                 t = LM_TC_TEXTRM;
51         }
52         if (sym == LM_oint) {
53                 pain.arc(x, y - 5 * width / 4, width, width, 0, 360*64,
54                          LColor::mathline);
55                 ++x;
56         }
57         pain.text(x, y, s, mathed_get_font(t, size));
58 }
59
60
61 void
62 MathBigopInset::Metrics()
63 {
64         //char c;
65         string s;
66         short t;
67         
68         if (sym < 256 || sym == LM_oint) {
69                 char c = (sym == LM_oint) ? LM_int: sym;
70                 s += c;
71                 t = LM_TC_BSYM;
72         } else {
73                 s = name;
74                 t = LM_TC_TEXTRM;
75         }
76         mathed_string_height(t, size, s, ascent, descent);
77         width = mathed_string_width(t, size, s);
78         if (sym == LM_oint) width += 2;
79 }
80
81
82 void MathBigopInset::Write(ostream & os, bool /* fragile */)
83 {
84         bool limp = GetLimits();
85         
86         os << '\\' << name;
87         
88         if (limp && !(sym != LM_int && sym != LM_oint
89                       && (GetStyle() == LM_ST_DISPLAY)))
90                 os << "\\limits ";
91         else 
92                 if (!limp && (sym != LM_int && sym != LM_oint
93                               && (GetStyle() == LM_ST_DISPLAY)))
94                         os << "\\nolimits ";
95                 else 
96                         os << ' ';
97 }