UNPKG

devexpress-richedit

Version:

DevExpress Rich Text Editor is an advanced word-processing tool designed for working with rich text documents.

54 lines (53 loc) 1.73 kB
export class RulerMultiControl { get activeSubControl() { return this.subControls[this.handleControlIndex]; } constructor(modelData, controls) { this.subControls = []; this.handleControlIndex = -1; this.viewState = []; this.zoomLevel = 1.0; this.zoomChanged = false; this.modelData = modelData; this.controls = controls; } dispose() { for (let elem of this.subControls) elem.dispose(); this.subControls = []; } update() { this.updateModelState(); this.updateView(); } updateModelState() { this.currModelState = this.getModelState(); this.prevModelState = this.currModelState.clone(); this.zoomChanged = this.zoomLevel != this.modelData.zoomLevel; this.zoomLevel = this.modelData.zoomLevel; } onMouseMove(distance, _source) { this.calculateNewModelState(distance); this.updateView(); this.activeSubControl.lineControlSetPosition(); } onEscPress() { this.currModelState = this.prevModelState.clone(); this.finishHandle(); } finishHandle() { this.controls.lineControl.hide(); const activeSubControl = this.activeSubControl; if (activeSubControl) activeSubControl.hideShadow(); } setCount(count) { let diff = this.subControls.length - count; if (diff > 0) while (diff--) this.subControls.pop().dispose(); else { diff = Math.abs(diff); while (diff--) this.subControls.push(this.createSubControl()); } } }