1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 interface nsITreeSelection;
8 interface mixin TreeView
11 * The total number of rows in the tree (including the offscreen rows).
13 readonly attribute long rowCount;
16 * The selection for this view.
19 attribute nsITreeSelection? selection;
22 * A whitespace delimited list of properties. For each property X the view
23 * gives back will cause the pseudoclasses ::-moz-tree-cell(x),
24 * ::-moz-tree-row(x), ::-moz-tree-twisty(x), ::-moz-tree-image(x),
25 * ::-moz-tree-cell-text(x). to be matched on the pseudoelement
29 DOMString getRowProperties(long row);
32 * A whitespace delimited list of properties for a given cell. Each
33 * property, x, that the view gives back will cause the pseudoclasses
34 * ::-moz-tree-cell(x), ::-moz-tree-row(x), ::-moz-tree-twisty(x),
35 * ::-moz-tree-image(x), ::-moz-tree-cell-text(x). to be matched on the
39 DOMString getCellProperties(long row, TreeColumn column);
42 * Called to get properties to paint a column background. For shading the sort
45 DOMString getColumnProperties(TreeColumn column);
48 * Methods that can be used to test whether or not a twisty should be drawn,
49 * and if so, whether an open or closed twisty should be used.
52 boolean isContainer(long row);
54 boolean isContainerOpen(long row);
56 boolean isContainerEmpty(long row);
59 * isSeparator is used to determine if the row is a separator.
60 * A value of true will result in the tree drawing a horizontal separator.
61 * The tree uses the ::moz-tree-separator pseudoclass to draw the separator.
64 boolean isSeparator(long row);
67 * Specifies if there is currently a sort on any column. Used mostly by dragdrop
68 * to affect drop feedback.
72 const short DROP_BEFORE = -1;
73 const short DROP_ON = 0;
74 const short DROP_AFTER = 1;
76 * Methods used by the drag feedback code to determine if a drag is allowable at
77 * the current location. To get the behavior where drops are only allowed on
78 * items, such as the mailNews folder pane, always return false when
79 * the orientation is not DROP_ON.
82 boolean canDrop(long row, long orientation, DataTransfer? dataTransfer);
85 * Called when the user drops something on this view. The |orientation| param
86 * specifies before/on/after the given |row|.
89 undefined drop(long row, long orientation, DataTransfer? dataTransfer);
92 * Methods used by the tree to draw thread lines in the tree.
93 * getParentIndex is used to obtain the index of a parent row.
94 * If there is no parent row, getParentIndex returns -1.
97 long getParentIndex(long row);
100 * hasNextSibling is used to determine if the row at rowIndex has a nextSibling
101 * that occurs *after* the index specified by afterIndex. Code that is forced
102 * to march down the view looking at levels can optimize the march by starting
106 boolean hasNextSibling(long row, long afterIndex);
109 * The level is an integer value that represents
110 * the level of indentation. It is multiplied by the width specified in the
111 * :moz-tree-indentation pseudoelement to compute the exact indendation.
114 long getLevel(long row);
117 * The image path for a given cell. For defining an icon for a cell.
118 * If the empty string is returned, the :moz-tree-image pseudoelement
122 DOMString getImageSrc(long row, TreeColumn column);
125 * The value for a given cell. This method is only called for columns
126 * of type other than |text|.
129 DOMString getCellValue(long row, TreeColumn column);
132 * The text for a given cell. If a column consists only of an image, then
133 * the empty string is returned.
136 DOMString getCellText(long row, TreeColumn column);
139 * Called during initialization to link the view to the front end box object.
142 undefined setTree(XULTreeElement? tree);
145 * Called on the view when an item is opened or closed.
148 undefined toggleOpenState(long row);
151 * Called on the view when a header is clicked.
154 undefined cycleHeader(TreeColumn column);
157 * Should be called from a XUL onselect handler whenever the selection changes.
159 undefined selectionChanged();
162 * Called on the view when a cell in a non-selectable cycling column (e.g., unread/flag/etc.) is clicked.
164 undefined cycleCell(long row, TreeColumn column);
167 * isEditable is called to ask the view if the cell contents are editable.
168 * A value of true will result in the tree popping up a text field when
169 * the user tries to inline edit the cell.
172 boolean isEditable(long row, TreeColumn column);
175 * setCellValue is called when the value of the cell has been set by the user.
176 * This method is only called for columns of type other than |text|.
179 undefined setCellValue(long row, TreeColumn column, DOMString value);
182 * setCellText is called when the contents of the cell have been edited by the user.
185 undefined setCellText(long row, TreeColumn column, DOMString value);