| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // The callback method type invoked when the selection changes. | 5 // The callback method type invoked when the selection changes. |
| 6 typedef void SelectionCallback(); | 6 typedef void SelectionCallback(); |
| 7 | 7 |
| 8 // The method type for the SelectionManager.applyToSelectedCells method. | 8 // The method type for the SelectionManager.applyToSelectedCells method. |
| 9 typedef void SelectionApply(CellLocation location); | 9 typedef void SelectionApply(CellLocation location); |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 _selectionCorner = value; | 45 _selectionCorner = value; |
| 46 } | 46 } |
| 47 | 47 |
| 48 Spreadsheet get spreadsheet() => _spreadsheet; | 48 Spreadsheet get spreadsheet() => _spreadsheet; |
| 49 | 49 |
| 50 SelectionManager(this._spreadsheet, SpreadsheetPresenter presenter, Window win
dow, this._table) | 50 SelectionManager(this._spreadsheet, SpreadsheetPresenter presenter, Window win
dow, this._table) |
| 51 : _selectedCell = null, _selectionCorner = null, _originRow = 0, _originCo
lumn = 0 { | 51 : _selectedCell = null, _selectionCorner = null, _originRow = 0, _originCo
lumn = 0 { |
| 52 Document doc = window.document; | 52 Document doc = window.document; |
| 53 | 53 |
| 54 Element spreadsheetElement = presenter.spreadsheetElement; | 54 Element spreadsheetElement = presenter.spreadsheetElement; |
| 55 _selectionDiv = doc.createElement("div"); | 55 _selectionDiv = new Element.tag("div"); |
| 56 _selectionDiv.id = "selection-${_spreadsheet.name}"; | 56 _selectionDiv.id = "selection-${_spreadsheet.name}"; |
| 57 _selectionDiv.attributes["class"] = "selection"; | 57 _selectionDiv.attributes["class"] = "selection"; |
| 58 _selectionDiv.style.setProperty("display", "none"); | 58 _selectionDiv.style.setProperty("display", "none"); |
| 59 spreadsheetElement.nodes.add(_selectionDiv); | 59 spreadsheetElement.nodes.add(_selectionDiv); |
| 60 | 60 |
| 61 Element thumb = doc.createElement("div"); | 61 Element thumb = new Element.tag("div"); |
| 62 thumb.id = "selection-thumb-${_spreadsheet.name}"; | 62 thumb.id = "selection-thumb-${_spreadsheet.name}"; |
| 63 thumb.attributes["class"] = "selection-thumb"; | 63 thumb.attributes["class"] = "selection-thumb"; |
| 64 _selectionDiv.nodes.add(thumb); | 64 _selectionDiv.nodes.add(thumb); |
| 65 | 65 |
| 66 // Update selection after changing zoom factor, to reduce problems with posi
tion precision | 66 // Update selection after changing zoom factor, to reduce problems with posi
tion precision |
| 67 // Only create a single tracker per page | 67 // Only create a single tracker per page |
| 68 if (_zoomTracker == null) { | 68 if (_zoomTracker == null) { |
| 69 _zoomTracker = new ZoomTracker(window); | 69 _zoomTracker = new ZoomTracker(window); |
| 70 _zoomTracker.addListener((double oldZoom, double newZoom) { | 70 _zoomTracker.addListener((double oldZoom, double newZoom) { |
| 71 updateSelection(); | 71 updateSelection(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 return new CellRange.columns(corner1.spreadsheet, minCol, maxCol); | 269 return new CellRange.columns(corner1.spreadsheet, minCol, maxCol); |
| 270 } | 270 } |
| 271 | 271 |
| 272 return new CellRange(corner1.spreadsheet, new RowCol(minRow, minCol), | 272 return new CellRange(corner1.spreadsheet, new RowCol(minRow, minCol), |
| 273 new RowCol(maxRow, maxCol)); | 273 new RowCol(maxRow, maxCol)); |
| 274 } | 274 } |
| 275 | 275 |
| 276 // Return the value closest to x in the range [min, max] | 276 // Return the value closest to x in the range [min, max] |
| 277 int _pin(int x, int min, int max) => Math.max(Math.min(x, max), min); | 277 int _pin(int x, int min, int max) => Math.max(Math.min(x, max), min); |
| 278 } | 278 } |
| OLD | NEW |