| 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 /** | 5 /** |
| 6 * A class encapsulating the managemnet of the Html [:<table>:] representing the
spreadsheet grid. | 6 * A class encapsulating the managemnet of the Html [:<table>:] representing the
spreadsheet grid. |
| 7 */ | 7 */ |
| 8 class HtmlTable { | 8 class HtmlTable { |
| 9 | 9 |
| 10 DivElement _formulaCellSelectingDiv; | 10 DivElement _formulaCellSelectingDiv; |
| 11 Spreadsheet _spreadsheet; | 11 Spreadsheet _spreadsheet; |
| 12 TableElement _table; | 12 TableElement _table; |
| 13 | 13 |
| 14 // Must be called after the creation of the <tbody> element | 14 // Must be called after the creation of the <tbody> element |
| 15 DivElement get formulaCellSelectingDiv() { | 15 DivElement get formulaCellSelectingDiv() { |
| 16 if (_formulaCellSelectingDiv == null) { | 16 if (_formulaCellSelectingDiv == null) { |
| 17 _formulaCellSelectingDiv = _table.document.createElement("div"); | 17 _formulaCellSelectingDiv = new Element.tag("div"); |
| 18 _formulaCellSelectingDiv.id = "formulaSelectingCell-${_spreadsheet.name}"; | 18 _formulaCellSelectingDiv.id = "formulaSelectingCell-${_spreadsheet.name}"; |
| 19 _formulaCellSelectingDiv.attributes["class"] = "formulaSelectingCell"; | 19 _formulaCellSelectingDiv.attributes["class"] = "formulaSelectingCell"; |
| 20 } | 20 } |
| 21 _table.nodes.add(_formulaCellSelectingDiv); | 21 _table.nodes.add(_formulaCellSelectingDiv); |
| 22 return _formulaCellSelectingDiv; | 22 return _formulaCellSelectingDiv; |
| 23 } | 23 } |
| 24 | 24 |
| 25 // FIXME | 25 // FIXME |
| 26 ElementEvents get on() => _table.on; | 26 ElementEvents get on() => _table.on; |
| 27 | 27 |
| 28 HtmlTable(this._spreadsheet, Element parent) { | 28 HtmlTable(this._spreadsheet, Element parent) { |
| 29 Document doc = parent.document; | 29 Document doc = parent.document; |
| 30 | 30 |
| 31 _table = doc.createElement("table"); | 31 _table = new Element.tag("table"); |
| 32 _table.attributes["class"] = "spreadsheet"; | 32 _table.attributes["class"] = "spreadsheet"; |
| 33 _table.style.setProperty("position", "absolute"); | 33 _table.style.setProperty("position", "absolute"); |
| 34 _table.style.setProperty("z-index", "2"); | 34 _table.style.setProperty("z-index", "2"); |
| 35 _table.style.setProperty("left", "0"); | 35 _table.style.setProperty("left", "0"); |
| 36 _table.style.setProperty("top", "0"); | 36 _table.style.setProperty("top", "0"); |
| 37 | 37 |
| 38 parent.nodes.add(_table); | 38 parent.nodes.add(_table); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void addColumn(int col, int columnWidth) { | 41 void addColumn(int col, int columnWidth) { |
| 42 Document doc = _table.document; | 42 Document doc = _table.document; |
| 43 bool first = true; | 43 bool first = true; |
| 44 for (TableRowElement row in _table.rows) { | 44 for (TableRowElement row in _table.rows) { |
| 45 TableCellElement cell; | 45 TableCellElement cell; |
| 46 if (first) { | 46 if (first) { |
| 47 first = false; | 47 first = false; |
| 48 cell = doc.createElement("td"); | 48 cell = new Element.tag("td"); |
| 49 cell.width = HtmlUtils.toPx(columnWidth); | 49 cell.width = HtmlUtils.toPx(columnWidth); |
| 50 row.insertBefore(cell, row.cells[col]); | 50 row.insertBefore(cell, row.cells[col]); |
| 51 } else { | 51 } else { |
| 52 cell = row.insertCell(col); | 52 cell = row.insertCell(col); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 void addRow(int row, int columns) { | 57 void addRow(int row, int columns) { |
| 58 TableRowElement rowElement = _table.insertRow(row); | 58 TableRowElement rowElement = _table.insertRow(row); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 if (row <= 0 || row > rows) { | 413 if (row <= 0 || row > rows) { |
| 414 return false; | 414 return false; |
| 415 } | 415 } |
| 416 int col = rowCol.col - columnShift; | 416 int col = rowCol.col - columnShift; |
| 417 if (col <= 0 || col > columns) { | 417 if (col <= 0 || col > columns) { |
| 418 return false; | 418 return false; |
| 419 } | 419 } |
| 420 return true; | 420 return true; |
| 421 } | 421 } |
| 422 } | 422 } |
| OLD | NEW |