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