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

separator, group characters

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@49721 954022d7-b5bf-4e40-9824-e11837661b57
parent 586300f0
......@@ -615,7 +615,6 @@ CMathBase.prototype =
var mouseCoord = {x: null, y: null},
posCurs = {x: null, y: null};
var sumWidth = 0;
var sumHeight = 0;
......
......@@ -454,8 +454,8 @@ CMathContent.prototype =
case MATH_DELIMITER:
mathElem = new CDelimiter();
break;
case MATH_SEPARATOR_DELIMITER:
mathElem = new CSeparatorDelimiter();
case MATH_GROUP_CHARACTER:
mathElem = new CGroupCharacter();
break;
case MATH_FUNCTION:
mathElem = new CMathFunc();
......@@ -3325,12 +3325,20 @@ CMathContent.prototype =
break;
case 96:
var delim = this.addMComponent(MATH_DELIMITER);
var props =
/* var props =
{
begChr: {type: PARENTHESIS_LEFT},
sepChr: {type: BRACKET_ANGLE_LEFT},
endChr: {type: BRACKET_CURLY_RIGHT},
column: 2
};*/
var props =
{
begChr: {type: PARENTHESIS_LEFT},
sepChr: {type: DELIMITER_LINE},
endChr: {type: PARENTHESIS_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 2
};
delim.init(props);
delim.fillPlaceholders();
......@@ -3339,153 +3347,313 @@ CMathContent.prototype =
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: PARENTHESIS_LEFT},
sepChr: {type: BRACKET_ANGLE_LEFT},
endChr: {type: BRACKET_CURLY_RIGHT},
column: 5
begChr: {type: BRACKET_CURLY_LEFT},
sepChr: {type: DELIMITER_LINE},
endChr: {type: BRACKET_CURLY_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 2
};
delim.init(props);
delim.fillPlaceholders();
break;
break;
case 98:
var delim = this.addMComponent(10);
delim.init(3, 2);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: BRACKET_ANGLE_LEFT},
sepChr: {type: DELIMITER_LINE},
endChr: {type: BRACKET_ANGLE_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 2
};
delim.init(props);
delim.fillPlaceholders();
break;
case 99:
var delim = this.addMComponent(10);
delim.init(3, 3);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: BRACKET_ANGLE_LEFT},
sepChr: {type: DELIMITER_LINE},
endChr: {type: BRACKET_ANGLE_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 3
};
delim.init(props);
delim.fillPlaceholders();
break;
case 100:
var delim = this.addMComponent(9);
delim.init(0,2,0);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: PARENTHESIS_LEFT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 101:
var delim = this.addMComponent(9);
delim.init(0,3,1);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
endChr: {type: PARENTHESIS_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 102:
var delim = this.addMComponent(9);
delim.init(2,2,0);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: BRACKET_SQUARE_LEFT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 103:
var delim = this.addMComponent(9);
delim.init(2,3,1);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
endChr: {type: BRACKET_SQUARE_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 104:
var delim = this.addMComponent(9);
delim.init(1,2,0);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: BRACKET_CURLY_LEFT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 105:
var delim = this.addMComponent(9);
delim.init(1,3,1);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
endChr: {type: BRACKET_CURLY_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 106:
var delim = this.addMComponent(9);
delim.init(3,2,0);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: BRACKET_ANGLE_LEFT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 107:
var delim = this.addMComponent(9);
delim.init(3,3,1);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
endChr: {type: BRACKET_ANGLE_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 108:
var delim = this.addMComponent(9);
delim.init(4,2,0);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: HALF_SQUARE_LEFT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 109:
var delim = this.addMComponent(9);
delim.init(4,3,1);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
endChr: {type: HALF_SQUARE_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 110:
var delim = this.addMComponent(9);
delim.init(4,2,2);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: HALF_SQUARE_LEFT_UPPER},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 111:
var delim = this.addMComponent(9);
delim.init(4,3,3);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
endChr: {type: HALF_SQUARE_RIGHT_UPPER},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 112:
var delim = this.addMComponent(9);
delim.init(5,2,0);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: DELIMITER_LINE},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 113:
var delim = this.addMComponent(9);
delim.init(5,3,1);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
endChr: {type: DELIMITER_LINE},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 114:
var delim = this.addMComponent(9);
delim.init(6,2,0);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: DELIMITER_DOUBLE_LINE},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 115:
var delim = this.addMComponent(9);
delim.init(6,3,1);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
endChr: {type: DELIMITER_DOUBLE_LINE},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 116:
var delim = this.addMComponent(9);
delim.init(7,2,0);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: WHITE_SQUARE_LEFT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 117:
var delim = this.addMComponent(9);
delim.init(7,3,1);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
endChr: {type: WHITE_SQUARE_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
delim.fillPlaceholders();
break;
case 118:
var delim = this.addMComponent(9);
delim.init(1,2,0);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: BRACKET_CURLY_LEFT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
var base = delim.getBase();
var matrix = base.addMComponent(21);
matrix.init(2, 1);
var matrix = base.addMComponent(MATH_MATRIX);
var props =
{
row : 2,
column: 1
};
matrix.init(props);
matrix.fillPlaceholders();
break;
case 119:
var delim = this.addMComponent(9);
delim.init(1,2,0);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: BRACKET_CURLY_LEFT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
var base = delim.getBase();
var matrix = base.addMComponent(21);
matrix.init(3, 1);
var matrix = base.addMComponent(MATH_MATRIX);
var props =
{
row : 3,
column: 1
};
matrix.init(props);
matrix.fillPlaceholders();
break;
case 120:
var fract = this.addMComponent(0);
fract.init();
fract.hideBar(true);
var fract = this.addMComponent(MATH_FRACTION);
fract.init({type: NO_BAR_FRACTION});
fract.fillPlaceholders();
break;
case 121:
var delim = this.addMComponent(9);
delim.init(0, 4, 0, 1);
var fract = delim.getBase().addMComponent(0);
fract.init();
fract.hideBar(true);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: PARENTHESIS_LEFT},
endChr: {type: PARENTHESIS_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
var base = delim.getBase();
var fract = base.addMComponent(MATH_FRACTION);
fract.init({type: NO_BAR_FRACTION});
fract.fillPlaceholders();
break;
case 122:
break;
case 123:
var delim = this.addMComponent(9);
delim.init(0, 4, 0, 1);
var fract = delim.getBase().addMComponent(0);
fract.init();
fract.hideBar(true);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: PARENTHESIS_LEFT},
endChr: {type: PARENTHESIS_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
var base = delim.getBase();
var fract = base.addMComponent(MATH_FRACTION);
fract.init({type: NO_BAR_FRACTION});
var num = fract.getNumerator();
num.addTxt("n");
......@@ -3493,11 +3661,18 @@ CMathContent.prototype =
den.addTxt("k");
break;
case 124:
var delim = this.addMComponent(9);
delim.init(3, 4, 0, 1);
var fract = delim.getBase().addMComponent(0);
fract.init();
fract.hideBar(true);
var delim = this.addMComponent(MATH_DELIMITER);
var props =
{
begChr: {type: BRACKET_ANGLE_LEFT},
endChr: {type: BRACKET_ANGLE_RIGHT},
shapeType: DELIMITER_SHAPE_MATH,
column: 1
};
delim.init(props);
var base = delim.getBase();
var fract = base.addMComponent(MATH_FRACTION);
fract.init({type: NO_BAR_FRACTION});
var num = fract.getNumerator();
num.addTxt("n");
......@@ -3861,50 +4036,87 @@ CMathContent.prototype =
line.fillPlaceholders();
break;
case 163:
var delim = this.addMComponent(9);
/*var delim = this.addMComponent(9);
delim.init(1,0,1);
delim.fillPlaceholders();*/
var delim = this.addMComponent(MATH_GROUP_CHARACTER);
var props =
{
chr: {type: BRACKET_CURLY_TOP},
location: LOCATION_TOP,
justif: VJUST_BOT
};
delim.init(props);
delim.fillPlaceholders();
break;
case 164:
var delim = this.addMComponent(9);
delim.init(1,1,2);
var delim = this.addMComponent(MATH_GROUP_CHARACTER);
var props =
{
location: LOCATION_BOT,
justif: VJUST_TOP
};
delim.init(props);
delim.fillPlaceholders();
break;
case 165:
var groupDelim = this.addMComponent(16);
groupDelim.init(1);
groupDelim.fillPlaceholders();
break;
case 166:
var groupDelim = this.addMComponent(16);
groupDelim.init(-1);
groupDelim.fillPlaceholders();
break;
case 167:
var arrow = this.addMComponent(17);
arrow.init(1, 0, 0); // left arrow top
arrow.fillPlaceholders();
var delim = this.addMComponent(MATH_GROUP_CHARACTER);
var props =
{
chr: {type: ARROW_LEFT},
location: LOCATION_TOP,
justif: VJUST_BOT
};
delim.init(props);
delim.fillPlaceholders();
break;
case 168:
var arrow = this.addMComponent(17);
arrow.init(1, 0, 1); // right arrow top
arrow.fillPlaceholders();
var delim = this.addMComponent(MATH_GROUP_CHARACTER);
var props =
{
chr: {type: ARROW_RIGHT},
location: LOCATION_TOP,
justif: VJUST_BOT
};
delim.init(props);
delim.fillPlaceholders();
break;
case 169:
var arrow = this.addMComponent(17);
arrow.init(2, 0, 0);
arrow.fillPlaceholders();
var delim = this.addMComponent(MATH_GROUP_CHARACTER);
var props =
{
chr: {type: ARROW_LR},
location: LOCATION_TOP,
justif: VJUST_BOT
};
delim.init(props);
delim.fillPlaceholders();
break;
case 170:
var arrow = this.addMComponent(17);
arrow.init(0, 0, 0);
arrow.fillPlaceholders();
var delim = this.addMComponent(MATH_GROUP_CHARACTER);
var props =
{
chr: {type: HALF_ARROW_LEFT},
location: LOCATION_TOP,
justif: VJUST_BOT
};
delim.init(props);
delim.fillPlaceholders();
break;
case 171:
var arrow = this.addMComponent(17);
arrow.init(0, 0, 1);
arrow.fillPlaceholders();
break;
var delim = this.addMComponent(MATH_GROUP_CHARACTER);
var props =
{
chr: {type: HALF_ARROW_RIGHT},
location: LOCATION_TOP,
justif: VJUST_BOT
};
delim.init(props);
delim.fillPlaceholders();
case 172:
break;
case 173:
......
......@@ -4,7 +4,7 @@ var MATH_DEGREESubSup = 2;
var MATH_RADICAL = 3;
var MATH_NARY = 4;
var MATH_DELIMITER = 5;
var MATH_SEPARATOR_DELIMITER = 6;
var MATH_GROUP_CHARACTER = 6;
var MATH_FUNCTION = 7;
var MATH_ACCENT = 8;
var MATH_BORDER_BOX = 9;
......@@ -66,11 +66,14 @@ var DELIMITER_LINE = 12;
var DELIMITER_DOUBLE_LINE = 13;
var WHITE_SQUARE_LEFT = 14;
var WHITE_SQUARE_RIGHT = 15;
var BRACKET_CURLY_TOP = 16;
var BRACKET_CURLY_BOTTOM = 17;
var ARROW_LEFT = 18;
var ARROW_RIGHT = 19;
var ARROW_LR = 20;
var HALF_ARROW_LEFT = 21;
var HALF_ARROW_RIGHT = 22;
var DELIMITER_LOCATION_TOP = 0;
var DELIMITER_LOCATION_BOTTOM = 1;
var DELIMITER_LOCATION_LEFT = 2;
var DELIMITER_LOCATION_RIGHT = 3;
var DELIMITER_TURN_0 = 0;
var DELIMITER_TURN_180 = 1;
var DELIMITER_TURN_MIRROR_0 = 2;
......
var BEGINNING_CHR = 0;
var SEPARATOR_CHR = 1;
var ENDING_CHR = 2;
var TOP_CHR = 3;
var BOTTOM_CHR = 4;
var LOCATION_TOP = 0;
var LOCATION_BOT = 1;
var LOCATION_LEFT = 2;
var LOCATION_RIGHT = 3;
var LOCATION_SEP = 4;
var VJUST_TOP = 0;
var VJUST_BOT = 1;
function CGlyphOperator()
{
......@@ -107,11 +108,16 @@ CGlyphOperator.prototype.draw_other = function() // с выравнивание
a1 = 0; b1 = 1; c1 = 0;
a2 = 1; b2 = 0; c2 = shH;
}
else
else if(this.loc == 3)
{
a1 = 0; b1 = 1; c1 = W - glW;
a2 = 1; b2 = 0; c2 = shH;
}
else if(this.loc == 4)
{
a1 = 0; b1 = 1; c1 = shW;
a2 = 1; b2 = 0; c2 = 0;
}
if(this.turn == 1)
{
......@@ -205,7 +211,6 @@ CGlyphOperator.prototype.getCoordinateGlyph = function()
W = this.size.width, H = this.size.height;
var bHor = this.loc == 0 || this.loc == 1;
var glW = 0, glH = 0;
if(bHor)
......@@ -219,19 +224,19 @@ CGlyphOperator.prototype.getCoordinateGlyph = function()
glH = coord.W;
}
var shW = (W - glW)/ 2, // выравниваем глиф по длине
shH = (H - glH)/2; // при повороте на 90 градусовы
var shW = (W - glW)/ 2, // выравниваем глиф по длине
shH = (H - glH)/2; // при повороте на 90 градусовы
// A*x + B*y + C = 0
if(bHor)
{
a1 = 1; b1 = 0; c1 = 0;
a2 = 0; b2 = 1; c2 = shH;
a2 = 0; b2 = 1; c2 = 0;
}
else
{
a1 = 0; b1 = 1; c1 = shW;
a1 = 0; b1 = 1; c1 = 0;
a2 = 1; b2 = 0; c2 = 0;
}
......@@ -251,16 +256,16 @@ CGlyphOperator.prototype.getCoordinateGlyph = function()
if(this.turn == 1)
{
a1 *= -1; b1 *= -1; c1 = W - c1; //c1 = W - c1;
a1 *= -1; b1 *= -1; c1 = glW;
}
else if(this.turn == 2)
{
a2 *= -1; b2 *= -1; c2 = H - c2;
a2 *= -1; b2 *= -1; c2 = H;
}
else if(this.turn == 3)
{
a1 *= -1; b1 *= -1; c1 = W - c1;
a2 *= -1; b2 *= -1; c2 = H - c2;
a1 *= -1; b1 *= -1; c1 = glW;
a2 *= -1; b2 *= -1; c2 = H;
}
var gpX = 0,
......@@ -709,7 +714,7 @@ old_CGlyphOperator.prototype.setTxtPrp = function(txtPrp)
}
function old_CDelimiter() /// ECMA: group characters
function old_CDelimiter()
{
// location
......@@ -995,7 +1000,7 @@ function GetGlyph(chr, location)
operator = new COperatorParenthesis();
var props =
{
location: DELIMITER_LOCATION_LEFT,
location: location,
turn: DELIMITER_TURN_0
};
operator.init(props);
......@@ -1005,7 +1010,7 @@ function GetGlyph(chr, location)
operator = new COperatorParenthesis();
var props =
{
location: DELIMITER_LOCATION_RIGHT,
location: location,
turn: DELIMITER_TURN_180
};
operator.init(props);
......@@ -1015,7 +1020,7 @@ function GetGlyph(chr, location)
operator = new COperatorBracket();
var props =
{
location: DELIMITER_LOCATION_LEFT,
location: location,
turn: DELIMITER_TURN_0
};
operator.init(props);
......@@ -1025,7 +1030,7 @@ function GetGlyph(chr, location)
operator = new COperatorBracket();
var props =
{
location: DELIMITER_LOCATION_RIGHT,
location: location,
turn: DELIMITER_TURN_180
};
operator.init(props);
......@@ -1035,8 +1040,7 @@ function GetGlyph(chr, location)
operator = new CSquareBracket();
var props =
{
location: DELIMITER_LOCATION_LEFT,
//location: location,
location: location,
turn: DELIMITER_TURN_0
};
operator.init(props);
......@@ -1046,8 +1050,7 @@ function GetGlyph(chr, location)
operator = new CSquareBracket();
var props =
{
location: DELIMITER_LOCATION_RIGHT,
//location: location,
location: location,
turn: DELIMITER_TURN_180
};
operator.init(props);
......@@ -1057,7 +1060,8 @@ function GetGlyph(chr, location)
operator = new COperatorAngleBracket();
var props =
{
location: DELIMITER_LOCATION_LEFT,
location: location,
//location: DELIMITER_LOCATION_LEFT,
turn: DELIMITER_TURN_0
};
operator.init(props);
......@@ -1067,7 +1071,8 @@ function GetGlyph(chr, location)
operator = new COperatorAngleBracket();
var props =
{
location: DELIMITER_LOCATION_RIGHT,
//location: DELIMITER_LOCATION_RIGHT,
location: location,
turn: DELIMITER_TURN_180
};
operator.init(props);
......@@ -1077,7 +1082,8 @@ function GetGlyph(chr, location)
operator = new COperatorLine();
var props =
{
location: DELIMITER_LOCATION_LEFT,
location: location,
//location: DELIMITER_LOCATION_LEFT,
turn: DELIMITER_TURN_0
};
operator.init(props);
......@@ -1087,7 +1093,8 @@ function GetGlyph(chr, location)
operator = new CHalfSquareBracket();
var props =
{
location: DELIMITER_LOCATION_LEFT,
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: DELIMITER_TURN_0
};
operator.init(props);
......@@ -1097,7 +1104,8 @@ function GetGlyph(chr, location)
operator = new CHalfSquareBracket();
var props =
{
location: DELIMITER_LOCATION_LEFT,
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: DELIMITER_TURN_180
};
operator.init(props);
......@@ -1107,7 +1115,8 @@ function GetGlyph(chr, location)
operator = new CHalfSquareBracket();
var props =
{
location: DELIMITER_LOCATION_LEFT,
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: DELIMITER_TURN_MIRROR_0
};
operator.init(props);
......@@ -1117,7 +1126,8 @@ function GetGlyph(chr, location)
operator = new CHalfSquareBracket();
var props =
{
location: DELIMITER_LOCATION_LEFT,
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: DELIMITER_TURN_MIRROR_180
};
operator.init(props);
......@@ -1127,8 +1137,9 @@ function GetGlyph(chr, location)
operator = new COperatorDoubleLine();
var props =
{
location: DELIMITER_LOCATION_LEFT,
turn: DELIMITER_TURN_MIRROR_180
location: location,
//location: DELIMITER_LOCATION_LEFT,
turn: DELIMITER_TURN_0
};
operator.init(props);
}
......@@ -1137,7 +1148,8 @@ function GetGlyph(chr, location)
operator = new CWhiteSquareBracket();
var props =
{
location: DELIMITER_LOCATION_LEFT,
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: DELIMITER_TURN_0
};
operator.init(props);
......@@ -1147,7 +1159,8 @@ function GetGlyph(chr, location)
operator = new CWhiteSquareBracket();
var props =
{
location: DELIMITER_LOCATION_LEFT,
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: DELIMITER_TURN_180
};
operator.init(props);
......@@ -1161,6 +1174,100 @@ function GetGlyph(chr, location)
return operator;
}
function GetGlyph_GrChr(chr, location)
{
var operator;
if(typeof(chr) === "undefined" ||chr === null)
{
{
operator = new COperatorBracket();
var props =
{
location: LOCATION_BOT,
turn: DELIMITER_TURN_MIRROR_0
};
operator.init(props);
}
}
else if(chr.value === "" || chr.type == BRACKET_CURLY_TOP)
{
operator = new COperatorBracket();
var props =
{
location: location,
turn: DELIMITER_TURN_0
};
operator.init(props);
}
else if(chr.value === "" || chr.type === BRACKET_CURLY_BOTTOM )
{
operator = new COperatorBracket();
var props =
{
location: location,
turn: DELIMITER_TURN_MIRROR_0
};
operator.init(props);
}
else if(chr.value === "" || chr.type === ARROW_LEFT)
{
operator = new CSingleArrow();
var props =
{
location: location,
turn: DELIMITER_TURN_0
};
operator.init(props);
}
else if(chr.value === "" || chr.type === ARROW_RIGHT)
{
operator = new CSingleArrow();
var props =
{
location: location,
turn: DELIMITER_TURN_180
};
operator.init(props);
}
else if(chr.value === "" || chr.type === ARROW_LR)
{
operator = new CLeftRightArrow();
var props =
{
location: location,
turn: DELIMITER_TURN_0
};
operator.init(props);
}
else if(chr.value === "" || chr.type === HALF_ARROW_LEFT)
{
operator = new CCombiningHalfArrow();
var props =
{
location: location,
turn: DELIMITER_TURN_0
};
operator.init(props);
}
else if(chr.value === "" || chr.type === HALF_ARROW_RIGHT)
{
operator = new CCombiningHalfArrow();
var props =
{
location: location,
turn: DELIMITER_TURN_180
};
operator.init(props);
}
return operator;
}
function CBaseDelimiter()
{
// location
......@@ -3140,7 +3247,8 @@ CSingleArrow.prototype.calcCoord = function(measure)
YY[i] = Y[i]*alpha;
}
var lng = measure - 10000*alpha;
//var lng = measure - 10000*alpha;
var lng = measure;
if(lng > XX[9])
{
......@@ -3231,7 +3339,7 @@ CLeftRightArrow.prototype.calcCoord = function(measure)
var w = X[10]*alpha;
var lng = measure - 10000*alpha - w;
var lng = measure - w;
if(lng > 0)
for(var i = 0; i < 8; i++)
......@@ -3909,9 +4017,9 @@ CDelimiter.prototype.init = function(props)
else
this.grow = true;
this.begOper = new COperator ( GetGlyph(props.begChr, BEGINNING_CHR) );
this.endOper = new COperator ( GetGlyph(props.endChr, ENDING_CHR) );
this.sepOper = new COperator ( GetGlyph(props.sepChr, SEPARATOR_CHR) );
this.begOper = new COperator ( GetGlyph(props.begChr, LOCATION_LEFT) );
this.endOper = new COperator ( GetGlyph(props.endChr, LOCATION_RIGHT) );
this.sepOper = new COperator ( GetGlyph(props.sepChr, LOCATION_SEP) );
var tPrp = this.getTxtPrp();
this.begOper.setTxtPrp(tPrp);
......@@ -3933,17 +4041,17 @@ CDelimiter.prototype.recalculateSize = function()
var height = 0,
width = 0, center = 0;
var ascent = 0,
descent = 0;
if(this.shape == DELIMITER_SHAPE_CENTERED)
{
var ascent = 0,
descent = 0;
for(var j = 0; j < this.nCol; j++)
{
var content = this.elements[0][j].size;
width += content.width;
ascent = content.center > ascent ? content.center : ascent;
descent = content.height - content.center > descent ? content.height - content.center : descent;
descent = content.height - content.center > descent ? content.height - content.center: descent;
}
height = ascent > descent ? 2*ascent : 2*descent;
......@@ -3956,22 +4064,38 @@ CDelimiter.prototype.recalculateSize = function()
{
var content = this.elements[0][j].size;
width += content.width;
center = content.center > center ? content.center : center;
height = content.height > height ? content.height : height;
ascent = content.center > ascent ? content.center : ascent;
descent = content.height - content.center > descent ? content.height - content.center: descent;
}
height = ascent + descent;
center = ascent;
}
this.begOper.fixSize(height);
width += this.begOper.size.width;
height = (height < this.begOper.size.height) ? this.begOper.size.height : height;
if(height < this.begOper.size.height)
{
height = this.begOper.size.height;
center = this.begOper.size.center;
}
this.endOper.fixSize(height);
width += this.endOper.size.width;
height = (height < this.endOper.size.height) ? this.endOper.size.height : height;
if(height < this.endOper.size.height)
{
height = this.endOper.size.height;
center = this.endOper.size.center;
}
this.sepOper.fixSize(height);
width += (this.nCol - 1)*this.sepOper.size.width;
height = (height < this.sepOper.size.height) ? this.sepOper.size.height : height;
if(height < this.endOper.size.height)
{
height = this.sepOper.size.height;
center = this.sepOper.size.center;
}
/*if(this.begOper !== -1)
......@@ -4076,68 +4200,71 @@ CDelimiter.prototype.setPosition = function(position)
pos = {x: x, y: y + this.align(this.endOper)};
this.endOper.setPosition([pos]);
/*for(var j = 0; j < this.nCol; j++)
{
var align = this.size.center - this.elements[0][j].size.center;
var position = { x: x1, y: y1 + align};
//var position = { x: x1, y: y1 };
this.elements[0][j].setPosition(position);
x1 += this.elements[0][j].size.width;
if(this.sepOper !== -1)
x1 += this.sepOper.size.width;
}*/
}
CDelimiter.prototype.findDisposition = function(pos)
{
var curs_X = 0,
curs_Y = 0;
var X, Y;
}
CDelimiter.prototype.draw = function()
{
/*
var x1 = this.pos.x,
y1 = this.pos.y;
var inside_flag = -1;
if(this.begOper !== -1)
if(pos.x < this.begOper.size.width)
{
var begCoord = this.begOper.getCoordinateGlyph();
var begPos = {x: x1, y: y1 + this.alignOperator(begCoord.H)};
this.drawOperator(begPos, begCoord, this.begOper);
x1 += this.begOper.size.width;
curs_Y = 0;
X = 0;
inside_flag = 0;
}
if(this.sepOper !== -1)
else if(pos.x > this.size.width - this.endOper.size.width)
{
var sepCoord = this.sepOper.getCoordinateGlyph();
for(var j = 0; j < this.nCol-1; j++)
{
var sepPos = {x: x1 + this.elements[0][j].size.width, y: y1};
this.drawOperator(sepPos, sepCoord, this.sepOper);
x1 += this.sepOper.size.width + this.elements[0][j].size.width;
}
x1 += this.elements[0][this.nCol-1].size.width;
curs_Y = this.nCol - 1;
X = this.elements[0][this.nCol - 1].size.width;
inside_flag = 1;
}
else
{
var xx = this.begOper.size.width;
for(var j = 0; j < this.nCol; j++)
x1 += this.elements[0][j].size.width;
{
if(xx + this.elements[0][j].size.width + this.sepOper.size.width/2 > pos.x)
{
curs_Y = j;
if( pos.x < xx + this.elements[0][j].size.width)
X = pos.x - xx;
else
X = xx + this.elements[0][j].size.width;
break;
}
xx += this.elements[0][j].size.width + this.sepOper.size.width;
}
}
if(this.endOper !== -1)
var align = this.align( this.elements[0][curs_Y]);
if(align > pos.y)
{
Y = 0;
inside_flag = 2;
}
else if(this.elements[0][curs_Y].size.height + align < pos.y)
{
var endCoord = this.endOper.getCoordinateGlyph();
var endPos = {x: x1, y: y1};
Y = this.elements[0][curs_Y].size.height;
inside_flag = 2;
}
else
Y = pos.y - align;
this.drawOperator(endPos, endCoord, this.endOper);
}*/
var mouseCoord = {x: X, y: Y},
posCurs = {x: curs_X, y: curs_Y};
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
CDelimiter.prototype.draw = function()
{
this.begOper.draw();
this.sepOper.draw();
this.endOper.draw();
......@@ -4168,6 +4295,14 @@ CDelimiter.prototype.align = function(element)
return align;
}
CDelimiter.prototype.getBase = function(numb)
{
if(numb !== numb - 0)
numb = 0;
return this.elements[0][numb];
}
function COperator(glyph)
......@@ -4204,13 +4339,25 @@ COperator.prototype.fixSize = function(measure)
{
this.glyph.fixSize(measure);
var dims = this.glyph.getCoordinateGlyph();
this.coordGlyph = {XX: dims.XX, YY: dims.YY};
var width = this.glyph.size.width > dims.Width ? this.glyph.size.width : dims.Width,
height = this.glyph.size.height > dims.Height ? this.glyph.size.height : dims.Height;
var width, height;
if(this.glyph.loc == 0 || this.glyph.loc == 1)
{
width = measure > this.glyph.size.width ? measure : this.glyph.size.width;
height = this.glyph.size.height;
}
else
{
height = this.glyph.size.height;
width = measure > this.glyph.size.width ? measure : this.glyph.size.width; //this.glyph.size.width;
}
var betta = this.TxtPrp.FontSize/36;
var center = height/2 + 0.2*betta;
this.size = { width: width, height: height, center: height/2};
this.size = { width: width, height: height, center: center};
}
}
COperator.prototype.setPosition = function(positions)
......@@ -4239,6 +4386,140 @@ COperator.prototype.relate = function(parent)
}
COperator.prototype.setTxtPrp = function(txtPrp)
{
this.TxtPrp = txtPrp;
if(this.glyph !== -1)
this.glyph.setTxtPrp(txtPrp);
}
function CGroupCharacter()
{
this.operator = null;
this.vertJust = VJUST_TOP;
this.loc = LOCATION_BOT;
CSubMathBase.call(this);
}
extend(CGroupCharacter, CSubMathBase);
CGroupCharacter.prototype.init = function(props)
{
if(props.pos === "top" || props.location === LOCATION_TOP)
this.loc = LOCATION_TOP;
else if(props.pos === "bot" || props.location === LOCATION_BOT)
this.loc = LOCATION_BOT;
if(props.vertJust === "top" || props.justif == VJUST_TOP)
this.vertJust = VJUST_TOP;
else if(props.vertJust === "bottom"|| props.justif == VJUST_BOT)
this.vertJust = VJUST_BOT;
this.operator = new COperator ( GetGlyph_GrChr(props.chr, this.loc) );
var tPrp = this.getTxtPrp();
this.operator.setTxtPrp(tPrp);
this.setDimension(1, 1);
this.setContent();
}
CGroupCharacter.prototype.recalculateSize = function()
{
var content = this.elements[0][0];
this.operator.fixSize(this.elements[0][0].size.width);
var width = content.size.width > this.operator.size.width ? content.size.width : this.operator.size.width,
height = content.size.height + this.operator.size.height,
center;
if(this.vertJust === VJUST_TOP && this.loc === LOCATION_TOP)
center = this.operator.size.height/2;
else if(this.vertJust === VJUST_BOT && this.loc === LOCATION_TOP )
center = this.operator.size.height + this.elements[0][0].size.center;
else if(this.vertJust === VJUST_TOP && this.loc === LOCATION_BOT )
center = this.elements[0][0].size.center;
else if(this.vertJust === VJUST_BOT && this.loc === LOCATION_BOT )
center = this.operator.size.height/2 + this.elements[0][0].size.height;
this.size = {height: height, width: width, center: center};
}
CGroupCharacter.prototype.draw = function()
{
this.elements[0][0].draw();
this.operator.draw();
}
CGroupCharacter.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
var alignOp = this.align(this.operator),
alignCnt = this.align(this.elements[0][0]);
if(this.loc === LOCATION_TOP)
{
var pos = {x: this.pos.x + alignOp, y: this.pos.y};
this.operator.setPosition([pos]);
pos = {x: this.pos.x + alignCnt, y: this.pos.y + this.operator.size.height};
this.elements[0][0].setPosition(pos);
}
else if(this.loc === LOCATION_BOT)
{
var pos = {x: this.pos.x + alignCnt, y: this.pos.y};
this.elements[0][0].setPosition(pos);
pos = {x: this.pos.x + alignOp, y: this.pos.y + this.elements[0][0].size.height};
this.operator.setPosition([pos]);
}
}
CGroupCharacter.prototype.align = function(element)
{
return (this.size.width - element.size.width)/2;
}
CGroupCharacter.prototype.findDisposition = function(pos)
{
var curs_X = 0,
curs_Y = 0;
var X, Y;
var inside_flag = -1;
var content = this.elements[0][0],
align = this.align(content);
if(pos.x < align)
{
X = 0;
inside_flag = 0;
}
else if(pos.x > align + content.size.width)
{
X = content.size.width;
inside_flag = 1;
}
else
X = pos.x - align;
if(this.loc === LOCATION_TOP)
{
if(pos.y < this.operator.size.height)
{
Y = 0;
inside_flag = 2;
}
else
Y = pos.y - this.operator.size.height;
}
else if(this.loc === LOCATION_BOT)
{
if(pos.y > content.size.height)
{
Y = content.size.height;
inside_flag = 2;
}
else
Y = pos.y;
}
var mouseCoord = {x: X, y: Y},
posCurs = {x: curs_X, y: curs_Y};
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
\ No newline at end of file
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