nsITreeView.idl 7.2 KB

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