Chromium Code Reviews| 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 typedef void EditCellRangeFunction(CellRange range); | 5 typedef void EditCellRangeFunction(CellRange range); |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Spreadsheet widget. | 8 * Spreadsheet widget. |
| 9 */ | 9 */ |
| 10 class SpreadsheetPresenter implements SpreadsheetListener, SelectionListener { | 10 class SpreadsheetPresenter implements SpreadsheetListener, SelectionListener { |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 667 _moveDragger.style.setProperty("left", HtmlUtils.toPx(3)); | 667 _moveDragger.style.setProperty("left", HtmlUtils.toPx(3)); |
| 668 _moveDragger.style.setProperty("top", HtmlUtils.toPx(3)); | 668 _moveDragger.style.setProperty("top", HtmlUtils.toPx(3)); |
| 669 _spreadsheetElement.nodes.add(_moveDragger); | 669 _spreadsheetElement.nodes.add(_moveDragger); |
| 670 | 670 |
| 671 _moveDragger.on.mouseDown.add((MouseEvent e) { | 671 _moveDragger.on.mouseDown.add((MouseEvent e) { |
| 672 _moveToTop(); | 672 _moveToTop(); |
| 673 _hideInnerMenu(true); | 673 _hideInnerMenu(true); |
| 674 | 674 |
| 675 int mouseStartX = e.x; | 675 int mouseStartX = e.x; |
| 676 int mouseStartY = e.y; | 676 int mouseStartY = e.y; |
| 677 ClientRect rect = _spreadsheetElement.getBoundingClientRect(); | |
| 678 int startX = rect.left; | |
| 679 int startY = rect.top; | |
| 680 _window.document.body.style.setProperty("cursor", "move"); | |
| 681 | 677 |
| 682 _setDragFunction((MouseEvent e) { | 678 _spreadsheetElement.rect.then((ElementRect elementRect) { |
| 683 int x = startX + e.x - mouseStartX; | 679 ClientRect rect = elementRect.bounding; |
| 684 int y = startY + e.y - mouseStartY; | 680 int startX = rect.left; |
| 681 int startY = rect.top; | |
| 682 _window.document.body.style.setProperty("cursor", "move"); | |
| 685 | 683 |
| 686 x = Math.max(x, CssStyles.OBJECTBAR_WIDTH); | 684 _setDragFunction((MouseEvent e) { |
| 687 y = Math.max(y, CssStyles.SANDBAR_HEIGHT); | 685 int x = startX + e.x - mouseStartX; |
|
arv (Not doing code reviews)
2011/10/27 05:50:24
e.x? We should kill that property... in another CL
Jacob
2011/10/27 20:59:25
Agreed. Can't wait till we cleanup the event class
| |
| 688 // Move the spreadsheet container | 686 int y = startY + e.y - mouseStartY; |
| 689 _spreadsheetElement.style.setProperty("left", HtmlUtils.toPx(x)); | 687 |
| 690 _spreadsheetElement.style.setProperty("top", HtmlUtils.toPx(y)); | 688 x = Math.max(x, CssStyles.OBJECTBAR_WIDTH); |
| 691 }); | 689 y = Math.max(y, CssStyles.SANDBAR_HEIGHT); |
| 690 // Move the spreadsheet container | |
| 691 _spreadsheetElement.style.setProperty("left", HtmlUtils.toPx(x)); | |
| 692 _spreadsheetElement.style.setProperty("top", HtmlUtils.toPx(y)); | |
| 693 }); | |
| 694 }); | |
| 692 | 695 |
| 693 _setUndragFunction((MouseEvent e) { | 696 _setUndragFunction((MouseEvent e) { |
| 694 _window.document.body.style.setProperty("cursor", "auto"); | 697 _window.document.body.style.setProperty("cursor", "auto"); |
| 695 }); | 698 }); |
| 696 }); | 699 }); |
| 697 } | 700 } |
| 698 | 701 |
| 699 void _createResizeDragger(Document doc) { | 702 void _createResizeDragger(Document doc) { |
| 700 _resizeDragger = doc.createElement("div"); | 703 _resizeDragger = doc.createElement("div"); |
| 701 _resizeDragger.id = "resizeDragger-${_spreadsheet.name}"; | 704 _resizeDragger.id = "resizeDragger-${_spreadsheet.name}"; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 877 | 880 |
| 878 // apply text selection now | 881 // apply text selection now |
| 879 _formulaCellSelectingSelectText(); | 882 _formulaCellSelectingSelectText(); |
| 880 | 883 |
| 881 // show cell selecting div | 884 // show cell selecting div |
| 882 { | 885 { |
| 883 DivElement div = _table.formulaCellSelectingDiv; | 886 DivElement div = _table.formulaCellSelectingDiv; |
| 884 CSSStyleDeclaration divStyle = div.style; | 887 CSSStyleDeclaration divStyle = div.style; |
| 885 int borderWidth = 2 + 2; | 888 int borderWidth = 2 + 2; |
| 886 CellRange cellRange = new CellRange(_spreadsheet, minCorner, maxCorner); | 889 CellRange cellRange = new CellRange(_spreadsheet, minCorner, maxCorner); |
| 887 BoundingBox box = _selectionManager.getBoundingBoxForRange(cellRange); | 890 _selectionManager.getBoundingBoxForRange(cellRange).then( |
| 888 if (box != null) { | 891 (BoundingBox box) { |
| 889 divStyle.setProperty("left", HtmlUtils.toPx(box.left)); | 892 if (box != null) { |
| 890 divStyle.setProperty("top", HtmlUtils.toPx(box.top)); | 893 divStyle.setProperty("left", HtmlUtils.toPx(box.left)); |
|
arv (Not doing code reviews)
2011/10/27 05:50:24
Is there a reason why we don't do divStyle.left =
Jacob
2011/10/27 20:59:25
Only historical reasons.
I'll do a separate CL th
| |
| 891 divStyle.setProperty("width", HtmlUtils.toPx(box.width - borderWidth)); | 894 divStyle.setProperty("top", HtmlUtils.toPx(box.top)); |
| 892 divStyle.setProperty("height", HtmlUtils.toPx(box.height - borderWidth)) ; | 895 divStyle.setProperty("width", HtmlUtils.toPx(box.width - borderWidth)) ; |
| 893 divStyle.removeProperty("display"); | 896 divStyle.setProperty("height", HtmlUtils.toPx(box.height - borderWidth )); |
| 894 } else { | 897 divStyle.removeProperty("display"); |
| 895 divStyle.setProperty("display", "none"); | 898 } else { |
| 896 } | 899 divStyle.setProperty("display", "none"); |
| 900 } | |
| 901 }); | |
| 897 } | 902 } |
| 898 } | 903 } |
| 899 | 904 |
| 900 void _formulaCellSelectingRememberSelectionRange() { | 905 void _formulaCellSelectingRememberSelectionRange() { |
| 901 _formulaCellSelectingTextStart = _formulaInput.selectionStart; | 906 _formulaCellSelectingTextStart = _formulaInput.selectionStart; |
| 902 _formulaCellSelectingTextEnd = _formulaInput.selectionEnd; | 907 _formulaCellSelectingTextEnd = _formulaInput.selectionEnd; |
| 903 } | 908 } |
| 904 | 909 |
| 905 void _formulaCellSelectingSelectText() { | 910 void _formulaCellSelectingSelectText() { |
| 906 _formulaInput.focus(); | 911 _formulaInput.focus(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1062 | 1067 |
| 1063 // Return the number of _rows currently being displayed (not counting the colu mn header row) | 1068 // Return the number of _rows currently being displayed (not counting the colu mn header row) |
| 1064 int _getVisibleTableHeight() => _getShiftedRowEnd(_rowShift + _rows, _rowShift ); | 1069 int _getVisibleTableHeight() => _getShiftedRowEnd(_rowShift + _rows, _rowShift ); |
| 1065 | 1070 |
| 1066 // Return the number of _columns currently being displayed (not counting the r ow header column) | 1071 // Return the number of _columns currently being displayed (not counting the r ow header column) |
| 1067 int _getVisibleTableWidth() => _getShiftedColumnEnd(_columnShift + _columns, _ columnShift); | 1072 int _getVisibleTableWidth() => _getShiftedColumnEnd(_columnShift + _columns, _ columnShift); |
| 1068 | 1073 |
| 1069 // Resize the formula input field to fit the contained text | 1074 // Resize the formula input field to fit the contained text |
| 1070 void _growFormulaInput() { | 1075 void _growFormulaInput() { |
| 1071 _formulaInputMeasure.text = _formulaInput.value; | 1076 _formulaInputMeasure.text = _formulaInput.value; |
| 1072 int textWidth = _formulaInputMeasure.clientWidth; | 1077 _formulaInputMeasure.rect.then((ElementRect rect) { |
| 1073 int width = Math.max(textWidth + 25, _formulaCellWidth); | 1078 int textWidth = rect.client.width; |
| 1074 _formulaDiv.style.setProperty("width", HtmlUtils.toPx(width)); | 1079 int width = Math.max(textWidth + 25, _formulaCellWidth); |
| 1075 _formulaInput.style.setProperty("width", HtmlUtils.toPx(width)); | 1080 _formulaDiv.style.setProperty("width", HtmlUtils.toPx(width)); |
| 1081 _formulaInput.style.setProperty("width", HtmlUtils.toPx(width)); | |
| 1082 }); | |
| 1076 } | 1083 } |
| 1077 | 1084 |
| 1078 // Fade out the formula input field | 1085 // Fade out the formula input field |
| 1079 void _hideFormula() { | 1086 void _hideFormula() { |
| 1080 _hideFormulaCellSelecting(); | 1087 _hideFormulaCellSelecting(); |
| 1081 _formulaEditing = false; | 1088 _formulaEditing = false; |
| 1082 _formulaDiv.classes.remove("fadeIn"); | 1089 _formulaDiv.classes.remove("fadeIn"); |
| 1083 _formulaDiv.classes.add("fadeOut"); | 1090 _formulaDiv.classes.add("fadeOut"); |
| 1084 } | 1091 } |
| 1085 | 1092 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1133 // update table row and column headers | 1140 // update table row and column headers |
| 1134 void _redrawHeaders() { | 1141 void _redrawHeaders() { |
| 1135 _setTableWidth(_getVisibleTableWidth()); | 1142 _setTableWidth(_getVisibleTableWidth()); |
| 1136 _tableSizeChanged(); | 1143 _tableSizeChanged(); |
| 1137 | 1144 |
| 1138 _table.redrawHeaders(_selectionManager, _rows, _columns, _rowShift, _columnS hift, | 1145 _table.redrawHeaders(_selectionManager, _rows, _columns, _rowShift, _columnS hift, |
| 1139 _cellDisplay); | 1146 _cellDisplay); |
| 1140 } | 1147 } |
| 1141 | 1148 |
| 1142 void _refreshResizeDragger() { | 1149 void _refreshResizeDragger() { |
| 1143 // We may be called before the dragger is ready | 1150 _table.rect.then((ElementRect elementRect) { |
| 1144 if (_resizeDragger == null) { | 1151 // We may be called before the dragger is ready |
| 1145 return; | 1152 if (_resizeDragger == null) { |
| 1146 } | 1153 return; |
| 1147 ClientRect rect = _table.getBoundingClientRect(); | 1154 } |
| 1155 ClientRect rect = elementRect.bounding; | |
| 1148 | 1156 |
| 1149 _resizeDragger.style.setProperty("left", HtmlUtils.toPx(rect.width)); | 1157 _resizeDragger.style.setProperty("left", HtmlUtils.toPx(rect.width)); |
| 1150 _resizeDragger.style.setProperty("top", HtmlUtils.toPx(rect.height)); | 1158 _resizeDragger.style.setProperty("top", HtmlUtils.toPx(rect.height)); |
| 1159 }); | |
| 1151 } | 1160 } |
| 1152 | 1161 |
| 1153 // Remove the HTML elements corresponding to the given column | 1162 // Remove the HTML elements corresponding to the given column |
| 1154 void _removeTableColumnHtml(int col) { | 1163 void _removeTableColumnHtml(int col) { |
| 1155 _table.removeColumn(col); | 1164 _table.removeColumn(col); |
| 1156 int width = _spreadsheet.getColumnWidth(col); | 1165 int width = _spreadsheet.getColumnWidth(col); |
| 1157 _setTableWidth(_tableWidth - width); | 1166 _setTableWidth(_tableWidth - width); |
| 1158 } | 1167 } |
| 1159 | 1168 |
| 1160 // Remove the HTML elements corresponding to the given row | 1169 // Remove the HTML elements corresponding to the given row |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1281 | 1290 |
| 1282 List<int> draggingRowColumn = new List<int>(2); | 1291 List<int> draggingRowColumn = new List<int>(2); |
| 1283 draggingRowColumn[COL] = -1; | 1292 draggingRowColumn[COL] = -1; |
| 1284 draggingRowColumn[ROW] = -1; | 1293 draggingRowColumn[ROW] = -1; |
| 1285 | 1294 |
| 1286 int oldSize; | 1295 int oldSize; |
| 1287 int start; | 1296 int start; |
| 1288 int x; | 1297 int x; |
| 1289 int y; | 1298 int y; |
| 1290 | 1299 |
| 1291 // Set x and y to the mouse coordinates, relative to the top left of the spr eadsheet table | |
| 1292 void getRelativeCoordinates(MouseEvent e) { | |
| 1293 ClientRect boundingRect = _table.getBoundingClientRect(); | |
| 1294 int scrollOffsetX = -boundingRect.left.toInt(); | |
| 1295 int scrollOffsetY = -boundingRect.top.toInt(); | |
| 1296 x = e.x + scrollOffsetX; | |
| 1297 y = e.y + scrollOffsetY; | |
| 1298 } | |
| 1299 | |
| 1300 // Sets the drag indicator to the given position, given as an absolute offse t from | 1300 // Sets the drag indicator to the given position, given as an absolute offse t from |
| 1301 // the upper-left corner of the spreadsheet | 1301 // the upper-left corner of the spreadsheet |
| 1302 void setDragPosition(int rowOrCol, int pos) { | 1302 void setDragPosition(int rowOrCol, int pos) { |
| 1303 if (rowOrCol == COL) { | 1303 if (rowOrCol == COL) { |
| 1304 pos -= _spreadsheet.getColumnShift(_columnShift); | 1304 pos -= _spreadsheet.getColumnShift(_columnShift); |
| 1305 _dragIndicators[COL].style.setProperty("left", HtmlUtils.toPx(pos)); | 1305 _dragIndicators[COL].style.setProperty("left", HtmlUtils.toPx(pos)); |
| 1306 } else { | 1306 } else { |
| 1307 pos -= _spreadsheet.getRowShift(_rowShift); | 1307 pos -= _spreadsheet.getRowShift(_rowShift); |
| 1308 // need to shift for the inner menu offset | 1308 // need to shift for the inner menu offset |
| 1309 pos += _getInnerMenuOffset(hoverRowColumn[ROW]); | 1309 pos += _getInnerMenuOffset(hoverRowColumn[ROW]); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1460 setDrag(COL, false); | 1460 setDrag(COL, false); |
| 1461 } | 1461 } |
| 1462 }); | 1462 }); |
| 1463 | 1463 |
| 1464 // The inline cell editing UI is displayed when a user makes the same single | 1464 // The inline cell editing UI is displayed when a user makes the same single |
| 1465 // cell selection over again. We keep track of the current single cell that | 1465 // cell selection over again. We keep track of the current single cell that |
| 1466 // is selected here to know when to enter edit mode. | 1466 // is selected here to know when to enter edit mode. |
| 1467 CellLocation currentSelectedSingleCell = null; | 1467 CellLocation currentSelectedSingleCell = null; |
| 1468 | 1468 |
| 1469 void mouseMove(MouseEvent e) { | 1469 void mouseMove(MouseEvent e) { |
| 1470 getRelativeCoordinates(e); | 1470 _table.rect.then((ElementRect rect) { |
| 1471 // Set x and y to the mouse coordinates, relative to the top left of | |
| 1472 // the spreadsheet table. | |
| 1473 ClientRect boundingRect = rect.bounding; | |
| 1474 int scrollOffsetX = -boundingRect.left.toInt(); | |
| 1475 int scrollOffsetY = -boundingRect.top.toInt(); | |
| 1476 x = e.x + scrollOffsetX; | |
| 1477 y = e.y + scrollOffsetY; | |
| 1471 | 1478 |
| 1472 // Update the dragger position and optionally the actual row/column size | 1479 // Update the dragger position and optionally the actual row/column size |
| 1473 if (dragRowColumn(false)) { | 1480 if (dragRowColumn(false)) { |
| 1474 return; | 1481 return; |
| 1475 } | 1482 } |
| 1476 | 1483 |
| 1477 // Show a row/column dragging indicator when hovering over row/column 0 | 1484 // Show a row/column dragging indicator when hovering over row/column 0 |
| 1478 if (x < _spreadsheet.getColumnWidth(0) && x > 0) { | 1485 if (x < _spreadsheet.getColumnWidth(0) && x > 0) { |
| 1479 hoverRowColumn[ROW] = _getRowOrColumn(y, ROW); | 1486 hoverRowColumn[ROW] = _getRowOrColumn(y, ROW); |
| 1480 } else { | |
| 1481 hoverRowColumn[ROW] = -1; | |
| 1482 } | |
| 1483 if (y < _spreadsheet.getRowHeight(0) && y > 0) { | |
| 1484 hoverRowColumn[COL] = _getRowOrColumn(x, COL); | |
| 1485 } else { | |
| 1486 hoverRowColumn[COL] = -1; | |
| 1487 } | |
| 1488 if (hoverRowColumn[COL] != -1) { | |
| 1489 hoverRowColumn[ROW] = -1; | |
| 1490 setDrag(COL, true); | |
| 1491 setDrag(ROW, false); | |
| 1492 } else { | |
| 1493 setDrag(COL, false); | |
| 1494 if (hoverRowColumn[ROW] != -1) { | |
| 1495 setDrag(ROW, true); | |
| 1496 } else { | 1487 } else { |
| 1488 hoverRowColumn[ROW] = -1; | |
| 1489 } | |
| 1490 if (y < _spreadsheet.getRowHeight(0) && y > 0) { | |
| 1491 hoverRowColumn[COL] = _getRowOrColumn(x, COL); | |
| 1492 } else { | |
| 1493 hoverRowColumn[COL] = -1; | |
| 1494 } | |
| 1495 if (hoverRowColumn[COL] != -1) { | |
| 1496 hoverRowColumn[ROW] = -1; | |
| 1497 setDrag(COL, true); | |
| 1497 setDrag(ROW, false); | 1498 setDrag(ROW, false); |
| 1499 } else { | |
| 1500 setDrag(COL, false); | |
| 1501 if (hoverRowColumn[ROW] != -1) { | |
| 1502 setDrag(ROW, true); | |
| 1503 } else { | |
| 1504 setDrag(ROW, false); | |
| 1505 } | |
| 1498 } | 1506 } |
| 1499 } | 1507 if (hoverRowColumn[COL] != -1) { |
| 1500 if (hoverRowColumn[COL] != -1) { | 1508 _table.setColResizeCursor(); |
| 1501 _table.setColResizeCursor(); | 1509 } else if (hoverRowColumn[ROW] != -1) { |
| 1502 } else if (hoverRowColumn[ROW] != -1) { | 1510 _table.setRowResizeCursor(); |
| 1503 _table.setRowResizeCursor(); | 1511 } else { |
| 1504 } else { | 1512 _table.setCellCursor(); |
| 1505 _table.setCellCursor(); | 1513 } |
| 1506 } | |
| 1507 | 1514 |
| 1508 // If dragging a selections, update the selection's second corner | 1515 // If dragging a selections, update the selection's second corner |
| 1509 if (!draggingSelection) { | 1516 if (!draggingSelection) { |
| 1510 return; | 1517 return; |
| 1511 } | 1518 } |
| 1512 Element target = e.target; | 1519 Element target = e.target; |
| 1513 CellLocation location = _getCellLocation(target); | 1520 CellLocation location = _getCellLocation(target); |
| 1514 if (location == null) { | 1521 if (location == null) { |
| 1515 return; | 1522 return; |
| 1516 } | 1523 } |
| 1517 _selectionManager.selectionCorner = location; | 1524 _selectionManager.selectionCorner = location; |
| 1518 // If the drag has selected more than one cell then we no longer | 1525 // If the drag has selected more than one cell then we no longer |
| 1519 // have a current single cell selection. | 1526 // have a current single cell selection. |
| 1520 if (!_selectionManager.isSingleCellSelection()) { | 1527 if (!_selectionManager.isSingleCellSelection()) { |
| 1521 currentSelectedSingleCell = null; | 1528 currentSelectedSingleCell = null; |
| 1522 } | 1529 } |
| 1523 _selectionManager.updateSelection(); | 1530 _selectionManager.updateSelection(); |
| 1524 _redrawHeaders(); | 1531 _redrawHeaders(); |
| 1532 }); | |
| 1525 } | 1533 } |
| 1526 | 1534 |
| 1527 _setMove(mouseMove); | 1535 _setMove(mouseMove); |
| 1528 | 1536 |
| 1529 _table.on.mouseDown.add((MouseEvent e) { | 1537 _table.on.mouseDown.add((MouseEvent e) { |
| 1530 _moveToTop(); | 1538 _moveToTop(); |
| 1531 | 1539 |
| 1532 // Right click toggles and positions the context menu | 1540 // Right click toggles and positions the context menu |
| 1533 if (e.button == 2 || (e.button == 0 && e.ctrlKey)) { | 1541 if (e.button == 2 || (e.button == 0 && e.ctrlKey)) { |
| 1534 ClientRect boundingRect = _table.getBoundingClientRect(); | 1542 _table.rect.then((ElementRect rect) { |
| 1535 int scrollOffsetX = -boundingRect.left; | 1543 ClientRect boundingRect = rect.bounding; |
| 1536 int scrollOffsetY = -boundingRect.top; | 1544 int scrollOffsetX = -boundingRect.left; |
| 1537 _contextMenu.show(e.x + scrollOffsetX, e.y + scrollOffsetY); | 1545 int scrollOffsetY = -boundingRect.top; |
| 1546 _contextMenu.show(e.x + scrollOffsetX, e.y + scrollOffsetY); | |
| 1547 }); | |
| 1538 return; | 1548 return; |
| 1539 } | 1549 } |
| 1540 | 1550 |
| 1541 _setDragFunction(mouseMove); | 1551 _setDragFunction(mouseMove); |
| 1542 | 1552 |
| 1543 _setUndragFunction((MouseEvent e) { | 1553 _setUndragFunction((MouseEvent e) { |
| 1544 dragRowColumn(true); | 1554 dragRowColumn(true); |
| 1545 _table.setDefaultCursor(); | 1555 _table.setDefaultCursor(); |
| 1546 draggingSelection = false; | 1556 draggingSelection = false; |
| 1547 draggingRowColumn[COL] = -1; | 1557 draggingRowColumn[COL] = -1; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1668 } | 1678 } |
| 1669 _activeInnerMenu = new InnerMenuView(_window, row, _selectionManager, style, | 1679 _activeInnerMenu = new InnerMenuView(_window, row, _selectionManager, style, |
| 1670 _spreadsheet.layout.getRowHeight(rowIndex), | 1680 _spreadsheet.layout.getRowHeight(rowIndex), |
| 1671 (){ _tableSizeChanged(); }, | 1681 (){ _tableSizeChanged(); }, |
| 1672 (){ _hideInnerMenu(true); _repositionFormulaInput(null, false); }); | 1682 (){ _hideInnerMenu(true); _repositionFormulaInput(null, false); }); |
| 1673 _innerMenuRowIndex = rowIndex; | 1683 _innerMenuRowIndex = rowIndex; |
| 1674 } | 1684 } |
| 1675 | 1685 |
| 1676 // Update the scroll mechanism due to a change in the visible table area | 1686 // Update the scroll mechanism due to a change in the visible table area |
| 1677 void _tableSizeChanged() { | 1687 void _tableSizeChanged() { |
| 1678 ClientRect rect = _table.getBoundingClientRect(); | 1688 _table.rect.then((ElementRect elementRect) { |
| 1689 ClientRect rect = elementRect.bounding; | |
| 1679 | 1690 |
| 1680 _tableScrollContainer.style.setProperty("width", HtmlUtils.toPx(rect.width + 10)); | 1691 _tableScrollContainer.style.setProperty("width", HtmlUtils.toPx(rect.width + 10)); |
|
arv (Not doing code reviews)
2011/10/27 05:50:24
long lines
Jacob
2011/10/27 20:59:25
Done.
| |
| 1681 _spreadsheetElement.style.setProperty("width", HtmlUtils.toPx(rect.width)); | 1692 _spreadsheetElement.style.setProperty("width", HtmlUtils.toPx(rect.width)) ; |
| 1682 | 1693 |
| 1683 _tableScrollContainer.style.setProperty("height", HtmlUtils.toPx(rect.height + 10)); | 1694 _tableScrollContainer.style.setProperty("height", HtmlUtils.toPx(rect.heig ht + 10)); |
| 1684 _spreadsheetElement.style.setProperty("height", HtmlUtils.toPx(rect.height)) ; | 1695 _spreadsheetElement.style.setProperty("height", HtmlUtils.toPx(rect.height )); |
| 1685 | 1696 |
| 1686 _tableScrollDiv.style.setProperty("width", | 1697 _tableScrollDiv.style.setProperty("width", |
| 1687 HtmlUtils.toPx(_spreadsheet.getColumnEnd(_spreadsheet.columnCount()))); | 1698 HtmlUtils.toPx(_spreadsheet.getColumnEnd(_spreadsheet.columnCount()))) ; |
| 1688 int extra = _activeInnerMenu == null ? 0 : _activeInnerMenu.currentRowHeight ; | 1699 int extra = _activeInnerMenu == null ? 0 : _activeInnerMenu.currentRowHeig ht; |
| 1689 _tableScrollDiv.style.setProperty("height", | 1700 _tableScrollDiv.style.setProperty("height", |
| 1690 HtmlUtils.toPx(_spreadsheet.getRowEnd(_spreadsheet.rowCount()) + extra)) ; | 1701 HtmlUtils.toPx(_spreadsheet.getRowEnd(_spreadsheet.rowCount()) + extra )); |
| 1691 | 1702 |
| 1692 // Reposition the scroll bars | 1703 // Reposition the scroll bars |
| 1693 _scroll(_rowShift, _columnShift); | 1704 _scroll(_rowShift, _columnShift); |
| 1694 // Move the resize dragger to the bottom-right corner | 1705 // Move the resize dragger to the bottom-right corner |
| 1695 _refreshResizeDragger(); | 1706 _refreshResizeDragger(); |
| 1707 }); | |
| 1696 } | 1708 } |
| 1697 | 1709 |
| 1698 void _updateInnerMenu() { | 1710 void _updateInnerMenu() { |
| 1699 if (_activeInnerMenu != null) { | 1711 if (_activeInnerMenu != null) { |
| 1700 _activeInnerMenu.updateSize(); | 1712 _activeInnerMenu.updateSize(); |
| 1701 } | 1713 } |
| 1702 } | 1714 } |
| 1703 | 1715 |
| 1704 // Change the width/height of a column or row. | 1716 // Change the width/height of a column or row. |
| 1705 void _updateRowColumnSize(int rowOrCol, int index, int size, int oldSize, bool mouseUp) { | 1717 void _updateRowColumnSize(int rowOrCol, int index, int size, int oldSize, bool mouseUp) { |
| 1706 if (mouseUp) { | 1718 if (mouseUp) { |
| 1707 Command command = new ResizeRowColumnCommand(_spreadsheet, rowOrCol, index , size, oldSize); | 1719 Command command = new ResizeRowColumnCommand(_spreadsheet, rowOrCol, index , size, oldSize); |
| 1708 _spreadsheet.execute(command); | 1720 _spreadsheet.execute(command); |
| 1709 } else { | 1721 } else { |
| 1710 if (rowOrCol == COL) { | 1722 if (rowOrCol == COL) { |
| 1711 _spreadsheet.setColumnWidth(index, size); | 1723 _spreadsheet.setColumnWidth(index, size); |
| 1712 } else { | 1724 } else { |
| 1713 _spreadsheet.setRowHeight(index, size); | 1725 _spreadsheet.setRowHeight(index, size); |
| 1714 } | 1726 } |
| 1715 } | 1727 } |
| 1716 } | 1728 } |
| 1717 } | 1729 } |
| OLD | NEW |