1999-09-27 18:44:28 +00:00
|
|
|
/*
|
|
|
|
* File: math_inset.C
|
|
|
|
* Purpose: Implementation of insets for mathed
|
|
|
|
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
|
|
|
* Created: January 1996
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* Dependencies: Xlib, XForms
|
|
|
|
*
|
|
|
|
* Copyright: (c) 1996, 1997 Alejandro Aguilar Sierra
|
|
|
|
*
|
|
|
|
* Version: 0.8beta.
|
|
|
|
*
|
|
|
|
* You are free to use and modify this code under the terms of
|
|
|
|
* the GNU General Public Licence version 2 or later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation "math_inset.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "math_iter.h"
|
|
|
|
#include "math_inset.h"
|
|
|
|
#include "symbol_def.h"
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
1999-11-23 14:39:02 +00:00
|
|
|
char * strnew(char const * s)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-23 14:39:02 +00:00
|
|
|
char * s1 = new char[strlen(s)+1];
|
1999-09-27 18:44:28 +00:00
|
|
|
return strcpy(s1, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-23 14:39:02 +00:00
|
|
|
MathedInset::MathedInset(MathedInset * inset)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (inset) {
|
|
|
|
name = inset->GetName();
|
|
|
|
objtype = inset->GetType();
|
|
|
|
size = inset->GetStyle();
|
|
|
|
width = inset->Width();
|
|
|
|
ascent = inset->Ascent();
|
|
|
|
descent = inset->Descent();
|
|
|
|
} else {
|
|
|
|
objtype = LM_OT_UNDEF;
|
|
|
|
size = LM_ST_TEXT;
|
|
|
|
width = ascent = descent = 0;
|
|
|
|
name = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
MathFuncInset::MathFuncInset(char const * nm, short ot, short st)
|
|
|
|
: MathedInset("", ot, st)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
ln = 0;
|
1999-11-15 11:06:41 +00:00
|
|
|
lims = (GetType() == LM_OT_FUNCLIM);
|
|
|
|
if (GetType() == LM_OT_UNDEF) {
|
1999-09-27 18:44:28 +00:00
|
|
|
fname = strnew(nm);
|
|
|
|
SetName(fname);
|
|
|
|
} else {
|
|
|
|
fname = 0;
|
|
|
|
SetName(nm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
MathedInset * MathFuncInset::Clone()
|
1999-11-23 14:39:02 +00:00
|
|
|
{
|
|
|
|
return new MathFuncInset(name, GetType(), GetStyle());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
MathSpaceInset::MathSpaceInset(int sp, short ot, short st)
|
|
|
|
: MathedInset("", ot, st), space(sp)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
MathedInset * MathSpaceInset::Clone()
|
1999-11-23 14:39:02 +00:00
|
|
|
{
|
|
|
|
return new MathSpaceInset(space, GetType(), GetStyle());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
MathParInset::MathParInset(short st, char const * nm, short ot)
|
|
|
|
: MathedInset(nm, ot, st)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
array = 0;
|
|
|
|
ascent = 8;
|
|
|
|
width = 4;
|
|
|
|
descent = 0;
|
|
|
|
flag = 1;
|
1999-11-15 11:06:41 +00:00
|
|
|
if (objtype == LM_OT_SCRIPT)
|
1999-09-27 18:44:28 +00:00
|
|
|
flag |= LMPF_SCRIPT;
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
MathParInset::MathParInset(MathParInset * p)
|
|
|
|
: MathedInset(p)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
flag = p->flag;
|
|
|
|
p->setArgumentIdx(0);
|
|
|
|
MathedIter it(p->GetData());
|
|
|
|
SetData(it.Copy());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MathParInset::~MathParInset()
|
|
|
|
{
|
|
|
|
if (array) {
|
|
|
|
MathedIter it(array);
|
|
|
|
it.Clear();
|
|
|
|
delete array;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
MathedInset * MathParInset::Clone()
|
1999-11-23 14:39:02 +00:00
|
|
|
{
|
|
|
|
return new MathParInset(this);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-23 14:39:02 +00:00
|
|
|
void MathParInset::SetData(LyxArrayBase * a)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
array = a;
|
|
|
|
|
|
|
|
// A standard paragraph shouldn't have any tabs nor CRs.
|
|
|
|
if (array) {
|
|
|
|
MathedIter it(array);
|
|
|
|
while (it.OK()) {
|
|
|
|
char c = it.GetChar();
|
1999-11-15 11:06:41 +00:00
|
|
|
if (c == LM_TC_TAB || c == LM_TC_CR)
|
1999-09-27 18:44:28 +00:00
|
|
|
it.Delete();
|
|
|
|
else
|
|
|
|
it.Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
MathSqrtInset::MathSqrtInset(short st)
|
|
|
|
: MathParInset(st, "sqrt", LM_OT_SQRT) {}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
MathedInset * MathSqrtInset::Clone()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-23 14:39:02 +00:00
|
|
|
MathSqrtInset * p = new MathSqrtInset(GetStyle());
|
1999-09-27 18:44:28 +00:00
|
|
|
MathedIter it(array);
|
|
|
|
p->SetData(it.Copy());
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathSqrtInset::Inside(int x, int y)
|
|
|
|
{
|
1999-11-24 22:14:46 +00:00
|
|
|
return x >= xo - hmax
|
|
|
|
&& x <= xo + width - hmax
|
|
|
|
&& y <= yo + descent
|
|
|
|
&& y >= yo - ascent;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
MathDelimInset::MathDelimInset(int l, int r, short st)
|
|
|
|
: MathParInset(st, "", LM_OT_DELIM), left(l), right(r) {}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
MathedInset * MathDelimInset::Clone()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-22 16:19:48 +00:00
|
|
|
MathDelimInset * p = new MathDelimInset(left, right, GetStyle());
|
1999-09-27 18:44:28 +00:00
|
|
|
MathedIter it(array);
|
|
|
|
p->SetData(it.Copy());
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
MathDecorationInset::MathDecorationInset(int d, short st)
|
|
|
|
: MathParInset(st, "", LM_OT_DECO), deco(d)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 11:06:41 +00:00
|
|
|
upper = (deco!= LM_underline && deco!= LM_underbrace);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
MathedInset * MathDecorationInset::Clone()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-22 16:19:48 +00:00
|
|
|
MathDecorationInset * p = new MathDecorationInset(deco, GetStyle());
|
1999-09-27 18:44:28 +00:00
|
|
|
MathedIter it(array);
|
|
|
|
p->SetData(it.Copy());
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
MathFracInset::MathFracInset(short ot)
|
|
|
|
: MathParInset(LM_ST_TEXT, "frac", ot)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
den = new MathParInset(LM_ST_TEXT); // this leaks
|
|
|
|
dh = 0;
|
|
|
|
idx = 0;
|
1999-11-15 11:06:41 +00:00
|
|
|
if (objtype == LM_OT_STACKREL) {
|
1999-09-27 18:44:28 +00:00
|
|
|
flag |= LMPF_SCRIPT;
|
|
|
|
SetName("stackrel");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
MathFracInset::~MathFracInset()
|
|
|
|
{
|
|
|
|
delete den;
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
MathedInset * MathFracInset::Clone()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-22 16:19:48 +00:00
|
|
|
MathFracInset * p = new MathFracInset(GetType());
|
1999-09-27 18:44:28 +00:00
|
|
|
MathedIter itn(array);
|
|
|
|
MathedIter itd(den->GetData());
|
|
|
|
p->SetData(itn.Copy(), itd.Copy());
|
|
|
|
p->idx = idx;
|
|
|
|
p->dh = dh;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
bool MathFracInset::setArgumentIdx(int i)
|
|
|
|
{
|
1999-11-15 11:06:41 +00:00
|
|
|
if (i == 0 || i == 1) {
|
1999-09-27 18:44:28 +00:00
|
|
|
idx = i;
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathFracInset::SetStyle(short st)
|
|
|
|
{
|
|
|
|
MathParInset::SetStyle(st);
|
|
|
|
dh = 0;
|
1999-11-24 22:14:46 +00:00
|
|
|
den->SetStyle((size == LM_ST_DISPLAY) ?
|
|
|
|
static_cast<short>(LM_ST_TEXT)
|
|
|
|
: size);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
1999-11-23 14:39:02 +00:00
|
|
|
void MathFracInset::SetData(LyxArrayBase * n, LyxArrayBase * d)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
den->SetData(d);
|
|
|
|
MathParInset::SetData(n);
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
1999-11-23 14:39:02 +00:00
|
|
|
void MathFracInset::SetData(LyxArrayBase * d)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 11:06:41 +00:00
|
|
|
if (idx == 0)
|
1999-09-27 18:44:28 +00:00
|
|
|
MathParInset::SetData(d);
|
|
|
|
else {
|
|
|
|
den->SetData(d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
1999-11-23 14:39:02 +00:00
|
|
|
void MathFracInset::GetXY(int & x, int & y) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 11:06:41 +00:00
|
|
|
if (idx == 0)
|
1999-09-27 18:44:28 +00:00
|
|
|
MathParInset::GetXY(x, y);
|
|
|
|
else
|
|
|
|
den->GetXY(x, y);
|
|
|
|
}
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
|
1999-11-23 14:39:02 +00:00
|
|
|
LyxArrayBase * MathFracInset::GetData()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 11:06:41 +00:00
|
|
|
if (idx == 0)
|
1999-09-27 18:44:28 +00:00
|
|
|
return array;
|
|
|
|
else
|
|
|
|
return den->GetData();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathFracInset::Inside(int x, int y)
|
|
|
|
{
|
1999-11-24 22:14:46 +00:00
|
|
|
int xx = xo - (width - w0) / 2;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
return x >= xx && x <= xx + width && y <= yo + descent && y >= yo - ascent;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void MathFracInset::SetFocus(int /*x*/, int y)
|
|
|
|
{
|
1999-10-07 18:44:17 +00:00
|
|
|
// lyxerr << "y " << y << " " << yo << " " << den->yo << " ";
|
1999-09-27 18:44:28 +00:00
|
|
|
idx = (y > yo) ? 1: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
MathMatrixInset::MathMatrixInset(int m, int n, short st)
|
|
|
|
: MathParInset(st, "array", LM_OT_MATRIX), nc(m)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
ws = new int[nc];
|
|
|
|
v_align = 0;
|
1999-11-24 22:14:46 +00:00
|
|
|
h_align = new char[nc + 1];
|
|
|
|
for (int i = 0; i < nc; ++i) h_align[i] = 'c';
|
1999-09-27 18:44:28 +00:00
|
|
|
h_align[nc] = '\0';
|
|
|
|
nr = 0;
|
|
|
|
row = 0;
|
|
|
|
flag = 15;
|
1999-11-24 22:14:46 +00:00
|
|
|
if (n > 0) {
|
1999-09-27 18:44:28 +00:00
|
|
|
row = new MathedRowSt(nc+1);
|
|
|
|
MathedXIter it(this);
|
1999-11-24 22:14:46 +00:00
|
|
|
for (int j = 1; j < n; ++j) it.addRow();
|
1999-09-27 18:44:28 +00:00
|
|
|
nr = n;
|
1999-11-24 22:14:46 +00:00
|
|
|
if (nr == 1 && nc > 1) {
|
|
|
|
for (int j = 0; j < nc - 1; ++j)
|
1999-09-27 18:44:28 +00:00
|
|
|
it.Insert('T', LM_TC_TAB);
|
|
|
|
}
|
1999-11-24 22:14:46 +00:00
|
|
|
} else if (n < 0) {
|
|
|
|
row = new MathedRowSt(nc + 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
nr = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
MathMatrixInset::MathMatrixInset(MathMatrixInset * mt)
|
|
|
|
: MathParInset(mt->GetStyle(), mt->GetName(), mt->GetType())
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-24 22:14:46 +00:00
|
|
|
nr = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
nc = mt->nc;
|
|
|
|
ws = new int[nc];
|
1999-11-24 22:14:46 +00:00
|
|
|
h_align = new char[nc + 1];
|
1999-09-27 18:44:28 +00:00
|
|
|
strcpy(h_align, mt->GetAlign(&v_align));
|
1999-11-24 22:14:46 +00:00
|
|
|
MathedIter it;
|
1999-09-27 18:44:28 +00:00
|
|
|
it.SetData(mt->GetData());
|
|
|
|
array = it.Copy();
|
|
|
|
if (mt->row != 0) {
|
1999-11-24 22:14:46 +00:00
|
|
|
MathedRowSt * r, * ro= 0, * mrow = mt->row;
|
|
|
|
//mrow = mt->row; // This must be redundant...
|
1999-09-27 18:44:28 +00:00
|
|
|
while (mrow) {
|
1999-11-24 22:14:46 +00:00
|
|
|
r = new MathedRowSt(nc + 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
r->numbered = mrow->numbered;
|
|
|
|
if (mrow->label)
|
|
|
|
r->label = strnew(mrow->label);
|
|
|
|
if (!ro)
|
|
|
|
row = r;
|
|
|
|
else
|
|
|
|
ro->next = r;
|
|
|
|
mrow = mrow->next;
|
|
|
|
ro = r;
|
1999-11-24 22:14:46 +00:00
|
|
|
++nr;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
row = 0;
|
|
|
|
flag = mt->flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MathMatrixInset::~MathMatrixInset()
|
|
|
|
{
|
|
|
|
delete[] ws;
|
|
|
|
|
1999-11-23 14:39:02 +00:00
|
|
|
MathedRowSt * r = row;
|
1999-09-27 18:44:28 +00:00
|
|
|
while (r) {
|
1999-11-23 14:39:02 +00:00
|
|
|
MathedRowSt * q = r->next;
|
1999-09-27 18:44:28 +00:00
|
|
|
delete r;
|
|
|
|
r = q;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
MathedInset * MathMatrixInset::Clone()
|
|
|
|
{
|
|
|
|
return new MathMatrixInset(this);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
void MathMatrixInset::SetAlign(char vv, char const * hh)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
v_align = vv;
|
|
|
|
strncpy(h_align, hh, nc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Check the number of tabs and crs
|
1999-11-23 14:39:02 +00:00
|
|
|
void MathMatrixInset::SetData(LyxArrayBase * a)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!a) return;
|
|
|
|
MathedIter it(a);
|
1999-11-24 22:14:46 +00:00
|
|
|
int nn = nc - 1;
|
1999-09-27 18:44:28 +00:00
|
|
|
nr = 1;
|
|
|
|
// count tabs per row
|
|
|
|
while (it.OK()) {
|
|
|
|
if (it.IsTab()) {
|
1999-11-24 22:14:46 +00:00
|
|
|
if (nn < 0) {
|
1999-09-27 18:44:28 +00:00
|
|
|
it.Delete();
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
// it.Next();
|
1999-11-24 22:14:46 +00:00
|
|
|
--nn;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (it.IsCR()) {
|
1999-11-24 22:14:46 +00:00
|
|
|
while (nn > 0) {
|
1999-09-27 18:44:28 +00:00
|
|
|
it.Insert(' ', LM_TC_TAB);
|
1999-11-24 22:14:46 +00:00
|
|
|
--nn;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-24 22:14:46 +00:00
|
|
|
nn = nc - 1;
|
|
|
|
++nr;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
it.Next();
|
1999-11-24 22:14:46 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
it.Reset();
|
|
|
|
|
|
|
|
// Automatically inserts tabs around bops
|
|
|
|
// DISABLED because it's very easy to insert tabs
|
|
|
|
array = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
void MathMatrixInset::draw(Painter & pain, int x, int baseline)
|
|
|
|
{
|
|
|
|
MathParInset::draw(pain, x, baseline);
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void MathMatrixInset::Metrics()
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
int i, hl, h = 0;
|
|
|
|
MathedRowSt * cprow= 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (!row) {
|
1999-10-07 18:44:17 +00:00
|
|
|
// lyxerr << " MIDA ";
|
1999-09-27 18:44:28 +00:00
|
|
|
MathedXIter it(this);
|
|
|
|
row = it.adjustVerticalSt();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clean the arrays
|
2000-02-17 19:59:08 +00:00
|
|
|
MathedRowSt * cxrow = row;
|
1999-09-27 18:44:28 +00:00
|
|
|
while (cxrow) {
|
1999-11-24 22:14:46 +00:00
|
|
|
for (i = 0; i <= nc; ++i) cxrow->w[i] = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
cxrow = cxrow->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Basic metrics
|
|
|
|
MathParInset::Metrics();
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
if (nc <= 1 && !row->next) {
|
1999-09-27 18:44:28 +00:00
|
|
|
row->asc = ascent;
|
|
|
|
row->desc = descent;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Vertical positions of each row
|
|
|
|
cxrow = row;
|
|
|
|
while (cxrow) {
|
1999-11-24 22:14:46 +00:00
|
|
|
for (i = 0; i < nc; ++i) {
|
1999-11-15 11:06:41 +00:00
|
|
|
if (cxrow == row || ws[i]<cxrow->w[i]) ws[i]= cxrow->w[i];
|
|
|
|
if (cxrow->next == 0 && ws[i] == 0) ws[i] = df_width;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
cxrow->y = (cxrow == row) ? cxrow->asc:
|
1999-09-27 18:44:28 +00:00
|
|
|
cxrow->asc + cprow->desc + MATH_ROWSEP + cprow->y;
|
|
|
|
h += cxrow->asc + cxrow->desc + MATH_ROWSEP;
|
|
|
|
cprow = cxrow;
|
|
|
|
cxrow = cxrow->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
hl = Descent();
|
|
|
|
h -= MATH_ROWSEP;
|
|
|
|
|
|
|
|
// Compute vertical align
|
|
|
|
switch (v_align) {
|
|
|
|
case 't': ascent = row->y; break;
|
|
|
|
case 'b': ascent = h - hl; break;
|
1999-11-24 22:14:46 +00:00
|
|
|
default: ascent = (row->next) ? h / 2: h - hl; break;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
descent = h - ascent + 2;
|
|
|
|
|
|
|
|
|
|
|
|
// Adjust local tabs
|
|
|
|
cxrow = row;
|
|
|
|
width = MATH_COLSEP;
|
|
|
|
while (cxrow) {
|
1999-11-24 22:14:46 +00:00
|
|
|
int rg = MATH_COLSEP, ww, lf = 0, * w = cxrow->w;
|
|
|
|
for (i = 0; i < nc; ++i) {
|
1999-09-27 18:44:28 +00:00
|
|
|
bool isvoid = false;
|
1999-11-24 22:14:46 +00:00
|
|
|
if (w[i] <= 0) {
|
1999-09-27 18:44:28 +00:00
|
|
|
w[i] = df_width;
|
|
|
|
isvoid = true;
|
|
|
|
}
|
|
|
|
switch (h_align[i]) {
|
|
|
|
case 'l': lf = 0; break;
|
|
|
|
case 'c': lf = (ws[i] - w[i])/2;
|
|
|
|
break;
|
|
|
|
case 'r': lf = ws[i] - w[i]; break;
|
|
|
|
}
|
|
|
|
ww = (isvoid) ? lf: lf + w[i];
|
|
|
|
w[i] = lf + rg;
|
|
|
|
rg = ws[i] - ww + MATH_COLSEP;
|
1999-11-15 11:06:41 +00:00
|
|
|
if (cxrow == row) width += ws[i] + MATH_COLSEP;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
cxrow->y -= ascent;
|
|
|
|
cxrow = cxrow->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
MathAccentInset::MathAccentInset(byte cx, MathedTextCodes f, int cd, short st)
|
|
|
|
: MathedInset("", LM_OT_ACCENT, st), c(cx), fn(f), code(cd)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
inset = 0;
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
MathAccentInset::MathAccentInset(MathedInset *ins, int cd, short st)
|
|
|
|
: MathedInset("", LM_OT_ACCENT, st),
|
|
|
|
c(0), fn(LM_TC_MIN), code(cd), inset(ins) {}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
MathAccentInset::~MathAccentInset()
|
|
|
|
{
|
2000-02-04 09:38:32 +00:00
|
|
|
delete inset;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
MathedInset * MathAccentInset::Clone()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-23 14:39:02 +00:00
|
|
|
MathAccentInset * p;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (inset)
|
|
|
|
p = new MathAccentInset(inset->Clone(), code, GetStyle());
|
|
|
|
else
|
|
|
|
p = new MathAccentInset(c, fn, code, GetStyle());
|
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
MathBigopInset::MathBigopInset(char const* nam, int id, short st)
|
|
|
|
: MathedInset(nam, LM_OT_BIGOP, st), sym(id)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
lims = -1;
|
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
MathedInset * MathBigopInset::Clone()
|
1999-11-23 14:39:02 +00:00
|
|
|
{
|
|
|
|
return new MathBigopInset(name, sym, GetStyle());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
|
|
|
MathDotsInset::MathDotsInset(char const * nam, int id, short st)
|
|
|
|
: MathedInset(nam, LM_OT_DOTS, st), code(id) {}
|
|
|
|
|
|
|
|
|
|
|
|
MathedInset * MathDotsInset::Clone()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-23 14:39:02 +00:00
|
|
|
return new MathDotsInset(name, code, GetStyle());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|