+bool MathDecorationInset::wide() const
+{
+ return
+ name_ == "overbrace" ||
+ name_ == "underbrace" ||
+ name_ == "overleftarrow" ||
+ name_ == "overrightarrow" ||
+ name_ == "widehat" ||
+ name_ == "widetilde";
+}
+
+
void MathDecorationInset::metrics(MathStyles st) const
{
xcell(0).metrics(st);
void MathDecorationInset::metrics(MathStyles st) const
{
xcell(0).metrics(st);
xo(x);
yo(x);
xcell(0).draw(pain, x, y);
xo(x);
yo(x);
xcell(0).draw(pain, x, y);
- mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
+ if (wide())
+ mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
+ else {
+ int w = 2 + mathed_char_width(LM_TC_VAR, size(), 'x');
+ mathed_draw_deco(pain, x + (width_ - w) / 2, y + dy_, w, dh_, name_);
+ }
bool upper() const;
///
bool protect() const;
bool upper() const;
///
bool protect() const;
+ /// is it a wide decoration?
+ bool wide() const;
class Matrix {
public:
///
class Matrix {
public:
///
- typedef float matriz_data[2][2];
+ typedef double matriz_data[2][2];
///
Matrix();
///
void rotate(int);
///
///
Matrix();
///
void rotate(int);
///
- void escalate(float, float);
+ void escalate(double, double);
- void transform(float, float, float &, float &);
+ void transform(double, double, double &, double &);
private:
///
matriz_data m_;
private:
///
matriz_data m_;
r[0][1] = 0;
r[1][0] = 0;
r[1][1] = 1;
r[0][1] = 0;
r[1][0] = 0;
r[1][1] = 1;
- float const cs = (code & 1) ? 0 : (1 - code);
- float const sn = (code & 1) ? (2 - code) : 0;
+ double const cs = (code & 1) ? 0 : (1 - code);
+ double const sn = (code & 1) ? (2 - code) : 0;
r[0][0] = cs;
r[0][1] = sn;
r[1][0] = -r[0][1];
r[0][0] = cs;
r[0][1] = sn;
r[1][0] = -r[0][1];
-void Matrix::escalate(float x, float y)
+void Matrix::escalate(double x, double y)
{
matriz_data s;
s[0][0] = x;
{
matriz_data s;
s[0][0] = x;
-void Matrix::transform(float xp, float yp, float & x, float & y)
+void Matrix::transform(double xp, double yp, double & x, double & y)
{
x = m_[0][0] * xp + m_[0][1] * yp;
y = m_[1][0] * xp + m_[1][1] * yp;
{
x = m_[0][0] * xp + m_[0][1] * yp;
y = m_[1][0] * xp + m_[1][1] * yp;
-float const parenthHigh[] = {
+double const parenthHigh[] = {
2.0, 13.0,
0.9840, 0.0014, 0.7143, 0.0323, 0.4603, 0.0772,
0.2540, 0.1278, 0.1746, 0.1966, 0.0952, 0.3300,
2.0, 13.0,
0.9840, 0.0014, 0.7143, 0.0323, 0.4603, 0.0772,
0.2540, 0.1278, 0.1746, 0.1966, 0.0952, 0.3300,
-float const parenth[] = {
+double const parenth[] = {
2.0, 13.0,
0.9930, 0.0071, 0.7324, 0.0578, 0.5141, 0.1126,
0.3380, 0.1714, 0.2183, 0.2333, 0.0634, 0.3621,
2.0, 13.0,
0.9930, 0.0071, 0.7324, 0.0578, 0.5141, 0.1126,
0.3380, 0.1714, 0.2183, 0.2333, 0.0634, 0.3621,
+double const brace[] = {
2.0, 21.0,
0.9492, 0.0020, 0.9379, 0.0020, 0.7458, 0.0243,
0.5819, 0.0527, 0.4859, 0.0892, 0.4463, 0.1278,
2.0, 21.0,
0.9492, 0.0020, 0.9379, 0.0020, 0.7458, 0.0243,
0.5819, 0.0527, 0.4859, 0.0892, 0.4463, 0.1278,
// Is this correct? (Lgb)
// Is this correct? (Lgb)
+double const arrow[] = {
4, 7,
0.0150, 0.7500, 0.2000, 0.6000, 0.3500, 0.3500,
0.5000, 0.0500, 0.6500, 0.3500, 0.8000, 0.6000,
4, 7,
0.0150, 0.7500, 0.2000, 0.6000, 0.3500, 0.3500,
0.5000, 0.0500, 0.6500, 0.3500, 0.8000, 0.6000,
// Is this correct? (Lgb)
// Is this correct? (Lgb)
+double const Arrow[] = {
4, 7,
0.0150, 0.7500, 0.2000, 0.6000, 0.3500, 0.3500,
0.5000, 0.0500, 0.6500, 0.3500, 0.8000, 0.6000,
4, 7,
0.0150, 0.7500, 0.2000, 0.6000, 0.3500, 0.3500,
0.5000, 0.0500, 0.6500, 0.3500, 0.8000, 0.6000,
-float const udarrow[] = {
+double const udarrow[] = {
2, 3,
0.015, 0.25, 0.5, 0.05, 0.95, 0.25,
2, 3,
2, 3,
0.015, 0.25, 0.5, 0.05, 0.95, 0.25,
2, 3,
-float const Udarrow[] = {
+double const Udarrow[] = {
2, 3,
0.015, 0.25, 0.5, 0.05, 0.95, 0.25,
2, 3,
2, 3,
0.015, 0.25, 0.5, 0.05, 0.95, 0.25,
2, 3,
+double const brack[] = {
2.0, 4,
0.95, 0.05, 0.05, 0.05, 0.05, 0.95, 0.95, 0.95,
0.0
};
2.0, 4,
0.95, 0.05, 0.05, 0.05, 0.05, 0.95, 0.95, 0.95,
0.0
};
-float const corner[] = {
+double const corner[] = {
2.0, 3,
0.95, 0.05, 0.05, 0.05, 0.05, 0.95,
0.0
};
2.0, 3,
0.95, 0.05, 0.05, 0.05, 0.05, 0.95,
0.0
};
+double const angle[] = {
2.0, 3,
1, 0, 0.05, 0.5, 1, 1,
0.0
};
2.0, 3,
1, 0, 0.05, 0.5, 1, 1,
0.0
};
+double const slash[] = {
1, 0.95, 0.05, 0.05, 0.95,
0.0
};
1, 0.95, 0.05, 0.05, 0.95,
0.0
};
+double const hline[] = {
1, 0.05, 0.5, 0.95, 0.5,
0.0
};
1, 0.05, 0.5, 0.95, 0.5,
0.0
};
-float const hline2[] = {
+double const hline2[] = {
1, 0.1, 0.5, 0.3, 0.5,
1, 0.7, 0.5, 0.9, 0.5,
0.0
};
1, 0.1, 0.5, 0.3, 0.5,
1, 0.7, 0.5, 0.9, 0.5,
0.0
};
-float const hline3[] = {
+double const hline3[] = {
1, 0.1, 0, 0.15, 0,
1, 0.475, 0, 0.525, 0,
1, 0.85, 0, 0.9, 0,
1, 0.1, 0, 0.15, 0,
1, 0.475, 0, 0.525, 0,
1, 0.85, 0, 0.9, 0,
-float const dline3[] = {
+double const dline3[] = {
1, 0.1, 0.1, 0.15, 0.15,
1, 0.475, 0.475, 0.525, 0.525,
1, 0.85, 0.85, 0.9, 0.9,
1, 0.1, 0.1, 0.15, 0.15,
1, 0.475, 0.475, 0.525, 0.525,
1, 0.85, 0.85, 0.9, 0.9,
-float const hlinesmall[] = {
+double const hlinesmall[] = {
1, 0.4, 0.5, 0.6, 0.5,
0.0
};
1, 0.4, 0.5, 0.6, 0.5,
0.0
};
1, 0.5, 0.05, 0.5, 0.95,
0.0
};
1, 0.5, 0.05, 0.5, 0.95,
0.0
};
1, 0.3, 0.05, 0.3, 0.95,
1, 0.7, 0.05, 0.7, 0.95,
0.0
};
1, 0.3, 0.05, 0.3, 0.95,
1, 0.7, 0.05, 0.7, 0.95,
0.0
};
+double const tilde[] = {
2.0, 4,
0.05, 0.8, 0.25, 0.2, 0.75, 0.8, 0.95, 0.2,
0.0
2.0, 4,
0.05, 0.8, 0.25, 0.2, 0.75, 0.8, 0.95, 0.2,
0.0
int angle;
};
struct named_deco_struct {
char const * name;
int angle;
};
struct named_deco_struct {
char const * name;
void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
const string & name)
{
void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
const string & name)
{
- Matrix mt;
- Matrix sqmt;
- int i = 0;
-
if (name == ".") {
pain.line(x + w/2, y, x + w/2, y + h,
LColor::mathcursor, Painter::line_onoffdash);
if (name == ".") {
pain.line(x + w/2, y, x + w/2, y + h,
LColor::mathcursor, Painter::line_onoffdash);
}
int const r = mds->angle;
}
int const r = mds->angle;
- float const * d = mds->data;
+ double const * d = mds->data;
if (h > 70 && (name == "(" || name == ")"))
d = parenthHigh;
if (h > 70 && (name == "(" || name == ")"))
d = parenthHigh;
+ Matrix mt;
+ Matrix sqmt;
+
mt.rotate(r);
mt.escalate(w, h);
mt.rotate(r);
mt.escalate(w, h);
- int code;
- do {
- float xx;
- float yy;
- float x2;
- float y2;
-
- code = int(d[i++]);
- switch (code) {
- case 0: break;
- case 1:
- case 3:
- {
- xx = d[i++]; yy = d[i++];
- x2 = d[i++]; y2 = d[i++];
+ for (int i = 0; d[i]; ) {
+ int code = int(d[i++]);
+ if (code & 1) { // code == 1 || code == 3
+ double xx = d[i++];
+ double yy = d[i++];
+ double x2 = d[i++];
+ double y2 = d[i++];
if (code == 3)
sqmt.transform(xx, yy, xx, yy);
else
mt.transform(xx, yy, xx, yy);
mt.transform(x2, y2, x2, y2);
pain.line(x + int(xx), y + int(yy),
if (code == 3)
sqmt.transform(xx, yy, xx, yy);
else
mt.transform(xx, yy, xx, yy);
mt.transform(x2, y2, x2, y2);
pain.line(x + int(xx), y + int(yy),
- x + int(x2), y + int(y2),
- LColor::mathline);
- break;
- }
- case 2:
- case 4:
- {
+ x + int(x2), y + int(y2),
+ LColor::mathline);
+ } else {
int xp[32];
int yp[32];
int const n = int(d[i++]);
for (int j = 0; j < n; ++j) {
int xp[32];
int yp[32];
int const n = int(d[i++]);
for (int j = 0; j < n; ++j) {
- xx = d[i++]; yy = d[i++];
+ double xx = d[i++];
+ double yy = d[i++];
// lyxerr << " " << xx << " " << yy << " ";
if (code == 4)
sqmt.transform(xx, yy, xx, yy);
// lyxerr << " " << xx << " " << yy << " ";
if (code == 4)
sqmt.transform(xx, yy, xx, yy);
}
pain.lines(xp, yp, n, LColor::mathline);
}
}
pain.lines(xp, yp, n, LColor::mathline);
}
int mathed_char_ascent(MathTextCodes type, MathStyles size, unsigned char c);
int mathed_char_descent(MathTextCodes type, MathStyles size, unsigned char c);
int mathed_char_ascent(MathTextCodes type, MathStyles size, unsigned char c);
int mathed_char_descent(MathTextCodes type, MathStyles size, unsigned char c);
-void mathed_draw_deco
- (Painter & pain, int x, int y, int w, int h, string const & name);
+void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
+ string const & name);
void mathed_string_dim(MathTextCodes type, MathStyles size, string const & s,
int & asc, int & des, int & wid);
void mathed_string_dim(MathTextCodes type, MathStyles size, string const & s,
int & asc, int & des, int & wid);