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