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