accessible/src/generic/TableAccessible.h

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef TABLE_ACCESSIBLE_H
     8 #define TABLE_ACCESSIBLE_H
    10 #include "nsString.h"
    11 #include "nsTArray.h"
    13 namespace mozilla {
    14 namespace a11y {
    16 class Accessible;
    18 /**
    19  * Accessible table interface.
    20  */
    21 class TableAccessible
    22 {
    23 public:
    25   /**
    26    * Return the caption accessible if any for this table.
    27    */
    28   virtual Accessible* Caption() { return nullptr; }
    30   /**
    31    * Get the summary for this table.
    32    */
    33   virtual void Summary(nsString& aSummary) { aSummary.Truncate(); }
    35   /**
    36    * Return the number of columns in the table.
    37    */
    38   virtual uint32_t ColCount() { return 0; }
    40   /**
    41    * Return the number of rows in the table.
    42    */
    43   virtual uint32_t RowCount() { return 0; }
    45   /**
    46    * Return the accessible for the cell at the given row and column indices.
    47    */
    48   virtual Accessible* CellAt(uint32_t aRowIdx, uint32_t aColIdx) { return nullptr; }
    50   /**
    51    * Return the index of the cell at the given row and column.
    52    */
    53   virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx)
    54     { return ColCount() * aRowIdx + aColIdx; }
    56   /**
    57    * Return the column index of the cell with the given index.
    58    */
    59   virtual int32_t ColIndexAt(uint32_t aCellIdx) 
    60     { return aCellIdx % ColCount(); }
    62   /**
    63    * Return the row index of the cell with the given index.
    64    */
    65   virtual int32_t RowIndexAt(uint32_t aCellIdx) 
    66     { return aCellIdx / ColCount(); }
    68   /**
    69    * Get the row and column indices for the cell at the given index.
    70    */
    71   virtual void RowAndColIndicesAt(uint32_t aCellIdx, int32_t* aRowIdx,
    72                                   int32_t* aColIdx) 
    73     { 
    74       uint32_t colCount = ColCount();
    75       *aRowIdx = aCellIdx / colCount;
    76       *aColIdx = aCellIdx % colCount;
    77     }
    79   /**
    80    * Return the number of columns occupied by the cell at the given row and
    81    * column indices.
    82    */
    83   virtual uint32_t ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; }
    85   /**
    86    * Return the number of rows occupied by the cell at the given row and column
    87    * indices.
    88    */
    89   virtual uint32_t RowExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; }
    91   /**
    92    * Get the description of the given column.
    93    */
    94   virtual void ColDescription(uint32_t aColIdx, nsString& aDescription)
    95     { aDescription.Truncate(); }
    97   /**
    98    * Get the description for the given row.
    99    */
   100   virtual void RowDescription(uint32_t aRowIdx, nsString& aDescription)
   101     { aDescription.Truncate(); }
   103   /**
   104    * Return true if the given column is selected.
   105    */
   106   virtual bool IsColSelected(uint32_t aColIdx) { return false; }
   108   /**
   109    * Return true if the given row is selected.
   110    */
   111   virtual bool IsRowSelected(uint32_t aRowIdx) { return false; }
   113   /**
   114    * Return true if the given cell is selected.
   115    */
   116   virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) { return false; }
   118   /**
   119    * Return the number of selected cells.
   120    */
   121   virtual uint32_t SelectedCellCount() { return 0; }
   123   /**
   124    * Return the number of selected columns.
   125    */
   126   virtual uint32_t SelectedColCount() { return 0; }
   128   /**
   129    * Return the number of selected rows.
   130    */
   131   virtual uint32_t SelectedRowCount() { return 0; }
   133   /**
   134    * Get the set of selected cells.
   135    */
   136   virtual void SelectedCells(nsTArray<Accessible*>* aCells) = 0;
   138   /**
   139    * Get the set of selected cell indices.
   140    */
   141   virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) = 0;
   143   /**
   144    * Get the set of selected column indices.
   145    */
   146   virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) = 0;
   148   /**
   149    * Get the set of selected row indices.
   150    */
   151   virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) = 0;
   153   /**
   154    * Select the given column unselecting any other selected columns.
   155    */
   156   virtual void SelectCol(uint32_t aColIdx) {}
   158   /**
   159    * Select the given row unselecting all other previously selected rows.
   160    */
   161   virtual void SelectRow(uint32_t aRowIdx) {}
   163   /**
   164    * Unselect the given column leaving other selected columns selected.
   165    */
   166   virtual void UnselectCol(uint32_t aColIdx) {}
   168   /**
   169    * Unselect the given row leaving other selected rows selected.
   170    */
   171   virtual void UnselectRow(uint32_t aRowIdx) {}
   173   /**
   174    * Return true if the table is probably for layout.
   175    */
   176   virtual bool IsProbablyLayoutTable() { return false; }
   178   /**
   179    * Convert the table to an Accessible*.
   180    */
   181   virtual Accessible* AsAccessible() = 0;
   182 };
   184 } // namespace a11y
   185 } // namespace mozilla
   187 #endif

mercurial