1 #include "math_bigopinset.h"
3 #include "mathed/support.h"
4 #include "support/LOstream.h"
9 MathBigopInset::MathBigopInset(string const & name, int id)
10 : MathUpDownInset(false, false), sym_(id), limits_(0)
16 MathInset * MathBigopInset::clone() const
18 return new MathBigopInset(*this);
22 int MathBigopInset::limits() const
28 void MathBigopInset::limits(int limits)
34 bool MathBigopInset::hasLimits() const
36 return limits_ == 1 || (limits_ == 0 && size() == LM_ST_DISPLAY);
40 void MathBigopInset::Write(ostream & os, bool fragile) const
42 //bool f = sym_ != LM_int && sym_ != LM_oint && size() == LM_ST_DISPLAY;
44 MathUpDownInset::Write(os, fragile);
48 void MathBigopInset::WriteNormal(ostream & os) const
50 os << "[bigop " << name() << "] ";
54 void MathBigopInset::Metrics(MathStyles st, int, int)
56 //cerr << "\nBigopDraw\n";
59 if (sym_ < 256 || sym_ == LM_oint) {
61 ssym_ += (sym_ == LM_oint) ? LM_int : sym_;
69 mathed_string_dim(code_, size(), ssym_, ascent_, descent_, wid);
72 //cerr << " asc: " << ascent_ << " des: " << descent_
73 // << " wid: " << wid << "\n";
74 //cerr << " hasLimits: " << hasLimits() << " up: "
75 // << up() << " down: " << down() << "\n";
82 //cerr << " 0: ascent_: " << xcell(0).ascent() << " descent_: " <<
83 // xcell(0).descent() << " width_: " << xcell(0).width() << "\n";
84 //cerr << " 1: ascent_: " << xcell(1).ascent() << " descent_: " <<
85 // xcell(1).descent() << " width_: " << xcell(1).width() << "\n";
87 ascent_ += xcell(0).height() + 1;
88 width_ = std::max(width_, xcell(0).width());
89 dy0_ = - (ascent_ - xcell(0).ascent());
92 descent_ += xcell(1).height() + 1;
93 width_ = std::max(width_, xcell(1).width());
94 dy1_ = descent_ - xcell(1).descent();
96 dxx_ = (width_ - wid) / 2;
97 dx0_ = (width_ - xcell(0).width()) / 2;
98 dx1_ = (width_ - xcell(1).width()) / 2;
99 //cerr << " ascent_: " << ascent_ << " descent_: "
100 // << descent_ << " width_: " << width_ << "\n";
101 //cerr << " dx0_: " << dx0_ << " dx1_: " << dx1_
102 // << " dxx_: " << dxx_ << "\n";
103 //cerr << " dy0_: " << dy0_ << " dy1_: " << dy1_
106 MathUpDownInset::Metrics(st, ascent_, descent_);
115 void MathBigopInset::draw(Painter & pain, int x, int y)
120 pain.text(x + dxx_, y, ssym_, mathed_get_font(code_, size()));
123 xcell(0).draw(pain, x + dx0_, y + dy0_);
125 xcell(1).draw(pain, x + dx1_, y + dy1_);
127 if (sym_ == LM_oint) {
129 int yy = y - (ascent_ - descent_) / 2;
130 pain.arc(xx, yy, width_, width_, 0, 360 * 64, LColor::mathline);