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