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