layout/xul/tree/nsITreeView.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/xul/tree/nsITreeView.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,215 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsISupports.idl"
    1.10 +
    1.11 +interface nsITreeBoxObject;
    1.12 +interface nsITreeSelection;
    1.13 +interface nsITreeColumn;
    1.14 +interface nsIDOMDataTransfer;
    1.15 +
    1.16 +[scriptable, uuid(091116f0-0bdc-4b32-b9c8-c8d5a37cb088)]
    1.17 +interface nsITreeView : nsISupports
    1.18 +{
    1.19 +  /**
    1.20 +   * The total number of rows in the tree (including the offscreen rows).
    1.21 +   */
    1.22 +  readonly attribute long rowCount;
    1.23 +
    1.24 +  /**
    1.25 +   * The selection for this view.
    1.26 +   */
    1.27 +  attribute nsITreeSelection selection;
    1.28 +
    1.29 +  /** 
    1.30 +   * A whitespace delimited list of properties.  For each property X the view
    1.31 +   * gives back will cause the pseudoclasses  ::-moz-tree-cell(x),
    1.32 +   * ::-moz-tree-row(x), ::-moz-tree-twisty(x), ::-moz-tree-image(x),
    1.33 +   * ::-moz-tree-cell-text(x).  to be matched on the pseudoelement
    1.34 +   * ::moz-tree-row.
    1.35 +   */
    1.36 +  AString getRowProperties(in long index);
    1.37 +
    1.38 +  /**
    1.39 +   * A whitespace delimited list of properties for a given cell.  Each
    1.40 +   * property, x, that the view gives back will cause the pseudoclasses
    1.41 +   *  ::-moz-tree-cell(x), ::-moz-tree-row(x), ::-moz-tree-twisty(x),
    1.42 +   *  ::-moz-tree-image(x), ::-moz-tree-cell-text(x). to be matched on the
    1.43 +   *  cell.
    1.44 +   */
    1.45 +  AString getCellProperties(in long row, in nsITreeColumn col);
    1.46 +  
    1.47 +  /**
    1.48 +   * Called to get properties to paint a column background.  For shading the sort
    1.49 +   * column, etc.
    1.50 +   */
    1.51 +  AString getColumnProperties(in nsITreeColumn col);
    1.52 +
    1.53 +  /**
    1.54 +   * Methods that can be used to test whether or not a twisty should be drawn,
    1.55 +   * and if so, whether an open or closed twisty should be used.
    1.56 +   */
    1.57 +  boolean isContainer(in long index);
    1.58 +  boolean isContainerOpen(in long index);
    1.59 +  boolean isContainerEmpty(in long index);
    1.60 + 
    1.61 +  /**
    1.62 +   * isSeparator is used to determine if the row at index is a separator.
    1.63 +   * A value of true will result in the tree drawing a horizontal separator.
    1.64 +   * The tree uses the ::moz-tree-separator pseudoclass to draw the separator.
    1.65 +   */
    1.66 +  boolean isSeparator(in long index);
    1.67 +
    1.68 +  /**
    1.69 +   * Specifies if there is currently a sort on any column. Used mostly by dragdrop
    1.70 +   * to affect drop feedback.
    1.71 +   */
    1.72 +  boolean isSorted();
    1.73 +  
    1.74 +  const short DROP_BEFORE = -1;
    1.75 +  const short DROP_ON = 0;
    1.76 +  const short DROP_AFTER = 1;
    1.77 +  /**
    1.78 +   * Methods used by the drag feedback code to determine if a drag is allowable at
    1.79 +   * the current location. To get the behavior where drops are only allowed on
    1.80 +   * items, such as the mailNews folder pane, always return false when
    1.81 +   * the orientation is not DROP_ON.
    1.82 +   */
    1.83 +  boolean canDrop(in long index, in long orientation, in nsIDOMDataTransfer dataTransfer);
    1.84 +
    1.85 +  /**
    1.86 +   * Called when the user drops something on this view. The |orientation| param
    1.87 +   * specifies before/on/after the given |row|.
    1.88 +   */
    1.89 +  void drop(in long row, in long orientation, in nsIDOMDataTransfer dataTransfer);
    1.90 +
    1.91 +  /**
    1.92 +   * Methods used by the tree to draw thread lines in the tree.
    1.93 +   * getParentIndex is used to obtain the index of a parent row.
    1.94 +   * If there is no parent row, getParentIndex returns -1.
    1.95 +   */
    1.96 +  long getParentIndex(in long rowIndex);
    1.97 +
    1.98 +  /**
    1.99 +   * hasNextSibling is used to determine if the row at rowIndex has a nextSibling
   1.100 +   * that occurs *after* the index specified by afterIndex.  Code that is forced
   1.101 +   * to march down the view looking at levels can optimize the march by starting
   1.102 +   * at afterIndex+1.
   1.103 +   */
   1.104 +  boolean hasNextSibling(in long rowIndex, in long afterIndex);
   1.105 +
   1.106 +  /**
   1.107 +   * The level is an integer value that represents
   1.108 +   * the level of indentation.  It is multiplied by the width specified in the 
   1.109 +   * :moz-tree-indentation pseudoelement to compute the exact indendation.
   1.110 +   */
   1.111 +  long getLevel(in long index);
   1.112 +
   1.113 +  /**
   1.114 +   * The image path for a given cell. For defining an icon for a cell.
   1.115 +   * If the empty string is returned, the :moz-tree-image pseudoelement
   1.116 +   * will be used.
   1.117 +   */
   1.118 +  AString getImageSrc(in long row, in nsITreeColumn col);
   1.119 +
   1.120 +  /**
   1.121 +   * The progress mode for a given cell. This method is only called for
   1.122 +   * columns of type |progressmeter|.
   1.123 +   */
   1.124 +  const short PROGRESS_NORMAL = 1;
   1.125 +  const short PROGRESS_UNDETERMINED = 2;
   1.126 +  const short PROGRESS_NONE = 3;
   1.127 +  long getProgressMode(in long row, in nsITreeColumn col);
   1.128 +
   1.129 +  /**
   1.130 +   * The value for a given cell. This method is only called for columns
   1.131 +   * of type other than |text|.
   1.132 +   */
   1.133 +  AString getCellValue(in long row, in nsITreeColumn col);
   1.134 +
   1.135 +  /**
   1.136 +   * The text for a given cell.  If a column consists only of an image, then
   1.137 +   * the empty string is returned.  
   1.138 +   */
   1.139 +  AString getCellText(in long row, in nsITreeColumn col);
   1.140 +
   1.141 +  /**
   1.142 +   * Called during initialization to link the view to the front end box object.
   1.143 +   */
   1.144 +  void setTree(in nsITreeBoxObject tree);
   1.145 +  
   1.146 +  /**
   1.147 +   * Called on the view when an item is opened or closed.
   1.148 +   */
   1.149 +  void toggleOpenState(in long index);
   1.150 +
   1.151 +  /**
   1.152 +   * Called on the view when a header is clicked.
   1.153 +   */
   1.154 +  void cycleHeader(in nsITreeColumn col);
   1.155 +
   1.156 +  /**
   1.157 +   * Should be called from a XUL onselect handler whenever the selection changes.
   1.158 +   */
   1.159 +  void selectionChanged();
   1.160 +
   1.161 +  /**
   1.162 +   * Called on the view when a cell in a non-selectable cycling column (e.g., unread/flag/etc.) is clicked.
   1.163 +   */
   1.164 +  void cycleCell(in long row, in nsITreeColumn col);
   1.165 +  
   1.166 +  /**
   1.167 +   * isEditable is called to ask the view if the cell contents are editable.
   1.168 +   * A value of true will result in the tree popping up a text field when 
   1.169 +   * the user tries to inline edit the cell.
   1.170 +   */
   1.171 +  boolean isEditable(in long row, in nsITreeColumn col);
   1.172 +
   1.173 +  /**
   1.174 +   * isSelectable is called to ask the view if the cell is selectable.
   1.175 +   * This method is only called if the selection style is |cell| or |text|.
   1.176 +   * XXXvarga shouldn't this be called isCellSelectable?
   1.177 +   */
   1.178 +  boolean isSelectable(in long row, in nsITreeColumn col);
   1.179 +
   1.180 +  /**
   1.181 +   * setCellValue is called when the value of the cell has been set by the user.
   1.182 +   * This method is only called for columns of type other than |text|.
   1.183 +   */
   1.184 +  void setCellValue(in long row, in nsITreeColumn col, in AString value);
   1.185 +
   1.186 +  /**
   1.187 +   * setCellText is called when the contents of the cell have been edited by the user.
   1.188 +   */   
   1.189 +  void setCellText(in long row, in nsITreeColumn col, in AString value);
   1.190 +
   1.191 +  /**
   1.192 +   * A command API that can be used to invoke commands on the selection.  The tree
   1.193 +   * will automatically invoke this method when certain keys are pressed.  For example,
   1.194 +   * when the DEL key is pressed, performAction will be called with the "delete" string.
   1.195 +   */
   1.196 +  void performAction(in wstring action);
   1.197 +
   1.198 +  /**
   1.199 +   * A command API that can be used to invoke commands on a specific row.
   1.200 +   */
   1.201 +  void performActionOnRow(in wstring action, in long row);
   1.202 +
   1.203 +  /**
   1.204 +   * A command API that can be used to invoke commands on a specific cell.
   1.205 +   */
   1.206 +  void performActionOnCell(in wstring action, in long row, in nsITreeColumn col);
   1.207 +};
   1.208 +
   1.209 +/**
   1.210 + * The following interface is not scriptable and MUST NEVER BE MADE scriptable.
   1.211 + * Native treeviews implement it, and we use this to check whether a treeview
   1.212 + * is native (and therefore suitable for use by untrusted content).
   1.213 + */
   1.214 +[uuid(46c90265-6553-41ae-8d39-7022e7d09145)]
   1.215 +interface nsINativeTreeView : nsITreeView
   1.216 +{
   1.217 +  [noscript] void ensureNative();
   1.218 +};

mercurial