1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Dave Hyatt <hyatt@mozilla.org> (Original Author)
24 * Jan Varga <varga@ku.sk>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or 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.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40 #include "nsITreeBoxObject.idl"
41 #include "nsISupportsArray.idl"
42 #include "domstubs.idl"
43
44 interface nsITreeSelection;
45 interface nsITreeColumn;
46
47 [scriptable, uuid(637276b5-58c0-4eff-89ea-c7f3c5bf0b54)]
48 interface nsITreeView : nsISupports
49 {
50 /**
51 * The total number of rows in the tree (including the offscreen rows).
52 */
53 readonly attribute long rowCount;
54
55 /**
56 * The selection for this view.
57 */
58 attribute nsITreeSelection selection;
59
60 /**
61 * An atomized list of properties for a given row. Each property, x, that
62 * the view gives back will cause the pseudoclass :moz-tree-row-x
63 * to be matched on the pseudoelement ::moz-tree-row.
64 */
65 void getRowProperties(in long index, in nsISupportsArray properties);
66
67 /**
68 * An atomized list of properties for a given cell. Each property, x, that
69 * the view gives back will cause the pseudoclass :moz-tree-cell-x
70 * to be matched on the ::moz-tree-cell pseudoelement.
71 */
72 void getCellProperties(in long row, in nsITreeColumn col, in nsISupportsArray properties);
73
74 /**
75 * Called to get properties to paint a column background. For shading the sort
76 * column, etc.
77 */
78 void getColumnProperties(in nsITreeColumn col, in nsISupportsArray properties);
79
80 /**
81 * Methods that can be used to test whether or not a twisty should be drawn,
82 * and if so, whether an open or closed twisty should be used.
83 */
84 boolean isContainer(in long index);
85 boolean isContainerOpen(in long index);
86 boolean isContainerEmpty(in long index);
87
88 /**
89 * isSeparator is used to determine if the row at index is a separator.
90 * A value of true will result in the tree drawing a horizontal separator.
91 * The tree uses the ::moz-tree-separator pseudoclass to draw the separator.
92 */
93 boolean isSeparator(in long index);
94
95 /**
96 * Specifies if there is currently a sort on any column. Used mostly by dragdrop
97 * to affect drop feedback.
98 */
99 boolean isSorted();
100
101 const short DROP_BEFORE = -1;
102 const short DROP_ON = 0;
103 const short DROP_AFTER = 1;
104 /**
105 * Methods used by the drag feedback code to determine if a drag is allowable at
106 * the current location. To get the behavior where drops are only allowed on
107 * items, such as the mailNews folder pane, always return false when
108 * the orientation is not DROP_ON.
109 */
110 boolean canDrop(in long index, in long orientation);
111
112 /**
113 * Called when the user drops something on this view. The |orientation| param
114 * specifies before/on/after the given |row|.
115 */
116 void drop(in long row, in long orientation);
117
118 /**
119 * Methods used by the tree to draw thread lines in the tree.
120 * getParentIndex is used to obtain the index of a parent row.
121 * If there is no parent row, getParentIndex returns -1.
122 */
123 long getParentIndex(in long rowIndex);
124
125 /**
126 * hasNextSibling is used to determine if the row at rowIndex has a nextSibling
127 * that occurs *after* the index specified by afterIndex. Code that is forced
128 * to march down the view looking at levels can optimize the march by starting
129 * at afterIndex+1.
130 */
131 boolean hasNextSibling(in long rowIndex, in long afterIndex);
132
133 /**
134 * The level is an integer value that represents
135 * the level of indentation. It is multiplied by the width specified in the
136 * :moz-tree-indentation pseudoelement to compute the exact indendation.
137 */
138 long getLevel(in long index);
139
140 /**
141 * The image path for a given cell. For defining an icon for a cell.
142 * If the empty string is returned, the :moz-tree-image pseudoelement
143 * will be used.
144 */
145 AString getImageSrc(in long row, in nsITreeColumn col);
146
147 /**
148 * The progress mode for a given cell. This method is only called for
149 * columns of type |progressmeter|.
150 */
151 const short PROGRESS_NORMAL = 1;
152 const short PROGRESS_UNDETERMINED = 2;
153 const short PROGRESS_NONE = 3;
154 long getProgressMode(in long row, in nsITreeColumn col);
155
156 /**
157 * The value for a given cell. This method is only called for columns
158 * of type other than |text|.
159 */
160 AString getCellValue(in long row, in nsITreeColumn col);
161
162 /**
163 * The text for a given cell. If a column consists only of an image, then
164 * the empty string is returned.
165 */
166 AString getCellText(in long row, in nsITreeColumn col);
167
168 /**
169 * Called during initialization to link the view to the front end box object.
170 */
171 void setTree(in nsITreeBoxObject tree);
172
173 /**
174 * Called on the view when an item is opened or closed.
175 */
176 void toggleOpenState(in long index);
177
178 /**
179 * Called on the view when a header is clicked.
180 */
181 void cycleHeader(in nsITreeColumn col);
182
183 /**
184 * Should be called from a XUL onselect handler whenever the selection changes.
185 */
186 void selectionChanged();
187
188 /**
189 * Called on the view when a cell in a non-selectable cycling column (e.g., unread/flag/etc.) is clicked.
190 */
191 void cycleCell(in long row, in nsITreeColumn col);
192
193 /**
194 * isEditable is called to ask the view if the cell contents are editable.
195 * A value of true will result in the tree popping up a text field when
196 * the user tries to inline edit the cell.
197 */
198 boolean isEditable(in long row, in nsITreeColumn col);
199
200 /**
201 * isSelectable is called to ask the view if the cell is selectable.
202 * This method is only called if the selection style is |cell| or |text|.
203 * XXXvarga shouldn't this be called isCellSelectable?
204 */
205 boolean isSelectable(in long row, in nsITreeColumn col);
206
207 /**
208 * setCellValue is called when the value of the cell has been set by the user.
209 * This method is only called for columns of type other than |text|.
210 */
211 void setCellValue(in long row, in nsITreeColumn col, in AString value);
212
213 /**
214 * setCellText is called when the contents of the cell have been edited by the user.
215 */
216 void setCellText(in long row, in nsITreeColumn col, in AString value);
217
218 /**
219 * A command API that can be used to invoke commands on the selection. The tree
220 * will automatically invoke this method when certain keys are pressed. For example,
221 * when the DEL key is pressed, performAction will be called with the "delete" string.
222 */
223 void performAction(in wstring action);
224
225 /**
226 * A command API that can be used to invoke commands on a specific row.
227 */
228 void performActionOnRow(in wstring action, in long row);
229
230 /**
231 * A command API that can be used to invoke commands on a specific cell.
232 */
233 void performActionOnCell(in wstring action, in long row, in nsITreeColumn col);
234 };
235
236 /**
237 * The following interface is not scriptable and MUST NEVER BE MADE scriptable.
238 * Native treeviews implement it, and we use this to check whether a treeview
239 * is native (and therefore suitable for use by untrusted content).
240 */
241 [uuid(38e0b44d-fa08-458c-83fb-3e10b12aeb45)]
242 interface nsINativeTreeView : nsITreeView
243 {
244 [noscript] void ensureNative();
245 };