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

CMathPosition для всех классов (вместе с багом на позицию)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56480 954022d7-b5bf-4e40-9824-e11837661b57
parent d2302860
...@@ -521,7 +521,8 @@ function CAccent(props) ...@@ -521,7 +521,8 @@ function CAccent(props)
//this.code = null; // храним код буквы и тип здесь //this.code = null; // храним код буквы и тип здесь
//this.typeOper = null; // т.к в класах, которые вызываем, не учитываем случаи, когда элементы (стрелки/скобки) переворачиваются //this.typeOper = null; // т.к в класах, которые вызываем, не учитываем случаи, когда элементы (стрелки/скобки) переворачиваются
CMathBase.call(this); CAccent.superclass.constructor.call(this);
//CMathBase.call(this);
if(props !== null && typeof(props) !== "undefined") if(props !== null && typeof(props) !== "undefined")
this.init(props); this.init(props);
...@@ -1105,10 +1106,6 @@ CAccent.prototype.setPosition = function(pos) ...@@ -1105,10 +1106,6 @@ CAccent.prototype.setPosition = function(pos)
this.elements[0][0].setPosition(PosBase); this.elements[0][0].setPosition(PosBase);
} }
CAccent.prototype.getAscent = function()
{
return this.operator.size.height + this.elements[0][0].size.ascent;
}
CAccent.prototype.getPropsForWrite = function() CAccent.prototype.getPropsForWrite = function()
{ {
var props = {}; var props = {};
...@@ -1164,7 +1161,7 @@ CAccent.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -1164,7 +1161,7 @@ CAccent.prototype.Resize = function(Parent, ParaMath, oMeasure)
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 + this.shiftX,
ascent = this.getAscent(oMeasure); ascent = this.operator.size.height + this.elements[0][0].size.ascent;
this.size = {height: height, width: width, ascent: ascent}; this.size = {height: height, width: width, ascent: ascent};
} }
......
...@@ -426,7 +426,7 @@ var inherit = function(obj, extObj) ...@@ -426,7 +426,7 @@ var inherit = function(obj, extObj)
arguments.callee(obj, arguments[a]); arguments.callee(obj, arguments[a]);
else else
for(var i in extObj) for(var i in extObj)
if( ! obj[i]) if (!obj[i])
obj[i] = extObj[i]; obj[i] = extObj[i];
return obj; return obj;
......
var CENTER = -1;
function CMathBase() function CMathBase()
{ {
this.typeObj = MATH_COMP; this.typeObj = MATH_COMP;
// {align: {height: alpha, width: betta}} alpha & betta коэффициенты в интервале от 0 до 1, либо CENTER // {align: {height: alpha, width: betta}} alpha & betta коэффициенты в интервале от 0 до 1, либо CENTER
CENTER = -1;
this.pos = new CMathPosition(); this.pos = new CMathPosition();
this.size = null; this.size = null;
...@@ -330,6 +329,7 @@ CMathBase.prototype = ...@@ -330,6 +329,7 @@ CMathBase.prototype =
break; break;
} }
} while( this.elements[this.CurPos_X][this.CurPos_Y].IsJustDraw() ) } while( this.elements[this.CurPos_X][this.CurPos_Y].IsJustDraw() )
;
//из цикла вышли если bJustDraw = false or bUpperLevel = true //из цикла вышли если bJustDraw = false or bUpperLevel = true
...@@ -367,6 +367,7 @@ CMathBase.prototype = ...@@ -367,6 +367,7 @@ CMathBase.prototype =
break; break;
} }
} while( this.elements[this.CurPos_X][this.CurPos_Y].IsJustDraw() ) } while( this.elements[this.CurPos_X][this.CurPos_Y].IsJustDraw() )
;
var content; var content;
if( bUpperLevel ) if( bUpperLevel )
...@@ -389,15 +390,11 @@ CMathBase.prototype = ...@@ -389,15 +390,11 @@ CMathBase.prototype =
}, },
select_moveRight: function() select_moveRight: function()
{ {
var res = this.elements[this.CurPos_X][this.CurPos_Y].select_moveRight(); return this.elements[this.CurPos_X][this.CurPos_Y].select_moveRight();
return res;
}, },
select_moveLeft: function() select_moveLeft: function()
{ {
var res = this.elements[this.CurPos_X][this.CurPos_Y].select_moveLeft(); return this.elements[this.CurPos_X][this.CurPos_Y].select_moveLeft();
return res;
}, },
goToLastElement: function() goToLastElement: function()
{ {
...@@ -684,7 +681,7 @@ CMathBase.prototype = ...@@ -684,7 +681,7 @@ CMathBase.prototype =
}, },
align: function(pos_x, pos_y) align: function(pos_x, pos_y)
{ {
var _x, _y; var PosAlign = new CMathPosition();
if(this.alignment.hgt[pos_y] == CENTER) if(this.alignment.hgt[pos_y] == CENTER)
{ {
...@@ -695,7 +692,7 @@ CMathBase.prototype = ...@@ -695,7 +692,7 @@ CMathBase.prototype =
var _ascent = this.elements[pos_x][j].size.ascent; var _ascent = this.elements[pos_x][j].size.ascent;
maxAsc = ( maxAsc > _ascent ) ? maxAsc : _ascent; maxAsc = ( maxAsc > _ascent ) ? maxAsc : _ascent;
} }
_y = (maxAsc - this.elements[pos_x][pos_y].size.ascent); PosAlign.y = (maxAsc - this.elements[pos_x][pos_y].size.ascent);
} }
else else
{ {
...@@ -706,7 +703,7 @@ CMathBase.prototype = ...@@ -706,7 +703,7 @@ CMathBase.prototype =
_h = this.elements[pos_x][j].size.height; _h = this.elements[pos_x][j].size.height;
maxH = ( maxH > _h ) ? maxH : _h; maxH = ( maxH > _h ) ? maxH : _h;
} }
_y = (maxH - this.elements[pos_x][pos_y].size.height)*this.alignment.hgt[pos_y]; PosAlign.y = (maxH - this.elements[pos_x][pos_y].size.height)*this.alignment.hgt[pos_y];
} }
var maxW = 0; var maxW = 0;
...@@ -717,11 +714,11 @@ CMathBase.prototype = ...@@ -717,11 +714,11 @@ CMathBase.prototype =
} }
if(this.alignment.wdt[pos_x] == CENTER) if(this.alignment.wdt[pos_x] == CENTER)
_x = (maxW - this.elements[pos_x][pos_y].size.width)*0.5; PosAlign.x = (maxW - this.elements[pos_x][pos_y].size.width)*0.5;
else else
_x = (maxW - this.elements[pos_x][pos_y].size.width)*this.alignment.wdt[pos_x]; PosAlign.x = (maxW - this.elements[pos_x][pos_y].size.width)*this.alignment.wdt[pos_x];
return {x: _x, y: _y}; return PosAlign;
}, },
findDisposition: function(mCoord) findDisposition: function(mCoord)
{ {
...@@ -920,25 +917,29 @@ CMathBase.prototype = ...@@ -920,25 +917,29 @@ CMathBase.prototype =
}, },
setPosition: function(pos) setPosition: function(pos)
{ {
this.pos.x = pos.x;
if(this.bMObjs === true) if(this.bMObjs === true)
this.pos = {x: pos.x, y : pos.y}; this.pos.y = pos.y;
else else
this.pos = {x: pos.x, y: pos.y - this.size.ascent}; ///!!!!!!!!!!!!!!!!!!!!!!!!!! this.pos.y = pos.y - this.size.ascent; ///!!!!
var maxWH = this.getWidthsHeights(); var maxWH = this.getWidthsHeights();
var Widths = maxWH.widths; var Widths = maxWH.widths;
var Heights = maxWH.heights; var Heights = maxWH.heights;
var h = 0, w = 0; var h = 0, w = 0;
var NewPos = new CMathPosition();
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
{ {
w = 0; w = 0;
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
{ {
var al = this.align(i, j); var al = this.align(i, j);
var X = this.pos.x + this.GapLeft + al.x + this.dW*j + w; NewPos.x = this.pos.x + this.GapLeft + al.x + this.dW*j + w;
var Y = this.pos.y + al.y + this.dH*i + h; NewPos.y = this.pos.y + al.y + this.dH*i + h;
this.elements[i][j].setPosition( {x: X, y: Y} ); this.elements[i][j].setPosition(NewPos);
w += Widths[j]; w += Widths[j];
} }
h += Heights[i]; h += Heights[i];
...@@ -1167,6 +1168,7 @@ CMathBase.prototype = ...@@ -1167,6 +1168,7 @@ CMathBase.prototype =
break; break;
} }
} while( this.elements[this.CurPos_X][this.CurPos_Y].IsJustDraw() ) } while( this.elements[this.CurPos_X][this.CurPos_Y].IsJustDraw() )
;
//из цикла вышли если bJustDraw = false or bUpperLevel = true //из цикла вышли если bJustDraw = false or bUpperLevel = true
...@@ -1202,6 +1204,7 @@ CMathBase.prototype = ...@@ -1202,6 +1204,7 @@ CMathBase.prototype =
break; break;
} }
} while( this.elements[this.CurPos_X][this.CurPos_Y].IsJustDraw() ) } while( this.elements[this.CurPos_X][this.CurPos_Y].IsJustDraw() )
;
var SelectContent; var SelectContent;
if( bUpperLevel ) if( bUpperLevel )
...@@ -1536,7 +1539,7 @@ CMathBase.prototype = ...@@ -1536,7 +1539,7 @@ CMathBase.prototype =
var bJDraw = this.elements[CurPos_X][CurPos_Y].IsJustDraw(), var bJDraw = this.elements[CurPos_X][CurPos_Y].IsJustDraw(),
usePlh = !bJDraw && bUseContent && this.elements[CurPos_X][CurPos_Y].IsPlaceholder(); usePlh = !bJDraw && bUseContent && this.elements[CurPos_X][CurPos_Y].IsPlaceholder();
if(!bJDraw && ! usePlh) if(!bJDraw && !usePlh)
{ {
this.elements[CurPos_X][CurPos_Y].Get_RightPos(SearchPos, ContentPos, Depth + 2, bUseContent, BegRun); this.elements[CurPos_X][CurPos_Y].Get_RightPos(SearchPos, ContentPos, Depth + 2, bUseContent, BegRun);
SearchPos.Pos.Update(CurPos_X, Depth); SearchPos.Pos.Update(CurPos_X, Depth);
......
...@@ -384,16 +384,23 @@ CBorderBox.prototype.old_draw = function(x, y, pGraphics) ...@@ -384,16 +384,23 @@ CBorderBox.prototype.old_draw = function(x, y, pGraphics)
} }
CBorderBox.prototype.setPosition = function(pos) CBorderBox.prototype.setPosition = function(pos)
{ {
this.pos = {x: pos.x, y: pos.y - this.size.ascent}; this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
var x = this.pos.x + this.GapLeft, y = this.pos.y; var NewPos = new CMathPosition();
if(this.Pr.hideLeft == false) if(this.Pr.hideLeft == false)
x += this.gapBrd; NewPos.x = this.pos.x + this.GapLeft + this.gapBrd;
else
NewPos.x = this.pos.x + this.GapLeft;
if(this.Pr.hideTop == false) if(this.Pr.hideTop == false)
y += this.gapBrd; NewPos.y = this.pos.y + this.gapBrd;
else
NewPos.y = this.pos.y;
this.elements[0][0].setPosition({x : x, y: y}); this.elements[0][0].setPosition(NewPos);
} }
CBorderBox.prototype.findDisposition = function(mCoord) CBorderBox.prototype.findDisposition = function(mCoord)
{ {
......
...@@ -227,50 +227,33 @@ CDegree.prototype.recalculateSubScript = function(oMeasure) ...@@ -227,50 +227,33 @@ CDegree.prototype.recalculateSubScript = function(oMeasure)
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
CDegree.prototype.old_old_setPosition = function(_pos) CDegree.prototype.setPosition = function(pos)
{ {
var pos = _pos; this.pos.x = pos.x;
if(this.bMObjs === true)
{
pos = {x: pos.x, y: pos.y + this.size.center };
}
this.elements[0][0].setPosition({x: pos.x, y: pos.y - this.elements[0][0].size.center });
this.elements[0][1].setPosition({x: pos.x + this.elements[0][0].size.width + this.dW, y: pos.y + this.shiftDegree - this.size.center});
}
CDegree.prototype.old_setPosition = function(pos)
{
if(this.bMObjs === true) if(this.bMObjs === true)
this.pos = pos; this.pos.y = pos.y;
else else
this.pos = {x: pos.x, y: pos.y - this.size.ascent}; this.pos.y = pos.y - this.size.ascent;
var shBase = 0, var PosBase = new CMathPosition();
shIter = 0;
if(this.upper > 0) PosBase.x = this.pos.x + this.GapLeft;
shBase = this.upper; PosBase.y = this.pos.y + this.upBase;
else
shIter = - this.upper;
this.elements[0][0].setPosition({x: this.pos.x, y: this.pos.y + shBase}); var PosIter = new CMathPosition();
this.elements[0][1].setPosition({x: this.pos.x + this.elements[0][0].size.width + this.dW, y: this.pos.y + shIter});
} PosIter.x = this.pos.x + this.GapLeft + this.elements[0][0].size.width + this.dW;
CDegree.prototype.setPosition = function(pos) PosIter.y = this.pos.y + this.upIter;
{
if(this.bMObjs === true)
this.pos = pos;
else
this.pos = {x: pos.x, y: pos.y - this.size.ascent};
var x1 = this.pos.x + this.GapLeft, //var x1 = this.pos.x + this.GapLeft,
y1 = this.pos.y + this.upBase; // y1 = this.pos.y + this.upBase;
var x2 = this.pos.x + this.GapLeft + this.elements[0][0].size.width + this.dW, //var x2 = this.pos.x + this.GapLeft + this.elements[0][0].size.width + this.dW,
y2 = this.pos.y + this.upIter; // y2 = this.pos.y + this.upIter;
this.elements[0][0].setPosition({x: x1, y: y1}); this.elements[0][0].setPosition(PosBase);
this.elements[0][1].setPosition({x: x2, y: y2}); this.elements[0][1].setPosition(PosIter);
} }
CDegree.prototype.old_findDisposition = function(mCoord) CDegree.prototype.old_findDisposition = function(mCoord)
{ {
......
...@@ -337,17 +337,22 @@ CFraction.prototype.setPosition = function(pos) ...@@ -337,17 +337,22 @@ CFraction.prototype.setPosition = function(pos)
{ {
if(this.Pr.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;
this.pos.y = pos.y - this.size.ascent;
var x1 = this.pos.x + this.GapLeft, var PosNum = new CMathPosition();
y1 = this.pos.y;
var x2 = this.pos.x + this.GapLeft + this.elements[0][0].size.width + this.gapSlash, PosNum.x = this.pos.x + this.GapLeft;
y2 = this.pos.y + this.elements[0][0].size.height; PosNum.y = this.pos.y;
this.elements[0][0].setPosition({x: x1, y: y1});
this.elements[0][1].setPosition({x: x2, y: y2}); var PosDen = new CMathPosition();
PosDen.x = this.pos.x + this.GapLeft + this.elements[0][0].size.width + this.gapSlash;
PosDen.y = this.pos.y + this.elements[0][0].size.height;
this.elements[0][0].setPosition(PosNum);
this.elements[0][1].setPosition(PosDen);
} }
else else
CFraction.superclass.setPosition.call(this, pos); CFraction.superclass.setPosition.call(this, pos);
...@@ -576,10 +581,7 @@ CNumerator.prototype.findDisposition = function(mCoord) ...@@ -576,10 +581,7 @@ CNumerator.prototype.findDisposition = function(mCoord)
} }
CNumerator.prototype.setPosition = function(pos) CNumerator.prototype.setPosition = function(pos)
{ {
var x = pos.x; this.elements[0][0].setPosition(pos);
var y = pos.y ;
this.elements[0][0].setPosition({x: x, y: y});
} }
CNumerator.prototype.getElement = function() CNumerator.prototype.getElement = function()
{ {
...@@ -651,10 +653,12 @@ CDenominator.prototype.findDisposition = function(mCoord) ...@@ -651,10 +653,12 @@ CDenominator.prototype.findDisposition = function(mCoord)
} }
CDenominator.prototype.setPosition = function(pos) CDenominator.prototype.setPosition = function(pos)
{ {
var x = pos.x; var NewPos = new CMathPosition();
var y = pos.y + this.gap;
NewPos.x = pos.x;
NewPos.y = pos.y + this.gap;
this.elements[0][0].setPosition({x: x, y: y}); this.elements[0][0].setPosition(NewPos);
} }
CDenominator.prototype.getElement = function(txt) CDenominator.prototype.getElement = function(txt)
{ {
......
...@@ -527,25 +527,6 @@ CRecalculateInfo.prototype = ...@@ -527,25 +527,6 @@ CRecalculateInfo.prototype =
// TO DO // TO DO
// убрать // убрать
/*function dist(_left, _right, _top, _bottom)
{
this.left = _left;
this.right = _right;
this.top = _top;
this.bottom = _bottom;
}
function mathElem(val)
{
this.value = val;
this.widthToEl = 0; // width to this element
this.gaps =
{
left: 0,
right: 0,
top: 0,
bottom: 0
}; //mm
}*/
/*function CMathRunPrp() /*function CMathRunPrp()
{ {
...@@ -853,10 +834,9 @@ function CMathContent() ...@@ -853,10 +834,9 @@ function CMathContent()
this.CurPos = 0; this.CurPos = 0;
this.WidthToElement = []; this.WidthToElement = [];
this.pos = {x:0, y:0}; // относительная позиция this.pos = new CMathPosition(); // относительная позиция
// Properties // Properties
//this.Composition = null; // ссылка на общую формулу
this.ParaMath = null; this.ParaMath = null;
this.argSize = 0; this.argSize = 0;
this.bDot = false; this.bDot = false;
...@@ -864,33 +844,6 @@ function CMathContent() ...@@ -864,33 +844,6 @@ function CMathContent()
this.bRoot = false; this.bRoot = false;
////////////////// //////////////////
/*
///*/
/** real select **//*
///
this.RealSelect =
{
startPos: 0, // эти позиции идут на отрисовку селекта
endPos: 0 // и по ним удаляем элементы из контента
};
///////////////////////////////
///*/
/** logical select **//*
///
this.LogicalSelect =
{
start: 0, // логические позиции селекта !!
end: 0 // откуда начали и где закончили селект
// особенно важна стартовая позиция
};
///////////////////////////////
///////////////////////////////
*/
this.bSelectionUse = false; this.bSelectionUse = false;
this.SelectStartPos = 0; this.SelectStartPos = 0;
this.SelectEndPos = 0; this.SelectEndPos = 0;
...@@ -4241,7 +4194,7 @@ CMathContent.prototype = ...@@ -4241,7 +4194,7 @@ CMathContent.prototype =
} }
else else
{ {
if( ! this.bRoot ) if (!this.bRoot)
{ {
var movement = this.Parent.cursor_moveRight(); var movement = this.Parent.cursor_moveRight();
SelectContent = CurrContent = movement.SelectContent; SelectContent = CurrContent = movement.SelectContent;
...@@ -4309,7 +4262,7 @@ CMathContent.prototype = ...@@ -4309,7 +4262,7 @@ CMathContent.prototype =
} }
else else
{ {
if( ! this.bRoot ) if(!this.bRoot)
{ {
var movement = this.Parent.cursor_moveRight(); var movement = this.Parent.cursor_moveRight();
SelectContent = CurrContent = movement.SelectContent; SelectContent = CurrContent = movement.SelectContent;
...@@ -4328,7 +4281,7 @@ CMathContent.prototype = ...@@ -4328,7 +4281,7 @@ CMathContent.prototype =
{ {
if( this.content[this.selection.startPos - 1].value.typeObj === MATH_COMP) if( this.content[this.selection.startPos - 1].value.typeObj === MATH_COMP)
{ {
if ( ! this.content[this.CurPos].value.select_moveRight() ) if ( !this.content[this.CurPos].value.select_moveRight() )
{ {
//выход за границы мат. объекта //выход за границы мат. объекта
var _active = this.selection.active; var _active = this.selection.active;
...@@ -4671,7 +4624,7 @@ CMathContent.prototype = ...@@ -4671,7 +4624,7 @@ CMathContent.prototype =
x += this.content[this.CurPos].widthToEl - this.content[this.CurPos].value.size.width - this.content[this.CurPos].gaps.right; x += this.content[this.CurPos].widthToEl - this.content[this.CurPos].value.size.width - this.content[this.CurPos].gaps.right;
y = 0; y = 0;
if( ! this.bRoot ) if( !this.bRoot )
{ {
var lowLevel = this.Parent.goToLowerLevel( {x: x, y: y} ); var lowLevel = this.Parent.goToLowerLevel( {x: x, y: y} );
bLow = lowLevel.bLow; bLow = lowLevel.bLow;
...@@ -4696,7 +4649,7 @@ CMathContent.prototype = ...@@ -4696,7 +4649,7 @@ CMathContent.prototype =
x += this.content[this.CurPos].widthToEl - this.content[this.CurPos].value.size.width - this.content[this.CurPos].gaps.right; x += this.content[this.CurPos].widthToEl - this.content[this.CurPos].value.size.width - this.content[this.CurPos].gaps.right;
y = 0; y = 0;
if( ! this.bRoot ) if( !this.bRoot )
{ {
var upLevel = this.Parent.goToUpperLevel( {x: x, y: y} ); var upLevel = this.Parent.goToUpperLevel( {x: x, y: y} );
bUp = upLevel.bUp; bUp = upLevel.bUp;
...@@ -4754,7 +4707,7 @@ CMathContent.prototype = ...@@ -4754,7 +4707,7 @@ CMathContent.prototype =
var state = true, var state = true,
SelectContent = null, CurrContent = null; SelectContent = null, CurrContent = null;
if( ! this.bRoot ) if( !this.bRoot )
{ {
var coord = {x: this.content[this.CurPos].value.size.width, y: 0}; var coord = {x: this.content[this.CurPos].value.size.width, y: 0};
var UpL = this.goToUpperLevel(coord); var UpL = this.goToUpperLevel(coord);
...@@ -4775,7 +4728,7 @@ CMathContent.prototype = ...@@ -4775,7 +4728,7 @@ CMathContent.prototype =
var state = true, var state = true,
SelectContent = null, CurrContent = null; SelectContent = null, CurrContent = null;
if( ! this.bRoot ) if( !this.bRoot )
{ {
var coord = {x: this.content[this.CurPos].value.size.width, y: 0}; var coord = {x: this.content[this.CurPos].value.size.width, y: 0};
var LowL = this.goToLowerLevel(coord); var LowL = this.goToLowerLevel(coord);
...@@ -4856,7 +4809,7 @@ CMathContent.prototype = ...@@ -4856,7 +4809,7 @@ CMathContent.prototype =
var coord = this.getCoordElem(this.CurPos, msCoord ); var coord = this.getCoordElem(this.CurPos, msCoord );
var movement = this.content[pos].value.mouseMove(coord); var movement = this.content[pos].value.mouseMove(coord);
if( ! movement.state ) if( !movement.state )
{ {
this.setEnd_Selection( pos + 1 ); this.setEnd_Selection( pos + 1 );
SelectContent = this; SelectContent = this;
...@@ -5536,7 +5489,7 @@ CMathContent.prototype = ...@@ -5536,7 +5489,7 @@ CMathContent.prototype =
var bRun = start - 1 > 0 ? this.content[start - 1].value.typeObj === MATH_RUN_PRP : false, var bRun = start - 1 > 0 ? this.content[start - 1].value.typeObj === MATH_RUN_PRP : false,
bNextText = start + 1 < this.content.length ? this.content[start + 1].value.typeObj == MATH_TEXT : false; // start < this.content.length - 1, значит последняя буква в контента bNextText = start + 1 < this.content.length ? this.content[start + 1].value.typeObj == MATH_TEXT : false; // start < this.content.length - 1, значит последняя буква в контента
var bOnlyLetter = bRun && ! bNextText; // если все текстовые элементы удалили из Run, нужно удалить RunPrp var bOnlyLetter = bRun && !bNextText; // если все текстовые элементы удалили из Run, нужно удалить RunPrp
if(bOnlyLetter) if(bOnlyLetter)
{ {
...@@ -5690,7 +5643,7 @@ CMathContent.prototype = ...@@ -5690,7 +5643,7 @@ CMathContent.prototype =
}, },
setPlaceholderAfterRemove: function() // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент setPlaceholderAfterRemove: function() // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
{ {
if(this.content.length == 1 && ! this.bRoot )//только CEmpty if(this.content.length == 1 && !this.bRoot )//только CEmpty
this.fillPlaceholders(); this.fillPlaceholders();
}, },
selectUse: function() selectUse: function()
...@@ -5705,7 +5658,7 @@ CMathContent.prototype = ...@@ -5705,7 +5658,7 @@ CMathContent.prototype =
} }
else if(this.content[this.SelectStartPos].typeObj == MATH_COMP) else if(this.content[this.SelectStartPos].typeObj == MATH_COMP)
{ {
result = ! this.content[this.SelectStartPos].IsSelectEmpty(); result = !this.content[this.SelectStartPos].IsSelectEmpty();
} }
} }
else else
...@@ -5735,24 +5688,29 @@ CMathContent.prototype = ...@@ -5735,24 +5688,29 @@ CMathContent.prototype =
}, },
setPosition: function(pos) setPosition: function(pos)
{ {
this.pos = {x: pos.x, y: pos.y}; this.pos.x = pos.x;
this.pos.y = pos.y;
var NewPos = new CMathPosition();
NewPos.x = pos.x;
NewPos.y = pos.y + this.size.ascent; // y по baseline;
var _pos = {x: pos.x, y: pos.y + this.size.ascent}; // y по baseline;
for(var i=0; i < this.content.length; i++) for(var i=0; i < this.content.length; i++)
{ {
if(this.content[i].typeObj == MATH_COMP) if(this.content[i].typeObj == MATH_COMP)
{ {
this.content[i].setPosition(_pos); this.content[i].setPosition(NewPos);
_pos.x += this.content[i].size.width; NewPos.x += this.content[i].size.width;
} }
else if(this.content[i].typeObj == MATH_PARA_RUN) else if(this.content[i].typeObj == MATH_PARA_RUN)
{ {
this.content[i].Math_SetPosition(_pos); this.content[i].Math_SetPosition(NewPos);
_pos.x += this.content[i].size.width; NewPos.x += this.content[i].size.width;
} }
else if(this.content[i].typeObj == MATH_PLACEHOLDER) else if(this.content[i].typeObj == MATH_PLACEHOLDER)
this.content[i].setPosition(_pos); this.content[i].setPosition(NewPos);
} }
}, },
///// properties ///// ///// properties /////
...@@ -6137,7 +6095,7 @@ CMathContent.prototype = ...@@ -6137,7 +6095,7 @@ CMathContent.prototype =
left = current; left = current;
} }
else if(! bDeleteEmptyRun ) else if(!bDeleteEmptyRun )
{ {
NewContent.push(this.content[i]); NewContent.push(this.content[i]);
left = current; left = current;
...@@ -9066,9 +9024,7 @@ CMathContent.prototype = ...@@ -9066,9 +9024,7 @@ CMathContent.prototype =
items.push(oElem); items.push(oElem);
History.Add(oParent, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: PosEnd}); History.Add(oParent, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: PosEnd});
} }
}, },
CreateFraction : function (oFraction,oParentElem,sNumText,sDenText) CreateFraction : function (oFraction,oParentElem,sNumText,sDenText)
{ {
this.CreateElem(oFraction, oParentElem); this.CreateElem(oFraction, oParentElem);
......
...@@ -62,14 +62,14 @@ function CMathText(bJDraw) ...@@ -62,14 +62,14 @@ function CMathText(bJDraw)
{ {
this.typeObj = MATH_TEXT; this.typeObj = MATH_TEXT;
this.bJDraw = false; this.bJDraw = bJDraw;
this.size = null; this.size = null;
this.value = null; this.value = null;
this.pos = new CMathPosition(); this.pos = new CMathPosition();
if(bJDraw === false || bJDraw === true) // if(bJDraw === false || bJDraw === true)
this.bJDraw = bJDraw; // this.bJDraw = bJDraw;
this.type = TXT_ROMAN; this.type = TXT_ROMAN;
...@@ -312,18 +312,28 @@ CMathText.prototype = ...@@ -312,18 +312,28 @@ CMathText.prototype =
}, },
setPosition: function(pos) setPosition: function(pos)
{ {
if( ! this.bJDraw) // for text /*try
{*/
if (!this.bJDraw) // for text
{
this.pos.x = pos.x + this.GapLeft;
this.pos.y = pos.y;
//this.pos = {x : pos.x + this.GapLeft, y: pos.y};
}
else // for symbol only drawing
{
this.pos.x = pos.x - this.rasterOffsetX;
this.pos.y = pos.y - this.rasterOffsetY;
}
/*}
catch(e)
{ {
this.pos.x = pos.x + this.GapLeft;
this.pos.y = pos.y;
//this.pos = {x : pos.x + this.GapLeft, y: pos.y}; }*/
}
else // for symbol only drawing
{
this.pos.x = pos.x - this.rasterOffsetX;
this.pos.y = pos.y - this.rasterOffsetY;
}
}, },
setCoeffTransform: function(sx, shx, shy, sy) setCoeffTransform: function(sx, shx, shy, sy)
{ {
......
...@@ -269,15 +269,19 @@ CMathMatrix.prototype.recalculateSize = function(oMeasure) ...@@ -269,15 +269,19 @@ CMathMatrix.prototype.recalculateSize = function(oMeasure)
} }
CMathMatrix.prototype.setPosition = function(pos) CMathMatrix.prototype.setPosition = function(pos)
{ {
this.pos.x = pos.x;
if(this.bMObjs === true) if(this.bMObjs === true)
this.pos = pos; this.pos.y = pos.y;
else else
this.pos = {x: pos.x, y: pos.y - this.size.ascent}; ///!!!!!!!!!!!!!!!!!!!!!!!!!! this.pos.y = pos.y - this.size.ascent; ///!!!!
var maxWH = this.getWidthsHeights(); var maxWH = this.getWidthsHeights();
var Widths = maxWH.widths; var Widths = maxWH.widths;
var Heights = maxWH.heights; var Heights = maxWH.heights;
var NewPos = new CMathPosition();
var h = 0, w = 0; var h = 0, w = 0;
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
...@@ -286,10 +290,10 @@ CMathMatrix.prototype.setPosition = function(pos) ...@@ -286,10 +290,10 @@ CMathMatrix.prototype.setPosition = function(pos)
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
{ {
var al = this.align(i, j); var al = this.align(i, j);
var X = this.pos.x + this.GapLeft + al.x + this.gaps.column[j] + w; NewPos.x = this.pos.x + this.GapLeft + al.x + this.gaps.column[j] + w;
var Y = this.pos.y + al.y + this.gaps.row[i] + h; NewPos.y = this.pos.y + al.y + this.gaps.row[i] + h;
this.elements[i][j].setPosition( {x: X, y: Y} ); this.elements[i][j].setPosition(NewPos);
w += Widths[j] + this.gaps.column[j]; w += Widths[j] + this.gaps.column[j];
} }
h += Heights[i] + this.gaps.row[i]; h += Heights[i] + this.gaps.row[i];
......
...@@ -494,19 +494,37 @@ CNaryUndOvr.prototype.recalculateSize = function() ...@@ -494,19 +494,37 @@ CNaryUndOvr.prototype.recalculateSize = function()
} }
CNaryUndOvr.prototype.setPosition = function(pos) CNaryUndOvr.prototype.setPosition = function(pos)
{ {
this.pos = {x: pos.x, y : pos.y - this.size.ascent}; this.pos.x = pos.x;
var xx = pos.x + this.GapLeft; this.pos.y = pos.y - this.size.ascent;
var x1 = xx + this.align(0, 0).x, var PosUpIter = new CMathPosition();
PosUpIter.x = pos.x + this.GapLeft + this.align(0, 0).x;
PosUpIter.y = pos.y;
var PosSign = new CMathPosition();
PosSign.x = pos.x + this.GapLeft + this.align(1,0).x;
PosSign.y = pos.y + this.elements[0][0].size.height + this.gapTop;
var PosLowIter = new CMathPosition();
PosLowIter.x = pos.x + this.GapLeft + this.align(2,0).x;
PosLowIter.y = PosSign.y + this.elements[1][0].size.height + this.gapBottom;
/*var x1 = pos.x + this.GapLeft + this.align(0, 0).x,
y1 = pos.y, y1 = pos.y,
x2 = xx + this.align(1,0).x, x2 = pos.x + this.GapLeft + this.align(1,0).x,
y2 = y1 + this.elements[0][0].size.height + this.gapTop, y2 = y1 + this.elements[0][0].size.height + this.gapTop,
x3 = xx + this.align(2,0).x, x3 = pos.x + this.GapLeft + this.align(2,0).x,
y3 = y2 + this.elements[1][0].size.height + this.gapBottom; y3 = y2 + this.elements[1][0].size.height + this.gapBottom;*/
this.elements[0][0].setPosition({x: x1, y :y1}); this.elements[0][0].setPosition(PosUpIter);
this.elements[1][0].setPosition({x: x2, y :y2}); this.elements[1][0].setPosition(PosSign);
this.elements[2][0].setPosition({x: x3, y :y3}); this.elements[2][0].setPosition(PosLowIter);
} }
CNaryUndOvr.prototype.findDisposition = function(mCoord) CNaryUndOvr.prototype.findDisposition = function(mCoord)
{ {
...@@ -569,6 +587,7 @@ CNaryUndOvr.prototype.getUpperIterator = function() ...@@ -569,6 +587,7 @@ CNaryUndOvr.prototype.getUpperIterator = function()
function CNaryOperator(flip) function CNaryOperator(flip)
{ {
this.pos = new CMathPosition();
this.ParaMath = null; this.ParaMath = null;
this.bFlip = (flip == -1); this.bFlip = (flip == -1);
this.sizeGlyph = null; this.sizeGlyph = null;
...@@ -643,13 +662,10 @@ CNaryOperator.prototype.IsJustDraw = function() ...@@ -643,13 +662,10 @@ CNaryOperator.prototype.IsJustDraw = function()
{ {
return true; return true;
} }
/*CNaryOperator.prototype.relate = function(parent)
{
this.Parent = parent;
}*/
CNaryOperator.prototype.setPosition = function(pos) CNaryOperator.prototype.setPosition = function(pos)
{ {
this.pos = {x: pos.x , y: pos.y}; this.pos.x = pos.x;
this.pos.y = pos.y;
} }
CNaryOperator.prototype.recalculateSize = function() CNaryOperator.prototype.recalculateSize = function()
{ {
...@@ -668,18 +684,10 @@ CNaryOperator.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -668,18 +684,10 @@ CNaryOperator.prototype.Resize = function(Parent, ParaMath, oMeasure)
this.recalculateSize(); //обычный пересчет, oMeasure не нужен this.recalculateSize(); //обычный пересчет, oMeasure не нужен
} }
/*CNaryOperator.prototype.setComposition = function(Compos)
{
this.Composition = Compos;
}*/
CNaryOperator.prototype.Get_CompiledCtrPrp = function() CNaryOperator.prototype.Get_CompiledCtrPrp = function()
{ {
return this.Parent.Get_CompiledCtrPrp(); return this.Parent.Get_CompiledCtrPrp();
} }
/*CNaryOperator.prototype.setReferenceComposition = function(Compos)
{
this.Composition = Compos;
}*/
CNaryOperator.prototype.IsOnlyText = function() CNaryOperator.prototype.IsOnlyText = function()
{ {
return false; return false;
......
...@@ -32,7 +32,7 @@ CGlyphOperator.prototype.init = function(props) ...@@ -32,7 +32,7 @@ CGlyphOperator.prototype.init = function(props)
CGlyphOperator.prototype.fixSize = function(stretch) CGlyphOperator.prototype.fixSize = function(stretch)
{ {
var sizeGlyph = this.calcSize(stretch); var sizeGlyph = this.calcSize(stretch);
var width, height, center; var width, height, ascent;
//var betta = this.getTxtPrp().FontSize/36; //var betta = this.getTxtPrp().FontSize/36;
var bHor = this.loc == 0 || this.loc == 1; var bHor = this.loc == 0 || this.loc == 1;
...@@ -72,6 +72,8 @@ CGlyphOperator.prototype.draw_other = function() // с выравнивание ...@@ -72,6 +72,8 @@ CGlyphOperator.prototype.draw_other = function() // с выравнивание
W = this.size.width, H = this.size.height, W = this.size.width, H = this.size.height,
glW, glH; glW, glH;
var a1, a2, b1, b2, c1, c2;
var bHor = this.loc == 0 || this.loc == 1; var bHor = this.loc == 0 || this.loc == 1;
if(bHor) if(bHor)
...@@ -128,8 +130,6 @@ CGlyphOperator.prototype.draw_other = function() // с выравнивание ...@@ -128,8 +130,6 @@ CGlyphOperator.prototype.draw_other = function() // с выравнивание
a2 *= -1; b2 *= -1; c2 += glH; a2 *= -1; b2 *= -1; c2 += glH;
} }
var shW = (W - glW)/ 2, // выравниваем глиф по длине
shH = (H - glH)/2; // при повороте на 90 градусовы
// A*x + B*y + C = 0 // A*x + B*y + C = 0
...@@ -1022,7 +1022,8 @@ COperatorParenthesis.prototype.calcCoord = function(stretch) ...@@ -1022,7 +1022,8 @@ COperatorParenthesis.prototype.calcCoord = function(stretch)
for(var i = 0; i < 10; i++) for(var i = 0; i < 10; i++)
{ {
YY[19 - i] = YY[i] = shiftY - Y[i]*alpha; YY[19 - i] = shiftY - Y[i]*alpha;
YY[i] = shiftY - Y[i]*alpha;
XX[19 - i] = X[i]*alpha; XX[19 - i] = X[i]*alpha;
XX[i] = stretch - X[i]*alpha; XX[i] = stretch - X[i]*alpha;
} }
...@@ -2250,13 +2251,15 @@ old_old_CSeparator.prototype.drawHorLine = function() ...@@ -2250,13 +2251,15 @@ old_old_CSeparator.prototype.drawHorLine = function()
function COperator(type) function COperator(type)
{ {
this.type = type; // delimiter, separator, group character, accent this.type = type; // delimiter, separator, group character, accent
this.operator = -1; this.operator = null;
this.code = null; this.code = null;
this.typeOper = null; // тип скобки : круглая и т.п. this.typeOper = null; // тип скобки : круглая и т.п.
this.defaultType = null; this.defaultType = null;
this.pos = null; //this.pos = null;
this.Positions = new Array();
this.coordGlyph = null; this.coordGlyph = null;
this.size = {width: 0, height: 0}; this.size = {width: 0, height: 0};
...@@ -2823,12 +2826,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop ...@@ -2823,12 +2826,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop
typeOper = BRACKET_CURLY_TOP; typeOper = BRACKET_CURLY_TOP;
operator = new COperatorBracket(); operator = new COperatorBracket();
var props = prp =
{ {
location: location, location: location,
turn: TURN_0 turn: TURN_0
}; };
operator.init(props); operator.init(prp);
} }
else if(code === 0x23DF || type === BRACKET_CURLY_BOTTOM) else if(code === 0x23DF || type === BRACKET_CURLY_BOTTOM)
{ {
...@@ -2836,12 +2839,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop ...@@ -2836,12 +2839,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop
typeOper = BRACKET_CURLY_BOTTOM; typeOper = BRACKET_CURLY_BOTTOM;
operator = new COperatorBracket(); operator = new COperatorBracket();
var props = prp =
{ {
location: location, location: location,
turn: TURN_MIRROR_0 turn: TURN_MIRROR_0
}; };
operator.init(props); operator.init(prp);
} }
else if(code === 0x2190 || type === ARROW_LEFT) else if(code === 0x2190 || type === ARROW_LEFT)
{ {
...@@ -2850,12 +2853,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop ...@@ -2850,12 +2853,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop
operator = new CSingleArrow(); operator = new CSingleArrow();
var props = prp =
{ {
location: location, location: location,
turn: TURN_0 turn: TURN_0
}; };
operator.init(props); operator.init(prp);
} }
else if(code === 0x2192 || type === ARROW_RIGHT) else if(code === 0x2192 || type === ARROW_RIGHT)
{ {
...@@ -2863,12 +2866,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop ...@@ -2863,12 +2866,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop
typeOper = ARROW_RIGHT; typeOper = ARROW_RIGHT;
operator = new CSingleArrow(); operator = new CSingleArrow();
var props = prp =
{ {
location: location, location: location,
turn: TURN_180 turn: TURN_180
}; };
operator.init(props); operator.init(prp);
} }
else if(code === 0x2194 || type === ARROW_LR) else if(code === 0x2194 || type === ARROW_LR)
{ {
...@@ -2876,12 +2879,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop ...@@ -2876,12 +2879,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop
typeOper = ARROW_LR; typeOper = ARROW_LR;
operator = new CLeftRightArrow(); operator = new CLeftRightArrow();
var props = prp =
{ {
location: location, location: location,
turn: TURN_0 turn: TURN_0
}; };
operator.init(props); operator.init(prp);
} }
else if(code === 0x21D0 || type === DOUBLE_LEFT_ARROW) else if(code === 0x21D0 || type === DOUBLE_LEFT_ARROW)
{ {
...@@ -2889,12 +2892,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop ...@@ -2889,12 +2892,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop
typeOper = DOUBLE_LEFT_ARROW; typeOper = DOUBLE_LEFT_ARROW;
operator = new CDoubleArrow(); operator = new CDoubleArrow();
var props = prp =
{ {
location: location, location: location,
turn: TURN_0 turn: TURN_0
}; };
operator.init(props); operator.init(prp);
} }
else if(code === 0x21D2 || type === DOUBLE_RIGHT_ARROW) else if(code === 0x21D2 || type === DOUBLE_RIGHT_ARROW)
{ {
...@@ -2902,12 +2905,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop ...@@ -2902,12 +2905,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop
typeOper = DOUBLE_RIGHT_ARROW; typeOper = DOUBLE_RIGHT_ARROW;
operator = new CDoubleArrow(); operator = new CDoubleArrow();
var props = prp =
{ {
location: location, location: location,
turn: TURN_180 turn: TURN_180
}; };
operator.init(props); operator.init(prp);
} }
else if(code === 0x21D4 || type === DOUBLE_ARROW_LR) else if(code === 0x21D4 || type === DOUBLE_ARROW_LR)
{ {
...@@ -2915,12 +2918,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop ...@@ -2915,12 +2918,12 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop
typeOper = DOUBLE_ARROW_LR; typeOper = DOUBLE_ARROW_LR;
operator = new CLR_DoubleArrow(); operator = new CLR_DoubleArrow();
var props = prp =
{ {
location: location, location: location,
turn: TURN_0 turn: TURN_0
}; };
operator.init(props); operator.init(prp);
} }
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
...@@ -2932,7 +2935,6 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop ...@@ -2932,7 +2935,6 @@ COperator.prototype.setProperties = function(properties, defaultProps) // prop
operator = new CMathText(true); operator = new CMathText(true);
operator.add(code); operator.add(code);
operator.setJustDraw(true);
} }
else else
operator = -1; operator = -1;
...@@ -3013,16 +3015,19 @@ COperator.prototype.draw = function(x, y, pGraphics) ...@@ -3013,16 +3015,19 @@ COperator.prototype.draw = function(x, y, pGraphics)
} }
COperator.prototype.drawOperator = function(absX, absY, pGraphics) COperator.prototype.drawOperator = function(absX, absY, pGraphics)
{ {
if(this.operator !== -1) if(this.typeOper !== OPERATOR_EMPTY)
{ {
var lng = this.coordGlyph.XX.length; var lng = this.coordGlyph.XX.length;
var X = new Array(), var X = new Array(),
Y = new Array(); Y = new Array();
var PosOper = this.Positions[0];
for(var j = 0; j < lng; j++) for(var j = 0; j < lng; j++)
{ {
X.push(this.pos.x + absX + this.coordGlyph.XX[j]); X.push(PosOper.x + absX + this.coordGlyph.XX[j]);
Y.push(this.pos.y + absY + this.coordGlyph.YY[j]); Y.push(PosOper.y + absY + this.coordGlyph.YY[j]);
} }
this.operator.draw(pGraphics, X, Y); this.operator.draw(pGraphics, X, Y);
...@@ -3030,18 +3035,21 @@ COperator.prototype.drawOperator = function(absX, absY, pGraphics) ...@@ -3030,18 +3035,21 @@ COperator.prototype.drawOperator = function(absX, absY, pGraphics)
} }
COperator.prototype.drawSeparator = function(absX, absY, pGraphics) COperator.prototype.drawSeparator = function(absX, absY, pGraphics)
{ {
if(this.operator !== -1) if(this.typeOper !== OPERATOR_EMPTY)
{ {
var lng = this.coordGlyph.XX.length; var lng = this.coordGlyph.XX.length;
for(var i = 0; i < this.pos.length; i++) for(var i = 0; i < this.Positions.length; i++)
{ {
var X = new Array(), var X = new Array(),
Y = new Array(); Y = new Array();
var PosOper = this.Positions[i];
for(var j = 0; j < lng; j++) for(var j = 0; j < lng; j++)
{ {
X.push(this.pos[i].x + absX + this.coordGlyph.XX[j]); X.push(PosOper.x + absX + this.coordGlyph.XX[j]);
Y.push(this.pos[i].y + absY + this.coordGlyph.YY[j]); Y.push(PosOper.y + absY + this.coordGlyph.YY[j]);
} }
this.operator.draw(pGraphics, X, Y); this.operator.draw(pGraphics, X, Y);
...@@ -3117,7 +3125,7 @@ COperator.prototype.old_fixSize = function(oMeasure, stretch) ...@@ -3117,7 +3125,7 @@ COperator.prototype.old_fixSize = function(oMeasure, stretch)
COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch) COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch)
{ {
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
if(this.operator !== -1) if(this.typeOper !== OPERATOR_EMPTY)
{ {
var width, height, ascent; var width, height, ascent;
...@@ -3183,13 +3191,21 @@ COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch) ...@@ -3183,13 +3191,21 @@ COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch)
else // vertical else // vertical
ascent = height/2 + shCenter; ascent = height/2 + shCenter;
this.size = { width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
} }
COperator.prototype.setPosition = function(pos) COperator.prototype.setPosition = function(Positions)
{ {
this.pos = pos; // для оператора, это будет просто позиция // для оператора, это будет просто позиция
// для сепаратора - массив позиций // для сепаратора - массив позиций
if(this.type == OPER_SEPARATOR)
this.Positions = Positions;
else
{
this.Positions.length = 0;
this.Positions[0] = Positions;
}
if(this.typeOper == OPERATOR_TEXT) if(this.typeOper == OPERATOR_TEXT)
{ {
...@@ -3203,14 +3219,31 @@ COperator.prototype.setPosition = function(pos) ...@@ -3203,14 +3219,31 @@ COperator.prototype.setPosition = function(pos)
this.operator.setPosition({x: x, y: y});*/ this.operator.setPosition({x: x, y: y});*/
var NewPos = new CMathPosition();
NewPos.x = this.Positions[0].x;
if(this.type == OPER_ACCENT) if(this.type == OPER_ACCENT)
NewPos.y = this.Positions[0].y + this.shiftAccent + this.operator.size.height;
else
NewPos.y = this.Positions[0].y;
var operator = this.operator;
if (!operator.bJDraw) // for text
{ {
this.operator.setPosition({x: pos.x, y: pos.y + this.shiftAccent + this.operator.size.height}); operator.pos.x = NewPos.x + operator.GapLeft;
operator.pos.y = NewPos.y;
//this.pos = {x : pos.x + this.GapLeft, y: pos.y};
}
else // for symbol only drawing
{
operator.pos.x = NewPos.x - operator.rasterOffsetX;
operator.pos.y = NewPos.y - operator.rasterOffsetY;
} }
else
this.operator.setPosition(pos);
}
this.operator.setPosition(NewPos);
}
} }
COperator.prototype.IsJustDraw = function() COperator.prototype.IsJustDraw = function()
{ {
...@@ -3221,7 +3254,7 @@ COperator.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -3221,7 +3254,7 @@ COperator.prototype.Resize = function(Parent, ParaMath, oMeasure)
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
this.Parent = Parent; this.Parent = Parent;
if(this.operator !== -1) if(this.typeOper !== OPERATOR_EMPTY)
{ {
var bHor = this.operator.loc == 0 || this.operator.loc == 1; var bHor = this.operator.loc == 0 || this.operator.loc == 1;
...@@ -3234,7 +3267,7 @@ COperator.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -3234,7 +3267,7 @@ COperator.prototype.Resize = function(Parent, ParaMath, oMeasure)
COperator.prototype.relate = function(parent) COperator.prototype.relate = function(parent)
{ {
this.Parent = parent; this.Parent = parent;
if(this.operator !== -1) if(this.typeOper !== OPERATOR_EMPTY)
this.operator.relate(this); this.operator.relate(this);
} }
COperator.prototype.Get_CompiledCtrPrp = function() COperator.prototype.Get_CompiledCtrPrp = function()
...@@ -3257,36 +3290,6 @@ COperator.prototype.IsArrow = function() ...@@ -3257,36 +3290,6 @@ COperator.prototype.IsArrow = function()
return this.operator.IsArrow(); return this.operator.IsArrow();
} }
function old_CSeparator(operator)
{
COperator.call(this, operator);
}
extend(old_CSeparator, COperator);
old_CSeparator.prototype.draw = function(pGraphics)
{
if(this.operator !== -1)
{
var lng = this.coordGlyph.XX.length;
for(var i = 0; i < this.positions.length; i++)
{
var X = new Array(),
Y = new Array();
for(var j = 0; j < lng; j++)
{
X.push(this.positions[i].x + this.coordGlyph.XX[j]);
Y.push(this.positions[i].y + this.coordGlyph.YY[j]);
}
this.operator.draw(pGraphics, X, Y);
}
}
}
old_CSeparator.prototype.setPosition = function(pos)
{
this.positions = pos;
}
function CDelimiter(props) function CDelimiter(props)
{ {
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
...@@ -3722,38 +3725,74 @@ CDelimiter.prototype.alignOperator = function(operator) // в качестве ...@@ -3722,38 +3725,74 @@ CDelimiter.prototype.alignOperator = function(operator) // в качестве
} }
CDelimiter.prototype.setPosition = function(position) CDelimiter.prototype.setPosition = function(position)
{ {
this.pos = {x: position.x, y: position.y - this.size.ascent}; this.pos.x = position.x;
this.pos.y = position.y - this.size.ascent;
var x = this.pos.x + this.GapLeft, var x = this.pos.x + this.GapLeft,
y = this.pos.y; y = this.pos.y;
var pos = {x: x, y: y + this.alignOperator(this.begOper)};
this.begOper.setPosition(pos); var PosBegOper = new CMathPosition();
PosBegOper.x = x;
PosBegOper.y = y + this.alignOperator(this.begOper);
this.begOper.setPosition(PosBegOper);
x += this.begOper.size.width; x += this.begOper.size.width;
var content = this.elements[0][0]; var content = this.elements[0][0];
pos = {x: x, y: y + this.align(content)};
content.setPosition(pos);
var PosContent = new CMathPosition();
PosContent.x = x;
PosContent.y = y + this.align(content);
x += content.size.width; x += content.size.width;
content.setPosition(PosContent); // CMathContent
var Positions = new Array(); var Positions = new Array();
for(var j = 1 ; j < this.nCol; j++) for(var j = 1 ; j < this.nCol; j++)
{ {
pos = {x: x, y: y + this.alignOperator(this.sepOper)}; var PosSep = new CMathPosition();
Positions.push(pos); PosSep.x = x;
PosSep.y = y + this.alignOperator(this.sepOper);
Positions.push(PosSep);
x += this.sepOper.size.width; x += this.sepOper.size.width;
content = this.elements[0][j]; content = this.elements[0][j];
pos = {x: x, y: y + this.align(content)};
content.setPosition(pos); var NewPosContent = new CMathPosition();
NewPosContent.x = x;
NewPosContent.y = y + this.align(content);
content.setPosition(NewPosContent);
x += content.size.width; x += content.size.width;
} }
this.sepOper.setPosition(Positions); this.sepOper.setPosition(Positions);
pos = {x: x, y: y + this.alignOperator(this.endOper)}; var PosEndOper = new CMathPosition();
this.endOper.setPosition(pos); PosEndOper.x = x;
PosEndOper.y = y + this.alignOperator(this.endOper);
this.endOper.setPosition(PosEndOper);
/*this.pos.x = position.x;
this.pos.y = position.y - this.size.ascent;
var x = this.pos.x + this.GapLeft,
y = this.pos.y;
var content = this.elements[0][0];
var PosContent = new CMathPosition();
PosContent.x = x;
PosContent.y = y + this.align(content);
x += content.size.width;
content.setPosition(PosContent); // CMathContent*/
} }
CDelimiter.prototype.findDisposition = function(pos) CDelimiter.prototype.findDisposition = function(pos)
{ {
...@@ -3978,34 +4017,38 @@ CCharacter.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -3978,34 +4017,38 @@ CCharacter.prototype.Resize = function(Parent, ParaMath, oMeasure)
} }
CCharacter.prototype.setPosition = function(pos) CCharacter.prototype.setPosition = function(pos)
{ {
this.pos = {x: pos.x, y: pos.y - this.size.ascent}; this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
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]);
var PosOper = new CMathPosition(),
PosBase = new CMathPosition();
if(this.Pr.pos === LOCATION_TOP) if(this.Pr.pos === LOCATION_TOP)
{ {
var x1 = this.pos.x + this.GapLeft + alignOp, PosOper.x = this.pos.x + this.GapLeft + alignOp;
y1 = this.pos.y; PosOper.y = this.pos.y;
this.operator.setPosition({x: x1, y: y1}); this.operator.setPosition(PosOper);
var x2 = this.pos.x + this.GapLeft + alignCnt, PosBase.x = this.pos.x + this.GapLeft + alignCnt;
y2 = this.pos.y + this.operator.size.height; PosBase.y = this.pos.y + this.operator.size.height;
this.elements[0][0].setPosition({x: x2, y: y2}); this.elements[0][0].setPosition(PosBase);
} }
else if(this.Pr.pos === LOCATION_BOT) else if(this.Pr.pos === LOCATION_BOT)
{ {
var x1 = this.pos.x + this.GapLeft + alignCnt, PosBase.x = this.pos.x + this.GapLeft + alignCnt;
y1 = this.pos.y; PosBase.y = this.pos.y;
this.elements[0][0].setPosition({x: x1, y: y1}); this.elements[0][0].setPosition(PosBase);
var x2 = this.pos.x + this.GapLeft + alignOp, PosOper.x = this.pos.x + this.GapLeft + alignOp;
y2 = this.pos.y + this.elements[0][0].size.height; PosOper.y = this.pos.y + this.elements[0][0].size.height;
this.operator.setPosition({x: x2, y: y2}); this.operator.setPosition(PosOper);
} }
} }
CCharacter.prototype.align = function(element) CCharacter.prototype.align = function(element)
...@@ -4342,7 +4385,7 @@ CGroupCharacter.prototype.old_getGlyph = function(code, type) ...@@ -4342,7 +4385,7 @@ CGroupCharacter.prototype.old_getGlyph = function(code, type)
///// /////
else if(typeof(code) !=="undefined" && code !== null) else if(typeof(code) !=="undefined" && code !== null)
{ {
operator = new CMathText(); operator = new CMathText(true);
operator.add(code); operator.add(code);
} }
else else
......
...@@ -1020,21 +1020,25 @@ CRadical.prototype.recalculateSize = function(oMeasure) ...@@ -1020,21 +1020,25 @@ CRadical.prototype.recalculateSize = function(oMeasure)
} }
CRadical.prototype.setPosition = function(pos) CRadical.prototype.setPosition = function(pos)
{ {
this.pos = {x: pos.x, y: pos.y - this.size.ascent}; this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
var PosBase = new CMathPosition(),
PosRadical = new CMathPosition();
if(this.Pr.type == SQUARE_RADICAL) if(this.Pr.type == SQUARE_RADICAL)
{ {
var gapLeft = this.size.width - this.elements[0][0].size.width; var gapLeft = this.size.width - this.elements[0][0].size.width;
var gapTop = this.size.ascent - this.elements[0][0].size.ascent; var gapTop = this.size.ascent - this.elements[0][0].size.ascent;
var x1 = this.pos.x + this.GapLeft, PosRadical.x = this.pos.x + this.GapLeft;
y1 = this.pos.y; PosRadical.y = this.pos.y;
var x2 = this.pos.x + this.GapLeft + gapLeft, PosBase.x = this.pos.x + this.GapLeft + gapLeft;
y2 = this.pos.y + gapTop; PosBase.y = this.pos.y + gapTop;
this.signRadical.setPosition({x: x1, y: y1}); this.signRadical.setPosition(PosRadical);
this.elements[0][0].setPosition({x: x2, y: y2}); this.elements[0][0].setPosition(PosBase);
} }
else if(this.Pr.type == DEGREE_RADICAL) else if(this.Pr.type == DEGREE_RADICAL)
{ {
...@@ -1044,21 +1048,25 @@ CRadical.prototype.setPosition = function(pos) ...@@ -1044,21 +1048,25 @@ CRadical.prototype.setPosition = function(pos)
var wTick = this.signRadical.measure.widthTick; var wTick = this.signRadical.measure.widthTick;
var x1 = this.pos.x + this.GapLeft + this.gapWidth, var PosDegree = new CMathPosition();
y1 = this.pos.y + this.gapDegree;
PosDegree.x = this.pos.x + this.GapLeft + this.gapWidth;
PosDegree.y = this.pos.y + this.gapDegree;
this.elements[0][0].setPosition({x: x1, y: y1}); this.elements[0][0].setPosition(PosDegree);
var wDegree = degr.width > wTick ? degr.width - wTick : 0; var wDegree = degr.width > wTick ? degr.width - wTick : 0;
var x2 = this.pos.x + this.GapLeft + wDegree,
y2 = this.pos.y + this.size.height - sign.height;
this.signRadical.setPosition({x: x2, y: y2}); PosRadical.x = this.pos.x + this.GapLeft + wDegree;
PosRadical.y = this.pos.y + this.size.height - sign.height;
this.signRadical.setPosition(PosRadical);
PosBase.x = this.pos.x + this.GapLeft + this.size.width - base.width;
PosBase.y = this.pos.y + this.size.ascent - base.ascent;
var x3 = this.pos.x + this.GapLeft + this.size.width - base.width,
y3 = this.pos.y + this.size.ascent - base.ascent;
this.elements[0][1].setPosition({x: x3, y: y3}); this.elements[0][1].setPosition(PosBase);
} }
} }
CRadical.prototype.findDisposition = function(mCoord) CRadical.prototype.findDisposition = function(mCoord)
......
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