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

убрала Resize, setPosition и UpdatePosition (for Edit)


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52813 954022d7-b5bf-4e40-9824-e11837661b57
parent 14481e06
......@@ -375,8 +375,6 @@ CControlComposition.prototype =
CreateEquation: function(indef)
{
this.Content[this.CurPos].CreateEquation(indef);
this.Content[this.CurPos].RecalculateReverse(oMeasure);
this.Content[this.CurPos].UpdatePosition();
},
Paragraph_Add: function(TextPr)
{
......@@ -415,14 +413,6 @@ CControlComposition.prototype =
{
this.Content[this.CurPos].Refresh();
},
old_Set_SelectionState: function(State)
{
this.Content[this.CurPos].Set_SelectionState(State);
},
old_Get_SelectionState: function()
{
return this.Content[this.CurPos].Get_SelectionState();
},
UpdateCursor: function()
{
this.Content[this.CurPos].UpdateCursor();
......@@ -1268,7 +1258,7 @@ function Set_Container(dimension, path, index)
document.getElementById("Container").style.display = "none";
// AddMathComponent -> CreateEquation
//MathControl.CreateEquation(index + _i*column + _j);
MathComposition.CreateEquation(index + _i*column + _j);
MathComposition.CreateEquation2(index + _i*column + _j);
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, { Width : Page_Width, Height : Page_Height, Margins : {
Left : X_Left_Field,
Right : X_Right_Field,
......
......@@ -521,10 +521,6 @@ CMathBase.prototype =
return content;
},
drawSelect: function()
{
this.elements[this.CurPos_X][this.CurPos_Y].drawSelect();
},
cursor_MoveToStartPos: function() // home => cursor_MoveToStartPos
{
this.CurPos_X = 0;
......@@ -873,11 +869,11 @@ CMathBase.prototype =
this.size = {width: _width, height: _height, center: _center};
},
RecalculateReverse: function(oMeasure)
/*RecalculateReverse: function(oMeasure)
{
this.recalculateSize();
this.Parent.RecalculateReverse(oMeasure);
},
},*/
Resize: function(oMeasure)
{
for(var i=0; i < this.nRow; i++)
......
......@@ -1332,7 +1332,7 @@ CDocument.prototype =
this.Document_UpdateRulersState();
//**
//MathControl.UpdateCursor();
MathComposition.UpdateCursor();
MathComposition.UpdateCursor2();
//this.RecalculateCurPos();
//**
//this.RecalculateCurPos();
......
......@@ -7,8 +7,6 @@ function CFraction()
extend(CFraction, CMathBase);
CFraction.prototype.init = function(props)
{
if (props.type == undefined)
props.type = BAR_FRACTION;
var bValid = typeof(props.type) !== "undefined" && props.type !== null;
if(bValid)
......@@ -576,7 +574,7 @@ old_CBarFraction.prototype.setSimple = function(flag)
else
this.setReduct(1);
this./**/Resize();
this.Resize();
}
//////////
......
......@@ -4412,20 +4412,7 @@ CMathContent.prototype =
this.update_widthContent(); /// !!!!
},
RecalculateReverse: function(oMeasure)
{
// for add component, set Txt Properties
var start = this.rInterval.startPos,
end = this.rInterval.endPos;
for(var i = start; i < end; i++)
this.content[i].value.Resize(oMeasure);
this.rInterval.startPos = this.rInterval.endPos = this.CurPos;
this.recalculateSize();
if(! this.bRoot )
this.Parent.RecalculateReverse(oMeasure);
},
Resize: function(oMeasure) // пересчитываем всю формулу
{
var bItalic = true;
......@@ -4437,7 +4424,7 @@ CMathContent.prototype =
if(type == MATH_TEXT)
{
this.content[i].value.setMText(bItalic);
this.content[i].value.resize(oMeasure);
this.content[i].value.Resize(oMeasure);
}
else if(type == MATH_COMP)
{
......@@ -4468,7 +4455,7 @@ CMathContent.prototype =
txtPrp.Italic = false;
g_oTextMeasurer.SetFont(txtPrp);
this.content[i].value.resize(oMeasure);
this.content[i].value.Resize(oMeasure);
}
}
}
......@@ -5079,44 +5066,6 @@ CMathContent.prototype =
this.drawSelect();
}
},
//TODO
//переделать
old_drawSelect: function()
{
var start = this.selection.startPos;
var end = this.selection.endPos ;
if( start > end)
{
var tmp = start;
start = end;
end = tmp;
}
var widthSelect = 0;
try
{
for(var j = start; j < end ; j++)
widthSelect += this.content[j].widthToEl - this.content[j-1].widthToEl;
}
catch(e)
{
//console.log("Don't work update_widthContent");
console.log("Don't work drawSelect");
}
if( widthSelect != 0)
{
editor.WordControl.m_oLogicDocument.DrawingDocument.SelectClear(); // "обнуляем" логический селект
editor.WordControl.m_oLogicDocument.DrawingDocument.SelectEnabled(true); // select
/// ...Selectenabled(false) deselect, убираем слой
//editor.WordControl.m_oLogicDocument.DrawingDocument.TargetEnd();
//editor.WordControl.m_oLogicDocument.DrawingDocument.AddPageSelection(0,this.pos.x + this.content[start-1].widthToEl, this.pos.y, widthSelect, heightSelect );
editor.WordControl.m_oLogicDocument.DrawingDocument.SelectShow();
//editor.WordControl.m_oLogicDocument.DrawingDocument.TargetStart();
}
},
IsPlaceholder: function()
{
var flag = false;
......@@ -5168,7 +5117,7 @@ CMathContent.prototype =
this.content[i].value.setPosition(t);
}
},
drawSelect2: function()
drawSelect: function()
{
var start = this.RealSelect.startPos,
end = this.RealSelect.endPos;
......@@ -6061,6 +6010,26 @@ CMathContent.prototype =
//this.selection.active = false;
}
/////////////////////////////////////////////////////////////////
//// test function for me ////
/*RecalculateReverse: function(oMeasure)
{
// for add component, set Txt Properties
var start = this.rInterval.startPos,
end = this.rInterval.endPos;
for(var i = start; i < end; i++)
this.content[i].value.Resize(oMeasure);
this.rInterval.startPos = this.rInterval.endPos = this.CurPos;
this.recalculateSize();
if(! this.bRoot )
this.Parent.RecalculateReverse(oMeasure);
},*/
//////////////* end of test functions *//////////////////
}
//todo
//разобраться с gaps
......@@ -6093,222 +6062,297 @@ CMathComposition.prototype =
// сделать глобальную булевскую переменную для того, чтобы запоминать нужен пересчет контента или нет
// необходима тк на backspace может не быть реального удаления переменных, а только селект
Init: function()
//// test function for me ////
TestSetPosition: function()
{
// TODO
// переделать gaps
//var g_Unif = 6*g_dKoef_pix_to_mm;
var g_Unif = 0;
var gps = new dist(g_Unif, g_Unif, g_Unif, g_Unif);
this.Root = new CMathContent();
this.Root.g_mContext = gps;
this.Root.setComposition(this);
//this.SetTestRunPrp();
//this.Root.setTxtPrp(this.TxtPrp);
this.CurrentContent = this.Root;
this.SelectContent = this.Root;
this.Root.relate(-1); // корень
this.Root.setPosition(this.posCompos);
},
/*SetTestRunPrp: function()
{
var runPrp = new CTextPr();
runPrp.Merge(this.DefaultTxtPrp);
this.Root.addRunPrp(runPrp);
},*/
GetTxtPrp: function()
TestSetFontAllSymbols: function(font)
{
return this.DefaultTxtPrp;
this.Root.setFont(font);
},
//TODO
// переделать Draw (для режима редактирования передавать координату для отрисовки формулы) !!
// position вычислить естественно до того, как придет Draw, чтобы не пришлось пересчитывать при изменении в тексте документа
Draw_2: function(pGraphics)
{
if(this.Root.content.length > 1)
CheckTarget: function()
{
var w_Box = this.Root.size.width;
var h_Box = this.Root.size.height;
pGraphics.p_color(224, 238, 224, 255); // "p_color" for stroke
// "b_color1" for fill
//context.b_color1(224, 238, 230, 255);
pGraphics.drawHorLine(0, this.pos.y, this.pos.x, this.pos.x + w_Box, 0.2);
pGraphics.drawHorLine(0, this.pos.y + h_Box, this.pos.x, this.pos.x + w_Box, 0.2);
pGraphics.drawVerLine(0,this.pos.x, this.pos.y, this.pos.y + h_Box, 0.2 );
pGraphics.drawVerLine(0,this.pos.x + w_Box, this.pos.y, this.pos.y + h_Box, 0.2 );
}
var bSelect = this.SelectContent.selectUse(),
bTarget = this.SelectContent.IsPlaceholder(),
bHideTgt = this.SelectContent.plhHide;
this.Root.draw(pGraphics);
},
Draw: function(x, y, pGraphics)
if(bTarget)
{
if(this.Root.content.length > 1)
if(!bHideTgt)
{
this.pos = {x: x, y: y - this.Root.size.center};
this.Root.setPosition({x: x, y: y - this.Root.size.center});
this.Root.draw(pGraphics);
//this.UpdateCursor();
this.SelectContent.tgtSelect();
this.HideCursor();
}
},
GetFirstPrp: function()
else
{
return this.Root.getFirstPrp();
this.SelectContent.setPositionHideTgt();
this.ShowCursor();
}
}
else if(bSelect)
this.HideCursor();
else
{
this.ShowCursor();
}
this.CurrentContent.update_Cursor();
},
Cursor_MoveLeft: function()
Cursor_MoveRight_2: function()
{
var move = this.SelectContent.cursor_moveLeft();
this.ClearSelect();
var move = this.SelectContent.cursor_moveRight();
//передаем состояние, т.к. можем выйти за пределы формулы
if(move.state)
{
// SelectContent == CurrentContent
this.SelectContent = move.SelectContent;
this.CurrentContent = move.CurrContent;
this.CheckTarget();
}
return move.state;
},
Cursor_MoveRight: function()
Cursor_MoveLeft_2: function()
{
var move = this.SelectContent.cursor_moveRight();
this.ClearSelect();
var move = this.SelectContent.cursor_moveLeft();
//передаем состояние, т.к. можем выйти за пределы формулы
if(move.state)
{
this.SelectContent = move.SelectContent;
this.CurrentContent = move.CurrContent;
this.CheckTarget();
}
return move.state;
},
Cursor_MoveUp: function()
Cursor_MoveUp_2: function()
{
//TODO !!!
//сделать как в Cursor_MoveLeft/Right
// в зависимости от пришедшего флага выставлять/не выставлять контент
this.ClearSelect();
var move = this.SelectContent.cursor_moveUp();
this.CurrentContent = move.CurrContent;
this.SelectContent = move.SelectContent;
return move.state;
},
Cursor_MoveDown: function()
{
var move = this.SelectContent.cursor_moveDown();
this.CurrentContent = move.CurrContent;
this.SelectContent = move.SelectContent;
this.CheckTarget();
return move.state;
},
Cursor_MoveToStartPos: function()
OnKeyDown: function(e)
{
this.Root.cursor_MoveToStartPos();
this.CurrentContent = this.SelectContent = this.Root;
},
Cursor_MoveToEndPos: function()
//стрелка вверх
if(e.KeyCode==38)
{
this.Root.cursor_MoveToEndPos();
this.CurrentContent = this.SelectContent = this.Root;
},
this.Cursor_MoveUp_2();
getSize: function()
return true;
}
//стрелка вниз
else if(e.KeyCode==40)
{
/*return this.Root.size;*/
this.Cursor_MoveDown_2();
//
var sh = 0.2487852283770651*g_oTextMeasurer.GetHeight();
//
var size =
return true;
}
//стрелка влево
if(e.KeyCode==37)
{
Width: this.Root.size.width,
WidthVisible: this.Root.size.width,
Height: this.Root.size.height,
Ascent: this.Root.size.center + sh,
Descent: this.Root.size.height - this.Root.size.center
};
this.Cursor_MoveLeft_2();
return size;
},
Remove: function(order, bOnAdd)
return true;
}
//стрелка вправо
else if(e.KeyCode==39)
{
////* History */////
History.Create_NewPoint();
/*var start = this.SelectContent.selection.startPos,
end = this.SelectContent.selection.endPos;*/
var start = this.SelectContent.RealSelect.startPos,
end = this.SelectContent.RealSelect.endPos;
var Pos;
if(start !== end)
Pos = start < end ? start: end;
else if(order == 1)
Pos = this.SelectContent.CurPos;
else
Pos = this.SelectContent.CurPos + 1;
this.Cursor_MoveRight_2();
///////////////////////////
return true;
}
//backspace
else if(e.KeyCode==8)
{
try
{
if(this.Remove_2(1))
{
//this.UpdatePosition();
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, editor.WordControl.m_oLogicDocument.Pages[0]);
}
}
catch(e)
{
var removeMComp = true;
}
if(bOnAdd)
{
this.SelectContent.removeAreaSelect();
return true;
}
else
//delete
else if ( e.KeyCode == 46)
{
var result = this.SelectContent.remove(order);
var bRoot = this.SelectContent.bRoot === true,
bToUpper = result.state.bBegin || result.state.bEnd; // наверх нужно ли прокидовать
if(this.Remove_2(-1))
{
//this.UpdatePosition();
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, editor.WordControl.m_oLogicDocument.Pages[0]);
}
}
if( result.state.bDelete )
History.Add(this.CurrentContent, {Type: historyitem_Math_RemoveItem, Items: result.items, Pos: Pos});
if(e.CtrlKey == true && e.KeyCode == 81)
{
simulatorMComposition(this, MATH_READ);
return false;
}
return false;
},
OnKeyPress: function(e)
{
var code = e.CharCode;
this.CurrentContent = result.CurrContent;
this.SelectContent = result.SelectContent;
this.CurrentContent.setPlaceholderAfterRemove(); // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
//
/*if(code == 42)
code = 8727;
else if(code == 45)
code = 8722;
removeMComp = !(bRoot && bToUpper); // посылаем false, если в начале + backspace или в конце + delete
else if(code == 37)
code = 0x222B;
else if(code==94)
code = 0x2211;
if(code == 0x0068)
code = 0x210E;*/
/*else if(code > 0x0040 && code < 0x005B)
code = code + 0x1D3F3;
else if(code > 0x0060 && code < 0x007b)
code = code + 0x1D3ED;*/
if(code>=0x0020 )
{
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, editor.WordControl.m_oLogicDocument.Pages[0]);
this.AddLetter_2(code);
return true;
}
return removeMComp;
return false;
},
OnMouseDown: function(x,y)
{
var coord = this.GetCoordComp(x,y);
UpdatePosition: function()
if( this.IsRect(coord.x, coord.y) )
this.MouseDown(coord.x, coord.y);
},
OnMouseMove: function(x,y)
{
this.Root.setPosition(this.pos);
var coord = this.GetCoordComp(x,y);
if( this.IsRect(coord.x, coord.y) )
this.MouseMove(coord.x, coord.y);
},
SetPosition: function(pos)
OnMouseUp: function()
{
this.pos = pos;
this.Root.setPosition(this.pos);
this.MouseUp();
},
RecalculateReverse: function(oMeasure) // for edit
MouseDown: function(mouseX, mouseY)
{
this.SelectContent.RecalculateReverse(oMeasure);
this.ClearSelect();
this.CurrentContent = this.SelectContent = this.Root.mouseDown({x: mouseX, y: mouseY}, -1);
this.TEST_SELECT_ACTIVE = true;
this.CheckTarget();
},
Resize: function(oMeasure)
MouseMove: function(mouseX, mouseY)
{
if(this.TEST_SELECT_ACTIVE)
{
this.ClearSelect();
var movement = this.Root.mouseMove({x: mouseX, y: mouseY});
this.SelectContent = movement.SelectContent;
this.CheckTarget();
}
},
MouseUp: function()
{
this.TEST_SELECT_ACTIVE = false;
},
Remove_2: function(order)
{
if(TEST)
{
History.Create_NewPoint();
/*var start = this.SelectContent.selection.startPos,
end = this.SelectContent.selection.endPos;*/
var start = this.SelectContent.RealSelect.startPos,
end = this.SelectContent.RealSelect.endPos;
var Pos;
if(start !== end)
Pos = start < end ? start: end;
else if(order == 1)
Pos = this.SelectContent.CurPos;
else
Pos = this.SelectContent.CurPos + 1;
}
this.ClearSelect();
var result = this.SelectContent.remove(order);
this.CurrentContent = result.CurrContent;
this.SelectContent = result.SelectContent;
this.CurrentContent.setPlaceholderAfterRemove(); // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
if( result.state.bDelete )
{
if(TEST)
{
History.Add(this.CurrentContent, {Type: historyitem_Math_RemoveItem, Items: result.items, Pos: Pos});
}
// временно
//this.CurrentContent.RecalculateReverse();
this.Resize(g_oTextMeasurer);
this.UpdatePosition();
}
this.CheckTarget();
return result.state.bDelete;
},
RecalculateComposition_2: function(oMeasure)
{
//this.SetReferenceComposition();
this.Root.Resize(oMeasure);
this.Root.setPosition(this.pos);
this.UpdateCursor();
},
AddLetter: function(code)
AddLetter_2: function(code)
{
if(TEST)
{
History.Create_NewPoint();
}
//this.ClearSelect();
//this.SelectContent.removeAreaSelect();
this.ClearSelect();
this.SelectContent.removeAreaSelect();
/*if(this.Root.IsEmpty())
......@@ -6340,63 +6384,41 @@ CMathComposition.prototype =
},
CreateEquation2: function(indef)
{
if(TEST)
{
History.Create_NewPoint();
}
//this.ClearSelect();
//this.SelectContent.removeAreaSelect();
if(TEST)
var Pos = this.SelectContent.CurPos + 1;
var items = this.SelectContent.createEquation(indef);
///
this.CreateEquation(indef);
// временно
//this.RecalculateReverse();
//this.Root.Resize();
this.Resize(g_oTextMeasurer);
this.UpdatePosition();
///
if(TEST)
},
UpdateCursor2: function()
{
//var Pos = this.SelectContent.CurPos - 1,
var EndPos = this.SelectContent.CurPos + 1;
History.Add(this.CurrentContent, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: EndPos});
}
this.CurrentContent = this.SelectContent;
this.CurrentContent.update_Cursor();
//this.CurrentContent.update_Cursor();
this.SelectContent.update_Cursor();
if( this.SelectContent.selectUse())
this.HideCursor();
else
this.ShowCursor();
},
Get_SelectionState : function()
HideCursor: function()
{
var State = new Object();
var stackCurrent = new Array();
this.CurrentContent.getStackPositions( stackCurrent );
State.Current =
editor.WordControl.m_oLogicDocument.DrawingDocument.TargetEnd();
},
ShowCursor: function()
{
stack: stackCurrent
};
var stackSelect = new Array();
this.SelectContent.getStackPositions( stackSelect );
State.Select =
//узнать зачем обе функции вызывать
editor.WordControl.m_oLogicDocument.DrawingDocument.TargetStart();
editor.WordControl.m_oLogicDocument.DrawingDocument.TargetShow();
},
old_SetTxtPrp: function(txtPrp)
{
StartSelect: this.SelectContent.RealSelect.startPos - 1,
EndSelect: this.SelectContent.RealSelect.endPos - 1,
stack: stackSelect
};
return State;
this.SelectContent.changeTxtPrp(txtPrp, false);
//this.SelectContent.setTxtPrp(txtPrp, false);
this.Resize();
this.UpdatePosition();
this.UpdateCursor();
},
Set_SelectionState : function(State)
Set_SelectionState_2 : function(State)
{
this.ClearSelect();
// временно
......@@ -6426,7 +6448,6 @@ CMathComposition.prototype =
this.UpdateCursor();
}*/
},
ClearSelect: function()
{
if(this.SelectContent.selectUse())
......@@ -6435,264 +6456,198 @@ CMathComposition.prototype =
editor.WordControl.m_oLogicDocument.DrawingDocument.SelectEnabled(false);
}
},
old_SetTxtPrp: function(txtPrp)
Draw_2: function(pGraphics)
{
this.SelectContent.changeTxtPrp(txtPrp, false);
//this.SelectContent.setTxtPrp(txtPrp, false);
this.Resize();
this.UpdatePosition();
this.UpdateCursor();
},
UpdateCursor: function()
if(this.Root.content.length > 1)
{
//this.CurrentContent.update_Cursor();
this.SelectContent.update_Cursor();
/*if( this.SelectContent.selection.startPos !== this.SelectContent.selection.endPos)
this.HideCursor();
else
this.ShowCursor();*/
var w_Box = this.Root.size.width;
var h_Box = this.Root.size.height;
pGraphics.p_color(224, 238, 224, 255); // "p_color" for stroke
// "b_color1" for fill
//context.b_color1(224, 238, 230, 255);
pGraphics.drawHorLine(0, this.pos.y, this.pos.x, this.pos.x + w_Box, 0.2);
pGraphics.drawHorLine(0, this.pos.y + h_Box, this.pos.x, this.pos.x + w_Box, 0.2);
pGraphics.drawVerLine(0,this.pos.x, this.pos.y, this.pos.y + h_Box, 0.2 );
pGraphics.drawVerLine(0,this.pos.x + w_Box, this.pos.y, this.pos.y + h_Box, 0.2 );
}
this.Root.draw(pGraphics);
},
/*GetPrpSelectContent: function()
UpdatePosition: function()
{
return this.SelectContent.getSelectTPrp(true);
},*/
//// test function ////
TestSetPosition: function()
this.Root.setPosition(this.pos);
},
SetPosition: function(pos)
{
this.Root.setPosition(this.posCompos);
this.pos = pos;
this.Root.setPosition(this.pos);
},
TestSetFontAllSymbols: function(font)
IsRect: function(x, y)
{
this.Root.setFont(font);
var size = this.Root.size;
return ( x > 0 && x < size.width && y > 0 && y < size.height);
},
CheckTarget: function()
GetCoordComp: function(x, y)
{
var bSelect = this.SelectContent.selectUse(),
bTarget = this.SelectContent.IsPlaceholder(),
bHideTgt = this.SelectContent.plhHide;
var _x = x - this.pos.x;
var _y = y - this.pos.y;
if(bTarget)
{
if(!bHideTgt)
return {x: _x, y: _y};
},
Resize: function(oMeasure)
{
this.SelectContent.tgtSelect();
this.HideCursor();
}
else
{
this.SelectContent.setPositionHideTgt();
this.ShowCursor();
}
}
else if(bSelect)
this.HideCursor();
else
{
this.ShowCursor();
}
this.CurrentContent.update_Cursor();
this.Root.Resize(oMeasure);
},
Cursor_MoveRight_2: function()
test_for_edit: function()
{
this.ClearSelect();
var move = this.SelectContent.cursor_moveRight();
//передаем состояние, т.к. можем выйти за пределы формулы
if(move.state)
var props =
{
// SelectContent == CurrentContent
this.SelectContent = move.SelectContent;
this.CurrentContent = move.CurrContent;
type: BAR_FRACTION
};
var fract = new CFraction();
this.CheckTarget();
}
addToContent_ForRead(this.Root, fract, props);
return move.state;
fract.getNumerator().addTxt("a");
fract.getDenominator().addTxt("b");
},
Cursor_MoveLeft_2: function()
test_for_edit_2: function()
{
this.ClearSelect();
var move = this.SelectContent.cursor_moveLeft();
if(move.state)
simulatorMComposition(this, MATH_EDIT);
},
/*RecalculateReverse: function(oMeasure) // for edit
{
this.SelectContent = move.SelectContent;
this.CurrentContent = move.CurrContent;
this.CheckTarget();
}
this.SelectContent.RecalculateReverse(oMeasure);
},*/
//////////////* end of test functions *//////////////////
return move.state;
},
Cursor_MoveUp_2: function()
Init: function()
{
//TODO !!!
//сделать как в Cursor_MoveLeft/Right
// в зависимости от пришедшего флага выставлять/не выставлять контент
this.ClearSelect();
var move = this.SelectContent.cursor_moveUp();
// TODO
// переделать gaps
//var g_Unif = 6*g_dKoef_pix_to_mm;
var g_Unif = 0;
var gps = new dist(g_Unif, g_Unif, g_Unif, g_Unif);
this.CurrentContent = move.CurrContent;
this.SelectContent = move.SelectContent;
this.Root = new CMathContent();
this.Root.g_mContext = gps;
this.Root.setComposition(this);
//this.SetTestRunPrp();
//this.Root.setTxtPrp(this.TxtPrp);
this.CheckTarget();
this.CurrentContent = this.Root;
this.SelectContent = this.Root;
return move.state;
this.Root.relate(-1); // корень
},
OnKeyDown: function(e)
{
//стрелка вверх
if(e.KeyCode==38)
/*SetTestRunPrp: function()
{
this.Cursor_MoveUp_2();
var runPrp = new CTextPr();
runPrp.Merge(this.DefaultTxtPrp);
return true;
}
//стрелка вниз
else if(e.KeyCode==40)
this.Root.addRunPrp(runPrp);
},*/
GetTxtPrp: function()
{
this.Cursor_MoveDown_2();
return true;
}
//стрелка влево
if(e.KeyCode==37)
return this.DefaultTxtPrp;
},
//TODO
// position вычислить естественно до того, как придет Draw, чтобы не пришлось пересчитывать при изменении в тексте документа
Draw: function(x, y, pGraphics)
{
this.Cursor_MoveLeft_2();
return true;
}
//стрелка вправо
else if(e.KeyCode==39)
if(this.Root.content.length > 1)
{
this.Cursor_MoveRight_2();
return true;
this.pos = {x: x, y: y - this.Root.size.center};
this.Root.setPosition({x: x, y: y - this.Root.size.center});
this.Root.draw(pGraphics);
}
//backspace
else if(e.KeyCode==8)
{
try
},
GetFirstPrp: function()
{
if(this.Remove_2(1))
return this.Root.getFirstPrp();
},
Cursor_MoveLeft: function()
{
//this.UpdatePosition();
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, editor.WordControl.m_oLogicDocument.Pages[0]);
var move = this.SelectContent.cursor_moveLeft();
}
}
catch(e)
if(move.state)
{
this.SelectContent = move.SelectContent;
this.CurrentContent = move.CurrContent;
}
return true;
}
//delete
else if ( e.KeyCode == 46)
{
if(this.Remove_2(-1))
return move.state;
},
Cursor_MoveRight: function()
{
//this.UpdatePosition();
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, editor.WordControl.m_oLogicDocument.Pages[0]);
}
}
var move = this.SelectContent.cursor_moveRight();
if(e.CtrlKey == true && e.KeyCode == 81)
//передаем состояние, т.к. можем выйти за пределы формулы
if(move.state)
{
simulatorMComposition(this, MATH_READ);
return false;
this.SelectContent = move.SelectContent;
this.CurrentContent = move.CurrContent;
}
return false;
return move.state;
},
OnKeyPress: function(e)
{
var code = e.CharCode;
//
/*if(code == 42)
code = 8727;
else if(code == 45)
code = 8722;
else if(code == 37)
code = 0x222B;
else if(code==94)
code = 0x2211;
if(code == 0x0068)
code = 0x210E;*/
/*else if(code > 0x0040 && code < 0x005B)
code = code + 0x1D3F3;
else if(code > 0x0060 && code < 0x007b)
code = code + 0x1D3ED;*/
if(code>=0x0020 )
Cursor_MoveUp: function()
{
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, editor.WordControl.m_oLogicDocument.Pages[0]);
this.AddLetter(code);
//TODO !!!
//сделать как в Cursor_MoveLeft/Right
// в зависимости от пришедшего флага выставлять/не выставлять контент
return true;
}
var move = this.SelectContent.cursor_moveUp();
this.CurrentContent = move.CurrContent;
this.SelectContent = move.SelectContent;
return false;
return move.state;
},
OnMouseDown: function(x,y)
Cursor_MoveDown: function()
{
var coord = this.GetCoordComp(x,y);
var move = this.SelectContent.cursor_moveDown();
if( this.IsRect(coord.x, coord.y) )
this.MouseDown(coord.x, coord.y);
},
OnMouseMove: function(x,y)
{
var coord = this.GetCoordComp(x,y);
this.CurrentContent = move.CurrContent;
this.SelectContent = move.SelectContent;
if( this.IsRect(coord.x, coord.y) )
this.MouseMove(coord.x, coord.y);
return move.state;
},
OnMouseUp: function()
Cursor_MoveToStartPos: function()
{
this.MouseUp();
this.Root.cursor_MoveToStartPos();
this.CurrentContent = this.SelectContent = this.Root;
},
MouseDown: function(mouseX, mouseY)
Cursor_MoveToEndPos: function()
{
this.ClearSelect();
this.CurrentContent = this.SelectContent = this.Root.mouseDown({x: mouseX, y: mouseY}, -1);
this.TEST_SELECT_ACTIVE = true;
this.CheckTarget();
this.Root.cursor_MoveToEndPos();
this.CurrentContent = this.SelectContent = this.Root;
},
MouseMove: function(mouseX, mouseY)
{
if(this.TEST_SELECT_ACTIVE)
getSize: function()
{
this.ClearSelect();
var movement = this.Root.mouseMove({x: mouseX, y: mouseY});
this.SelectContent = movement.SelectContent;
/*return this.Root.size;*/
this.CheckTarget();
}
},
MouseUp: function()
//
var sh = 0.2487852283770651*g_oTextMeasurer.GetHeight();
//
var size =
{
this.TEST_SELECT_ACTIVE = false;
Width: this.Root.size.width,
WidthVisible: this.Root.size.width,
Height: this.Root.size.height,
Ascent: this.Root.size.center + sh,
Descent: this.Root.size.height - this.Root.size.center
};
return size;
},
Remove_2: function(order)
{
if(TEST)
Remove: function(order, bOnAdd)
{
////* History */////
History.Create_NewPoint();
/*var start = this.SelectContent.selection.startPos,
end = this.SelectContent.selection.endPos;*/
var start = this.SelectContent.RealSelect.startPos,
end = this.SelectContent.RealSelect.endPos;
var Pos;
......@@ -6703,103 +6658,73 @@ CMathComposition.prototype =
Pos = this.SelectContent.CurPos;
else
Pos = this.SelectContent.CurPos + 1;
}
this.ClearSelect();
///////////////////////////
var removeMComp = true;
if(bOnAdd)
{
this.SelectContent.removeAreaSelect();
}
else
{
var result = this.SelectContent.remove(order);
this.CurrentContent = result.CurrContent;
this.SelectContent = result.SelectContent;
this.CurrentContent.setPlaceholderAfterRemove(); // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
var bRoot = this.SelectContent.bRoot === true,
bToUpper = result.state.bBegin || result.state.bEnd; // наверх нужно ли прокидовать
if( result.state.bDelete )
{
if(TEST)
{
History.Add(this.CurrentContent, {Type: historyitem_Math_RemoveItem, Items: result.items, Pos: Pos});
}
// временно
//this.CurrentContent.RecalculateReverse();
this.Resize(g_oTextMeasurer);
this.UpdatePosition();
}
this.CheckTarget();
this.CurrentContent = result.CurrContent;
this.SelectContent = result.SelectContent;
this.CurrentContent.setPlaceholderAfterRemove(); // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
removeMComp = !(bRoot && bToUpper); // посылаем false, если в начале + backspace или в конце + delete
}
return result.state.bDelete;
return removeMComp;
},
RecalculateComposition_2: function(oMeasure)
AddLetter: function(code)
{
//this.SetReferenceComposition();
History.Create_NewPoint();
this.Root.Resize(oMeasure);
this.Root.setPosition(this.pos);
this.UpdateCursor();
},
////
var items = this.SelectContent.addLetter(code);
this.CurrentContent = this.SelectContent;
////// ///////
HideCursor: function()
{
editor.WordControl.m_oLogicDocument.DrawingDocument.TargetEnd();
},
ShowCursor: function()
{
//узнать зачем обе функции вызывать
editor.WordControl.m_oLogicDocument.DrawingDocument.TargetStart();
editor.WordControl.m_oLogicDocument.DrawingDocument.TargetShow();
},
///
////////
var Pos = this.SelectContent.CurPos,
EndPos = this.SelectContent.CurPos + 1;
DrawSelect2: function()
{
this.SelectContent.drawSelect2();
},
Refresh_RecalcData2: function()
{
this.Parent.Refresh_RecalcData2();
History.Add(this.CurrentContent, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: EndPos});
},
//test
// из MathControl
IsRect: function(x, y)
CreateEquation: function(indef)
{
var size = this.Root.size;
return ( x > 0 && x < size.width && y > 0 && y < size.height);
History.Create_NewPoint();
var Pos = this.SelectContent.CurPos + 1;
var items = this.SelectContent.createEquation(indef);
this.CurrentContent = this.SelectContent;
var EndPos = this.SelectContent.CurPos + 1;
History.Add(this.CurrentContent, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: EndPos});
},
GetCoordComp: function(x, y)
UpdateCursor: function()
{
var _x = x - this.pos.x;
var _y = y - this.pos.y;
return {x: _x, y: _y};
this.SelectContent.update_Cursor();
},
CreateEquation: function(indef)
Refresh_RecalcData2: function()
{
this.CreateEquation2(indef);
// временно
//this.RecalculateReverse();
//this.Root.Resize();
this.Resize(g_oTextMeasurer);
this.UpdatePosition();
this.Parent.Refresh_RecalcData2();
},
RecalculateComposition: function(oMeasure, TextPr) // textPrp в тестовом режиме, просто отрисуем с ними формулу
{
////* test *////
/*var textPrp = new TextPr();
this.DefaultTxtPrp.FontSize = 11;
textPrp.Marge(this.DefaultTxtPrp);
textPrp.Merge(TextPr);
this.DefaultTxtPrp = textPrp;*/
///////////////////////
this.Root.Resize(oMeasure); // пересчитываем всю формулу
var width = this.Root.size.width,
......@@ -6807,37 +6732,12 @@ CMathComposition.prototype =
return {Width: width, Height: height, WidthVisible: width };
},
SetReferenceComposition: function()
{
this.Root.setReferenceComposition(this);
},
//////// For edit ////////
test_for_edit: function()
{
var props =
{
type: BAR_FRACTION
};
var fract = new CFraction();
addToContent_ForRead(this.Root, fract, props);
fract.getNumerator().addTxt("a");
fract.getDenominator().addTxt("b");
},
test_for_edit_2: function()
{
simulatorMComposition(this, MATH_EDIT);
},
Selection_SetStart: function(X, Y, PageNum)
{
var x = X - this.pos.x,
y = Y - this.pos.y;
this.Root.selection_Start(x, y);
//this.SelectContent = result.SelectContent; // если SetEnd придет раньше
},
Selection_SetEnd: function(X, Y, PageNum, MouseEvent)
{
......@@ -6849,7 +6749,7 @@ CMathComposition.prototype =
},
Selection_Draw: function()
{
this.SelectContent.drawSelect2();
this.SelectContent.drawSelect();
},
Selection_Beginning: function(bStart) // если приходит bStart = false, то это означает Selection_SetEnd (конец селекта в начале контента)
{
......@@ -6875,7 +6775,41 @@ CMathComposition.prototype =
Is_Empty: function()
{
return this.Root.IsEmpty();
},
///////// for Undo/Redo ////////
Get_SelectionState : function()
{
var State = new Object();
var stackCurrent = new Array();
this.CurrentContent.getStackPositions( stackCurrent );
State.Current =
{
stack: stackCurrent
};
var stackSelect = new Array();
this.SelectContent.getStackPositions( stackSelect );
State.Select =
{
StartSelect: this.SelectContent.RealSelect.startPos - 1,
EndSelect: this.SelectContent.RealSelect.endPos - 1,
stack: stackSelect
};
return State;
},
Set_SelectionState : function(State)
{
var stackSelect = Common_CopyObj(State.Select.stack),
stackCurrent = Common_CopyObj(State.Current.stack);
this.SelectContent = this.Root.getContent( stackSelect, false );
this.CurrentContent = this.Root.getContent( stackCurrent, true );
}
/////////////////////////////////////////
}
......
......@@ -184,7 +184,7 @@ CMathText.prototype =
this.size = {width: _width, widthG: widthG, height: _height, center: _center, ascent: _ascent, descent: _descent};
},
resize: function(oMeasure)
Resize: function(oMeasure)
{
var letter = this.getCode();
......@@ -341,10 +341,6 @@ CMathText.prototype =
this.size.center = this.size.center*(this.transform.sy + this.transform.shy);*/
},
Resize: function(oMeasure)
{
this.resize(oMeasure);
},
IsJustDraw: function()
{
return this.bJDraw;
......
......@@ -2533,14 +2533,14 @@ COperator.prototype.getProps = function(props, defaultProps)
this.defaultType = defaultProps.type;
var bDelimiter = this.type == OPER_DELIMITER || this.type == OPER_SEPARATOR,
bType = typeof(props.type)!=="undefined" && props.type !== null,
bNotType = typeof(props.type)=="undefined" || props.type == null,
bEmptyStr = typeof(chr) === "string" && chr.length == 0,
bCode = typeof(chr) === "string" && chr.length > 0;
var code = bCode ? chr.charCodeAt(0) : null;
var bDPrpDelim = bDelimiter && !bType && bEmptyStr,
bDPrpOther = !bDelimiter && !bType && !bCode;
var bDPrpDelim = bDelimiter && bNotType && bEmptyStr,
bDPrpOther = !bDelimiter && bNotType && !bCode;
if(bDPrpDelim || bDPrpOther)
{
......@@ -2722,15 +2722,6 @@ CDelimiter.prototype.init = function(props)
else if(props.grow == false || props.grow == 0)
this.grow = false;
if(props.begChr == undefined)
props.begChrType = PARENTHESIS_LEFT;
if(props.endChr == undefined)
props.endChrType = PARENTHESIS_RIGHT;
if(props.endChr == undefined && props.column >1)
props.sepChrType = DELIMITER_LINE;
var begPrp =
{
chr: props.begChr,
......@@ -3253,7 +3244,7 @@ CGroupCharacter.prototype.init = function(props)
/*this.setOperator(new COperator(glyph));*/
if(this.operator.IsArrow())
this.setReduct(DEGR_REDUCT); /// заменить впоследствии на более подходящую функцию
this.setReduct(DEGR_REDUCT);
}
CGroupCharacter.prototype.getCenter = function()
{
......
......@@ -18,7 +18,7 @@ function simulatorMComposition( MComposition, ttype)
props =
{
type: BAR_FRACTION
//type: BAR_FRACTION
};
var fract = new CFraction();
addToContent_ForRead(accent.getBase(), fract, props);
......@@ -52,10 +52,13 @@ function simulatorMComposition( MComposition, ttype)
props =
{
begChrType: PARENTHESIS_LEFT,
begChr: "",
endChr: "",
sepChr: "",
//begChrType: PARENTHESIS_LEFT,
//endChrType: PARENTHESIS_RIGHT,
endChr: ")",
sepChrType: DELIMITER_LINE,
//endChr: ")",
//sepChrType: DELIMITER_LINE,
column: 2
};
......@@ -230,7 +233,7 @@ function simulatorMComposition( MComposition, ttype)
lastElem.addTxt("w");
var oper = new CGroupCharacter();
/*var oper = new CGroupCharacter();
props =
{
chrType: DOUBLE_ARROW_LR,
......@@ -239,7 +242,7 @@ function simulatorMComposition( MComposition, ttype)
addToContent_ForRead(lastElem, oper, props);
oper.getBase().addTxt("a");
oper.getBase().addTxt("a");*/
lastElem.addTxt("y");
......
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