michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef TABLE_ACCESSIBLE_H michael@0: #define TABLE_ACCESSIBLE_H michael@0: michael@0: #include "nsString.h" michael@0: #include "nsTArray.h" michael@0: michael@0: namespace mozilla { michael@0: namespace a11y { michael@0: michael@0: class Accessible; michael@0: michael@0: /** michael@0: * Accessible table interface. michael@0: */ michael@0: class TableAccessible michael@0: { michael@0: public: michael@0: michael@0: /** michael@0: * Return the caption accessible if any for this table. michael@0: */ michael@0: virtual Accessible* Caption() { return nullptr; } michael@0: michael@0: /** michael@0: * Get the summary for this table. michael@0: */ michael@0: virtual void Summary(nsString& aSummary) { aSummary.Truncate(); } michael@0: michael@0: /** michael@0: * Return the number of columns in the table. michael@0: */ michael@0: virtual uint32_t ColCount() { return 0; } michael@0: michael@0: /** michael@0: * Return the number of rows in the table. michael@0: */ michael@0: virtual uint32_t RowCount() { return 0; } michael@0: michael@0: /** michael@0: * Return the accessible for the cell at the given row and column indices. michael@0: */ michael@0: virtual Accessible* CellAt(uint32_t aRowIdx, uint32_t aColIdx) { return nullptr; } michael@0: michael@0: /** michael@0: * Return the index of the cell at the given row and column. michael@0: */ michael@0: virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx) michael@0: { return ColCount() * aRowIdx + aColIdx; } michael@0: michael@0: /** michael@0: * Return the column index of the cell with the given index. michael@0: */ michael@0: virtual int32_t ColIndexAt(uint32_t aCellIdx) michael@0: { return aCellIdx % ColCount(); } michael@0: michael@0: /** michael@0: * Return the row index of the cell with the given index. michael@0: */ michael@0: virtual int32_t RowIndexAt(uint32_t aCellIdx) michael@0: { return aCellIdx / ColCount(); } michael@0: michael@0: /** michael@0: * Get the row and column indices for the cell at the given index. michael@0: */ michael@0: virtual void RowAndColIndicesAt(uint32_t aCellIdx, int32_t* aRowIdx, michael@0: int32_t* aColIdx) michael@0: { michael@0: uint32_t colCount = ColCount(); michael@0: *aRowIdx = aCellIdx / colCount; michael@0: *aColIdx = aCellIdx % colCount; michael@0: } michael@0: michael@0: /** michael@0: * Return the number of columns occupied by the cell at the given row and michael@0: * column indices. michael@0: */ michael@0: virtual uint32_t ColExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; } michael@0: michael@0: /** michael@0: * Return the number of rows occupied by the cell at the given row and column michael@0: * indices. michael@0: */ michael@0: virtual uint32_t RowExtentAt(uint32_t aRowIdx, uint32_t aColIdx) { return 1; } michael@0: michael@0: /** michael@0: * Get the description of the given column. michael@0: */ michael@0: virtual void ColDescription(uint32_t aColIdx, nsString& aDescription) michael@0: { aDescription.Truncate(); } michael@0: michael@0: /** michael@0: * Get the description for the given row. michael@0: */ michael@0: virtual void RowDescription(uint32_t aRowIdx, nsString& aDescription) michael@0: { aDescription.Truncate(); } michael@0: michael@0: /** michael@0: * Return true if the given column is selected. michael@0: */ michael@0: virtual bool IsColSelected(uint32_t aColIdx) { return false; } michael@0: michael@0: /** michael@0: * Return true if the given row is selected. michael@0: */ michael@0: virtual bool IsRowSelected(uint32_t aRowIdx) { return false; } michael@0: michael@0: /** michael@0: * Return true if the given cell is selected. michael@0: */ michael@0: virtual bool IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) { return false; } michael@0: michael@0: /** michael@0: * Return the number of selected cells. michael@0: */ michael@0: virtual uint32_t SelectedCellCount() { return 0; } michael@0: michael@0: /** michael@0: * Return the number of selected columns. michael@0: */ michael@0: virtual uint32_t SelectedColCount() { return 0; } michael@0: michael@0: /** michael@0: * Return the number of selected rows. michael@0: */ michael@0: virtual uint32_t SelectedRowCount() { return 0; } michael@0: michael@0: /** michael@0: * Get the set of selected cells. michael@0: */ michael@0: virtual void SelectedCells(nsTArray* aCells) = 0; michael@0: michael@0: /** michael@0: * Get the set of selected cell indices. michael@0: */ michael@0: virtual void SelectedCellIndices(nsTArray* aCells) = 0; michael@0: michael@0: /** michael@0: * Get the set of selected column indices. michael@0: */ michael@0: virtual void SelectedColIndices(nsTArray* aCols) = 0; michael@0: michael@0: /** michael@0: * Get the set of selected row indices. michael@0: */ michael@0: virtual void SelectedRowIndices(nsTArray* aRows) = 0; michael@0: michael@0: /** michael@0: * Select the given column unselecting any other selected columns. michael@0: */ michael@0: virtual void SelectCol(uint32_t aColIdx) {} michael@0: michael@0: /** michael@0: * Select the given row unselecting all other previously selected rows. michael@0: */ michael@0: virtual void SelectRow(uint32_t aRowIdx) {} michael@0: michael@0: /** michael@0: * Unselect the given column leaving other selected columns selected. michael@0: */ michael@0: virtual void UnselectCol(uint32_t aColIdx) {} michael@0: michael@0: /** michael@0: * Unselect the given row leaving other selected rows selected. michael@0: */ michael@0: virtual void UnselectRow(uint32_t aRowIdx) {} michael@0: michael@0: /** michael@0: * Return true if the table is probably for layout. michael@0: */ michael@0: virtual bool IsProbablyLayoutTable() { return false; } michael@0: michael@0: /** michael@0: * Convert the table to an Accessible*. michael@0: */ michael@0: virtual Accessible* AsAccessible() = 0; michael@0: }; michael@0: michael@0: } // namespace a11y michael@0: } // namespace mozilla michael@0: michael@0: #endif