accessible/src/generic/TableAccessible.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/src/generic/TableAccessible.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,187 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef TABLE_ACCESSIBLE_H
    1.11 +#define TABLE_ACCESSIBLE_H
    1.12 +
    1.13 +#include "nsString.h"
    1.14 +#include "nsTArray.h"
    1.15 +
    1.16 +namespace mozilla {
    1.17 +namespace a11y {
    1.18 +
    1.19 +class Accessible;
    1.20 +
    1.21 +/**
    1.22 + * Accessible table interface.
    1.23 + */
    1.24 +class TableAccessible
    1.25 +{
    1.26 +public:
    1.27 +
    1.28 +  /**
    1.29 +   * Return the caption accessible if any for this table.
    1.30 +   */
    1.31 +  virtual Accessible* Caption() { return nullptr; }
    1.32 +
    1.33 +  /**
    1.34 +   * Get the summary for this table.
    1.35 +   */
    1.36 +  virtual void Summary(nsString& aSummary) { aSummary.Truncate(); }
    1.37 +
    1.38 +  /**
    1.39 +   * Return the number of columns in the table.
    1.40 +   */
    1.41 +  virtual uint32_t ColCount() { return 0; }
    1.42 +
    1.43 +  /**
    1.44 +   * Return the number of rows in the table.
    1.45 +   */
    1.46 +  virtual uint32_t RowCount() { return 0; }
    1.47 +
    1.48 +  /**
    1.49 +   * Return the accessible for the cell at the given row and column indices.
    1.50 +   */
    1.51 +  virtual Accessible* CellAt(uint32_t aRowIdx, uint32_t aColIdx) { return nullptr; }
    1.52 +
    1.53 +  /**
    1.54 +   * Return the index of the cell at the given row and column.
    1.55 +   */
    1.56 +  virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx)
    1.57 +    { return ColCount() * aRowIdx + aColIdx; }
    1.58 +
    1.59 +  /**
    1.60 +   * Return the column index of the cell with the given index.
    1.61 +   */
    1.62 +  virtual int32_t ColIndexAt(uint32_t aCellIdx) 
    1.63 +    { return aCellIdx % ColCount(); }
    1.64 +
    1.65 +  /**
    1.66 +   * Return the row index of the cell with the given index.
    1.67 +   */
    1.68 +  virtual int32_t RowIndexAt(uint32_t aCellIdx) 
    1.69 +    { return aCellIdx / ColCount(); }
    1.70 +
    1.71 +  /**
    1.72 +   * Get the row and column indices for the cell at the given index.
    1.73 +   */
    1.74 +  virtual void RowAndColIndicesAt(uint32_t aCellIdx, int32_t* aRowIdx,
    1.75 +                                  int32_t* aColIdx) 
    1.76 +    { 
    1.77 +      uint32_t colCount = ColCount();
    1.78 +      *aRowIdx = aCellIdx / colCount;
    1.79 +      *aColIdx = aCellIdx % colCount;
    1.80 +    }
    1.81 +
    1.82 +  /**
    1.83 +   * Return the number of columns occupied by the cell at the given row and
    1.84 +   * column indices.
    1.85 +   */
    1.86 +  virtual uint32_t ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; }
    1.87 +
    1.88 +  /**
    1.89 +   * Return the number of rows occupied by the cell at the given row and column
    1.90 +   * indices.
    1.91 +   */
    1.92 +  virtual uint32_t RowExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; }
    1.93 +
    1.94 +  /**
    1.95 +   * Get the description of the given column.
    1.96 +   */
    1.97 +  virtual void ColDescription(uint32_t aColIdx, nsString& aDescription)
    1.98 +    { aDescription.Truncate(); }
    1.99 +
   1.100 +  /**
   1.101 +   * Get the description for the given row.
   1.102 +   */
   1.103 +  virtual void RowDescription(uint32_t aRowIdx, nsString& aDescription)
   1.104 +    { aDescription.Truncate(); }
   1.105 +
   1.106 +  /**
   1.107 +   * Return true if the given column is selected.
   1.108 +   */
   1.109 +  virtual bool IsColSelected(uint32_t aColIdx) { return false; }
   1.110 +
   1.111 +  /**
   1.112 +   * Return true if the given row is selected.
   1.113 +   */
   1.114 +  virtual bool IsRowSelected(uint32_t aRowIdx) { return false; }
   1.115 +
   1.116 +  /**
   1.117 +   * Return true if the given cell is selected.
   1.118 +   */
   1.119 +  virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) { return false; }
   1.120 +
   1.121 +  /**
   1.122 +   * Return the number of selected cells.
   1.123 +   */
   1.124 +  virtual uint32_t SelectedCellCount() { return 0; }
   1.125 +
   1.126 +  /**
   1.127 +   * Return the number of selected columns.
   1.128 +   */
   1.129 +  virtual uint32_t SelectedColCount() { return 0; }
   1.130 +
   1.131 +  /**
   1.132 +   * Return the number of selected rows.
   1.133 +   */
   1.134 +  virtual uint32_t SelectedRowCount() { return 0; }
   1.135 +
   1.136 +  /**
   1.137 +   * Get the set of selected cells.
   1.138 +   */
   1.139 +  virtual void SelectedCells(nsTArray<Accessible*>* aCells) = 0;
   1.140 +
   1.141 +  /**
   1.142 +   * Get the set of selected cell indices.
   1.143 +   */
   1.144 +  virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) = 0;
   1.145 +
   1.146 +  /**
   1.147 +   * Get the set of selected column indices.
   1.148 +   */
   1.149 +  virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) = 0;
   1.150 +
   1.151 +  /**
   1.152 +   * Get the set of selected row indices.
   1.153 +   */
   1.154 +  virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) = 0;
   1.155 +
   1.156 +  /**
   1.157 +   * Select the given column unselecting any other selected columns.
   1.158 +   */
   1.159 +  virtual void SelectCol(uint32_t aColIdx) {}
   1.160 +
   1.161 +  /**
   1.162 +   * Select the given row unselecting all other previously selected rows.
   1.163 +   */
   1.164 +  virtual void SelectRow(uint32_t aRowIdx) {}
   1.165 +
   1.166 +  /**
   1.167 +   * Unselect the given column leaving other selected columns selected.
   1.168 +   */
   1.169 +  virtual void UnselectCol(uint32_t aColIdx) {}
   1.170 +
   1.171 +  /**
   1.172 +   * Unselect the given row leaving other selected rows selected.
   1.173 +   */
   1.174 +  virtual void UnselectRow(uint32_t aRowIdx) {}
   1.175 +
   1.176 +  /**
   1.177 +   * Return true if the table is probably for layout.
   1.178 +   */
   1.179 +  virtual bool IsProbablyLayoutTable() { return false; }
   1.180 +
   1.181 +  /**
   1.182 +   * Convert the table to an Accessible*.
   1.183 +   */
   1.184 +  virtual Accessible* AsAccessible() = 0;
   1.185 +};
   1.186 +
   1.187 +} // namespace a11y
   1.188 +} // namespace mozilla
   1.189 +
   1.190 +#endif

mercurial