Commit fbed8d82 authored by Alexey Musinov's avatar Alexey Musinov Committed by KirillovIlya

DrawingArea _this -> prototype

parent ea52adf6
...@@ -565,72 +565,70 @@ function FrozenPlace(ws, type) { ...@@ -565,72 +565,70 @@ function FrozenPlace(ws, type) {
// Container // Container
function DrawingArea(ws) { function DrawingArea(ws) {
var _this = this;
var asc = window["Asc"]; var asc = window["Asc"];
var api = asc["editor"]; this.api = asc["editor"];
_this.worksheet = ws; this.worksheet = ws;
_this.frozenPlaces = []; this.frozenPlaces = [];
}
// Methods DrawingArea.prototype.init = function() {
_this.init = function() { this.frozenPlaces = [];
_this.frozenPlaces = []; if ( this.worksheet ) {
if ( _this.worksheet ) {
var place; var place;
if ( _this.worksheet.topLeftFrozenCell ) { if ( this.worksheet.topLeftFrozenCell ) {
place = new FrozenPlace(_this.worksheet, FrozenAreaType.Top); place = new FrozenPlace(this.worksheet, FrozenAreaType.Top);
if ( place.isValid ) if ( place.isValid )
_this.frozenPlaces.push(place); this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.Bottom); place = new FrozenPlace(this.worksheet, FrozenAreaType.Bottom);
if ( place.isValid ) if ( place.isValid )
_this.frozenPlaces.push(place); this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.Left); place = new FrozenPlace(this.worksheet, FrozenAreaType.Left);
if ( place.isValid ) if ( place.isValid )
_this.frozenPlaces.push(place); this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.Right); place = new FrozenPlace(this.worksheet, FrozenAreaType.Right);
if ( place.isValid ) if ( place.isValid )
_this.frozenPlaces.push(place); this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.LeftTop); place = new FrozenPlace(this.worksheet, FrozenAreaType.LeftTop);
if ( place.isValid ) if ( place.isValid )
_this.frozenPlaces.push(place); this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.RightTop); place = new FrozenPlace(this.worksheet, FrozenAreaType.RightTop);
if ( place.isValid ) if ( place.isValid )
_this.frozenPlaces.push(place); this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.LeftBottom); place = new FrozenPlace(this.worksheet, FrozenAreaType.LeftBottom);
if ( place.isValid ) if ( place.isValid )
_this.frozenPlaces.push(place); this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.RightBottom); place = new FrozenPlace(this.worksheet, FrozenAreaType.RightBottom);
if ( place.isValid ) if ( place.isValid )
_this.frozenPlaces.push(place); this.frozenPlaces.push(place);
} }
else else
_this.frozenPlaces.push(new FrozenPlace(_this.worksheet, FrozenAreaType.Center)); this.frozenPlaces.push(new FrozenPlace(this.worksheet, FrozenAreaType.Center));
} }
}; };
_this.clear = function() { DrawingArea.prototype.clear = function() {
_this.worksheet.drawingGraphicCtx.clear(); this.worksheet.drawingGraphicCtx.clear();
}; };
_this.drawObject = function(object) { DrawingArea.prototype.drawObject = function(object) {
for ( var i = 0; i < _this.frozenPlaces.length; i++ ) { for ( var i = 0; i < this.frozenPlaces.length; i++ ) {
if ( _this.frozenPlaces[i].isObjectInside(object) ) { if ( this.frozenPlaces[i].isObjectInside(object) ) {
_this.frozenPlaces[i].drawObject(object); this.frozenPlaces[i].drawObject(object);
} }
} }
}; };
_this.reinitRanges = function() DrawingArea.prototype.reinitRanges = function() {
{ for ( var i = 0; i < this.frozenPlaces.length; i++ ) {
for ( var i = 0; i < _this.frozenPlaces.length; i++ ) { this.frozenPlaces[i].initRange();
_this.frozenPlaces[i].initRange();
} }
}; };
_this.drawSelection = function(drawingDocument) { DrawingArea.prototype.drawSelection = function(drawingDocument) {
var canvas = _this.worksheet.objectRender.getDrawingCanvas(); var canvas = this.worksheet.objectRender.getDrawingCanvas();
var shapeCtx = canvas.shapeCtx; var shapeCtx = canvas.shapeCtx;
var shapeOverlayCtx = canvas.shapeOverlayCtx; var shapeOverlayCtx = canvas.shapeOverlayCtx;
var autoShapeTrack = canvas.autoShapeTrack; var autoShapeTrack = canvas.autoShapeTrack;
...@@ -640,30 +638,30 @@ function DrawingArea(ws) { ...@@ -640,30 +638,30 @@ function DrawingArea(ws) {
trackOverlay.Clear(); trackOverlay.Clear();
drawingDocument.Overlay = trackOverlay; drawingDocument.Overlay = trackOverlay;
_this.worksheet.overlayCtx.clear(); this.worksheet.overlayCtx.clear();
_this.worksheet.overlayGraphicCtx.clear(); this.worksheet.overlayGraphicCtx.clear();
_this.worksheet._drawCollaborativeElements(); this.worksheet._drawCollaborativeElements();
if ( !_this.worksheet.objectRender.controller.selectedObjects.length && !api.isStartAddShape ) if ( !this.worksheet.objectRender.controller.selectedObjects.length && !this.api.isStartAddShape )
_this.worksheet._drawSelection(); this.worksheet._drawSelection();
var chart; var chart;
var controller = _this.worksheet.objectRender.controller; var controller = this.worksheet.objectRender.controller;
var selected_objects = controller.selection.groupSelection ? controller.selection.groupSelection.selectedObjects : controller.selectedObjects; var selected_objects = controller.selection.groupSelection ? controller.selection.groupSelection.selectedObjects : controller.selectedObjects;
if(selected_objects.length === 1 && selected_objects[0].getObjectType() === historyitem_type_ChartSpace) if(selected_objects.length === 1 && selected_objects[0].getObjectType() === historyitem_type_ChartSpace)
{ {
chart = selected_objects[0]; chart = selected_objects[0];
_this.worksheet.objectRender.selectDrawingObjectRange(chart); this.worksheet.objectRender.selectDrawingObjectRange(chart);
//shapeOverlayCtx.ClearMode = true; //shapeOverlayCtx.ClearMode = true;
////selected_objects[0].draw(shapeOverlayCtx); ////selected_objects[0].draw(shapeOverlayCtx);
//shapeOverlayCtx.ClearMode = false; //shapeOverlayCtx.ClearMode = false;
} }
for ( var i = 0; i < _this.frozenPlaces.length; i++ ) { for ( var i = 0; i < this.frozenPlaces.length; i++ ) {
_this.frozenPlaces[i].setTransform(shapeCtx, shapeOverlayCtx, autoShapeTrack); this.frozenPlaces[i].setTransform(shapeCtx, shapeOverlayCtx, autoShapeTrack);
// Clip // Clip
_this.frozenPlaces[i].clip(shapeOverlayCtx); this.frozenPlaces[i].clip(shapeOverlayCtx);
if (null == drawingDocument.m_oDocumentRenderer) { if (null == drawingDocument.m_oDocumentRenderer) {
if (drawingDocument.m_bIsSelection) { if (drawingDocument.m_bIsSelection) {
...@@ -674,17 +672,17 @@ function DrawingArea(ws) { ...@@ -674,17 +672,17 @@ function DrawingArea(ws) {
trackOverlay.m_oContext = trackOverlay.m_oControl.HtmlElement.getContext('2d'); trackOverlay.m_oContext = trackOverlay.m_oControl.HtmlElement.getContext('2d');
} }
drawingDocument.private_StartDrawSelection(trackOverlay); drawingDocument.private_StartDrawSelection(trackOverlay);
_this.worksheet.objectRender.controller.drawTextSelection(); this.worksheet.objectRender.controller.drawTextSelection();
drawingDocument.private_EndDrawSelection(); drawingDocument.private_EndDrawSelection();
} }
ctx.globalAlpha = 1.0; ctx.globalAlpha = 1.0;
_this.worksheet.objectRender.controller.drawSelection(drawingDocument); this.worksheet.objectRender.controller.drawSelection(drawingDocument);
if ( _this.worksheet.objectRender.controller.needUpdateOverlay() ) { if ( this.worksheet.objectRender.controller.needUpdateOverlay() ) {
trackOverlay.Show(); trackOverlay.Show();
shapeOverlayCtx.put_GlobalAlpha(true, 0.5); shapeOverlayCtx.put_GlobalAlpha(true, 0.5);
_this.worksheet.objectRender.controller.drawTracks(shapeOverlayCtx); this.worksheet.objectRender.controller.drawTracks(shapeOverlayCtx);
shapeOverlayCtx.put_GlobalAlpha(true, 1); shapeOverlayCtx.put_GlobalAlpha(true, 1);
} }
} }
...@@ -704,16 +702,15 @@ function DrawingArea(ws) { ...@@ -704,16 +702,15 @@ function DrawingArea(ws) {
} }
// Restore // Restore
_this.frozenPlaces[i].restore(shapeOverlayCtx); this.frozenPlaces[i].restore(shapeOverlayCtx);
} }
}; };
_this.getOffsets = function(x, y, bEvents) { DrawingArea.prototype.getOffsets = function(x, y, bEvents) {
for ( var i = 0; i < _this.frozenPlaces.length; i++ ) { for ( var i = 0; i < this.frozenPlaces.length; i++ ) {
if ( _this.frozenPlaces[i].isPointInside(x, y, bEvents) ) { if ( this.frozenPlaces[i].isPointInside(x, y, bEvents) ) {
return { x: _this.frozenPlaces[i].getHorizontalScroll(), y: _this.frozenPlaces[i].getVerticalScroll() } return { x: this.frozenPlaces[i].getHorizontalScroll(), y: this.frozenPlaces[i].getVerticalScroll() }
} }
} }
return null; return null;
}; };
\ No newline at end of file
}
\ 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