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

accent: dot, two dots, three dots, accent grave, accent acute, breve

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@49850 954022d7-b5bf-4e40-9824-e11837661b57
parent aa2666aa
......@@ -523,7 +523,7 @@ CLine.prototype.draw_doubleLine = function()
}
// TODO: установить смещение в зависимости от наклона буквы (как в old_CAccent)
function CSign()
/*function CSign()
{
this.index = null;
CBaseDiacritic.call(this);
......@@ -561,7 +561,7 @@ CSign.prototype.recalculateSize = function()
this.shiftArg = (this.size.width - arg.width)/2;
this.shiftAccent = (this.size.width - widthAcc)/2;
/*var accent = new CMathText(this.params);
*//*var accent = new CMathText(this.params);
accent.init(0x303);
//accent.setIndefSize(SizeDiacritic);
var size = accent.size;
......@@ -569,7 +569,7 @@ CSign.prototype.recalculateSize = function()
accent = new CMathText(this.params);
accent.init(0x32E);
accent.setIndefSize(SizeDiacritic);
size = accent.size;*/
size = accent.size;*//*
}
CSign.prototype.draw = function()
......@@ -761,17 +761,14 @@ CSign.prototype.draw_breve = function(up)
MathControl.pGraph.SetIntegerGrid(intGrid);
}
}*/
function CTilde()
{
this.incline = 0;
CBaseDiacritic.call(this);
}
extend(CTilde, CBaseDiacritic);
CTilde.prototype.fixSize = function()
{
var betta = this.getTxtPrp().FontSize/36;
var betta = this.txtPrp.FontSize/36;
var width = 9.047509765625*betta; // реальная на отрисовке width 7.495282031249999
var height = 2.469444444444444*betta;
......@@ -815,7 +812,7 @@ CTilde.prototype.draw = function()
var XX = new Array(),
YY = new Array();
var fontSize = this.getTxtPrp().FontSize;
var fontSize = this.txtPrp.FontSize;
var textScale = fontSize/1000, // 1000 pt
alpha = textScale*25.4/96 /64 ; // g_dKoef_px_to_mm = 25.4/96
......@@ -866,7 +863,213 @@ CTilde.prototype.setPosition = function(pos)
{
this.pos = pos;
}
CTilde.prototype.setTxtPrp = function(txtPrp)
{
this.txtPrp = txtPrp;
}
function CBreve()
{
this.turn = null;
}
CBreve.prototype.setTurn = function(tturn)
{
this.turn = tturn;
}
CBreve.prototype.fixSize = function()
{
var betta = this.txtPrp.FontSize/36;
var width = 4.2333333333333325*betta;
var height = 2.469444444444445*betta;
this.size = {width: width, height: height};
}
CBreve.prototype.setPosition = function(pos)
{
this.pos = pos;
}
CBreve.prototype.draw = function()
{
var X = new Array(),
Y = new Array();
X[0] = 25161; Y[0] = 11372;
X[1] = 24077; Y[1] = 5749;
X[2] = 20932; Y[2] = 2875;
X[3] = 17787; Y[3] = 0;
X[4] = 12247; Y[4] = 0;
X[5] = 7082; Y[5] = 0;
X[6] = 4083; Y[6] = 2854;
X[7] = 1083; Y[7] = 5707;
X[8] = 0; Y[8] = 11372;
X[9] = 3208; Y[9] = 12371;
X[10] = 4249; Y[10] = 9623;
X[11] = 5561; Y[11] = 8083;
X[12] = 6873; Y[12] = 6542;
X[13] = 8456; Y[13] = 5959;
X[14] = 10039; Y[14] = 5376;
X[15] = 12414; Y[15] = 5376;
X[16] = 14746; Y[16] = 5376;
X[17] = 16454; Y[17] = 5980;
X[18] = 18162; Y[18] = 6583;
X[19] = 19558; Y[19] = 8124;
X[20] = 20953; Y[20] = 9665;
X[21] = 21953; Y[21] = 12371;
X[22] = 25161; Y[22] = 11372;
var XX = new Array(),
YY = new Array();
var fontSize = this.txtPrp.FontSize;
var textScale = fontSize/1000, // 1000 pt
alpha = textScale*25.4/96 /64 ; // g_dKoef_px_to_mm = 25.4/96
var align = this.size.width - X[22]*alpha;
var x = this.pos.x + align/2,
y = this.pos.y;
var a, b;
if(this.turn == TURN_0)
{
a = 0; b = 1;
}
else
{
a = Y[22]; // height
b = -1;
}
for(var i = 0; i < X.length; i++)
{
XX[i] = x + X[i]*alpha ;
YY[i] = y + (a + b*Y[i])*alpha ;
}
var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W;
penW *= 96/25.4;
var intGrid = MathControl.pGraph.GetIntegerGrid();
MathControl.pGraph.SetIntegerGrid(false);
MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(XX[0], YY[0]);
MathControl.pGraph._c(XX[0], YY[0], XX[1], YY[1], XX[2], YY[2] );
MathControl.pGraph._c(XX[2], YY[2], XX[3], YY[3], XX[4], YY[4] );
MathControl.pGraph._c(XX[4], YY[4], XX[5], YY[5], XX[6], YY[6] );
MathControl.pGraph._c(XX[6], YY[6], XX[7], YY[7], XX[8], YY[8] );
MathControl.pGraph._l(XX[9], YY[9]);
MathControl.pGraph._c(XX[9], YY[9], XX[10], YY[10], XX[11], YY[11] );
MathControl.pGraph._c(XX[11], YY[11], XX[12], YY[12], XX[13], YY[13] );
MathControl.pGraph._c(XX[13], YY[13], XX[14], YY[14], XX[15], YY[15] );
MathControl.pGraph._c(XX[15], YY[15], XX[16], YY[16], XX[17], YY[17] );
MathControl.pGraph._c(XX[17], YY[17], XX[18], YY[18], XX[19], YY[19] );
MathControl.pGraph._c(XX[19], YY[19], XX[20], YY[20], XX[21], YY[21] );
MathControl.pGraph._l(XX[22], YY[22]);
MathControl.pGraph.df();
MathControl.pGraph.SetIntegerGrid(intGrid);
}
CBreve.prototype.setTxtPrp = function(txtPrp)
{
this.txtPrp = txtPrp;
}
function CSign()
{
this.sign = new CMathText();
this.type = null;
}
CSign.prototype.setSign = function(props)
{
var bDot = props.code === 0x307 || props.type === ACCENT_ONE_DOT,
b2Dots = props.code === 0x308 || props.type === ACCENT_TWO_DOTS,
b3Dots = props.code === 0x20DB || props.type === ACCENT_THREE_DOTS,
bAccGrave = props.code === 0x300 || props.type === ACCENT_GRAVE,
bAccAcute = props.code === 0x301 || props.type === ACCENT_ACUTE;
if(bDot)
{
this.type = ACCENT_ONE_DOT;
this.sign.add(0x307);
}
else if(b2Dots)
{
this.type = ACCENT_TWO_DOTS;
this.sign.add(0x308);
}
else if(b3Dots)
{
this.type = ACCENT_THREE_DOTS;
this.sign.add(0x20DB);
}
else if(bAccGrave)
{
this.type = ACCENT_GRAVE;
this.sign.add(0x300);
}
else if(bAccAcute)
{
this.type = ACCENT_ACUTE;
this.sign.add(0x301);
}
else
{
this.type = MATH_TEXT;
this.sign.add(sign.code);
}
}
CSign.prototype.setPosition = function(pos)
{
var shX = 0;
if(this.type == ACCENT_GRAVE)
shX = 1.1*this.sign.size.widthG;
else if(this.type == ACCENT_ACUTE)
shX = 1.25*this.sign.size.widthG;
else if(this.type == ACCENT_ONE_DOT)
shX = 1.53*this.sign.size.widthG;
else if(this.type == ACCENT_TWO_DOTS)
shX = 0.95*this.sign.size.widthG;
else if(this.type == ACCENT_THREE_DOTS)
shX = 0.015*this.sign.size.widthG;
var position =
{
x: pos.x + shX ,
y: pos.y + this.sign.size.ascent
};
this.sign.setPosition(position);
}
CSign.prototype.fixSize = function(bIncline)
{
this.sign.recalculateSize();
var height = this.sign.size.height,
width = this.sign.size.widthG;
if(bIncline)
width += 0.1 * this.sign.size.height; // incline
this.size = {width: width, height: height};
}
CSign.prototype.draw = function()
{
this.sign.draw();
}
CSign.prototype.setTxtPrp = function(txtPrp)
{
this.sign.setTxtPrp(txtPrp);
}
function old_CAccent()
{
......@@ -995,7 +1198,7 @@ old_CAccent.prototype.setDistance = function()
this.dH = 0.7*this.getTxtPrp().FontSize/36;
}
function CAccent()
/*function CAccent()
{
this.bDiacritic = true;
this.type = null;
......@@ -1111,4 +1314,79 @@ CAccent.prototype.draw = function()
{
this.accent.draw();
this.elements[0][0].draw();
}*/
function CAccent()
{
this.loc = LOCATION_TOP;
CCharacter.call(this);
}
extend(CAccent, CCharacter);
CAccent.prototype.init = function(props)
{
var code, accent;
if(typeof(props.chr.value) === "string")
code = props.chr.value.charCodeAt(0);
/*var bDot = code === 0x307 || props.chr.type === ACCENT_ONE_DOT,
b2Dots = code === 0x308 || props.chr.type === ACCENT_TWO_DOTS,
b3Dots = code === 0x20DB || props.chr.type === ACCENT_THREE_DOTS,
bAccGrave = code === 0x300 || props.chr.type === ACCENT_GRAVE,
bAccAcute = code === 0x301 || props.chr.type === ACCENT_ACUTE;
if(bDot || b2Dots || b3Dots || bAccGrave || bAccAcute)
{
this.accent = new CMathText();
this.accent.add(code);
this.type = props.chr.type;
}*/
if(code === 0x302 || props.chr.type === ACCENT_CIRCUMFLEX)
{
accent = new CCircumflex();
accent.setTurn(TURN_0);
}
else if(code === 0x30C || props.chr.type === ACCENT_COMB_CARON)
{
accent = new CCircumflex();
accent.setTurn(TURN_MIRROR_0);
}
else if(code === 0x332 || props.chr.type === ACCENT_LINE)
{
accent = new CLine();
accent.setPrp(SINGLE_LINE);
}
else if(code === 0x333 || props.chr.type === ACCENT_DOUBLE_LINE)
{
accent = new CLine();
accent.setPrp(DOUBLE_LINE);
}
else if(code === 0x303 || props.chr.type === ACCENT_TILDE)
{
accent = new CTilde();
}
else if(code === 0x306 || props.chr.type === ACCENT_BREVE)
{
accent = new CBreve();
accent.setTurn(TURN_MIRROR_0);
}
else if(code == 0x311 || props.chr.type == ACCENT_INVERT_BREVE)
{
accent = new CBreve();
accent.setTurn(TURN_0);
}
else
{
accent = new CSign();
var props =
{
type: props.chr.type,
code: code
};
accent.setSign(props);
}
this.setOperator(accent);
}
\ No newline at end of file
......@@ -3958,48 +3958,70 @@ CMathContent.prototype =
arg2.addTxt("θ");
break;
case 152:
/*var diac = this.addMComponent(15);
diac.init(3);
diac.fillPlaceholders();*/
var accent = this.addMComponent(MATH_ACCENT);
var props =
{
chr: {type: ACCENT_ONE_DOT}
};
accent.init(props);
accent.fillPlaceholders();
break;
case 153:
var diac = this.addMComponent(15);
diac.init(4);
diac.fillPlaceholders();
var accent = this.addMComponent(MATH_ACCENT);
var props =
{
chr: {type: ACCENT_TWO_DOTS}
};
accent.init(props);
accent.fillPlaceholders();
break;
case 154:
var diac = this.addMComponent(15);
diac.init(5);
diac.fillPlaceholders();
var accent = this.addMComponent(MATH_ACCENT);
var props =
{
chr: {type: ACCENT_THREE_DOTS}
};
accent.init(props);
accent.fillPlaceholders();
break;
case 155:
var diac = this.addMComponent(12);
diac.init();
diac.setIndex(-1);
diac.fillPlaceholders();
break;
case 156:
var diac = this.addMComponent(12);
diac.init();
diac.setIndex(1);
diac.fillPlaceholders();
var accent = this.addMComponent(MATH_ACCENT);
var props =
{
chr: {type: ACCENT_CIRCUMFLEX}
};
accent.init(props);
accent.fillPlaceholders();
break;
case 157:
var diac = this.addMComponent(15);
diac.init(2);
diac.fillPlaceholders();
var accent = this.addMComponent(MATH_ACCENT);
var props =
{
chr: {type: ACCENT_ACUTE}
};
accent.init(props);
accent.fillPlaceholders();
break;
case 158:
var diac = this.addMComponent(15);
diac.init(1);
diac.fillPlaceholders();
var accent = this.addMComponent(MATH_ACCENT);
var props =
{
chr: {type: ACCENT_GRAVE}
};
accent.init(props);
accent.fillPlaceholders();
break;
case 159:
var diac = this.addMComponent(13);
diac.init();
diac.setIndex(1);
diac.fillPlaceholders();
var accent = this.addMComponent(MATH_ACCENT);
var props =
{
chr: {type: ACCENT_BREVE}
};
accent.init(props);
accent.fillPlaceholders();
break;
case 160:
var accent = this.addMComponent(MATH_ACCENT);
......
......@@ -97,7 +97,10 @@ var ACCENT_DOUBLE_LINE = 8;
var SINGLE_LINE = 9;
var DOUBLE_LINE = 10;
var ACCENT_TILDE = 11;
var MATH_TEXT = 12;
var ACCENT_BREVE = 12;
var ACCENT_INVERT_BREVE = 13;
var MATH_TEXT = 14;
var MATRIX_CENTER = 0;
var MATRIX_TOP = 1;
......
//var NameFunctions = ["min", "max", "lim", "log", "ln", "sin", "cos", "tg", "ctg", "ch", "sh", "th", "cth", "sec", "csc", "cot", "csch", "sech", "coth"];
//var NameFunctions = ["min", "max", "lim", "log", "ln", "sin", "cos", "tan", "ctg", "cosh", "sinh", "tanh", "cth", "sec", "csc", "cot", "csch", "sech", "coth"];
//var Diff = ["dx","dy","dθ"];
function CLogarithm()
{
CSubMathBase.call(this,1,2);
}
extend(CLogarithm, CSubMathBase);
CLogarithm.prototype.setContent = function()
{
var oBase = new CMathContent();
var GParams = Common_CopyObj(this.params);
GParams.bMText = false;
oBase.init(GParams);
oBase.relate(this);
oBase.addText("log");
//oBase.setContent.apply(oBase, NameFunctions.minimax[3] );
var oFunc = new CDegreeOrdinary(-1);
oFunc.init(this.params);
oFunc.relate(this);
oFunc.setContent(oBase); //здесь выставляется для Base, что родительский класс CDegree...
//todo
//проверить !!!
//var oArg = new CMathBase(1, 1);
var oArg = new CMathContent();
oArg.init(this.params);
oArg.relate(this);
oArg.fillPlaceholders();
CLogarithm.superclass.setContent.call(this, oFunc, oArg);
}
CLogarithm.prototype.getFunction = function()
{
return this.elements[0][0].getBase();
}
CLogarithm.prototype.getBase = function()
{
return this.elements[0][0].getIterator();
}
CLogarithm.prototype.getArgument = function()
{
return this.elements[0][1];
}
function CLimLowUp()
{
CMathBase.call(this);
}
extend(CLimLowUp, CMathBase);
CLimLowUp.prototype.init = function(props)
{
this.type = props.type;
this.setDimension(2, 1);
var oBase = new CMathContent();
oBase.setOwnTPrp({Italic: false});
var oIter = new CMathContent();
oIter.setReduct(DEGR_REDUCT);
if(props.type == LIMIT_LOW)
this.addMCToContent(oBase, oIter);
else if(props.type == LIMIT_UP)
this.addMCToContent(oIter, oBase);
}
CLimLowUp.prototype.getCenter = function()
{
return this.elements[0][0].size.center;
}
CLimLowUp.prototype.getFName = function()
{
return this.elements[0][0];
}
CLimLowUp.prototype.getIterator = function()
{
return this.elements[1][0];
}
CLimLowUp.prototype.setDistance = function()
{
this.dH = 0.03674768518518519*this.getTxtPrp().FontSize;
}
function old_CMinimax()
{
CSubMathBase.call(this);
}
extend(old_CMinimax, CSubMathBase);
old_CMinimax.prototype.init = function()
{
this.setDimension(1, 2);
var oFunc = new old_CMinimaxFunc();
oFunc.init();
var oArg = new CMathContent();
this.addMCToContent(oFunc, oArg);
}
old_CMinimax.prototype.getFName = function()
{
return this.elements[0][0].getBase();
}
old_CMinimax.prototype.getIterator = function()
{
return this.elements[0][0].getIterator();
}
old_CMinimax.prototype.getArgument = function()
{
return this.elements[0][1];
}
old_CMinimax.prototype.setDistance = function()
{
this.dW = this.getTxtPrp().FontSize/6*g_dKoef_pt_to_mm;
this.dH = 0;
}
function CMathFunc()
{
CMathBase.call(this);
}
extend(CMathFunc, CMathBase);
CMathFunc.prototype.init = function()
{
this.setDimension(1, 2);
this.setContent();
this.elements[0][0].setOwnTPrp({Italic: false}); // trigonometrical function
//this.elements[0][0].mergeTxtPrp({Italic: false}); // trigonometrical function
}
CMathFunc.prototype.setDistance = function()
{
this.dW = this.getTxtPrp().FontSize/6*g_dKoef_pt_to_mm;
}
CMathFunc.prototype.getFName = function()
{
return this.elements[0][0];
}
CMathFunc.prototype.getArgument = function()
{
return this.elements[0][1];
}
function old_CDifferential(num)
{
this.num = num;
CSubMathBase.call(this, 1,1);
}
extend(old_CDifferential, CSubMathBase);
old_CDifferential.prototype.setContent = function()
{
var oDiff = new CMathContent();
oDiff.init(this.params);
oDiff.addText(Diff[this.num]);
old_CMathFunc.superclass.setContent.call(this, oDiff);
}
function old_CTrigFunc(num)
{
if(num != num + 0 || num < 0 || num > 14)
return;
this.num = num;
//CSubMathBase.call(this, 1, 2);
CMathBase.call(this, 1,2);
}
//extend(old_CTrigFunc,CSubMathBase);
extend(old_CTrigFunc, CMathBase);
old_CTrigFunc.prototype.setContent = function()
{
var oFunc = new CMathContent();
var GParms = Common_CopyObj(this.params);
GParms.bMText = false;
oFunc.init(GParms);
oFunc.setContent.apply(oFunc, NameFunctions.trig[this.num] );
var oArg = new CMathContent();
oArg.init(this.params);
oArg.fillPlaceholders();
old_CTrigFunc.superclass.setContent.call(this, oFunc, oArg);
}
old_CTrigFunc.prototype.setDistance = function()
{
//todo
//переделать!
this.dW = slashWidth(this.params.font);
this.dH = 0;
}
old_CTrigFunc.prototype.getFunction = function()
{
return this.elemens[0][0];
}
old_CTrigFunc.prototype.getArgument = function()
{
return this.elemens[0][1];
}
......@@ -4195,7 +4195,7 @@ CDelimiter.prototype.setPosition = function(position)
y = this.pos.y;
var pos = {x: x, y: y + this.align(this.begOper)};
this.begOper.setPosition([pos]);
this.begOper.setPosition(pos);
x += this.begOper.size.width;
var content = this.elements[0][0];
......@@ -4220,7 +4220,7 @@ CDelimiter.prototype.setPosition = function(position)
this.sepOper.setPosition(Positions);
pos = {x: x, y: y + this.align(this.endOper)};
this.endOper.setPosition([pos]);
this.endOper.setPosition(pos);
}
CDelimiter.prototype.findDisposition = function(pos)
{
......@@ -4332,13 +4332,13 @@ function COperator(glyph)
{
this.glyph = glyph;
this.positions = null;
this.pos = null;
this.coordGlyph = null;
this.size = {width: 0, height: 0};
}
COperator.prototype.draw = function()
{
if(this.glyph !== -1)
/*if(this.glyph !== -1)
{
var lng = this.coordGlyph.XX.length;
......@@ -4354,7 +4354,23 @@ COperator.prototype.draw = function()
this.glyph.draw(X, Y);
}
}*/
if(this.glyph !== -1)
{
var lng = this.coordGlyph.XX.length;
var X = new Array(),
Y = new Array();
for(var j = 0; j < lng; j++)
{
X.push(this.pos.x + this.coordGlyph.XX[j]);
Y.push(this.pos.y + this.coordGlyph.YY[j]);
}
this.glyph.draw(X, Y);
}
}
COperator.prototype.fixSize = function(measure)
{
......@@ -4387,9 +4403,10 @@ COperator.prototype.fixSize = function(measure)
this.size = { width: width, height: height, center: center};
}
}
COperator.prototype.setPosition = function(positions)
COperator.prototype.setPosition = function(pos)
{
this.positions = positions;
this.pos = pos;
//this.positions = positions;
}
COperator.prototype.IsJustDraw = function()
{
......@@ -4418,7 +4435,8 @@ COperator.prototype.setTxtPrp = function(txtPrp)
this.glyph.setTxtPrp(txtPrp);
}
function CGroupCharacter()
function old_CGroupCharacter()
{
this.operator = null;
this.vertJust = VJUST_TOP;
......@@ -4426,8 +4444,8 @@ function CGroupCharacter()
CSubMathBase.call(this);
}
extend(CGroupCharacter, CSubMathBase);
CGroupCharacter.prototype.init = function(props)
extend(old_CGroupCharacter, CSubMathBase);
old_CGroupCharacter.prototype.init = function(props)
{
if(props.pos === "top" || props.location === LOCATION_TOP)
this.loc = LOCATION_TOP;
......@@ -4446,7 +4464,7 @@ CGroupCharacter.prototype.init = function(props)
this.setDimension(1, 1);
this.setContent();
}
CGroupCharacter.prototype.recalculateSize = function()
old_CGroupCharacter.prototype.recalculateSize = function()
{
var content = this.elements[0][0];
......@@ -4467,12 +4485,12 @@ CGroupCharacter.prototype.recalculateSize = function()
this.size = {height: height, width: width, center: center};
}
CGroupCharacter.prototype.draw = function()
old_CGroupCharacter.prototype.draw = function()
{
this.elements[0][0].draw();
this.operator.draw();
}
CGroupCharacter.prototype.setPosition = function(pos)
old_CGroupCharacter.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
......@@ -4496,11 +4514,123 @@ CGroupCharacter.prototype.setPosition = function(pos)
this.operator.setPosition([pos]);
}
}
CGroupCharacter.prototype.align = function(element)
old_CGroupCharacter.prototype.align = function(element)
{
return (this.size.width - element.size.width)/2;
}
old_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};
}
function CCharacter()
{
this.operator = null;
CSubMathBase.call(this);
}
extend(CCharacter, CSubMathBase);
CCharacter.prototype.setOperator = function(operator)
{
this.operator = operator;
var tPrp = this.getTxtPrp();
this.operator.setTxtPrp(tPrp);
this.setDimension(1, 1);
this.setContent();
}
CCharacter.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 = this.getCenter();
this.size = {height: height, width: width, center: center};
}
CCharacter.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);
}
}
CCharacter.prototype.align = function(element)
{
return (this.size.width - element.size.width)/2;
}
CGroupCharacter.prototype.findDisposition = function(pos)
CCharacter.prototype.draw = function()
{
this.elements[0][0].draw();
this.operator.draw();
}
CCharacter.prototype.findDisposition = function(pos)
{
var curs_X = 0,
curs_Y = 0;
......@@ -4550,3 +4680,43 @@ CGroupCharacter.prototype.findDisposition = function(pos)
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
function CGroupCharacter()
{
this.vertJust = VJUST_TOP;
this.loc = LOCATION_BOT;
CCharacter.call(this);
}
extend(CGroupCharacter, CCharacter);
CGroupCharacter.prototype.init = function(props)
{
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;
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;
var operator = new COperator ( GetGlyph_GrChr(props.chr, this.loc) );
this.setOperator(operator);
}
CGroupCharacter.prototype.getCenter = function()
{
var 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;
return center;
}
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