3 #include "math_bigopinset.h"
5 #include "mathed/support.h"
6 #include "support/LOstream.h"
11 MathBigopInset::MathBigopInset(string const & name, int id)
12 : MathUpDownInset(false, false), sym_(id), limits_(0)
18 MathInset * MathBigopInset::clone() const
20 return new MathBigopInset(*this);
24 int MathBigopInset::limits() const
30 void MathBigopInset::limits(int limits)
36 bool MathBigopInset::hasLimits() const
38 return limits_ == 1 || (limits_ == 0 && size() == LM_ST_DISPLAY);
42 void MathBigopInset::Write(ostream & os, bool fragile) const
44 //bool f = sym_ != LM_int && sym_ != LM_oint && size() == LM_ST_DISPLAY;
46 MathUpDownInset::Write(os, fragile);
50 void MathBigopInset::WriteNormal(ostream & os) const
52 os << "[bigop " << name() << "] ";
56 void MathBigopInset::Metrics(MathStyles st, int, int)
58 //cerr << "\nBigopDraw\n";
61 if (sym_ < 256 || sym_ == LM_oint) {
63 ssym_ += (sym_ == LM_oint) ? LM_int : sym_;
71 mathed_string_dim(code_, size(), ssym_, ascent_, descent_, wid);
74 //cerr << " asc: " << ascent_ << " des: " << descent_
75 // << " wid: " << wid << "\n";
76 //cerr << " hasLimits: " << hasLimits() << " up: "
77 // << up() << " down: " << down() << "\n";
84 //cerr << " 0: ascent_: " << xcell(0).ascent() << " descent_: " <<
85 // xcell(0).descent() << " width_: " << xcell(0).width() << "\n";
86 //cerr << " 1: ascent_: " << xcell(1).ascent() << " descent_: " <<
87 // xcell(1).descent() << " width_: " << xcell(1).width() << "\n";
89 ascent_ += xcell(0).height() + 1;
90 width_ = std::max(width_, xcell(0).width());
91 dy0_ = - (ascent_ - xcell(0).ascent());
94 descent_ += xcell(1).height() + 1;
95 width_ = std::max(width_, xcell(1).width());
96 dy1_ = descent_ - xcell(1).descent();
98 dxx_ = (width_ - wid) / 2;
99 dx0_ = (width_ - xcell(0).width()) / 2;
100 dx1_ = (width_ - xcell(1).width()) / 2;
101 //cerr << " ascent_: " << ascent_ << " descent_: "
102 // << descent_ << " width_: " << width_ << "\n";
103 //cerr << " dx0_: " << dx0_ << " dx1_: " << dx1_
104 // << " dxx_: " << dxx_ << "\n";
105 //cerr << " dy0_: " << dy0_ << " dy1_: " << dy1_
108 MathUpDownInset::Metrics(st, ascent_, descent_);
117 void MathBigopInset::draw(Painter & pain, int x, int y)
122 pain.text(x + dxx_, y, ssym_, mathed_get_font(code_, size()));
125 xcell(0).draw(pain, x + dx0_, y + dy0_);
127 xcell(1).draw(pain, x + dx1_, y + dy1_);
129 if (sym_ == LM_oint) {
131 int yy = y - (ascent_ - descent_) / 2;
132 pain.arc(xx, yy, width_, width_, 0, 360 * 64, LColor::mathline);