1
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3
* The contents of this file are subject to the Mozilla Public License
4
* Version 1.1 (the "License"); you may not use this file except in
5
* compliance with the License. You may obtain a copy of the License at
6
* http://www.mozilla.org/MPL/
3
* ***** BEGIN LICENSE BLOCK *****
4
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
* The contents of this file are subject to the Mozilla Public License Version
7
* 1.1 (the "License"); you may not use this file except in compliance with
8
* the License. You may obtain a copy of the License at
9
* http://www.mozilla.org/MPL/
8
11
* Software distributed under the License is distributed on an "AS IS" basis,
9
12
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10
13
* for the specific language governing rights and limitations under the
13
* The Original Code is The JavaScript Debugger
16
* The Original Code is The JavaScript Debugger.
15
18
* The Initial Developer of the Original Code is
16
* Netscape Communications Corporation
17
* Portions created by Netscape are
18
* Copyright (C) 1998 Netscape Communications Corporation.
20
* Alternatively, the contents of this file may be used under the
21
* terms of the GNU Public License (the "GPL"), in which case the
22
* provisions of the GPL are applicable instead of those above.
23
* If you wish to allow use of your version of this file only
24
* under the terms of the GPL and not to allow others to use your
25
* version of this file under the MPL, indicate your decision by
26
* deleting the provisions above and replace them with the notice
27
* and other provisions required by the GPL. If you do not delete
28
* the provisions above, a recipient may use your version of this
29
* file under either the MPL or the GPL.
19
* Netscape Communications Corporation.
20
* Portions created by the Initial Developer are Copyright (C) 1998
21
* the Initial Developer. All Rights Reserved.
32
* Robert Ginda, <rginda@netscape.com>, original author
24
* Robert Ginda, <rginda@netscape.com>, original author
26
* Alternatively, the contents of this file may be used under the terms of
27
* either the GNU General Public License Version 2 or later (the "GPL"), or
28
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
* in which case the provisions of the GPL or the LGPL are applicable instead
30
* of those above. If you wish to allow use of your version of this file only
31
* under the terms of either the GPL or the LGPL, and not to allow others to
32
* use your version of this file under the terms of the MPL, indicate your
33
* decision by deleting the provisions above and replace them with the notice
34
* and other provisions required by the GPL or the LGPL. If you do not delete
35
* the provisions above, a recipient may use your version of this file under
36
* the terms of any one of the MPL, the GPL or the LGPL.
38
* ***** END LICENSE BLOCK ***** */
37
41
* BasicOView provides functionality of tree whose elements have no children.
91
95
var headerRows = 1;
93
97
var first = this.tree.getFirstVisibleRow();
94
98
var last = this.tree.getLastVisibleRow();
95
var viz = last - first - headerRows; /* total number of visible rows */
99
var viz = last - first + 1 - headerRows; /* total number of visible rows */
97
101
/* all rows are visible, nothing to scroll */
98
if (first == 0 && last > this.rowCount)
102
if (first == 0 && last >= this.rowCount)
101
105
/* tree lines are 0 based, we accept one based lines, deal with it */
104
108
/* safety clamp */
107
if (line > this.rowCount)
108
line = this.rowCount;
111
if (line >= this.rowCount)
112
line = this.rowCount - 1;
112
if (line > this.rowCount - viz) /* overscroll, can't put a row from */
116
if (line > this.rowCount - viz) /* overscroll, can't put a row from */
113
117
line = this.rowCount - viz; /* last page at the top. */
114
118
this.tree.scrollToRow(line);
128
132
/* lines past this line can't be centered without causing the tree
129
133
* to show more rows than we have. */
130
134
var lastCenterable = this.rowCount - half_viz;
131
if (line > lastCenterable)
132
136
line = lastCenterable;
133
137
/* lines before this can't be centered without causing the tree
134
138
* to attempt to display negative rows. */
135
139
else if (line < half_viz)
142
/* round the vizible rows down to a whole number, or we try to end up
143
* on a N + 0.5 row! */
144
half_viz = Math.floor(half_viz);
137
146
this.tree.scrollToRow(line - half_viz);
141
150
BasicOView.prototype.__defineGetter__("selectedIndex", bov_getsel);
142
151
function bov_getsel()
144
if (!this.tree || this.tree.selection.getRangeCount() < 1)
153
if (!this.tree || this.tree.view.selection.getRangeCount() < 1)
147
156
var min = new Object();
148
this.tree.selection.getRangeAt(0, min, {});
157
this.tree.view.selection.getRangeAt(0, min, {});
149
158
return min.value;
166
175
BasicOView.prototype.rowCount = 0;
168
177
BasicOView.prototype.getCellProperties =
169
function bov_cellprops (row, colID, properties)
178
function bov_cellprops (row, col, properties)
173
182
BasicOView.prototype.getColumnProperties =
174
function bov_colprops (colID, elem, properties)
183
function bov_colprops (col, properties)
252
255
BasicOView.prototype.getImageSrc =
253
function bov_getimgsrc (row, colID)
256
function bov_getimgsrc (row, col)
257
260
BasicOView.prototype.getProgressMode =
258
function bov_getprgmode (row, colID)
261
function bov_getprgmode (row, col)
262
265
BasicOView.prototype.getCellValue =
263
function bov_getcellval (row, colID)
266
function bov_getcellval (row, col)
267
270
BasicOView.prototype.getCellText =
268
function bov_getcelltxt (row, colID)
271
function bov_getcelltxt (row, col)
270
273
if (!this.columnNames)
273
var ary = colID.match (/:(.*)/);
276
if (typeof col == "object")
279
var ary = col.match (/:(.*)/);
277
var col = this.columnNames[colID];
283
var colName = this.columnNames[col];
279
if (typeof col == "undefined")
285
if (typeof colName == "undefined")
282
return this.data[row][col];
288
return this.data[row][colName];
285
291
BasicOView.prototype.setTree =
306
312
BasicOView.prototype.cycleCell =
307
function bov_cyclecell (row, colID)
313
function bov_cyclecell (row, col)
311
317
BasicOView.prototype.isEditable =
312
function bov_isedit (row, colID)
318
function bov_isedit (row, col)
323
BasicOView.prototype.setCellValue =
324
function bov_setct (row, col, value)
317
328
BasicOView.prototype.setCellText =
318
function bov_setct (row, colID, value)
329
function bov_setct (row, col, value)
634
* this method will cause all child records to be resorted. any records
643
* this method will cause all child records to be reSorted. any records
635
644
* with the default sortCompare method will be sorted by the colID passed to
638
647
* the local parameter is used internally to control whether or not the
639
648
* sorted rows are invalidated. don't use it yourself.
641
XULTreeViewRecord.prototype.resort =
650
XULTreeViewRecord.prototype.reSort =
642
651
function xtvr_resort (leafSort)
644
653
if (!("childData" in this) || this.childData.length < 1 ||
777
778
if (!ASSERT(this.childData.length, "removing from empty childData"))
780
//for (var i = index + 1; i < this.childData.length; ++i)
781
// --this.childData[i].childIndex;
783
781
var orphan = this.childData[index];
784
782
var fpDelta = -orphan.visualFootprint;
785
783
var changeStart = orphan.calculateVisualRow();
786
//this.childData[index].childIndex = -1;
787
784
delete orphan.parentRecord;
788
785
arrayRemoveAt (this.childData, index);
1323
1313
XULTreeView.prototype.__defineGetter__("selectedIndex", xtv_getsel);
1324
1314
function xtv_getsel()
1326
if (!this.tree || this.tree.selection.getRangeCount() < 1)
1316
if (!this.tree || this.tree.view.selection.getRangeCount() < 1)
1329
1319
var min = new Object();
1330
this.tree.selection.getRangeAt(0, min, {});
1320
this.tree.view.selection.getRangeAt(0, min, {});
1331
1321
return min.value;
1334
1324
XULTreeView.prototype.__defineSetter__("selectedIndex", xtv_setsel);
1335
1325
function xtv_setsel(i)
1337
this.tree.selection.clearSelection();
1327
this.tree.view.selection.clearSelection();
1339
this.tree.selection.timedSelect (i, 500);
1329
this.tree.view.selection.timedSelect (i, 500);
1442
1405
XULTreeView.prototype.getImageSrc =
1443
function xtv_getimgsrc (index, colID)
1406
function xtv_getimgsrc (index, col)
1447
1410
XULTreeView.prototype.getProgressMode =
1448
function xtv_getprgmode (index, colID)
1411
function xtv_getprgmode (index, col)
1452
1415
XULTreeView.prototype.getCellValue =
1453
function xtv_getcellval (index, colID)
1416
function xtv_getcellval (index, col)
1457
1420
XULTreeView.prototype.getCellText =
1458
function xtv_getcelltxt (index, colID)
1421
function xtv_getcelltxt (index, col)
1460
1423
var row = this.childData.locateChildByVisualRow (index);
1461
1424
//ASSERT(row, "bogus row " + index);
1463
var ary = colID.match (/:(.*)/);
1426
if (typeof col == "object")
1429
var ary = col.match (/:(.*)/);
1467
if (row && row._colValues && colID in row._colValues)
1468
return row._colValues[colID];
1433
if (row && row._colValues && col in row._colValues)
1434
return row._colValues[col];
1473
1439
XULTreeView.prototype.getCellProperties =
1474
function xtv_cellprops (row, colID, properties)
1440
function xtv_cellprops (row, col, properties)
1477
1443
XULTreeView.prototype.getColumnProperties =
1478
function xtv_colprops (colID, elem, properties)
1444
function xtv_colprops (col, properties)
1481
1447
XULTreeView.prototype.getRowProperties =
1491
XULTreeView.prototype.canDropOn =
1492
function xtv_dropon (index)
1494
var row = this.childData.locateChildByVisualRow (index);
1495
//ASSERT(row, "bogus row " + index);
1496
return (row && ("canDropOn" in row) && row.canDropOn());
1499
XULTreeView.prototype.canDropBeforeAfter =
1500
function xtv_dropba (index, before)
1502
var row = this.childData.locateChildByVisualRow (index);
1503
//ASSERT(row, "bogus row " + index);
1504
return (row && ("canDropBeforeAfter" in row) &&
1505
row.canDropBeforeAfter(before));
1457
XULTreeView.prototype.canDrop =
1458
function xtv_drop (index, orientation)
1460
var row = this.childData.locateChildByVisualRow (index);
1461
//ASSERT(row, "bogus row " + index);
1462
return (row && ("canDrop" in row) && row.canDrop(orientation));
1508
1465
XULTreeView.prototype.drop =
1533
1490
XULTreeView.prototype.cycleCell =
1534
function xtv_cyclecell (row, colID)
1491
function xtv_cyclecell (row, col)
1538
1495
XULTreeView.prototype.isEditable =
1539
function xtv_isedit (row, colID)
1496
function xtv_isedit (row, col)
1501
XULTreeView.prototype.setCellValue =
1502
function xtv_setct (row, col, value)
1544
1506
XULTreeView.prototype.setCellText =
1545
function xtv_setct (row, colID, value)
1507
function xtv_setct (row, col, value)