Commit 8feefdd6 authored by Anna.Pavlova's avatar Anna.Pavlova Committed by Alexander.Trofimov

Свойства по формату : accent, delimiters, borderBox, bar, box, fraction,...

Свойства по формату : accent, delimiters, borderBox, bar, box, fraction, limit, nary, GroupCharacter

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56373 954022d7-b5bf-4e40-9824-e11837661b57
parent d89942bb
...@@ -786,13 +786,13 @@ ParaMath.prototype = ...@@ -786,13 +786,13 @@ ParaMath.prototype =
if(argSize == -1) if(argSize == -1)
{ {
//FSize = 0.0009*FSize*FSize + 0.68*FSize + 0.26; //FSize = 0.0009*FSize*FSize + 0.68*FSize + 0.26;
FSize = 0.77*FSize; FSize = 0.76*FSize;
} }
else if(argSize == -2) else if(argSize == -2)
{ {
//FSize = -0.0004*FSize*FSize + 0.66*FSize + 0.87; //FSize = -0.0004*FSize*FSize + 0.66*FSize + 0.87;
FSize = 0.77*0.77*FSize; FSize = 0.76*0.855*FSize;
} }
tPrp.FontSize = FSize; tPrp.FontSize = FSize;
......
...@@ -1640,8 +1640,8 @@ CAccent.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -1640,8 +1640,8 @@ CAccent.prototype.Resize = function(Parent, ParaMath, oMeasure)
this.operator.setProperties(prp, defaultPrp); this.operator.setProperties(prp, defaultPrp);
this.chr = String.fromCharCode(this.operator.code); this.Pr.chr = String.fromCharCode(this.operator.code);
this.chrType = this.operator.typeOper; this.Pr.chrType = this.operator.typeOper;
} }
this.operator.relate(this); this.operator.relate(this);
......
...@@ -976,7 +976,7 @@ CMathBase.prototype = ...@@ -976,7 +976,7 @@ CMathBase.prototype =
width += this.dW*(this.nCol - 1); width += this.dW*(this.nCol - 1);
width += this.GapLeft + this.GapRight; width += this.GapLeft + this.GapRight;
var ascent = this.getAscent(height, oMeasure); var ascent = this.getAscent(oMeasure, height);
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
}, },
...@@ -994,7 +994,7 @@ CMathBase.prototype = ...@@ -994,7 +994,7 @@ CMathBase.prototype =
{ {
this.Set_CompiledCtrPrp(); this.Set_CompiledCtrPrp();
this.RecalcInfo.bCtrPrp = false; this.RecalcInfo.bCtrPrp = false;
this.RecalcInfo.bProps = false; //this.RecalcInfo.bProps = false;
} }
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
...@@ -1017,12 +1017,12 @@ CMathBase.prototype = ...@@ -1017,12 +1017,12 @@ CMathBase.prototype =
return res; return res;
}, },
getAscent: function(_height, oMeasure) getAscent: function(oMeasure, _height)
{ {
var Ascent = 0; var Ascent = 0;
if(this.nRow > 1) if(this.nRow > 1)
{ {
Ascent = _height || this.size.height; Ascent = _height;
Ascent /=2; Ascent /=2;
var MergedCtrPrp = this.Get_CompiledCtrPrp(); var MergedCtrPrp = this.Get_CompiledCtrPrp();
Ascent += this.ParaMath.GetShiftCenter(oMeasure, MergedCtrPrp); Ascent += this.ParaMath.GetShiftCenter(oMeasure, MergedCtrPrp);
......
...@@ -22,10 +22,10 @@ function CBorderBox(props) ...@@ -22,10 +22,10 @@ function CBorderBox(props)
hideRight: false, hideRight: false,
hideTop: false, hideTop: false,
hideBot: false, hideBot: false,
strikeBLTR: true, strikeBLTR: false,
strikeTLBR: true, strikeTLBR: false,
strikeH: true, strikeH: false,
strikeV: true strikeV: false
}; };
CMathBase.call(this); CMathBase.call(this);
...@@ -62,35 +62,36 @@ CBorderBox.prototype.init = function(props) ...@@ -62,35 +62,36 @@ CBorderBox.prototype.init = function(props)
}*/ }*/
this.setBorders(props); this.setBorders(props);
this.setDimension(1, 1); this.setDimension(1, 1);
this.setContent(); this.setContent();
} }
CBorderBox.prototype.setBorders = function(props) CBorderBox.prototype.setBorders = function(props)
{ {
if(typeof(props) !== "undefined" && props !== null) if(typeof(props) !== "undefined" && props !== null)
{ {
if(typeof(this.Pr.hideLeft) !== "undefined" && this.Pr.hideLeft !== null) if(typeof(props.hideLeft) !== "undefined" && props.hideLeft !== null)
this.Pr.hideLeft = props.hideLeft; this.Pr.hideLeft = props.hideLeft;
if(typeof(this.Pr.hideRight) !== "undefined" && this.Pr.hideRight !== null) if(typeof(props.hideRight) !== "undefined" && props.hideRight !== null)
this.Pr.hideRight = props.hideRight; this.Pr.hideRight = props.hideRight;
if(typeof(this.Pr.hideTop) !== "undefined" && this.Pr.hideTop !== null) if(typeof(props.hideTop) !== "undefined" && props.hideTop !== null)
this.Pr.hideTop = props.hideTop; this.Pr.hideTop = props.hideTop;
if(typeof(this.Pr.hideBot) !== "undefined" && this.Pr.hideBot !== null) if(typeof(props.hideBot) !== "undefined" && props.hideBot !== null)
this.Pr.hideBot = props.hideBot; this.Pr.hideBot = props.hideBot;
if(typeof(this.Pr.strikeBLTR) !== "undefined" && this.Pr.strikeBLTR !== null) // right diagonal if(typeof(props.strikeBLTR) !== "undefined" && props.strikeBLTR !== null) // right diagonal
this.Pr.strikeBLTR = props.strikeBLTR; this.Pr.strikeBLTR = props.strikeBLTR;
if(typeof(this.Pr.strikeTLBR) !== "undefined" && this.Pr.strikeTLBR !== null) // left diagonal if(typeof(props.strikeTLBR) !== "undefined" && props.strikeTLBR !== null) // left diagonal
this.Pr.strikeTLBR = props.strikeTLBR; this.Pr.strikeTLBR = props.strikeTLBR;
if(typeof(this.Pr.strikeH) !== "undefined" && this.Pr.strikeH !== null) if(typeof(props.strikeH) !== "undefined" && props.strikeH !== null)
this.Pr.strikeH = props.strikeH; this.Pr.strikeH = props.strikeH;
if(typeof(this.Pr.strikeV) !== "undefined" && this.Pr.strikeV !== null) if(typeof(props.strikeV) !== "undefined" && props.strikeV !== null)
this.Pr.strikeV = props.strikeV; this.Pr.strikeV = props.strikeV;
} }
...@@ -129,7 +130,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics) ...@@ -129,7 +130,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
//var penW = this.Get_CompiledCtrPrp().FontSize* 25.4/72 * 0.06 ; //var penW = this.Get_CompiledCtrPrp().FontSize* 25.4/72 * 0.06 ;
var penW = this.Get_CompiledCtrPrp().FontSize*0.02; var penW = this.Get_CompiledCtrPrp().FontSize*0.02;
if(this.Pr.hideTop == false) if(!this.Pr.hideTop)
{ {
var x1 = this.pos.x + x, var x1 = this.pos.x + x,
x2 = this.pos.x + x + this.size.width - penW/2, x2 = this.pos.x + x + this.size.width - penW/2,
...@@ -145,7 +146,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics) ...@@ -145,7 +146,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
pGraphics.drawHorLine(0, y1 + penW, x1 + 2*25.4/96, x2 , 25.4/96);*/ pGraphics.drawHorLine(0, y1 + penW, x1 + 2*25.4/96, x2 , 25.4/96);*/
} }
if(this.Pr.hideBot == false) if(!this.Pr.hideBot)
{ {
var x1 = this.pos.x + x, var x1 = this.pos.x + x,
x2 = this.pos.x + x + this.size.width - penW/2, x2 = this.pos.x + x + this.size.width - penW/2,
...@@ -155,7 +156,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics) ...@@ -155,7 +156,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
pGraphics.drawHorLine(0, y1, x1, x2, penW); pGraphics.drawHorLine(0, y1, x1, x2, penW);
} }
if(this.Pr.hideLeft == false) if(!this.Pr.hideLeft)
{ {
var x1 = this.pos.x + x, var x1 = this.pos.x + x,
y1 = this.pos.y + y, y1 = this.pos.y + y,
...@@ -165,7 +166,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics) ...@@ -165,7 +166,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
pGraphics.drawVerLine(0, x1, y1, y2, penW); pGraphics.drawVerLine(0, x1, y1, y2, penW);
} }
if(this.Pr.hideRight == false) if(!this.Pr.hideRight)
{ {
var x1 = this.pos.x + x + this.size.width - penW/2, var x1 = this.pos.x + x + this.size.width - penW/2,
y1 = this.pos.y + y, y1 = this.pos.y + y,
...@@ -227,7 +228,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics) ...@@ -227,7 +228,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
} }
if(this.bHor) if(this.Pr.strikeH)
{ {
var x1 = this.pos.x + x, var x1 = this.pos.x + x,
x2 = this.pos.x + x + this.size.width - penW, x2 = this.pos.x + x + this.size.width - penW,
...@@ -237,7 +238,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics) ...@@ -237,7 +238,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
pGraphics.drawHorLine(0, y1, x1, x2, penW); pGraphics.drawHorLine(0, y1, x1, x2, penW);
} }
if(this.bVert) if(this.Pr.strikeV)
{ {
var x1 = this.pos.x + x + this.size.width/2 - penW/2, var x1 = this.pos.x + x + this.size.width/2 - penW/2,
y1 = this.pos.y + y, y1 = this.pos.y + y,
...@@ -247,6 +248,135 @@ CBorderBox.prototype.draw = function(x, y, pGraphics) ...@@ -247,6 +248,135 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
pGraphics.drawVerLine(0, x1, y1, y2, penW); pGraphics.drawVerLine(0, x1, y1, y2, penW);
} }
}
CBorderBox.prototype.old_draw = function(x, y, pGraphics)
{
this.elements[0][0].draw(x, y, pGraphics);
//var penW = this.getCtrPrp().FontSize* 25.4/96 * 0.08 ;
var penW = this.Get_CompiledCtrPrp().FontSize*0.02;
if(!this.Pr.hideTop)
{
var x1 = this.pos.x + x,
//x2 = this.pos.x + x + this.size.width - 25.4/96,
x2 = this.pos.x + x + this.size.width - penW,
y1 = this.pos.y + y;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawHorLine(0, y1, x1, x2, penW);
}
if(!this.Pr.hideBot)
{
var x1 = this.pos.x + x,
//x2 = this.pos.x + x + this.size.width - 25.4/96,
x2 = this.pos.x + x + this.size.width - penW,
y1 = this.pos.y + y + this.size.height - penW;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawHorLine(0, y1, x1, x2, penW);
}
if(!this.Pr.hideLeft)
{
var x1 = this.pos.x + x,
y1 = this.pos.y + y,
y2 = this.pos.y + y + this.size.height - penW;
//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);
}
if(!this.Pr.hideRight)
{
var x1 = this.pos.x + x + this.size.width - penW,
y1 = this.pos.y + y,
y2 = this.pos.y + y + this.size.height - penW;
//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);
}
if(this.Pr.strikeTLBR)
{
var pW = penW*0.8;
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 + this.size.width - penW, y3 = y1 + this.size.height - pW - penW,
x4 = x3, y4 = y3 + pW,
x5 = x4 - pW, y5 = y4,
x6 = x1, y6 = y1 + pW,
x7 = x1, y7 = y1;
pGraphics.p_width(1000);
pGraphics.b_color1(0,0,0, 255);
pGraphics._s();
pGraphics._m(x1, y1);
pGraphics._l(x2, y2);
pGraphics._l(x3, y3);
pGraphics._l(x4, y4);
pGraphics._l(x5, y5);
pGraphics._l(x6, y6);
pGraphics._l(x7, y7);
pGraphics.df();
}
if(this.Pr.strikeBLTR)
{
var pW = penW*0.8;
var x1 = this.pos.x + x + this.size.width - pW - penW, y1 = this.pos.y + y,
//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 + x + pW, y4 = this.pos.y + y + this.size.height - penW,
//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;
pGraphics.p_width(1000);
pGraphics.b_color1(0,0,0, 255);
pGraphics._s();
pGraphics._m(x1, y1);
pGraphics._l(x2, y2);
pGraphics._l(x3, y3);
pGraphics._l(x4, y4);
pGraphics._l(x5, y5);
pGraphics._l(x6, y6);
pGraphics._l(x7, y7);
pGraphics.df();
}
if(this.Pr.strikeH)
{
var x1 = this.pos.x + x,
x2 = this.pos.x + x + this.size.width - penW,
//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);
}
if(this.Pr.strikeV)
{
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 - penW;
//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);
}
} }
CBorderBox.prototype.setPosition = function(pos) CBorderBox.prototype.setPosition = function(pos)
{ {
...@@ -594,6 +724,20 @@ CBar.prototype.init = function(props) ...@@ -594,6 +724,20 @@ CBar.prototype.init = function(props)
else if(props.pos === LOCATION_BOT || props.location === LOCATION_BOT) else if(props.pos === LOCATION_BOT || props.location === LOCATION_BOT)
this.Pr.pos = LOCATION_BOT; this.Pr.pos = LOCATION_BOT;
var prp =
{
loc: this.Pr.pos,
type: DELIMITER_LINE
};
var defaultProps =
{
loc: LOCATION_BOT
};
this.setCharacter(prp, defaultProps);
if(props.ctrPrp !== null && typeof(props.ctrPrp) !== "undefined") if(props.ctrPrp !== null && typeof(props.ctrPrp) !== "undefined")
this.setCtrPrp(props.ctrPrp); this.setCtrPrp(props.ctrPrp);
} }
...@@ -602,14 +746,8 @@ CBar.prototype.setLocation = function(pos) ...@@ -602,14 +746,8 @@ CBar.prototype.setLocation = function(pos)
this.Pr.pos = pos; this.Pr.pos = pos;
this.RecalcInfo.bProps = true; this.RecalcInfo.bProps = true;
} }
CBar.prototype.Resize = function() CBar.prototype.Resize = function(Parent, ParaMath, oMeasure)
{ {
if(this.RecalcInfo.bCtrPrp == true)
{
this.Set_CompiledCtrPrp();
this.RecalcInfo.bCtrPrp = false;
}
if(this.RecalcInfo.bProps == true) if(this.RecalcInfo.bProps == true)
{ {
var prp = var prp =
...@@ -624,9 +762,10 @@ CBar.prototype.Resize = function() ...@@ -624,9 +762,10 @@ CBar.prototype.Resize = function()
}; };
this.setCharacter(prp, defaultProps); this.setCharacter(prp, defaultProps);
this.RecalcInfo.bProps = false;
} }
CBar.superclass.Resize.call(this); CBar.superclass.Resize.call(this, Parent, ParaMath, oMeasure);
} }
CBar.prototype.getAscent = function() CBar.prototype.getAscent = function()
{ {
......
...@@ -3,7 +3,12 @@ function CFraction(props) ...@@ -3,7 +3,12 @@ function CFraction(props)
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
this.kind = MATH_FRACTION; this.kind = MATH_FRACTION;
this.type = BAR_FRACTION; this.Pr =
{
type: BAR_FRACTION
};
//this.type = BAR_FRACTION;
this.bHideBar = false; this.bHideBar = false;
CMathBase.call(this); CMathBase.call(this);
...@@ -31,10 +36,10 @@ CFraction.prototype.setType = function(type) ...@@ -31,10 +36,10 @@ CFraction.prototype.setType = function(type)
bLin = type === LINEAR_FRACTION; bLin = type === LINEAR_FRACTION;
if(bBar || bSkew || bLin) // на всякий случай if(bBar || bSkew || bLin) // на всякий случай
this.type = props.type; this.Pr.type = type;
} }
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
{ {
var num = new CNumerator(); var num = new CNumerator();
...@@ -42,17 +47,17 @@ CFraction.prototype.setType = function(type) ...@@ -42,17 +47,17 @@ CFraction.prototype.setType = function(type)
this.setDimension(2, 1); this.setDimension(2, 1);
if(this.type == NO_BAR_FRACTION) if(this.Pr.type == NO_BAR_FRACTION)
this.bHideBar = true; this.bHideBar = true;
this.addMCToContent(num, den); this.addMCToContent(num, den);
} }
else if(this.type == SKEWED_FRACTION) else if(this.Pr.type == SKEWED_FRACTION)
{ {
this.setDimension(1, 2); this.setDimension(1, 2);
this.setContent(); this.setContent();
} }
else if(this.type == LINEAR_FRACTION) else if(this.Pr.type == LINEAR_FRACTION)
{ {
this.setDimension(1, 2); this.setDimension(1, 2);
this.setContent(); this.setContent();
...@@ -60,15 +65,15 @@ CFraction.prototype.setType = function(type) ...@@ -60,15 +65,15 @@ CFraction.prototype.setType = function(type)
} }
CFraction.prototype.getType = function() CFraction.prototype.getType = function()
{ {
return this.type; return this.Pr.type;
} }
CFraction.prototype.draw = function(x, y, pGraphics) CFraction.prototype.draw = function(x, y, pGraphics)
{ {
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
this.drawBarFraction(x, y, pGraphics); this.drawBarFraction(x, y, pGraphics);
else if(this.type == SKEWED_FRACTION) else if(this.Pr.type == SKEWED_FRACTION)
this.drawSkewedFraction(x, y, pGraphics); this.drawSkewedFraction(x, y, pGraphics);
else if(this.type == LINEAR_FRACTION) else if(this.Pr.type == LINEAR_FRACTION)
this.drawLinearFraction(x, y, pGraphics); this.drawLinearFraction(x, y, pGraphics);
} }
CFraction.prototype.drawBarFraction = function(x, y, pGraphics) CFraction.prototype.drawBarFraction = function(x, y, pGraphics)
...@@ -234,7 +239,7 @@ CFraction.prototype.getNumerator = function() ...@@ -234,7 +239,7 @@ CFraction.prototype.getNumerator = function()
{ {
var numerator; var numerator;
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
numerator = this.elements[0][0].getElement(); numerator = this.elements[0][0].getElement();
else else
numerator = this.elements[0][0]; numerator = this.elements[0][0];
...@@ -245,7 +250,7 @@ CFraction.prototype.getDenominator = function() ...@@ -245,7 +250,7 @@ CFraction.prototype.getDenominator = function()
{ {
var denominator; var denominator;
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
denominator = this.elements[1][0].getElement(); denominator = this.elements[1][0].getElement();
else else
denominator = this.elements[0][1]; denominator = this.elements[0][1];
...@@ -254,11 +259,11 @@ CFraction.prototype.getDenominator = function() ...@@ -254,11 +259,11 @@ CFraction.prototype.getDenominator = function()
} }
CFraction.prototype.recalculateSize = function(oMeasure) CFraction.prototype.recalculateSize = function(oMeasure)
{ {
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
this.recalculateBarFraction(oMeasure); this.recalculateBarFraction(oMeasure);
else if(this.type == SKEWED_FRACTION) else if(this.Pr.type == SKEWED_FRACTION)
this.recalculateSkewed(oMeasure); this.recalculateSkewed(oMeasure);
else if(this.type == LINEAR_FRACTION) else if(this.Pr.type == LINEAR_FRACTION)
this.recalculateLinear(oMeasure); this.recalculateLinear(oMeasure);
} }
CFraction.prototype.recalculateBarFraction = function(oMeasure) CFraction.prototype.recalculateBarFraction = function(oMeasure)
...@@ -330,7 +335,7 @@ CFraction.prototype.recalculateLinear = function() ...@@ -330,7 +335,7 @@ CFraction.prototype.recalculateLinear = function()
} }
CFraction.prototype.setPosition = function(pos) CFraction.prototype.setPosition = function(pos)
{ {
if(this.type == SKEWED_FRACTION) if(this.Pr.type == SKEWED_FRACTION)
{ {
this.pos = {x: pos.x, y: pos.y - this.size.ascent}; this.pos = {x: pos.x, y: pos.y - this.size.ascent};
...@@ -351,7 +356,7 @@ CFraction.prototype.findDisposition = function( mCoord ) ...@@ -351,7 +356,7 @@ CFraction.prototype.findDisposition = function( mCoord )
{ {
var disposition; var disposition;
if(this.type == SKEWED_FRACTION) if(this.Pr.type == SKEWED_FRACTION)
{ {
var mouseCoord = {x: mCoord.x, y: mCoord.y}, var mouseCoord = {x: mCoord.x, y: mCoord.y},
posCurs = {x: null, y: null}, posCurs = {x: null, y: null},
...@@ -416,11 +421,7 @@ CFraction.prototype.findDisposition = function( mCoord ) ...@@ -416,11 +421,7 @@ CFraction.prototype.findDisposition = function( mCoord )
} }
CFraction.prototype.getPropsForWrite = function() CFraction.prototype.getPropsForWrite = function()
{ {
var props = { return this.Pr;
type: this.type
};
return props;
} }
CFraction.prototype.Save_Changes = function(Data, Writer) CFraction.prototype.Save_Changes = function(Data, Writer)
......
function CLimit(props) function CLimit(props)
{ {
this.Id = g_oIdCounter.Get_NewId(); this.kind = MATH_LIMIT; this.Id = g_oIdCounter.Get_NewId();
this.kind = MATH_LIMIT;
this.Pr =
{
type: LIMIT_LOW
};
this.type = LIMIT_LOW;
CMathBase.call(this); CMathBase.call(this);
if(props.type === LIMIT_UP || props.type === LIMIT_LOW) if(props.type === LIMIT_UP || props.type === LIMIT_LOW)
this.type = props.type; this.Pr.type = props.type;
this.setDimension(2, 1); this.setDimension(2, 1);
...@@ -15,24 +21,22 @@ function CLimit(props) ...@@ -15,24 +21,22 @@ function CLimit(props)
var oIter = new CMathContent(); var oIter = new CMathContent();
oIter.decreaseArgSize(); oIter.decreaseArgSize();
if(this.type == LIMIT_LOW) if(this.Pr.type == LIMIT_LOW)
this.addMCToContent(oBase, oIter); this.addMCToContent(oBase, oIter);
else if(this.type == LIMIT_UP) else if(this.Pr.type == LIMIT_UP)
this.addMCToContent(oIter, oBase); this.addMCToContent(oIter, oBase);
this.setCtrPrp(props.ctrPrp); this.setCtrPrp(props.ctrPrp);
/// вызов этой функции обязательно в конце
//this.WriteContentsToHistory();
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
extend(CLimit, CMathBase); extend(CLimit, CMathBase);
CLimit.prototype.getAscent = function() CLimit.prototype.getAscent = function()
{ {
var ascent; var ascent;
if(this.type == LIMIT_LOW) if(this.Pr.type == LIMIT_LOW)
ascent = this.elements[0][0].size.ascent; ascent = this.elements[0][0].size.ascent;
else if(this.type == LIMIT_UP) else if(this.Pr.type == LIMIT_UP)
ascent = this.elements[0][0].size.height + this.dH + this.elements[1][0].size.ascent; ascent = this.elements[0][0].size.height + this.dH + this.elements[1][0].size.ascent;
return ascent; return ascent;
...@@ -40,9 +44,9 @@ CLimit.prototype.getAscent = function() ...@@ -40,9 +44,9 @@ CLimit.prototype.getAscent = function()
CLimit.prototype.getFName = function() CLimit.prototype.getFName = function()
{ {
var fName; var fName;
if(this.type == LIMIT_LOW) if(this.Pr.type == LIMIT_LOW)
fName = this.elements[0][0]; fName = this.elements[0][0];
else if(this.type == LIMIT_UP) else if(this.Pr.type == LIMIT_UP)
fName = this.elements[1][0]; fName = this.elements[1][0];
return fName; return fName;
...@@ -50,9 +54,9 @@ CLimit.prototype.getFName = function() ...@@ -50,9 +54,9 @@ CLimit.prototype.getFName = function()
CLimit.prototype.getIterator = function() CLimit.prototype.getIterator = function()
{ {
var iterator; var iterator;
if(this.type == LIMIT_LOW) if(this.Pr.type == LIMIT_LOW)
iterator = this.elements[1][0]; iterator = this.elements[1][0];
else if(this.type == LIMIT_UP) else if(this.Pr.type == LIMIT_UP)
iterator = this.elements[0][0]; iterator = this.elements[0][0];
return iterator; return iterator;
...@@ -63,12 +67,7 @@ CLimit.prototype.setDistance = function() ...@@ -63,12 +67,7 @@ CLimit.prototype.setDistance = function()
} }
CLimit.prototype.getPropsForWrite = function() CLimit.prototype.getPropsForWrite = function()
{ {
var props = return this.Pr;
{
type: this.type
};
return props;
} }
CLimit.prototype.Save_Changes = function(Data, Writer) CLimit.prototype.Save_Changes = function(Data, Writer)
{ {
...@@ -106,10 +105,14 @@ CLimit.prototype.Get_Id = function() ...@@ -106,10 +105,14 @@ CLimit.prototype.Get_Id = function()
{ {
return this.Id; return this.Id;
} }
function CMathFunc(props) function CMathFunc(props)
{ {
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
this.kind = MATH_FUNCTION; this.kind = MATH_FUNCTION;
this.Pr = {};
CMathBase.call(this); CMathBase.call(this);
this.setDimension(1, 2); this.setDimension(1, 2);
...@@ -117,8 +120,6 @@ function CMathFunc(props) ...@@ -117,8 +120,6 @@ function CMathFunc(props)
this.setCtrPrp(props.ctrPrp); this.setCtrPrp(props.ctrPrp);
/// вызов этой функции обязательно в конце
//this.WriteContentsToHistory();
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
extend(CMathFunc, CMathBase); extend(CMathFunc, CMathBase);
......
...@@ -5103,7 +5103,8 @@ CMathContent.prototype = ...@@ -5103,7 +5103,8 @@ CMathContent.prototype =
{ {
if(!this.bRoot) if(!this.bRoot)
{ {
var oWPrp = this.Parent.Get_CtrPrp(); //var oWPrp = this.Parent.Get_CtrPrp();
var oWPrp = this.Parent.Get_CompiledCtrPrp();
//this.applyArgSize(oWPrp); //this.applyArgSize(oWPrp);
this.ParaMath.ApplyArgSize(oWPrp, this.argSize); this.ParaMath.ApplyArgSize(oWPrp, this.argSize);
...@@ -5242,7 +5243,8 @@ CMathContent.prototype = ...@@ -5242,7 +5243,8 @@ CMathContent.prototype =
{ {
pGraphics.b_color1(0,0,0,255); pGraphics.b_color1(0,0,0,255);
var oWPrp = this.Parent.Get_CtrPrp(); //var oWPrp = this.Parent.Get_CtrPrp();
var oWPrp = this.Parent.Get_CompiledCtrPrp();
//this.applyArgSize(oWPrp); //this.applyArgSize(oWPrp);
this.ParaMath.ApplyArgSize(oWPrp, this.argSize); this.ParaMath.ApplyArgSize(oWPrp, this.argSize);
...@@ -6289,7 +6291,7 @@ CMathContent.prototype = ...@@ -6289,7 +6291,7 @@ CMathContent.prototype =
var TextPr; var TextPr;
if(this.IsPlaceholder()) if(this.IsPlaceholder())
TextPr = this.Parent.getCtrPrp(); TextPr = this.Parent.Get_CtrPrp();
else else
TextPr = this.content[pos].Get_TextPr(ContentPos, Depth + 1); TextPr = this.content[pos].Get_TextPr(ContentPos, Depth + 1);
...@@ -6301,7 +6303,7 @@ CMathContent.prototype = ...@@ -6301,7 +6303,7 @@ CMathContent.prototype =
if(this.IsPlaceholder()) if(this.IsPlaceholder())
{ {
TextPr = this.Parent.getCtrPrp(); TextPr = this.Parent.Get_CompiledCtrPrp();
} }
else if ( true === this.bSelectionUse || bAll == true) else if ( true === this.bSelectionUse || bAll == true)
{ {
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
var DIV_CENT = 0.1386; var DIV_CENT = 0.1386;
var StartTextElement = 0x2B1A; // Cambria Math var StartTextElement = 0x2B1A; // Cambria Math
// TODO // TODO
...@@ -279,6 +281,8 @@ CMathText.prototype = ...@@ -279,6 +281,8 @@ CMathText.prototype =
var X = this.pos.x + x, var X = this.pos.x + x,
Y = this.pos.y + y; Y = this.pos.y + y;
//console.log(String.fromCharCode(this.getCode()) + ": X " + X);
/*var tx = 0; /*var tx = 0;
var ty = 0; var ty = 0;
......
...@@ -202,6 +202,3 @@ var extend = function(Child, Parent) ...@@ -202,6 +202,3 @@ var extend = function(Child, Parent)
Child.superclass = Parent.prototype; Child.superclass = Parent.prototype;
} }
// default Txt Prp
// argSize
//величина символа "сигма" не меняется в зависимости от аргумента //величина символа "сигма" не меняется в зависимости от аргумента
//если не выставлено в настройках //если не выставлено в настройках
/////////////////////****////////////////////////// /////////////////////****//////////////////////////
// IterType:
// 0 - без итераторов
// 1 - итератор сверху
// 2 - итератор снизу
// 3 - оба итератора
// OrderType
// 0 - итраторы по прямой линии
// 1 - итераторы расположены также, как у степени
function CNary(props) function CNary(props)
{ {
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
this.kind = MATH_NARY; this.kind = MATH_NARY;
this.type = null; this.Pr =
this.code = null; // for "read" {
this.grow = false; chr: null,
this.supHide = false; chrType: NARY_INTEGRAL,
this.subHide = false; supHide: false,
subHide: false,
grow: false,
limLoc: null
};
//this.limLoc = null;
//this.type = null;
//this.code = null; // for "read"
//this.grow = false;
//this.supHide = false;
//this.subHide = false;
CMathBase.call(this); CMathBase.call(this);
this.init(props); this.init(props);
this.setCtrPrp(props.ctrPrp); //this.setCtrPrp(props.ctrPrp);
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
extend(CNary, CMathBase); extend(CNary, CMathBase);
CNary.prototype.init = function(props) CNary.prototype.init = function(props)
{ {
if(props.ctrPrp !== null && typeof(props.ctrPrp)!== "undefined")
this.setCtrPrp(props.ctrPrp);
if(props.supHide === true || props.supHide === 1) if(props.supHide === true || props.supHide === 1)
this.supHide = true; this.Pr.supHide = true;
if(props.subHide === true || props.subHide === 1) if(props.subHide === true || props.subHide === 1)
this.subHide = true; this.Pr.subHide = true;
if(props.grow === true || props.grow === 1) if(props.grow === true || props.grow === 1)
this.grow = true; this.Pr.grow = true;
this.setDimension(1, 2); this.setDimension(1, 2);
var signCode, sign; var oSign = this.getSign(props.chr, props.signType);
var bChr = false;
if(typeof(props.chr) === "string") //this.Pr.chrType = oSign.chrType;
{ //this.Pr.chr = String.fromCharCode(oSign.chrCode);
signCode = props.chr.charCodeAt(0);
bChr = true; this.Pr.chrType = props.chrType;
} this.Pr.chr = props.chr;
if(props.limLoc == NARY_UndOvr) if(props.limLoc == NARY_UndOvr)
this.limLoc = NARY_UndOvr; this.Pr.limLoc = NARY_UndOvr;
else if(props.limLoc == NARY_SubSup) else if(props.limLoc == NARY_SubSup)
this.limLoc = NARY_SubSup; this.Pr.limLoc = NARY_SubSup;
else else
{ {
var bIntegral = signCode > 0x222A && signCode < 0x2231; var bIntegral = oSign.chrCode > 0x222A && oSign.chrCode < 0x2231;
//var MPrp = this.Parent.Composition.GetMathPr(); //var MPrp = this.Parent.Composition.GetMathPr();
if(bIntegral) if(bIntegral)
this.limLoc = g_oMathSettings.intLim; this.Pr.limLoc = g_oMathSettings.intLim;
else else
this.limLoc = g_oMathSettings.naryLim; this.Pr.limLoc = g_oMathSettings.naryLim;
} }
var arg = new CMathContent(),
base;
if(signCode == 0x222B || props.signType == NARY_INTEGRAL) if(this.Pr.limLoc === NARY_UndOvr)
{ {
this.code = 0x222B; if(this.Pr.supHide && this.Pr.subHide)
this.type = NARY_INTEGRAL; {
sign = new CIntegral(); base = oSign.operator;
} }
else if(signCode == 0x222C || props.signType == NARY_DOUBLE_INTEGRAL) else if( this.Pr.supHide && !this.Pr.subHide )
{ {
this.code = 0x222C; base = new CNaryOvr();
this.type = NARY_DOUBLE_INTEGRAL; base.init(oSign.operator);
sign = new CDoubleIntegral();
base.setCtrPrp(this.CtrPrp.Copy());
} }
else if(signCode == 0x222D || props.signType == NARY_TRIPLE_INTEGRAL) else if( !this.Pr.supHide && this.Pr.subHide )
{ {
this.code = 0x222D; base = new CNaryUnd();
this.type = NARY_TRIPLE_INTEGRAL; base.init(oSign.operator);
sign = new CTripleIntegral(); base.setCtrPrp(this.CtrPrp.Copy());
} }
else if(signCode == 0x222E || props.signType == NARY_CONTOUR_INTEGRAL ) else
{ {
this.code = 0x222E; base = new CNaryUndOvr();
this.type = NARY_CONTOUR_INTEGRAL; base.init(oSign.operator);
sign = new CContourIntegral(); base.setCtrPrp(this.CtrPrp.Copy());
} }
else if(signCode == 0x222F || props.signType == NARY_SURFACE_INTEGRAL )
}
else
{ {
this.code = 0x222F; if( this.Pr.supHide && !this.Pr.subHide )
this.type = NARY_SURFACE_INTEGRAL; {
sign = new CSurfaceIntegral(); var prp = {type: DEGREE_SUBSCRIPT, indef: 2, oBase: oSign.operator, ctrPrp: this.CtrPrp.Copy() };
base = new CDegree(prp);
} }
else if(signCode == 0x2230 || props.signType == NARY_VOLUME_INTEGRAL) else if( !this.Pr.supHide && this.Pr.subHide )
{ {
this.code = 0x2230; var prp = {type: DEGREE_SUPERSCRIPT, indef: 2, oBase: oSign.operator, ctrPrp: this.CtrPrp.Copy()};
this.type = NARY_VOLUME_INTEGRAL; base = new CDegree(prp);
sign = new CVolumeIntegral();
} }
else if(signCode == 0x2211 || props.signType == NARY_SIGMA) else
{ {
this.code = 0x2211; var prp = {type: DEGREE_SubSup, indef: 2, oBase: oSign.operator, ctrPrp: this.CtrPrp.Copy()};
this.type = NARY_SIGMA; base = new CDegreeSubSup(prp);
sign = new CSigma();
} }
else if(signCode == 0x220F || props.signType == NARY_PRODUCT) }
this.addMCToContent(base, arg);
}
CNary.prototype.Resize = function(Parent, ParaMath, oMeasure)
{
if(this.RecalcInfo.bProps)
{ {
this.code = 0x220F; var oSign = this.getSign(this.Pr.chr, this.Pr.chrType);
this.type = NARY_PRODUCT;
sign = new CProduct(); this.Pr.chrType = oSign.chrType;
this.Pr.chr = String.fromCharCode(oSign.chrCode);
} }
else if(signCode == 0x2210 || props.signType == NARY_COPRODUCT)
CNary.superclass.Resize.call(this, Parent, ParaMath, oMeasure);
}
CNary.prototype.getSign = function(chr, chrType)
{
var result =
{ {
this.code = 0x2210; chrCode: null,
this.type = NARY_COPRODUCT; chrType: null,
sign = new CProduct(-1); operator: null
} }
else if(signCode == 0x22C3 || props.signType == NARY_UNION)
var bChr = false;
var chrCode;
if(typeof(chr) === "string")
{ {
this.code = 0x22C3; chrCode = chr.charCodeAt(0);
this.type = NARY_UNION; bChr = true;
sign = new CUnion();
} }
else if(signCode == 0x22C2 || props.signType == NARY_INTERSECTION)
if(chrCode == 0x222B || chrType == NARY_INTEGRAL)
{ {
this.code = 0x22C2; result.chrCode = 0x222B;
this.type = NARY_INTERSECTION; result.chrType = NARY_INTEGRAL;
sign = new CUnion(-1); result.operator = new CIntegral();
} }
else if(signCode == 0x22C1 || props.signType == NARY_LOGICAL_OR) else if(chrCode == 0x222C || chrType == NARY_DOUBLE_INTEGRAL)
{ {
this.code = 0x22C1; result.chrCode = 0x222C;
this.type = NARY_LOGICAL_OR; result.chrType = NARY_DOUBLE_INTEGRAL;
sign = new CLogicalOr(); result.operator = new CDoubleIntegral();
} }
else if(signCode == 0x22C0 || props.signType == NARY_LOGICAL_AND) else if(chrCode == 0x222D || chrType == NARY_TRIPLE_INTEGRAL)
{ {
this.code = 0x22C0; result.chrCode = 0x222D;
this.type = NARY_LOGICAL_AND; result.chrType = NARY_TRIPLE_INTEGRAL;
sign = new CLogicalOr(-1); result.operator = new CTripleIntegral();
} }
else if(bChr) else if(chrCode == 0x222E || chrType == NARY_CONTOUR_INTEGRAL )
{ {
this.code = signCode; result.chrCode = 0x222E;
this.type = NARY_TEXT_OPER; result.chrType = NARY_CONTOUR_INTEGRAL;
sign = new CMathText(true); result.operator = new CContourIntegral();
sign.add(signCode);
} }
else else if(chrCode == 0x222F || chrType == NARY_SURFACE_INTEGRAL )
{ {
this.code = 0x222B; result.chrCode = 0x222F;
this.type = NARY_INTEGRAL; result.chrType = NARY_SURFACE_INTEGRAL;
sign = new CIntegral(); result.operator = new CSurfaceIntegral();
} }
else if(chrCode == 0x2230 || chrType == NARY_VOLUME_INTEGRAL)
var arg = new CMathContent(),
base;
if(this.limLoc === NARY_UndOvr)
{ {
if(this.supHide && this.subHide) result.chrCode = 0x2230;
result.chrType = NARY_VOLUME_INTEGRAL;
result.operator = new CVolumeIntegral();
}
else if(chrCode == 0x2211 || chrType == NARY_SIGMA)
{ {
base = sign; result.chrCode = 0x2211;
result.chrType = NARY_SIGMA;
result.operator = new CSigma();
} }
else if( this.supHide && !this.subHide ) else if(chrCode == 0x220F || chrType == NARY_PRODUCT)
{ {
base = new CNaryOvr(); result.chrCode = 0x220F;
base.init(sign); result.chrType = NARY_PRODUCT;
result.operator = new CProduct();
base.setCtrPrp(this.CtrPrp.Copy());
} }
else if( !this.supHide && this.subHide ) else if(chrCode == 0x2210 || chrType == NARY_COPRODUCT)
{ {
base = new CNaryUnd(); result.chrCode = 0x2210;
base.init(sign); result.chrType = NARY_COPRODUCT;
base.setCtrPrp(this.CtrPrp.Copy()); result.operator = new CProduct(-1);
} }
else else if(chrCode == 0x22C3 || chrType == NARY_UNION)
{ {
base = new CNaryUndOvr(); result.chrCode = 0x22C3;
base.init(sign); result.chrType = NARY_UNION;
base.setCtrPrp(this.CtrPrp.Copy()); result.operator = new CUnion();
} }
else if(chrCode == 0x22C2 || chrType == NARY_INTERSECTION)
{
result.chrCode = 0x22C2;
result.chrType = NARY_INTERSECTION;
result.operator = new CUnion(-1);
} }
else else if(chrCode == 0x22C1 || chrType == NARY_LOGICAL_OR)
{ {
if( this.supHide && !this.subHide ) result.chrCode = 0x22C1;
result.chrType = NARY_LOGICAL_OR;
result.operator = new CLogicalOr();
}
else if(chrCode == 0x22C0 || chrType == NARY_LOGICAL_AND)
{ {
var prp = {type: DEGREE_SUBSCRIPT, indef: 2, oBase: sign, ctrPrp: this.CtrPrp.Copy() }; result.chrCode = 0x22C0;
base = new CDegree(prp); result.chrType = NARY_LOGICAL_AND;
result.operator = new CLogicalOr(-1);
} }
else if( !this.supHide && this.subHide ) else if(bChr)
{ {
var prp = {type: DEGREE_SUPERSCRIPT, indef: 2, oBase: sign, ctrPrp: this.CtrPrp.Copy()}; result.chrCode = chrCode;
base = new CDegree(prp); result.chrType = NARY_TEXT_OPER;
result.operator = new CMathText(true);
result.operator.add(chrCode);
} }
else else
{ {
var prp = {type: DEGREE_SubSup, indef: 2, oBase: sign, ctrPrp: this.CtrPrp.Copy()}; result.chrCode = 0x222B;
base = new CDegreeSubSup(prp); result.chrType = NARY_INTEGRAL;
} result.operator = new CIntegral();
} }
/*if(!this.supHide || !this.subHide) return result;
base.setCtrPrp(this.CtrPrp); */ // выставляем аналогично как в CMathContent при добавлении элемента в addMComponent
this.addMCToContent(base, arg);
/// вызов этой функции обязательно в конце
//this.WriteContentsToHistory();
} }
CNary.prototype.setCtrPrp = function(txtPrp) CNary.prototype.setCtrPrp = function(txtPrp)
{ {
...@@ -238,12 +273,12 @@ CNary.prototype.getBase = function() ...@@ -238,12 +273,12 @@ CNary.prototype.getBase = function()
} }
CNary.prototype.getUpperIterator = function() CNary.prototype.getUpperIterator = function()
{ {
if (!this.supHide) if (!this.Pr.supHide)
return this.elements[0][0].getUpperIterator(); return this.elements[0][0].getUpperIterator();
} }
CNary.prototype.getLowerIterator = function() CNary.prototype.getLowerIterator = function()
{ {
if (!this.subHide) if (!this.Pr.subHide)
return this.elements[0][0].getLowerIterator(); return this.elements[0][0].getLowerIterator();
} }
CNary.prototype.getPropsForWrite = function() CNary.prototype.getPropsForWrite = function()
......
...@@ -3121,6 +3121,7 @@ COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch) ...@@ -3121,6 +3121,7 @@ COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch)
{ {
var width, height, ascent; var width, height, ascent;
if(this.typeOper == OPERATOR_TEXT) // отдельный случай для текста в качестве оператора if(this.typeOper == OPERATOR_TEXT) // отдельный случай для текста в качестве оператора
{ {
var ctrPrp = this.Get_CompiledCtrPrp(); var ctrPrp = this.Get_CompiledCtrPrp();
...@@ -3148,10 +3149,10 @@ COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch) ...@@ -3148,10 +3149,10 @@ COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch)
height = this.operator.size.height; height = this.operator.size.height;
} }
var letterX = new CMathText(true); /*var letterX = new CMathText(true);
letterX.add(0x78); letterX.add(0x78);
letterX.Resize(null, oMeasure); letterX.Resize(null, oMeasure);
this.shiftAccent = letterX.size.ascent; this.shiftAccent = letterX.size.ascent;*/
} }
else else
{ {
...@@ -3295,88 +3296,65 @@ function CDelimiter(props) ...@@ -3295,88 +3296,65 @@ function CDelimiter(props)
this.endOper = new COperator (OPER_DELIMITER); this.endOper = new COperator (OPER_DELIMITER);
this.sepOper = new COperator (OPER_SEPARATOR); this.sepOper = new COperator (OPER_SEPARATOR);
this.shape = DELIMITER_SHAPE_CENTERED; this.Pr =
this.grow = true; {
begChr: null,
begChrType: null,
endChr: null,
endChrType: null,
this.code = null; sepChr: null,
this.typeOper = null; sepChrType: null,
//// special for "read" //// //// special for "read" ////
this.column = 0; column: 0,
////
shp: DELIMITER_SHAPE_CENTERED,
grow: true
};
//this.shape = DELIMITER_SHAPE_CENTERED;
//this.grow = true;
CMathBase.call(this); CMathBase.call(this);
this.init(props); this.init(props);
this.setCtrPrp(props.ctrPrp);
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
extend(CDelimiter, CMathBase); extend(CDelimiter, CMathBase);
CDelimiter.prototype.init = function(props) CDelimiter.prototype.init = function(props)
{ {
if(props.grow == true || props.grow == 1) if(props.grow == true || props.grow == 1)
this.grow = true; this.Pr.grow = true;
else if(props.grow == false || props.grow == 0) else if(props.grow == false || props.grow == 0)
this.grow = false; this.Pr.grow = false;
var begPrp = this.Pr.begChr = props.begChr;
{ this.Pr.begChrType = props.begChrType;
chr: props.begChr,
type: props.begChrType,
loc: LOCATION_LEFT
};
var begDefaultPrp =
{
type: PARENTHESIS_LEFT
};
this.begOper.setProperties(begPrp, begDefaultPrp);
this.begOper.relate(this);
var endPrp = this.Pr.endChr = props.endChr;
{ this.Pr.endChrType = props.endChrType;
chr: props.endChr,
type: props.endChrType,
loc: LOCATION_RIGHT
};
var endDefaultPrp =
{
type: PARENTHESIS_RIGHT
};
this.endOper.setProperties(endPrp, endDefaultPrp); this.Pr.sepChr = props.sepChr;
this.endOper.relate(this); this.Pr.sepChrType = props.sepChrType;
var sepPrp =
{
chr: props.sepChr,
type: props.sepChrType,
loc: LOCATION_SEP
};
var sepDefaultPrp =
{
type: DELIMITER_LINE
};
if(props.column == 1 )
sepPrp.type = OPERATOR_EMPTY;
this.sepOper.setProperties(sepPrp, sepDefaultPrp);
this.sepOper.relate(this);
if(props.shape == DELIMITER_SHAPE_MATH || props.shp == DELIMITER_SHAPE_MATH) if(props.shape == DELIMITER_SHAPE_MATH || props.shp == DELIMITER_SHAPE_MATH)
this.shape = DELIMITER_SHAPE_MATH; this.Pr.shp = DELIMITER_SHAPE_MATH;
else if(props.shape == DELIMITER_SHAPE_CENTERED || props.shp == DELIMITER_SHAPE_CENTERED) else if(props.shape == DELIMITER_SHAPE_CENTERED || props.shp == DELIMITER_SHAPE_CENTERED)
this.shape = DELIMITER_SHAPE_CENTERED; this.Pr.shp = DELIMITER_SHAPE_CENTERED;
if(props.column === null || typeof(props.column) === "undefined" ) if(props.column === null || typeof(props.column) === "undefined")
props.column = 1; props.column = 1;
if(props.ctrPrp !== null && typeof(props.ctrPrp) !== "undefined")
this.setCtrPrp(props.ctrPrp);
this.setDimension(1, props.column); this.setDimension(1, props.column);
this.setContent(); this.setContent();
/// вызов этой функции обязательно в конце
//this.WriteContentsToHistory();
} }
CDelimiter.prototype.old_recalculateSize = function() CDelimiter.prototype.old_recalculateSize = function()
{ {
...@@ -3529,6 +3507,56 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -3529,6 +3507,56 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure)
this.RecalcInfo.bCtrPrp = false; this.RecalcInfo.bCtrPrp = false;
} }
if(this.RecalcInfo.bProps == true)
{
var begPrp =
{
chr: this.Pr.begChr,
type: this.Pr.begChrType,
loc: LOCATION_LEFT
};
var begDefaultPrp =
{
type: PARENTHESIS_LEFT
};
this.begOper.setProperties(begPrp, begDefaultPrp);
this.begOper.relate(this);
var endPrp =
{
chr: this.Pr.endChr,
type: this.Pr.endChrType,
loc: LOCATION_RIGHT
};
var endDefaultPrp =
{
type: PARENTHESIS_RIGHT
};
this.endOper.setProperties(endPrp, endDefaultPrp);
this.endOper.relate(this);
var sepPrp =
{
chr: this.Pr.sepChr,
type: this.Pr.sepChrType,
loc: LOCATION_SEP
};
var sepDefaultPrp =
{
type: DELIMITER_LINE
};
if(this.nCol == 1 )
sepPrp.type = OPERATOR_EMPTY;
this.sepOper.setProperties(sepPrp, sepDefaultPrp);
this.sepOper.relate(this);
this.RecalcInfo.bProps = false;
}
// размеры аргумента // размеры аргумента
var heightG = 0, widthG = 0, var heightG = 0, widthG = 0,
ascentG = 0, descentG = 0; ascentG = 0, descentG = 0;
...@@ -3546,7 +3574,6 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -3546,7 +3574,6 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure)
heightG = ascentG + descentG; heightG = ascentG + descentG;
var mgCtrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp); var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
var maxAD = ascentG - shCenter > descentG + shCenter ? ascentG - shCenter: descentG + shCenter; var maxAD = ascentG - shCenter > descentG + shCenter ? ascentG - shCenter: descentG + shCenter;
...@@ -3554,7 +3581,7 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -3554,7 +3581,7 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure)
var plH = 9.877777777777776 * mgCtrPrp.FontSize/36; var plH = 9.877777777777776 * mgCtrPrp.FontSize/36;
var bTextContent = ascentG < plH || descentG < plH; // для текста операторы в случае центрирования не увеличиваем var bTextContent = ascentG < plH || descentG < plH; // для текста операторы в случае центрирования не увеличиваем
var bCentered = this.shape == DELIMITER_SHAPE_CENTERED, var bCentered = this.Pr.shp == DELIMITER_SHAPE_CENTERED,
b2Max = bCentered && (2*maxAD - heightG > 0.001); b2Max = bCentered && (2*maxAD - heightG > 0.001);
...@@ -3580,7 +3607,7 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -3580,7 +3607,7 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure)
var height, ascent, descent; var height, ascent, descent;
if(this.shape == DELIMITER_SHAPE_CENTERED) if(this.Pr.shp == DELIMITER_SHAPE_CENTERED)
{ {
var deltaHeight = heightG - maxDimOper.height; var deltaHeight = heightG - maxDimOper.height;
if(deltaHeight < 0) if(deltaHeight < 0)
...@@ -3671,12 +3698,12 @@ CDelimiter.prototype.alignOperator = function(operator) // в качестве ...@@ -3671,12 +3698,12 @@ CDelimiter.prototype.alignOperator = function(operator) // в качестве
if(bAlign) if(bAlign)
{ {
if(this.shape == DELIMITER_SHAPE_CENTERED) if(this.Pr.shp == DELIMITER_SHAPE_CENTERED)
{ {
align = this.size.ascent > dimOper.ascent ? this.size.ascent - dimOper.ascent : 0; align = this.size.ascent > dimOper.ascent ? this.size.ascent - dimOper.ascent : 0;
} }
else if(this.shape === DELIMITER_SHAPE_MATH) else if(this.Pr.shp === DELIMITER_SHAPE_MATH)
{ {
var shCenter = dimOper.ascent - dimOper.height/2; // так получаем shCenter, иначе соотношение м/ду ascent и descent будет неверное var shCenter = dimOper.ascent - dimOper.height/2; // так получаем shCenter, иначе соотношение м/ду ascent и descent будет неверное
...@@ -3911,14 +3938,13 @@ CDelimiter.prototype.Get_Id = function() ...@@ -3911,14 +3938,13 @@ CDelimiter.prototype.Get_Id = function()
function CCharacter() function CCharacter()
{ {
this.operator = new COperator(OPER_GROUP_CHAR); this.operator = new COperator(OPER_GROUP_CHAR);
this.shiftX = 0;
CMathBase.call(this); CMathBase.call(this);
} }
extend(CCharacter, CMathBase); extend(CCharacter, CMathBase);
CCharacter.prototype.setCharacter = function(props, defaultProps) CCharacter.prototype.setCharacter = function(props, defaultProps)
{ {
this.operator.init(props, defaultProps); this.operator.setProperties(props, defaultProps);
this.operator.relate(this); this.operator.relate(this);
this.setDimension(1, 1); this.setDimension(1, 1);
...@@ -3940,17 +3966,13 @@ CCharacter.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -3940,17 +3966,13 @@ CCharacter.prototype.Resize = function(Parent, ParaMath, oMeasure)
this.operator.fixSize(ParaMath, oMeasure, base.size.width); this.operator.fixSize(ParaMath, oMeasure, base.size.width);
var letterX = new CMathText(true); var ctrPrp = this.Get_CompiledCtrPrp();
letterX.add(0x78); oMeasure.SetFont(ctrPrp);
letterX.Resize(null, oMeasure);
this.shiftX = base.size.ascent - letterX.size.ascent;
var width = base.size.width > this.operator.size.width ? base.size.width : this.operator.size.width, var width = base.size.width > this.operator.size.width ? base.size.width : this.operator.size.width,
height = base.size.height + this.operator.size.height + this.shiftX, height = base.size.height + this.operator.size.height,
ascent = this.getAscent(oMeasure); ascent = this.getAscent(oMeasure);
var ctrPrp = this.Get_CompiledCtrPrp();
oMeasure.SetFont(ctrPrp);
this.size = {height: height, width: width, ascent: ascent}; this.size = {height: height, width: width, ascent: ascent};
} }
...@@ -3961,7 +3983,7 @@ CCharacter.prototype.setPosition = function(pos) ...@@ -3961,7 +3983,7 @@ CCharacter.prototype.setPosition = function(pos)
var alignOp = this.align(this.operator), var alignOp = this.align(this.operator),
alignCnt = this.align(this.elements[0][0]); alignCnt = this.align(this.elements[0][0]);
if(this.loc === LOCATION_TOP) if(this.Pr.pos === LOCATION_TOP)
{ {
var x1 = this.pos.x + this.GapLeft + alignOp, var x1 = this.pos.x + this.GapLeft + alignOp,
y1 = this.pos.y; y1 = this.pos.y;
...@@ -3969,11 +3991,11 @@ CCharacter.prototype.setPosition = function(pos) ...@@ -3969,11 +3991,11 @@ CCharacter.prototype.setPosition = function(pos)
this.operator.setPosition({x: x1, y: y1}); this.operator.setPosition({x: x1, y: y1});
var x2 = this.pos.x + this.GapLeft + alignCnt, var x2 = this.pos.x + this.GapLeft + alignCnt,
y2 = this.pos.y + this.operator.size.height + this.shiftX; y2 = this.pos.y + this.operator.size.height;
this.elements[0][0].setPosition({x: x2, y: y2}); this.elements[0][0].setPosition({x: x2, y: y2});
} }
else if(this.loc === LOCATION_BOT) else if(this.Pr.pos === LOCATION_BOT)
{ {
var x1 = this.pos.x + this.GapLeft + alignCnt, var x1 = this.pos.x + this.GapLeft + alignCnt,
y1 = this.pos.y; y1 = this.pos.y;
...@@ -4035,7 +4057,7 @@ CCharacter.prototype.findDisposition = function(pos) ...@@ -4035,7 +4057,7 @@ CCharacter.prototype.findDisposition = function(pos)
else else
X = pos.x - align; X = pos.x - align;
if(this.loc === LOCATION_TOP) if(this.Pr.pos === LOCATION_TOP)
{ {
if(pos.y < this.operator.size.height) if(pos.y < this.operator.size.height)
{ {
...@@ -4045,7 +4067,7 @@ CCharacter.prototype.findDisposition = function(pos) ...@@ -4045,7 +4067,7 @@ CCharacter.prototype.findDisposition = function(pos)
else else
Y = pos.y - this.operator.size.height; Y = pos.y - this.operator.size.height;
} }
else if(this.loc === LOCATION_BOT) else if(this.Pr.pos === LOCATION_BOT)
{ {
if(pos.y > content.size.height) if(pos.y > content.size.height)
{ {
...@@ -4067,14 +4089,21 @@ CCharacter.prototype.getBase = function() ...@@ -4067,14 +4089,21 @@ CCharacter.prototype.getBase = function()
} }
function CGroupCharacter(props) function CGroupCharacter(props)
{ {
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
this.kind = MATH_GROUP_CHARACTER; this.kind = MATH_GROUP_CHARACTER;
this.vertJust = VJUST_TOP; this.Pr =
this.loc = LOCATION_BOT; {
chr: null,
chrType: null,
vertJc: VJUST_TOP,
pos: LOCATION_BOT
};
//this.vertJust = VJUST_TOP;
//this.loc = LOCATION_BOT;
CCharacter.call(this); CCharacter.call(this);
...@@ -4084,10 +4113,15 @@ extend(CGroupCharacter, CCharacter); ...@@ -4084,10 +4113,15 @@ extend(CGroupCharacter, CCharacter);
CGroupCharacter.prototype.init = function(props) CGroupCharacter.prototype.init = function(props)
{ {
if(props.vertJc === VJUST_TOP || props.vertJc === VJUST_BOT) if(props.vertJc === VJUST_TOP || props.vertJc === VJUST_BOT)
this.vertJust = props.vertJc; this.Pr.vertJc = props.vertJc;
if(props.pos === LOCATION_TOP || props.pos === LOCATION_BOT) if(props.pos === LOCATION_TOP || props.pos === LOCATION_BOT)
this.loc = LOCATION_TOP; this.Pr.pos = props.pos;
this.Pr.chr = props.chr;
this.Pr.chrType = props.chrType;
///////////////////////////////////////////////////////////////
var operDefaultPrp = var operDefaultPrp =
{ {
...@@ -4097,34 +4131,68 @@ CGroupCharacter.prototype.init = function(props) ...@@ -4097,34 +4131,68 @@ CGroupCharacter.prototype.init = function(props)
var operProps = var operProps =
{ {
type: props.chrType, type: this.Pr.chrType,
chr: props.chr, chr: this.Pr.chr,
loc: this.loc loc: this.Pr.pos
}; };
this.setCharacter(operProps, operDefaultPrp); this.setCharacter(operProps, operDefaultPrp);
this.Pr.chrType = this.operator.typeOper;
this.Pr.chr = String.fromCharCode(this.operator.code);
//////////////////////////////////////////////////////////////////
if(props.ctrPrp !== null && typeof(props.ctrPrp)!== "undefined") if(props.ctrPrp !== null && typeof(props.ctrPrp)!== "undefined")
this.setCtrPrp(props.ctrPrp); this.setCtrPrp(props.ctrPrp);
/// вызов этой функции обязательно в конце /// вызов этой функции обязательно в конце
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
CGroupCharacter.prototype.Resize = function(Parent, ParaMath, oMeasure)
{
if(this.RecalcInfo.bProps == true)
{
var operDefaultPrp =
{
type: BRACKET_CURLY_BOTTOM,
loc: LOCATION_BOT
};
var operProps =
{
type: this.Pr.chrType,
chr: this.Pr.chr,
loc: this.Pr.pos
};
this.setCharacter(operProps, operDefaultPrp);
this.Pr.chrType = this.operator.typeOper;
this.Pr.chr = String.fromCharCode(this.operator.code);
this.RecalcInfo.bProps = false;
}
CGroupCharacter.superclass.Resize.call(this, Parent, ParaMath, oMeasure);
}
CGroupCharacter.prototype.getAscent = function(oMeasure) CGroupCharacter.prototype.getAscent = function(oMeasure)
{ {
var ascent; var ascent;
//var shCent = DIV_CENT*this.getCtrPrp().FontSize; //var shCent = DIV_CENT*this.getCtrPrp().FontSize;
var ctrPrp = this.Get_CompiledCtrPrp(); var ctrPrp = this.Get_CompiledCtrPrp();
var shCent = this.ParaMath.GetShiftCenter(oMeasure, ctrPrp); var shCent = this.ParaMath.GetShiftCenter(oMeasure, ctrPrp);
if(this.vertJust === VJUST_TOP && this.loc === LOCATION_TOP) if(this.Pr.vertJc === VJUST_TOP && this.Pr.pos === LOCATION_TOP)
ascent = this.operator.size.ascent + shCent; ascent = this.operator.size.ascent + shCent;
else if(this.vertJust === VJUST_BOT && this.loc === LOCATION_TOP ) else if(this.Pr.vertJc === VJUST_BOT && this.Pr.pos === LOCATION_TOP )
ascent = this.operator.size.height + this.elements[0][0].size.ascent; ascent = this.operator.size.height + this.elements[0][0].size.ascent;
else if(this.vertJust === VJUST_TOP && this.loc === LOCATION_BOT ) else if(this.Pr.vertJc === VJUST_TOP && this.Pr.pos === LOCATION_BOT )
ascent = this.elements[0][0].size.ascent; ascent = this.elements[0][0].size.ascent;
else if(this.vertJust === VJUST_BOT && this.loc === LOCATION_BOT ) else if(this.Pr.vertJc === VJUST_BOT && this.Pr.pos === LOCATION_BOT )
ascent = this.elements[0][0].size.height + shCent + this.operator.size.height - this.operator.size.ascent; ascent = this.elements[0][0].size.height + shCent + this.operator.size.height - this.operator.size.ascent;
//ascent = this.operator.size.height/2 + shCent + this.elements[0][0].size.height; //ascent = this.operator.size.height/2 + shCent + this.elements[0][0].size.height;
...@@ -4289,20 +4357,10 @@ CGroupCharacter.prototype.old_getGlyph = function(code, type) ...@@ -4289,20 +4357,10 @@ CGroupCharacter.prototype.old_getGlyph = function(code, type)
} }
return operator; return operator;
}
CGroupCharacter.prototype.setPos = function() // change location
{
} }
CGroupCharacter.prototype.getPropsForWrite = function() CGroupCharacter.prototype.getPropsForWrite = function()
{ {
var props = { return this.Pr;
chr: this.operator.getChr(),
pos: this.loc,
vertJc: this.vertJc
};
return props;
} }
CGroupCharacter.prototype.Save_Changes = function(Data, Writer) CGroupCharacter.prototype.Save_Changes = function(Data, Writer)
{ {
......
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