Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
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 #include "nsISupports.idl"
8 interface nsITreeBoxObject;
9 interface nsITreeSelection;
10 interface nsITreeColumn;
11 interface nsIDOMDataTransfer;
13 [scriptable, uuid(091116f0-0bdc-4b32-b9c8-c8d5a37cb088)]
14 interface nsITreeView : nsISupports
15 {
16 /**
17 * The total number of rows in the tree (including the offscreen rows).
18 */
19 readonly attribute long rowCount;
21 /**
22 * The selection for this view.
23 */
24 attribute nsITreeSelection selection;
26 /**
27 * A whitespace delimited list of properties. For each property X the view
28 * gives back will cause the pseudoclasses ::-moz-tree-cell(x),
29 * ::-moz-tree-row(x), ::-moz-tree-twisty(x), ::-moz-tree-image(x),
30 * ::-moz-tree-cell-text(x). to be matched on the pseudoelement
31 * ::moz-tree-row.
32 */
33 AString getRowProperties(in long index);
35 /**
36 * A whitespace delimited list of properties for a given cell. Each
37 * property, x, that the view gives back will cause the pseudoclasses
38 * ::-moz-tree-cell(x), ::-moz-tree-row(x), ::-moz-tree-twisty(x),
39 * ::-moz-tree-image(x), ::-moz-tree-cell-text(x). to be matched on the
40 * cell.
41 */
42 AString getCellProperties(in long row, in nsITreeColumn col);
44 /**
45 * Called to get properties to paint a column background. For shading the sort
46 * column, etc.
47 */
48 AString getColumnProperties(in nsITreeColumn col);
50 /**
51 * Methods that can be used to test whether or not a twisty should be drawn,
52 * and if so, whether an open or closed twisty should be used.
53 */
54 boolean isContainer(in long index);
55 boolean isContainerOpen(in long index);
56 boolean isContainerEmpty(in long index);
58 /**
59 * isSeparator is used to determine if the row at index 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.
62 */
63 boolean isSeparator(in long index);
65 /**
66 * Specifies if there is currently a sort on any column. Used mostly by dragdrop
67 * to affect drop feedback.
68 */
69 boolean isSorted();
71 const short DROP_BEFORE = -1;
72 const short DROP_ON = 0;
73 const short DROP_AFTER = 1;
74 /**
75 * Methods used by the drag feedback code to determine if a drag is allowable at
76 * the current location. To get the behavior where drops are only allowed on
77 * items, such as the mailNews folder pane, always return false when
78 * the orientation is not DROP_ON.
79 */
80 boolean canDrop(in long index, in long orientation, in nsIDOMDataTransfer dataTransfer);
82 /**
83 * Called when the user drops something on this view. The |orientation| param
84 * specifies before/on/after the given |row|.
85 */
86 void drop(in long row, in long orientation, in nsIDOMDataTransfer dataTransfer);
88 /**
89 * Methods used by the tree to draw thread lines in the tree.
90 * getParentIndex is used to obtain the index of a parent row.
91 * If there is no parent row, getParentIndex returns -1.
92 */
93 long getParentIndex(in long rowIndex);
95 /**
96 * hasNextSibling is used to determine if the row at rowIndex has a nextSibling
97 * that occurs *after* the index specified by afterIndex. Code that is forced
98 * to march down the view looking at levels can optimize the march by starting
99 * at afterIndex+1.
100 */
101 boolean hasNextSibling(in long rowIndex, in long afterIndex);
103 /**
104 * The level is an integer value that represents
105 * the level of indentation. It is multiplied by the width specified in the
106 * :moz-tree-indentation pseudoelement to compute the exact indendation.
107 */
108 long getLevel(in long index);
110 /**
111 * The image path for a given cell. For defining an icon for a cell.
112 * If the empty string is returned, the :moz-tree-image pseudoelement
113 * will be used.
114 */
115 AString getImageSrc(in long row, in nsITreeColumn col);
117 /**
118 * The progress mode for a given cell. This method is only called for
119 * columns of type |progressmeter|.
120 */
121 const short PROGRESS_NORMAL = 1;
122 const short PROGRESS_UNDETERMINED = 2;
123 const short PROGRESS_NONE = 3;
124 long getProgressMode(in long row, in nsITreeColumn col);
126 /**
127 * The value for a given cell. This method is only called for columns
128 * of type other than |text|.
129 */
130 AString getCellValue(in long row, in nsITreeColumn col);
132 /**
133 * The text for a given cell. If a column consists only of an image, then
134 * the empty string is returned.
135 */
136 AString getCellText(in long row, in nsITreeColumn col);
138 /**
139 * Called during initialization to link the view to the front end box object.
140 */
141 void setTree(in nsITreeBoxObject tree);
143 /**
144 * Called on the view when an item is opened or closed.
145 */
146 void toggleOpenState(in long index);
148 /**
149 * Called on the view when a header is clicked.
150 */
151 void cycleHeader(in nsITreeColumn col);
153 /**
154 * Should be called from a XUL onselect handler whenever the selection changes.
155 */
156 void selectionChanged();
158 /**
159 * Called on the view when a cell in a non-selectable cycling column (e.g., unread/flag/etc.) is clicked.
160 */
161 void cycleCell(in long row, in nsITreeColumn col);
163 /**
164 * isEditable is called to ask the view if the cell contents are editable.
165 * A value of true will result in the tree popping up a text field when
166 * the user tries to inline edit the cell.
167 */
168 boolean isEditable(in long row, in nsITreeColumn col);
170 /**
171 * isSelectable is called to ask the view if the cell is selectable.
172 * This method is only called if the selection style is |cell| or |text|.
173 * XXXvarga shouldn't this be called isCellSelectable?
174 */
175 boolean isSelectable(in long row, in nsITreeColumn col);
177 /**
178 * setCellValue is called when the value of the cell has been set by the user.
179 * This method is only called for columns of type other than |text|.
180 */
181 void setCellValue(in long row, in nsITreeColumn col, in AString value);
183 /**
184 * setCellText is called when the contents of the cell have been edited by the user.
185 */
186 void setCellText(in long row, in nsITreeColumn col, in AString value);
188 /**
189 * A command API that can be used to invoke commands on the selection. The tree
190 * will automatically invoke this method when certain keys are pressed. For example,
191 * when the DEL key is pressed, performAction will be called with the "delete" string.
192 */
193 void performAction(in wstring action);
195 /**
196 * A command API that can be used to invoke commands on a specific row.
197 */
198 void performActionOnRow(in wstring action, in long row);
200 /**
201 * A command API that can be used to invoke commands on a specific cell.
202 */
203 void performActionOnCell(in wstring action, in long row, in nsITreeColumn col);
204 };
206 /**
207 * The following interface is not scriptable and MUST NEVER BE MADE scriptable.
208 * Native treeviews implement it, and we use this to check whether a treeview
209 * is native (and therefore suitable for use by untrusted content).
210 */
211 [uuid(46c90265-6553-41ae-8d39-7022e7d09145)]
212 interface nsINativeTreeView : nsITreeView
213 {
214 [noscript] void ensureNative();
215 };