Commit 9f53ba18 authored by Anna.Pavlova's avatar Anna.Pavlova Committed by Alexander.Trofimov

тестовая версия center~> baseline

fraction,
radical,
borderBox,
nary (UndOvr)
delimiters

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53308 954022d7-b5bf-4e40-9824-e11837661b57
parent 5f2f0f17
......@@ -585,8 +585,8 @@ CMathBase.prototype =
{
var size = this.elements[i][j].size;
Widths[j] = ( Widths[j] > size.width ) ? Widths[j] : size.width;
Ascents[i] = (Ascents[i] > size.center ) ? Ascents[i] : size.center;
Descents[i] = (Descents[i] > size.height - size.center ) ? Descents[i] : size.height - size.center;
Ascents[i] = (Ascents[i] > size.ascent ) ? Ascents[i] : size.ascent;
Descents[i] = (Descents[i] > size.height - size.ascent ) ? Descents[i] : size.height - size.ascent;
}
var Heights = [];
......@@ -632,14 +632,14 @@ CMathBase.prototype =
if(this.alignment.hgt[pos_y] == CENTER)
{
var maxC = 0;
var maxAsc = 0;
for(var j = 0; j < this.nCol; j++)
{
_c = this.elements[pos_x][j].size.center;
maxC = ( maxC > _c ) ? maxC : _c;
var _ascent = this.elements[pos_x][j].size.ascent;
maxAsc = ( maxAsc > _ascent ) ? maxAsc : _ascent;
}
_y = (maxC - this.elements[pos_x][pos_y].size.center);
_y = (maxAsc - this.elements[pos_x][pos_y].size.ascent);
}
else
{
......@@ -772,7 +772,7 @@ CMathBase.prototype =
// -1 - в пределах границы
// 0 - начало контента
// 1 - конец контента
// 2 - выщли за границы контента по Y
// 2 - вышли за границы контента по Y
var inside_flag = -1;
......@@ -815,7 +815,7 @@ CMathBase.prototype =
if(this.bMObjs === true)
this.pos = {x: pos.x, y : pos.y};
else
this.pos = {x: pos.x, y: pos.y - this.size.center}; ///!!!!!!!!!!!!!!!!!!!!!!!!!!
this.pos = {x: pos.x, y: pos.y - this.size.ascent}; ///!!!!!!!!!!!!!!!!!!!!!!!!!!
var maxWH = this.getWidthsHeights();
var Widths = maxWH.widths;
......@@ -834,11 +834,11 @@ CMathBase.prototype =
h += Heights[i];
}
},
draw: function(pGraphics)
draw: function(x, y, pGraphics)
{
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
this.elements[i][j].draw(pGraphics);
this.elements[i][j].draw(x, y, pGraphics);
},
remove: function(order)
{
......@@ -866,9 +866,9 @@ CMathBase.prototype =
_width += this.dW*(this.nCol - 1);
var _center = this.getCenter(_height);
var _ascent = this.getAscent(_height);
this.size = {width: _width, height: _height, center: _center};
this.size = {width: _width, height: _height, ascent: _ascent};
},
/*RecalculateReverse: function(oMeasure)
{
......@@ -883,7 +883,7 @@ CMathBase.prototype =
this.recalculateSize();
},
getCenter: function(_height)
old_getCenter: function(_height)
{
var res = 0;
if(this.nRow > 1)
......@@ -897,6 +897,20 @@ CMathBase.prototype =
return res;
},
getAscent: function(_height)
{
var Ascent = 0;
if(this.nRow > 1)
{
Ascent = _height || this.size.height;
Ascent /=2;
}
else
for(var i=0; i< this.nCol; i++)
Ascent = (this.elements[0][i].size.ascent > Ascent) ? this.elements[0][i].size.ascent : Ascent;
return Ascent;
},
alignHor: function(pos, coeff)
{
if(pos!=-1)
......
......@@ -49,18 +49,18 @@ CBorderBox.prototype.init = function(props)
}
CBorderBox.prototype.recalculateSize = function()
{
var ss = this.elements[0][0].size;
var base = this.elements[0][0].size;
var width = ss.width;
var height = ss.height;
var center = ss.center;
var width = base.width;
var height = base.height;
var ascent = base.ascent;
this.gapBrd = this.getCtrPrp().FontSize*0.08104587131076388;
if(this.bTop)
{
height += this.gapBrd;
center += this.gapBrd;
ascent += this.gapBrd;
}
if(this.bBot)
height += this.gapBrd;
......@@ -70,19 +70,19 @@ CBorderBox.prototype.recalculateSize = function()
if(this.bRight)
width += this.gapBrd;
this.size = {width : width, height: height, center: center};
this.size = {width : width, height: height, ascent: ascent};
}
CBorderBox.prototype.draw = function(pGraphics)
CBorderBox.prototype.draw = function(x, y, pGraphics)
{
this.elements[0][0].draw(pGraphics);
this.elements[0][0].draw(x, y, pGraphics);
var penW = this.getCtrPrp().FontSize* 25.4/96 * 0.08 ;
if(this.bTop)
{
var x1 = this.pos.x,
x2 = this.pos.x + this.size.width - 25.4/96,
y1 = this.pos.y;
var x1 = this.pos.x + x,
x2 = this.pos.x + x + this.size.width - 25.4/96,
y1 = this.pos.y + y;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawHorLine(0, y1, x1, x2, penW);
......@@ -90,9 +90,9 @@ CBorderBox.prototype.draw = function(pGraphics)
if(this.bBot)
{
var x1 = this.pos.x,
x2 = this.pos.x + this.size.width - 25.4/96,
y1 = this.pos.y + this.size.height - penW;
var x1 = this.pos.x + x,
x2 = this.pos.x + x + this.size.width - 25.4/96,
y1 = this.pos.y + y + this.size.height - penW;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawHorLine(0, y1, x1, x2, penW);
......@@ -100,9 +100,9 @@ CBorderBox.prototype.draw = function(pGraphics)
if(this.bLeft)
{
var x1 = this.pos.x ,
y1 = this.pos.y,
y2 = this.pos.y + this.size.height - 25.4/96;
var x1 = this.pos.x + x,
y1 = this.pos.y + y,
y2 = this.pos.y + y + this.size.height - 25.4/96;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
......@@ -110,9 +110,9 @@ CBorderBox.prototype.draw = function(pGraphics)
if(this.bRight)
{
var x1 = this.pos.x + this.size.width - penW ,
y1 = this.pos.y,
y2 = this.pos.y + this.size.height - 25.4/96 ;
var x1 = this.pos.x + x + this.size.width - penW ,
y1 = this.pos.y + y,
y2 = this.pos.y + y + this.size.height - 25.4/96 ;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
......@@ -121,9 +121,9 @@ CBorderBox.prototype.draw = function(pGraphics)
if(this.bLDiag)
{
var pW = penW*0.8;
var x1 = this.pos.x , y1 = this.pos.y,
var x1 = this.pos.x + x , y1 = this.pos.y + y,
x2 = x1 + pW, y2 = y1,
x3 = x1 + this.size.width - 25.4/96, y3 = y1 + this.size.height - pW - 25.4/96,
x3 = x1 + x + this.size.width - 25.4/96, y3 = y1 + this.size.height - pW - 25.4/96,
x4 = x3, y4 = y3 + pW,
x5 = x4 - pW, y5 = y4,
x6 = x1, y6 = y1 + pW,
......@@ -147,10 +147,10 @@ CBorderBox.prototype.draw = function(pGraphics)
if(this.bRDiag)
{
var pW = penW*0.8;
var x1 = this.pos.x + this.size.width - pW - 25.4/96, y1 = this.pos.y,
var x1 = this.pos.x + x + this.size.width - pW - 25.4/96, y1 = this.pos.y + y,
x2 = x1 + pW, y2 = y1,
x3 = x2, y3 = y2 + pW,
x4 = this.pos.x + pW, y4 = this.pos.y + this.size.height - 25.4/96,
x4 = this.pos.x + x + pW, y4 = this.pos.y + y + this.size.height - 25.4/96,
x5 = x4 - pW, y5 = y4,
x6 = x5, y6 = y5 - pW,
x7 = x1, y7 = y1;
......@@ -172,9 +172,9 @@ CBorderBox.prototype.draw = function(pGraphics)
if(this.bHor)
{
var x1 = this.pos.x,
x2 = this.pos.x + this.size.width - 25.4/96,
y1 = this.pos.y + this.size.height/2 - penW/2;
var x1 = this.pos.x + x,
x2 = this.pos.x + x + this.size.width - 25.4/96,
y1 = this.pos.y + y + this.size.height/2 - penW/2;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawHorLine(0, y1, x1, x2, penW);
......@@ -182,9 +182,9 @@ CBorderBox.prototype.draw = function(pGraphics)
if(this.bVert)
{
var x1 = this.pos.x + this.size.width/2 - penW/2,
y1 = this.pos.y,
y2 = this.pos.y + this.size.height - 25.4/96;
var x1 = this.pos.x + x + this.size.width/2 - penW/2,
y1 = this.pos.y + y,
y2 = this.pos.y + y + this.size.height - 25.4/96;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
......@@ -193,7 +193,7 @@ CBorderBox.prototype.draw = function(pGraphics)
}
CBorderBox.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
this.pos = {x: pos.x, y: pos.y - this.size.ascent};
var x = this.pos.x, y = this.pos.y;
......@@ -277,7 +277,6 @@ CBorderBox.prototype.getPropsForWrite = function()
return props;
}
function CBox()
{
this.kind = MATH_BOX;
......@@ -369,16 +368,16 @@ CBar.prototype.init = function(props)
this.setCharacter(props, defaultProps);
}
CBar.prototype.getCenter = function()
CBar.prototype.getAscent = function()
{
var center;
var ascent;
if(this.loc === LOCATION_TOP )
center = this.operator.size.height + this.elements[0][0].size.center;
ascent = this.operator.size.height + this.elements[0][0].size.ascent;
else if(this.loc === LOCATION_BOT )
center = this.elements[0][0].size.center;
ascent = this.elements[0][0].size.ascent;
return center;
return ascent;
}
CBar.prototype.getPropsForWrite = function()
{
......
......@@ -38,7 +38,11 @@ CDegree.prototype.init_2 = function(props, oBase)
CDegree.prototype.recalculateSize = function()
{
var Widths = this.getWidthsHeights().widths;
var Heights = [this.elements[0][0].size.height, this.elements[0][1].size.height];
var Heights = [];
Heights[0] = this.elements[0][0].size.height;
Heights[1] = this.elements[0][1].size.height;
var _center;
var middle = ((Heights[0] > Heights[1]) ? Heights[1] : Heights[0])* 2/3; /// 2/3 от высоты
......
......@@ -51,7 +51,7 @@ CFraction.prototype.getType = function()
{
return this.type;
}
CFraction.prototype.getCenter = function()
CFraction.prototype.old_getCenter = function()
{
var center;
......@@ -71,23 +71,25 @@ CFraction.prototype.getCenter = function()
return center;
}
CFraction.prototype.draw = function(pGraphics)
CFraction.prototype.draw = function(x, y, pGraphics)
{
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
this.drawBarFraction(pGraphics);
this.drawBarFraction(x, y, pGraphics);
else if(this.type == SKEWED_FRACTION)
this.drawSkewedFraction(pGraphics);
this.drawSkewedFraction(x, y, pGraphics);
else if(this.type == LINEAR_FRACTION)
this.drawLinearFraction(pGraphics);
this.drawLinearFraction(x, y, pGraphics);
}
CFraction.prototype.drawBarFraction = function(pGraphics)
CFraction.prototype.drawBarFraction = function(x, y, pGraphics)
{
var ctrPrp = this.getCtrPrp();
var penW = ctrPrp.FontSize* this.reduct* 25.4/96 * 0.08;
var x1 = this.pos.x,
x2 = this.pos.x + this.size.width,
y1 = y2 = this.pos.y + this.size.center - penW/2;
var numHeight = this.elements[0][0].size.height;
var x1 = this.pos.x + x ,
x2 = this.pos.x + x + this.size.width,
y1 = this.pos.y + y + numHeight - penW/2;
if( !this.bHideBar )
{
......@@ -98,9 +100,9 @@ CFraction.prototype.drawBarFraction = function(pGraphics)
pGraphics.drawHorLine(0, y1, x1, x2, penW);
}
CFraction.superclass.draw.call(this, pGraphics);
CFraction.superclass.draw.call(this, x, y, pGraphics);
}
CFraction.prototype.drawSkewedFraction = function(pGraphics)
CFraction.prototype.drawSkewedFraction = function(x, y, pGraphics)
{
var ctrPrp = this.getCtrPrp();
......@@ -139,11 +141,11 @@ CFraction.prototype.drawSkewedFraction = function(pGraphics)
var x1 = (y1 - b)/tg,
x2 = (y2 - b)/tg;
var xx1 = this.pos.x + x1,
xx2 = this.pos.x + x2;
var xx1 = this.pos.x + x + x1,
xx2 = this.pos.x + x + x2;
var yy1 = this.pos.y + y1,
yy2 = this.pos.y + y2;
var yy1 = this.pos.y + y + y1,
yy2 = this.pos.y + y + y2;
}
else
......@@ -170,11 +172,11 @@ CFraction.prototype.drawSkewedFraction = function(pGraphics)
var x1 = (y1 - b)/tg,
x2 = (y2 - b)/tg;
var xx1 = this.pos.x + x1,
xx2 = this.pos.x + x2;
var xx1 = this.pos.x + x + x1,
xx2 = this.pos.x + x + x2;
var yy1 = this.pos.y + y1 ,
yy2 = this.pos.y + y2;
var yy1 = this.pos.y + y + y1 ,
yy2 = this.pos.y + y + y2;
}
......@@ -189,23 +191,16 @@ CFraction.prototype.drawSkewedFraction = function(pGraphics)
pGraphics._l(xx2, yy2);
pGraphics.ds();
CFraction.superclass.draw.call(this, pGraphics);
CFraction.superclass.draw.call(this, x, y, pGraphics);
}
CFraction.prototype.drawLinearFraction = function(pGraphics)
CFraction.prototype.drawLinearFraction = function(x, y, pGraphics)
{
var first = this.elements[0][0].size,
sec = this.elements[0][1].size;
var cent = first.center > sec.center ? first.center : sec.center,
desc1 = first.height - first.center, desc2 = sec.height - sec.center,
desc = desc1 > desc2 ? desc1 : desc2;
var shift = 0.1*this.dW;
var x1 = this.pos.x + this.elements[0][0].size.width + this.dW - shift,
y1 = this.pos.y + this.size.center - cent,
x2 = this.pos.x + this.elements[0][0].size.width + shift,
y2 = this.pos.y + this.size.center + desc;
var x1 = this.pos.x + x + this.elements[0][0].size.width + this.dW - shift,
y1 = this.pos.y + y,
x2 = this.pos.x + x + this.elements[0][0].size.width + shift,
y2 = this.pos.y + y + this.size.height;
var ctrPrp = this.getCtrPrp();
var penW = ctrPrp.FontSize/12.5*g_dKoef_pix_to_mm;
......@@ -221,7 +216,7 @@ CFraction.prototype.drawLinearFraction = function(pGraphics)
pGraphics._l(x2, y2);
pGraphics.ds();
CFraction.superclass.draw.call(this, pGraphics);
CFraction.superclass.draw.call(this, x, y, pGraphics);
}
CFraction.prototype.getNumerator = function()
{
......@@ -248,26 +243,42 @@ CFraction.prototype.getDenominator = function()
CFraction.prototype.recalculateSize = function()
{
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
CFraction.superclass.recalculateSize.call(this);
this.recalculateBarFraction();
else if(this.type == SKEWED_FRACTION)
this.recalculateSkewed();
else if(this.type == LINEAR_FRACTION)
this.recalculateLinear();
}
CFraction.prototype.recalculateBarFraction = function()
{
var num = this.elements[0][0].size,
den = this.elements[1][0].size;
var width = num.width > den.width ? num.width : den.width;
var height = num.height + den.height;
var shCenter = DIV_CENT*this.getCtrPrp().FontSize;
var ascent = num.height + shCenter;
this.size = {width: width, height: height, ascent: ascent};
}
CFraction.prototype.recalculateSkewed = function()
{
var ctrPrp = this.getCtrPrp();
this.gapSlash = 5.011235894097222 * ctrPrp.FontSize/36;
var _width = this.elements[0][0].size.width + this.gapSlash + this.elements[0][1].size.width;
var _height = this.elements[0][0].size.height + this.elements[0][1].size.height;
var _center = this.getCenter();
var _ascent = this.elements[0][0].size.height + ctrPrp.FontSize*DIV_CENT;
this.size = {width: _width, height: _height, center: _center};
this.size = {width: _width, height: _height, ascent: _ascent};
}
CFraction.prototype.recalculateLinear = function()
{
var H = this.elements[0][0].size.center + this.elements[0][1].size.height - this.elements[0][1].size.center;
//var txtPrp = this.getTxtPrp();
var AscentFirst = this.elements[0][0].size.ascent,
DescentFirst = this.elements[0][0].size.height - this.elements[0][0].size.ascent,
AscentSecond = this.elements[0][1].size.ascent,
DescentSecond = this.elements[0][1].size.height - this.elements[0][1].size.ascent;
var H = AscentFirst + DescentSecond;
var ctrPrp = this.getCtrPrp();
var gap = 5.011235894097222*ctrPrp.FontSize/36;
......@@ -285,34 +296,26 @@ CFraction.prototype.recalculateLinear = function()
else
this.dW = 3.4*gap;
var h1 = this.elements[0][0].size.height,
h2 = this.elements[0][1].size.height;
var c1 = this.elements[0][0].size.center,
c2 = this.elements[0][1].size.center;
var ascent = AscentFirst > AscentSecond ? AscentFirst : AscentSecond;
var descent = DescentFirst > DescentSecond ? DescentFirst : DescentSecond;
var asc = c1 > c2 ? c1 : c2;
var desc = h1 - c1 > h2 - c2 ? h1- c1 : h2 - c2;
var height = asc + desc;
var height = ascent + descent;
var width = this.elements[0][0].size.width + this.dW + this.elements[0][1].size.width;
var center = this.getCenter();
this.size = {height: height, width: width, center: center};
this.size = {height: height, width: width, ascent: ascent};
}
CFraction.prototype.setPosition = function(pos)
{
if(this.type == SKEWED_FRACTION)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
this.pos = {x: pos.x, y: pos.y - this.size.ascent};
this.elements[0][0].setPosition(this.pos);
var x = this.pos.x + this.elements[0][0].size.width + this.gapSlash,
y = this.pos.y + this.size.center;
y = this.pos.y + this.elements[0][0].size.height;
this.elements[0][1].setPosition({x: x, y: y});
}
else
CFraction.superclass.setPosition.call(this, pos);
......@@ -405,6 +408,7 @@ CFraction.prototype.getPropsForWrite = function()
function CNumerator()
{
this.gap = 0;
CMathBase.call(this);
}
extend(CNumerator, CMathBase);
......@@ -422,19 +426,19 @@ CNumerator.prototype.recalculateSize = function()
var ctrPrp = this.getCtrPrp();
var Descent = arg.height - arg.ascent; // baseLine
var gap = 7.832769097222222 * ctrPrp.FontSize/36,
var gapNum = 7.832769097222222 * ctrPrp.FontSize/36,
minGap = ctrPrp.FontSize* 25.4/96 * 0.16;
// var delta = 0.65*gap - Descent;
var delta = 0.8076354679802956*gap - Descent;
var delta = 0.8076354679802956*gapNum - Descent;
var GapNum = delta > minGap ? delta - 0.95*minGap: minGap;
this.gap = delta > minGap ? delta - 0.95*minGap: minGap;
var width = arg.width;
var height = arg.height + GapNum;
var center = arg.center;
var height = arg.height + this.gap;
var ascent = arg.ascent;
this.size = {width : width, height: height, center: center};
this.size = {width : width, height: height, ascent: ascent};
}
CNumerator.prototype.findDisposition = function(mCoord)
{
......@@ -467,6 +471,7 @@ CNumerator.prototype.getCtrPrp = function()
function CDenominator()
{
this.gap = 0;
CMathBase.call(this);
}
extend(CDenominator, CMathBase);
......@@ -478,42 +483,38 @@ CDenominator.prototype.init = function()
CDenominator.prototype.recalculateSize = function()
{
var arg = this.elements[0][0].size;
/*var txtPrp = this.getTxtPrp();
txtPrp.FontSize *= this.Parent.reduct;*/
var ctrPrp = this.getCtrPrp();
var gap = 7.832769097222222 * ctrPrp.FontSize/36,
Ascent = arg.center - 4.938888888888888*ctrPrp.FontSize/36,
minGap = ctrPrp.FontSize* 25.4/96 * 0.24;
var gapDen = 7.325682539682539 * ctrPrp.FontSize/36,
Ascent = arg.ascent - 4.938888888888888*ctrPrp.FontSize/36,
minGap = gapDen/3;
var delta = 0.47*gap - Ascent;
var GapDen = delta > minGap ? delta : minGap;
var delta = gapDen - Ascent;
this.gap = delta > minGap ? delta : minGap;
var width = arg.width;
var height = arg.height + GapDen;
var center = arg.center + GapDen;
var height = arg.height + this.gap;
var ascent = arg.ascent + this.gap;
this.size = {width : width, height: height, center: center};
this.size = {width : width, height: height, ascent: ascent};
}
CDenominator.prototype.findDisposition = function(mCoord)
{
var arg = this.elements[0][0].size;
var gap = this.size.height - arg.height;
if(mCoord.y < gap)
if(mCoord.y < this.gap)
mCoord.y = 0;
else if (mCoord.y > arg.height + gap)
else if (mCoord.y > arg.height + this.gap)
mCoord.y = arg.height;
else
mCoord.y -= gap;
mCoord.y -= this.gap;
return CDenominator.superclass.findDisposition.call(this, mCoord);
}
CDenominator.prototype.setPosition = function(pos)
{
var x = pos.x;
var y = pos.y + this.size.height - this.elements[0][0].size.height;
var y = pos.y + this.gap;
this.elements[0][0].setPosition({x: x, y: y});
}
......
......@@ -12,23 +12,23 @@
//Bugs
//При добавлении в началло контента элемента , он вставляется с размером шрифта 11, посмотреть getCurrRunPrp
// При добавлении в начало контента элемента , он вставляется с размером шрифта 11, посмотреть getCurrRunPrp
// При удаление из начала контента элемента, у всех остальных автоматом 11 размер шрифта
/// TODO
// 1. properties для записи в файл
// 2. выставить setFont для accent, group charater в случае, если придет текст
// 3. центр => baseline
// 4. поправить центр для delimiters (когда оператор текст)
// 5. Поправить пересчет размера для delimiters (для скобок (control object) идет смещение для baseline)
// 0. Пересмотреть схему для findDisposition(base.js), т.к. если нажали за границами элемента, то происходит селект, т.к. теперь на mouseDown и mouseDown одни и те же функции
// 1. центр => baseline
// 2. поправить центр для delimiters (когда оператор текст)
// 3. Поправить пересчет размера для delimiters (для скобок (control object) идет смещение для baseline)
// 5. сделать gaps для мат. объектов, +, - в зависимости от расположения в контенте
// 6. баг с отрисовкой кругового интеграла
// 7. cursor_Up, cursor_Down (+ c зажитым shift)
// 8. Merge textPrp и mathTextPrp (bold, italic)
// 9. Поправить баги для CAccent с точками : смещение, когда идут подряд с одной точкой, двумя и тремя они перекрываются
// 10. Для управляющих символов запрашивать не getCtrPrp, getPrpToControlLetter (реализована, нужно только протащить для всех управляющих элементов)
// 11. объединение формул на remove и add
// 6. Размер разделительной черты для линейной дроби ограничить также как и для наклонной дроби
// 7. баг с отрисовкой кругового интеграла
// 8. cursor_Up, cursor_Down (+ c зажитым shift)
// 9. Merge textPrp и mathTextPrp (bold, italic)
// 10. Поправить баги для CAccent с точками : смещение, когда идут подряд с одной точкой, двумя и тремя они перекрываются
// 11. Для управляющих символов запрашивать не getCtrPrp, getPrpToControlLetter (реализована, нужно только протащить для всех управляющих элементов)
// 12. объединение формул на remove и add
// TODO Refactoring
// 1. CAccent ~> COperator
......@@ -37,7 +37,6 @@
/// TODO
// !!! Проверить типы для groupCharacter, delimiters и accent
// 1. Посмотреть стрелки и прочее для delimiters (которые используются для accent), при необходимости привести к одному типу
// 2. Убрать ненужные(!!) setTxtPrp и getTxtPrp
// 3. Проверить что будет, если какие-то настройки убрать/добавить из ctrPrp, влияют ли они на отрисовку управляющих элементов (например, Italic, Bold)
......@@ -282,14 +281,8 @@ function CMathContent()
this.content = new Array(); // array of mathElem
this.CurPos = 0;
this.pos = {x:0, y:0};
this.g_mContext = null;
this.pos = {x:0, y:0}; // относительная позиция
/*this.RunPrp = new CTextPr();
this.TxtPrp = new CTextPr();*/
//this.TxtPrp = new CMathTextPrp();
//this.OwnTPrp = new CMathTextPrp();
this.Composition = null; // ссылка на общую формулу
this.reduct = 1; // индефикатор для степени (уменьшение размера шрифта)
......@@ -326,7 +319,6 @@ CMathContent.prototype =
{
init: function()
{
this.g_mContext = new dist(0,0,0,0);
this.content.push( new mathElem(new CEmpty(), new dist(0,0,0,0), 0) );
},
// переделать для селекта
......@@ -4627,37 +4619,23 @@ CMathContent.prototype =
var width = 0 ;
var ascent = 0 ;
var descent = 0 ;
var center = 0 ;
var height = 0 ;
for(var i = 0; i < this.content.length; i++)
{
var oSize = this.content[i].value.size,
type = this.content[i].value.typeObj;
var oSize = this.content[i].value.size;
var gps = this.content[i].g_mContext;
width += oSize.width + gps.left + gps.right;
if(type == MATH_COMP)
{
ascent = ascent > oSize.center ? ascent : oSize.center;
descent = descent < ( oSize.height - oSize.center + gps.bottom) ? (oSize.height - oSize.center + gps.bottom ) : descent;
}
else if(type == MATH_TEXT || type == MATH_PLACEHOLDER)
{
ascent = ascent > oSize.ascent ? ascent : oSize.ascent;
descent = descent < ( oSize.height - oSize.ascent + gps.bottom) ? (oSize.height - oSize.ascent + gps.bottom ) : descent;
}
}
width += this.g_mContext.left + this.g_mContext.right;
height = ascent + descent + this.g_mContext.top + this.g_mContext.bottom;
center = ascent + this.g_mContext.top;
ascent = ascent > oSize.ascent ? ascent : oSize.ascent;
var oDescent = oSize.height - oSize.ascent;
descent = descent < oDescent ? oDescent : descent;
}
this.size = {width: width, height: height, center: center};
this.size = {width: width, height: ascent + descent, ascent: ascent};
this.update_widthContent(); /// !!!!
},
Resize: function(oMeasure) // пересчитываем всю формулу
{
var bItalic = true;
......@@ -4686,8 +4664,6 @@ CMathContent.prototype =
txtPrp.Italic = false;
oMeasure.SetFont(txtPrp);
//g_oTextMeasurer.SetFont(txtPrp);
}
else if(type == MATH_PLACEHOLDER)
{
......@@ -4701,7 +4677,7 @@ CMathContent.prototype =
txtPrp.Italic = false;
oMeasure.SetFont(txtPrp);
//g_oTextMeasurer.SetFont(txtPrp);
this.content[i].value.Resize(oMeasure);
}
}
......@@ -4709,7 +4685,7 @@ CMathContent.prototype =
this.recalculateSize();
},
draw: function(pGraphics)
old_draw: function(pGraphics)
{
var bHidePlh = this.plhHide && this.IsPlaceholder();
......@@ -4748,13 +4724,51 @@ CMathContent.prototype =
}
}
},
draw: function(x, y, pGraphics)
{
var bHidePlh = this.plhHide && this.IsPlaceholder();
if( !bHidePlh )
{
for(var i=1; i < this.content.length;i++)
{
if(this.content[i].value.typeObj == MATH_RUN_PRP)
{
pGraphics.b_color1(0,0,0,255);
var rPrp = new CMathTextPrp();
rPrp.Merge(DEFAULT_RUN_PRP);
rPrp.Merge( this.content[i].value.getWRunPrp() );
rPrp.Italic = false;
pGraphics.SetFont(rPrp);
}
else if(this.content[i].value.typeObj == MATH_PLACEHOLDER)
{
pGraphics.b_color1(0,0,0,255);
var ctrPrp = this.Parent.getCtrPrp();
var rPrp = new CMathTextPrp();
rPrp.Merge(DEFAULT_RUN_PRP);
rPrp.Merge(ctrPrp);
rPrp.Italic = false;
pGraphics.SetFont(rPrp);
this.content[i].value.draw(x, y, pGraphics);
}
else
this.content[i].value.draw(x, y, pGraphics);
}
}
},
update_widthContent: function()
{
for(var i = 1; i <this.content.length; i++)
{
this.content[i].widthToEl = this.content[i-1].widthToEl + this.content[i].value.size.width + this.content[i].g_mContext.left + this.content[i].g_mContext.right;
}
},
update_Cursor: function()
{
......@@ -4764,8 +4778,10 @@ CMathContent.prototype =
rPrp.Merge(DEFAULT_RUN_PRP);
rPrp.Merge(this.getCurrRunPrp());
var absPos = this.Composition.absPos;
var sizeCursor = rPrp.FontSize*g_dKoef_pt_to_mm;
var position = {x: this.pos.x + this.content[this.CurPos].widthToEl, y: this.pos.y + this.size.center - sizeCursor*0.8 };
var position = {x: this.pos.x + absPos.x + this.content[this.CurPos].widthToEl, y: this.pos.y + absPos.y + this.size.ascent - sizeCursor*0.8 };
editor.WordControl.m_oLogicDocument.DrawingDocument.SetTargetSize( sizeCursor );
editor.WordControl.m_oDrawingDocument.UpdateTargetFromPaint = true;
......@@ -4773,7 +4789,7 @@ CMathContent.prototype =
editor.WordControl.m_oDrawingDocument.UpdateTargetFromPaint = false;
},
coordWOGaps: function( msCoord )
old_coordWOGaps: function( msCoord )
{
var x = msCoord.x;
var y = msCoord.y;
......@@ -4814,7 +4830,6 @@ CMathContent.prototype =
pos--;
else if(mouseX >= widthToEl - gps.right)
pos++;
}
else
{
......@@ -4841,7 +4856,7 @@ CMathContent.prototype =
return pos;
},
getCoordElem: function(index, mCoord) // without gaps of Math Component ( например, если справа/слева есть относительно мат элемента компонент, то добавляем gaps справа/слева для этого мат элемента )
old_getCoordElem: function(index, mCoord) // without gaps of Math Component ( например, если справа/слева есть относительно мат элемента компонент, то добавляем gaps справа/слева для этого мат элемента )
{
var widthToPrev = this.content[index-1].widthToEl;
var widthToCur = this.content[index].widthToEl;
......@@ -4865,6 +4880,34 @@ CMathContent.prototype =
return {x: X, y: Y};
},
getCoordElem: function(index, mCoord) // without gaps of Math Component ( например, если справа/слева есть относительно мат элемента компонент, то добавляем gaps справа/слева для этого мат элемента )
{
var widthToPrev = this.content[index-1].widthToEl;
var widthToCur = this.content[index].widthToEl;
var X;
var Y;
var gps = this.content[index].g_mContext;
if( widthToPrev <= mCoord.x && mCoord.x <= (widthToPrev + gps.left) )
X = 0;
else if( (widthToCur - gps.right) <= mCoord.x && mCoord.x <= widthToCur )
X = this.content[index].value.size.width;
else
X = mCoord.x - widthToPrev - gps.left;
var Height = this.content[index].value.size.height,
Ascent = this.content[index].value.size.ascent,
Descent = this.content[index].value.size.height - this.content[index].value.size.ascent;
if( mCoord.y <= (this.size.ascent - Ascent) )
Y = 0;
else if( mCoord.y >= this.size.ascent + Descent)
Y = Height;
else
Y = mCoord.y - (this.size.ascent - Ascent);
return {x: X, y: Y};
},
remove: function(order)
{
var state =
......@@ -5415,7 +5458,7 @@ CMathContent.prototype =
{
return false;
},
setPosition: function( pos )
old_setPosition: function(pos)
{
this.pos = { x: pos.x + this.g_mContext.left, y: pos.y};
var max_cent = this.size.center;
......@@ -5439,16 +5482,16 @@ CMathContent.prototype =
this.content[i].value.setPosition(t);
}
},
new_setPosition: function( _pos )
setPosition: function(pos)
{
this.pos = { x: _pos.x + this.g_mContext.left, y: _pos.y};
this.pos = {x: pos.x, y: pos.y};
for(var i=1; i<this.content.length;i++)
for(var i=1; i < this.content.length;i++)
{
var t =
{
x: this.pos.x + this.content[i-1].widthToEl + this.content[i].g_mContext.left,
y: this.pos.y + this.size.center
y: this.pos.y + this.size.ascent //baseline
};
this.content[i].value.setPosition(t);
......@@ -5479,8 +5522,11 @@ CMathContent.prototype =
for(var j= start; j < end ; j++)
widthSelect += this.content[j].widthToEl - this.content[j-1].widthToEl;
var X = this.pos.x + this.Composition.absPos.x + this.content[start-1].widthToEl,
Y = this.pos.y + this.Composition.absPos.y;
if( widthSelect != 0)
editor.WordControl.m_oLogicDocument.DrawingDocument.AddPageSelection(0,this.pos.x + this.content[start-1].widthToEl, this.pos.y, widthSelect, heightSelect );
editor.WordControl.m_oLogicDocument.DrawingDocument.AddPageSelection(0, X, Y, widthSelect, heightSelect );
},
///// properties /////
SetDot: function(flag)
......@@ -6028,8 +6074,8 @@ CMathContent.prototype =
}
else
{
var msCoord = this.coordWOGaps({x: x, y: y});
var pos = this.findPosition( msCoord);
var msCoord = {x: x, y: y};
var pos = this.findPosition(msCoord);
this.LogicalSelect.start = pos;
this.LogicalSelect.end = pos;
......@@ -6054,7 +6100,7 @@ CMathContent.prototype =
}
else
{
var msCoord = this.coordWOGaps({x: x, y: y});
var msCoord = {x: x, y: y};
var posEnd = this.findPosition(msCoord),
posStart = this.LogicalSelect.start;
......@@ -6257,18 +6303,16 @@ CMathContent.prototype =
}
else
{
var msCoord = this.coordWOGaps(mouseCoord);
if(inside_flag == 0)
this.CurPos = 0;
else if(inside_flag == 1)
this.CurPos = this.content.length - 1;
else
this.CurPos = this.findPosition( msCoord );
this.CurPos = this.findPosition(mouseCoord);
if( this.content[this.CurPos].value.typeObj === MATH_COMP )
{
var coord = this.getCoordElem(this.CurPos, msCoord);
var coord = this.getCoordElem(this.CurPos, mouseCoord);
result = this.content[this.CurPos].value.mouseDown(coord);
}
else
......@@ -6291,15 +6335,14 @@ CMathContent.prototype =
}
else
{
var msCoord = this.coordWOGaps(mouseCoord);
var pos = this.findPosition( msCoord );
var pos = this.findPosition( mouseCoord );
//селект внутри элемента (дроби и пр.)
if(this.CurPos === pos && this.content[pos].value.typeObj === MATH_COMP)
{
//this.setStart_Selection( pos - 1 );
this.setStartPos_Selection(pos - 1);
var coord = this.getCoordElem(this.CurPos, msCoord );
var coord = this.getCoordElem(this.CurPos, mouseCoord );
var movement = this.content[pos].value.mouseMove(coord);
if( ! movement.state )
......@@ -6385,7 +6428,7 @@ CMathContent.prototype =
function CMathComposition()
{
this.TEST_SELECT_ACTIVE = false;
this.pos = null;
this.absPos = null;
this.Root = null;
this.CurrentContent = null;
......@@ -6689,7 +6732,7 @@ CMathComposition.prototype =
//this.SetReferenceComposition();
this.Root.Resize(oMeasure);
this.Root.setPosition(this.pos);
this.Root.setPosition(this.absPos);
this.UpdateCursor();
},
AddLetter_2: function(code)
......@@ -6815,22 +6858,22 @@ CMathComposition.prototype =
// "b_color1" for fill
//context.b_color1(224, 238, 230, 255);
pGraphics.drawHorLine(0, this.pos.y, this.pos.x, this.pos.x + w_Box, 0.2);
pGraphics.drawHorLine(0, this.pos.y + h_Box, this.pos.x, this.pos.x + w_Box, 0.2);
pGraphics.drawVerLine(0,this.pos.x, this.pos.y, this.pos.y + h_Box, 0.2 );
pGraphics.drawVerLine(0,this.pos.x + w_Box, this.pos.y, this.pos.y + h_Box, 0.2 );
pGraphics.drawHorLine(0, this.absPos.y, this.absPos.x, this.absPos.x + w_Box, 0.2);
pGraphics.drawHorLine(0, this.absPos.y + h_Box, this.absPos.x, this.absPos.x + w_Box, 0.2);
pGraphics.drawVerLine(0,this.absPos.x, this.absPos.y, this.absPos.y + h_Box, 0.2 );
pGraphics.drawVerLine(0,this.absPos.x + w_Box, this.absPos.y, this.absPos.y + h_Box, 0.2 );
}
this.Root.draw(pGraphics);
},
UpdatePosition: function()
{
this.Root.setPosition(this.pos);
this.Root.setPosition(this.absPos);
},
SetPosition: function(pos)
{
this.pos = pos;
this.Root.setPosition(this.pos);
this.absPos = pos;
this.Root.setPosition(this.absPos);
},
IsRect: function(x, y)
{
......@@ -6839,14 +6882,15 @@ CMathComposition.prototype =
},
GetCoordComp: function(x, y)
{
var _x = x - this.pos.x;
var _y = y - this.pos.y;
var _x = x - this.absPos.x;
var _y = y - this.absPos.y;
return {x: _x, y: _y};
},
Resize: function(oMeasure)
{
this.Root.Resize(oMeasure);
this.Root.setPosition({x: 0, y: 0});
},
test_for_edit: function()
{
......@@ -6873,14 +6917,8 @@ CMathComposition.prototype =
Init: function()
{
// TODO
// переделать gaps
//var g_Unif = 6*g_dKoef_pix_to_mm;
var g_Unif = 0;
var gps = new dist(g_Unif, g_Unif, g_Unif, g_Unif);
this.Root = new CMathContent();
this.Root.g_mContext = gps;
//this.Root.g_mContext = gps;
this.Root.setComposition(this);
//this.SetTestRunPrp();
//this.Root.setTxtPrp(this.TxtPrp);
......@@ -6905,12 +6943,10 @@ CMathComposition.prototype =
// position вычислить естественно до того, как придет Draw, чтобы не пришлось пересчитывать при изменении в тексте документа
Draw: function(x, y, pGraphics)
{
this.absPos = {x: x, y: y - this.Root.size.ascent};
if(this.Root.content.length > 1)
{
this.pos = {x: x, y: y - this.Root.size.center};
this.Root.setPosition({x: x, y: y - this.Root.size.center});
this.Root.draw(pGraphics);
}
this.Root.draw(this.absPos.x, this.absPos.y , pGraphics);
},
GetFirstPrp: function()
{
......@@ -6997,15 +7033,15 @@ CMathComposition.prototype =
/*return this.Root.size;*/
//
var sh = 0.2487852283770651*g_oTextMeasurer.GetHeight();
//var sh = 0.2487852283770651*g_oTextMeasurer.GetHeight();
//
var size =
{
Width: this.Root.size.width,
WidthVisible: this.Root.size.width,
Height: this.Root.size.height,
Ascent: this.Root.size.center + sh,
Descent: this.Root.size.height - this.Root.size.center
Ascent: this.Root.size.ascent,
Descent: this.Root.size.height - this.Root.size.ascent
};
return size;
......@@ -7093,7 +7129,7 @@ CMathComposition.prototype =
},
RecalculateComposition: function(oMeasure, TextPr) // textPrp в тестовом режиме, просто отрисуем с ними формулу
{
this.Root.Resize(oMeasure); // пересчитываем всю формулу
this.Resize(oMeasure); // пересчитываем всю формулу
var width = this.Root.size.width,
height = this.Root.size.height;
......@@ -7102,15 +7138,15 @@ CMathComposition.prototype =
},
Selection_SetStart: function(X, Y, PageNum)
{
var x = X - this.pos.x,
y = Y - this.pos.y;
var x = X - this.absPos.x,
y = Y - this.absPos.y;
this.Root.selection_Start(x, y);
},
Selection_SetEnd: function(X, Y, PageNum, MouseEvent)
{
var x = X - this.pos.x,
y = Y - this.pos.y;
var x = X - this.absPos.x,
y = Y - this.absPos.y;
var result = this.Root.selection_End(x, y, MouseEvent);
this.SelectContent = result.SelectContent;
......
......@@ -8,7 +8,8 @@
//api 2212: asc_docs_api.prototype.sync_TextPrFontFamilyCallBack
// возвращает название шрифта
var DIV_CENT = 0.2487852283770651;
//var DIV_CENT = 0.2487852283770651;
var DIV_CENT = 0.1;
function CMathTextPrp()
{
......@@ -153,7 +154,7 @@ CMathText.prototype =
// descent = Symbol.Descent ( = 0)
// gap = FontHeight - FontDescent - Placeholder.Height + FontDescent
old_recalculateSize: function()
old_old_recalculateSize: function()
{
/*var txtPrp = new CMathTextPrp();
txtPrp.Merge(this.getTxtPrp());
......@@ -184,7 +185,7 @@ CMathText.prototype =
this.size = {width: _width, widthG: widthG, height: _height, center: _center, ascent: _ascent, descent: _descent};
},
Resize: function(oMeasure)
old_Resize: function(oMeasure)
{
var letter = this.getCode();
......@@ -203,6 +204,21 @@ CMathText.prototype =
this.size = {width: _width, widthG: widthG, height: _height, center: _center, ascent: _ascent, descent: _descent};
},
Resize: function(oMeasure)
{
var letter = this.getCode();
var metricsTxt = oMeasure.Measure2Code(letter);
var width = metricsTxt.Width;
var ascent = metricsTxt.Ascent;
var descent = (metricsTxt.Height - metricsTxt.Ascent);
var height = ascent + descent;
var widthG = metricsTxt.WidthG;
this.size = {width: width, widthG: widthG, height: height, ascent: ascent};
},
old_draw: function()
{
var txtPrp = this.getTxtPrp();
......@@ -251,7 +267,7 @@ CMathText.prototype =
MathControl.pGraph.FillTextCode(xx, yy , this.getCode());
},
draw: function(pGraphics)
draw: function(x, y, pGraphics)
{
/*var txtPrp = new CMathTextPrp();
txtPrp.Merge(this.getTxtPrp());
......@@ -260,8 +276,8 @@ CMathText.prototype =
//pGraphics.b_color1(0,0,0,255);
//pGraphics.SetFont(txtPrp);
var X = this.pos.x ,
Y = this.pos.y;
var X = this.pos.x + x,
Y = this.pos.y + y;
var invert = new CMatrix();
invert.sx = this.transform.sx;
......@@ -297,7 +313,7 @@ CMathText.prototype =
pGraphics.transform(sx, shy, shx, sy, 0, 0);
pGraphics.FillTextCode(xx, yy , this.getCode());
pGraphics.FillTextCode(xx, yy , this.getCode()); //на отрисовку символа отправляем положение baseLine
//pGraphics.FillTextCode(xx, yy , this.value);
},
......@@ -306,7 +322,7 @@ CMathText.prototype =
if( ! this.bJDraw) // for text
this.pos = {x : pos.x, y: pos.y };
else // for symbol only drawing
this.pos = {x: pos.x , y: pos.y + this.size.center};
this.pos = {x: pos.x , y: pos.y + this.size.ascent};
},
new_setPosition: function(pos)
{
......
......@@ -216,7 +216,7 @@ CNary.prototype.getLowerIterator = function()
}
CNary.prototype.getPropsForWrite = function()
{
var limloc = null;
var limLoc = null;
if (this.limLoc == NARY_SubSup)
limLoc = 0;
else if (this.limLoc == NARY_UndOvr)
......@@ -253,7 +253,7 @@ CNaryUnd.prototype.setDistance = function()
}
CNaryUnd.prototype.getCenter = function()
{
return this.elements[0][0].size.height + this.dH + this.elements[1][0].size.center ;
return this.elements[0][0].size.height + this.dH + this.elements[1][0].size.ascent;
}
CNaryUnd.prototype.getUpperIterator = function()
{
......@@ -282,7 +282,7 @@ CNaryOvr.prototype.setDistance = function()
}
CNaryOvr.prototype.getCenter = function()
{
return this.elements[0][0].size.center;
return this.elements[0][0].size.ascent;
}
CNaryOvr.prototype.getLowerIterator= function()
{
......@@ -314,7 +314,7 @@ CNaryUndOvr.prototype.recalculateSize = function()
this.gapTop = zetta*0.25;
this.gapBottom = zetta*0.1;
var center = this.elements[0][0].size.height + this.gapTop + this.elements[1][0].size.center;
var ascent = this.elements[0][0].size.height + this.gapTop + this.elements[1][0].size.ascent;
var width = 0, height = 0;
for(var i = 0; i < 3; i++)
......@@ -325,11 +325,11 @@ CNaryUndOvr.prototype.recalculateSize = function()
height += this.gapTop + this.gapBottom;
this.size = {width: width, height: height, center: center};
this.size = {width: width, height: height, ascent: ascent};
}
CNaryUndOvr.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y : pos.y - this.size.center};
this.pos = {x: pos.x, y : pos.y - this.size.ascent};
var x1 = pos.x + this.align(0, 0).x,
y1 = pos.y,
x2 = pos.x + this.align(1,0).x,
......@@ -406,14 +406,14 @@ function CNaryOperator(flip)
this.bFlip = (flip == -1);
this.sizeGlyph = null;
}
CNaryOperator.prototype.draw = function(pGraphics)
CNaryOperator.prototype.draw = function(x, y, pGraphics)
{
if(this.typeObj == MATH_TEXT)
this.drawTextElem(pGraphics);
this.drawTextElem(x, y, pGraphics);
else
this.drawGlyph(pGraphics);
this.drawGlyph(x, y, pGraphics);
}
CNaryOperator.prototype.drawGlyph = function(pGraphics)
CNaryOperator.prototype.drawGlyph = function(x, y,pGraphics)
{
var coord = this.getCoord();
......@@ -442,8 +442,8 @@ CNaryOperator.prototype.drawGlyph = function(pGraphics)
for(var i = 0 ; i < X.length; i++)
{
XX[i] = this.pos.x + X[i]*alpha;
YY[i] = this.pos.y + (a*Y[i]*alpha + b);
XX[i] = this.pos.x + x + X[i]*alpha;
YY[i] = this.pos.y + y + (a*Y[i]*alpha + b);
}
var intGrid = pGraphics.GetIntegerGrid();
......@@ -460,7 +460,7 @@ CNaryOperator.prototype.drawGlyph = function(pGraphics)
pGraphics.df();
pGraphics.SetIntegerGrid(intGrid);
}
CNaryOperator.prototype.drawTextElem = function(pGraphics)
CNaryOperator.prototype.drawTextElem = function(x, y, pGraphics)
{
pGraphics.b_color1(0,0,0,255);
var rPrp = new CTextPr();
......@@ -470,7 +470,7 @@ CNaryOperator.prototype.drawTextElem = function(pGraphics)
pGraphics.SetFont(rPrp);
CNaryOperator.superclass.call.draw(this, pGraphics);
CNaryOperator.superclass.call.draw(this, x, y, pGraphics);
}
CNaryOperator.prototype.IsJustDraw = function()
{
......@@ -490,9 +490,9 @@ CNaryOperator.prototype.recalculateSize = function()
var height = this.sizeGlyph.height,
width = this.sizeGlyph.width,
center = this.sizeGlyph.height/2;
ascent = this.sizeGlyph.height/2 + DIV_CENT*this.getCtrPrp().FontSize;
this.size = {height: height, width: width, center: center};
this.size = {height: height, width: width, ascent: ascent};
}
CNaryOperator.prototype.Resize = function()
{
......
......@@ -2797,7 +2797,7 @@ COperator.prototype.getProps = function(props, defaultProps)
return {loc: location, type: type, code: code};
}
COperator.prototype.draw = function(pGraphics)
COperator.prototype.draw = function(x, y, pGraphics)
{
if(this.typeOper === OPERATOR_TEXT)
{
......@@ -2813,18 +2813,17 @@ COperator.prototype.draw = function(pGraphics)
////////////////////////////////////////////////
this.operator.draw(pGraphics);
this.operator.draw(x, y, pGraphics);
}
else
{
if(this.type === OPER_SEPARATOR)
this.drawSeparator(pGraphics);
this.drawSeparator(x, y,pGraphics);
else
this.drawOperator(pGraphics);
this.drawOperator(x, y, pGraphics);
}
}
COperator.prototype.drawOperator = function(pGraphics)
COperator.prototype.drawOperator = function( absX, absY, pGraphics)
{
if(this.operator !== -1)
{
......@@ -2834,14 +2833,14 @@ COperator.prototype.drawOperator = function(pGraphics)
Y = new Array();
for(var j = 0; j < lng; j++)
{
X.push(this.pos.x + this.coordGlyph.XX[j]);
Y.push(this.pos.y + this.coordGlyph.YY[j]);
X.push(this.pos.x + absX + this.coordGlyph.XX[j]);
Y.push(this.pos.y + absY + this.coordGlyph.YY[j]);
}
this.operator.draw(pGraphics, X, Y);
}
}
COperator.prototype.drawSeparator = function(pGraphics)
COperator.prototype.drawSeparator = function(absX, absY, pGraphics)
{
if(this.operator !== -1)
{
......@@ -2853,8 +2852,8 @@ COperator.prototype.drawSeparator = function(pGraphics)
Y = new Array();
for(var j = 0; j < lng; j++)
{
X.push(this.pos[i].x + this.coordGlyph.XX[j]);
Y.push(this.pos[i].y + this.coordGlyph.YY[j]);
X.push(this.pos[i].x + absX + this.coordGlyph.XX[j]);
Y.push(this.pos[i].y + absY + this.coordGlyph.YY[j]);
}
this.operator.draw(pGraphics, X, Y);
......@@ -2865,7 +2864,7 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
{
if(this.operator !== -1)
{
var width, height;
var width, height, ascent;
if(this.typeOper == OPERATOR_TEXT)
{
......@@ -2884,13 +2883,13 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
{
height = this.operator.size.height;
width = stretch > this.operator.size.width ? stretch : this.operator.size.width;
center = height/2;
ascent = height/2;
}
else
{
width = this.operator.size.width;
height = stretch > this.operator.size.height ? stretch : this.operator.size.height;
center = this.operator.size.height/2;
ascent = this.operator.size.height/2;
}
}
else
......@@ -2914,10 +2913,10 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
}
var betta = this.getCtrPrp().FontSize;
var center = height/2 + 0.2*betta;
ascent = height/2 + 0.2*betta;
}
this.size = { width: width, height: height, center: center};
this.size = { width: width, height: height, ascent: ascent};
}
}
COperator.prototype.setPosition = function(pos)
......@@ -3230,7 +3229,7 @@ CDelimiter.prototype.old_recalculateSize = function()
CDelimiter.prototype.Resize = function(oMeasure)
{
var height = 0,
width = 0, center = 0;
width = 0;
var ascent = 0,
descent = 0;
......@@ -3256,8 +3255,8 @@ CDelimiter.prototype.Resize = function(oMeasure)
{
var content = this.elements[0][j].size;
width += content.width;
ascent = content.center > ascent ? content.center : ascent;
descent = content.height - content.center > descent ? content.height - content.center: descent;
ascent = content.ascent > ascent ? content.ascent : ascent;
descent = content.height - content.ascent > descent ? content.height - content.ascent: descent;
}
maxH = ascent > descent ? ascent : descent;
......@@ -3268,20 +3267,17 @@ CDelimiter.prototype.Resize = function(oMeasure)
if(maxH < plH)
{
height = ascent + descent;
center = ascent;
}
else
{
div = ascent - plH;
height = ascent + descent + div;
center = ascent;
}
}
else
{
height = 2*maxH;
center = height/2;
ascent = height/2;
}
}
else
......@@ -3290,12 +3286,11 @@ CDelimiter.prototype.Resize = function(oMeasure)
{
var content = this.elements[0][j].size;
width += content.width;
ascent = content.center > ascent ? content.center : ascent;
descent = content.height - content.center > descent ? content.height - content.center: descent;
ascent = content.ascent > ascent ? content.ascent : ascent;
descent = content.height - content.ascent > descent ? content.height - content.ascent: descent;
}
height = ascent + descent;
center = ascent;
}
this.begOper.fixSize(oMeasure, height);
......@@ -3303,7 +3298,7 @@ CDelimiter.prototype.Resize = function(oMeasure)
if(height < this.begOper.size.height)
{
center = this.begOper.size.height - H2;
ascent = this.begOper.size.height - H2;
height = this.begOper.size.height;
//center = this.begOper.size.center;
......@@ -3314,16 +3309,17 @@ CDelimiter.prototype.Resize = function(oMeasure)
if(height < this.endOper.size.height)
{
//center += (height - this.endOper.size.height)/2;
center = this.endOper.size.height - H2;
ascent = this.endOper.size.height - H2;
height = this.endOper.size.height;
//center = this.endOper.size.center;
}
this.sepOper.fixSize(oMeasure, height);
width += (this.nCol - 1)*this.sepOper.size.width;
if(height < this.endOper.size.height)
if(height < this.sepOper.size.height)
{
//center += (height - this.sepOper.size.height)/2;
ascent = this.sepOper.size.height - H2;
height = this.sepOper.size.height;
//center = this.sepOper.size.center;
}
......@@ -3368,7 +3364,7 @@ CDelimiter.prototype.Resize = function(oMeasure)
center = (center < this.sepOper.size.center) ? this.sepOper.size.center : center;
}*/
this.size = {width: width, height: height, center: center};
this.size = {width: width, height: height, ascent: ascent};
}
CDelimiter.prototype.alignOperator = function(height)
......@@ -3399,7 +3395,7 @@ CDelimiter.prototype.alignOperator = function(height)
}
CDelimiter.prototype.setPosition = function(position)
{
this.pos = {x: position.x, y: position.y - this.size.center};
this.pos = {x: position.x, y: position.y - this.size.ascent};
var x = this.pos.x,
y = this.pos.y;
......@@ -3494,20 +3490,20 @@ CDelimiter.prototype.findDisposition = function(pos)
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
CDelimiter.prototype.draw = function(pGraphics)
CDelimiter.prototype.draw = function(x, y, pGraphics)
{
this.begOper.draw(pGraphics);
this.sepOper.draw(pGraphics);
this.endOper.draw(pGraphics);
this.begOper.draw(x, y, pGraphics);
this.sepOper.draw(x, y, pGraphics);
this.endOper.draw(x, y, pGraphics);
for(var j = 0; j < this.nCol; j++)
this.elements[0][j].draw(pGraphics);
this.elements[0][j].draw(x, y,pGraphics);
}
CDelimiter.prototype.align = function(element)
{
var align = 0;
if(!element.IsJustDraw())
align = this.size.center - element.size.center;
align = this.size.ascent - element.size.ascent;
else
align = (this.size.height - element.size.height)/2;
......
......@@ -7,7 +7,7 @@ function CSignRadical()
this.sizeTick = null;
this.widthSlash = null;
}
CSignRadical.prototype.draw = function(pGraphics)
CSignRadical.prototype.draw = function(x, y, pGraphics)
{
var txtPrp = this.Parent.getCtrPrp();
//var txtPrp = this.Parent.getTxtPrp();
......@@ -15,10 +15,10 @@ CSignRadical.prototype.draw = function(pGraphics)
var plH = 9.877777777777776 * txtPrp.FontSize /36;
var x1 = this.pos.x,
var x1 = this.pos.x + x,
x2 = x1 + 0.25*this.widthSlash;
var y2 = this.pos.y + this.size.height -this.sizeTick.height,
var y2 = this.pos.y + y + this.size.height -this.sizeTick.height,
y1 = y2 + 0.11*this.widthSlash;
......@@ -28,6 +28,8 @@ CSignRadical.prototype.draw = function(pGraphics)
var x3 = x2 - tX,
y3 = y2 - tY;
var x4;
/*var minHeight = plH * 1.1304931640625,
maxHeight = plH * 7.029296875;
......@@ -44,13 +46,13 @@ CSignRadical.prototype.draw = function(pGraphics)
else
x4 = x1 + this.widthSlash;
var y4 = this.pos.y + this.size.height - penW;
var y4 = this.pos.y + y + this.size.height - penW;
var x5 = x1 + this.widthSlash,
x6 = this.pos.x + this.size.width;
x6 = this.pos.x + x + this.size.width;
var y5 = this.pos.y,
y6 = this.pos.y;
var y5 = this.pos.y + y,
y6 = this.pos.y + y;
pGraphics.p_width(penW*0.8*1000);
......@@ -223,9 +225,10 @@ CRadical.prototype.recalculateSize = function()
var height = sign.height,
width = sign.width,
center = (height - arg.height)*0.6 + arg.center;
ascent = height - (arg.height - arg.ascent);
//center = (height - arg.height)*0.6 + arg.center;
this.size = {width: width, height: height, center: center};
this.size = {width: width, height: height, ascent: ascent};
}
else if(this.type == DEGREE_RADICAL)
{
......@@ -249,29 +252,33 @@ CRadical.prototype.recalculateSize = function()
var h1 = degr.height + this.gap + hTick,
h2 = sign.height;
var height, center;
var height, ascent;
if(h1 > h2)
{
height = h1;
center = h1 - h2 + (sign.height - base.height)*0.6 + base.center;
ascent = height - (base.height - base.ascent);
//center = h1 - h2 + (sign.height - base.height)*0.6 + base.center;
}
else
{
height = h2;
center = (sign.height - base.height)*0.6 + base.center;
ascent = height - (base.height - base.ascent);
//center = (sign.height - base.height)*0.6 + base.center;
}
this.size = {width: width, height: height, center: center};
this.size = {width: width, height: height, ascent: ascent};
}
}
CRadical.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.ascent};
if(this.type == SQUARE_RADICAL)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
this.gapLeft = this.size.width - this.elements[0][0].size.width;
this.gapTop = this.size.center - this.elements[0][0].size.center;
this.gapTop = this.size.ascent - this.elements[0][0].size.ascent;
var x = this.pos.x + this.gapLeft,
y = this.pos.y + this.gapTop;
......@@ -281,8 +288,6 @@ CRadical.prototype.setPosition = function(pos)
}
else if(this.type == DEGREE_RADICAL)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
var degr = this.elements[0][0].size,
base = this.elements[0][1].size,
sign = this.signRadical.size;
......@@ -301,7 +306,7 @@ CRadical.prototype.setPosition = function(pos)
this.signRadical.setPosition({x: x2, y: y2});
var x3 = this.pos.x + this.size.width - base.width,
y3 = this.pos.y + this.size.center - base.center;
y3 = this.pos.y + this.size.ascent - base.ascent;
this.elements[0][1].setPosition({x: x3, y: y3});
}
......@@ -390,7 +395,7 @@ CRadical.prototype.findDisposition = function(mCoord)
posCurs.y = 1;
mouseCoord.x = mCoord.x - (this.size.width - base.width);
var topBase = this.size.center - base.center;
var topBase = this.size.ascent - base.ascent;
if(mCoord.y < topBase)
{
......@@ -411,10 +416,10 @@ CRadical.prototype.findDisposition = function(mCoord)
return disposition;
}
CRadical.prototype.draw = function(pGraphics)
CRadical.prototype.draw = function(x, y, pGraphics)
{
this.signRadical.draw(pGraphics);
CRadical.superclass.draw.call(this, pGraphics);
this.signRadical.draw(x, y, pGraphics);
CRadical.superclass.draw.call(this, x, y, pGraphics);
}
CRadical.prototype.getBase = function()
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment