Search in sources :

Example 1 with AccessibleTableCellEvent

use of org.eclipse.swt.accessibility.AccessibleTableCellEvent in project eclipse.platform.swt by eclipse.

the class CTableColumn method getAccessible.

/* Returns the accessible for the column header. */
Accessible getAccessible(final Accessible accessibleTable) {
    if (accessible == null) {
        accessible = new Accessible(accessibleTable);
        accessible.addAccessibleListener(new AccessibleAdapter() {

            @Override
            public void getName(AccessibleEvent e) {
                e.result = getText();
                System.out.println("tableColumn getName = " + e.result);
            }
        });
        accessible.addAccessibleControlListener(new AccessibleControlAdapter() {

            @Override
            public void getChildAtPoint(AccessibleControlEvent e) {
                Point point = parent.toControl(e.x, e.y);
                int x = getX();
                if (x <= point.x && point.x <= x + getWidth()) {
                    e.childID = ACC.CHILDID_SELF;
                } else {
                    e.childID = ACC.CHILDID_NONE;
                }
            }

            @Override
            public void getChildCount(AccessibleControlEvent e) {
                e.detail = 0;
            }

            @Override
            public void getLocation(AccessibleControlEvent e) {
                Rectangle rect = parent.header.getBounds();
                rect.x = getX();
                Point pt = parent.toDisplay(rect.x, rect.y);
                e.x = pt.x;
                e.y = pt.y;
                e.width = width;
                e.height = rect.height;
            }

            @Override
            public void getRole(AccessibleControlEvent e) {
                e.detail = ACC.ROLE_TABLECELL;
            }
        });
        accessible.addAccessibleTableCellListener(new AccessibleTableCellListener() {

            @Override
            public void getColumnHeaders(AccessibleTableCellEvent e) {
            /* Column header does not have a header. */
            }

            @Override
            public void getColumnIndex(AccessibleTableCellEvent e) {
                e.index = getIndex();
            }

            @Override
            public void getColumnSpan(AccessibleTableCellEvent e) {
                e.count = 1;
            /* CTable cells only occupy one column. */
            }

            @Override
            public void getRowHeaders(AccessibleTableCellEvent e) {
            /* CTable does not support row headers. */
            }

            @Override
            public void getRowIndex(AccessibleTableCellEvent e) {
                e.index = 0;
            }

            @Override
            public void getRowSpan(AccessibleTableCellEvent e) {
                e.count = 1;
            /* CTable cells only occupy one row. */
            }

            @Override
            public void getTable(AccessibleTableCellEvent e) {
                e.accessible = accessibleTable;
            }

            @Override
            public void isSelected(AccessibleTableCellEvent e) {
                e.isSelected = false;
            /* CTable columns cannot be selected (only rows can be selected). */
            }
        });
    }
    return accessible;
}
Also used : AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) AccessibleControlAdapter(org.eclipse.swt.accessibility.AccessibleControlAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) AccessibleTableCellEvent(org.eclipse.swt.accessibility.AccessibleTableCellEvent) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) AccessibleTableCellListener(org.eclipse.swt.accessibility.AccessibleTableCellListener) Point(org.eclipse.swt.graphics.Point) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Accessible(org.eclipse.swt.accessibility.Accessible)

Example 2 with AccessibleTableCellEvent

use of org.eclipse.swt.accessibility.AccessibleTableCellEvent in project eclipse.platform.swt by eclipse.

the class CTableItem method getAccessible.

/* Returns the cell accessible for the specified column index in the receiver. */
Accessible getAccessible(final Accessible accessibleTable, final int columnIndex) {
    if (accessibles[columnIndex] == null) {
        Accessible accessible = new Accessible(accessibleTable);
        accessible.addAccessibleListener(new AccessibleAdapter() {

            @Override
            public void getName(AccessibleEvent e) {
                e.result = getText(columnIndex);
                System.out.println("tableItem getName = " + e.result);
            }
        });
        accessible.addAccessibleControlListener(new AccessibleControlAdapter() {

            @Override
            public void getChild(AccessibleControlEvent e) {
                /* CTable cells do not have children, so just return the index in parent. */
                switch(e.childID) {
                    case ACC.CHILDID_CHILD_INDEX:
                        e.detail = index * Math.max(1, parent.getColumnCount()) + columnIndex + parent.getColumnCount();
                        break;
                }
            }

            @Override
            public void getChildAtPoint(AccessibleControlEvent e) {
                Point point = parent.toControl(e.x, e.y);
                if (getBounds(columnIndex).contains(point)) {
                    e.childID = ACC.CHILDID_SELF;
                } else {
                    e.childID = ACC.CHILDID_NONE;
                }
            }

            @Override
            public void getFocus(AccessibleControlEvent e) {
                e.childID = (parent.focusItem == CTableItem.this && parent.isFocusControl()) ? ACC.CHILDID_SELF : ACC.CHILDID_NONE;
            }

            @Override
            public void getLocation(AccessibleControlEvent e) {
                Rectangle location = getBounds(columnIndex);
                Point pt = parent.toDisplay(location.x, location.y);
                e.x = pt.x;
                e.y = pt.y;
                e.width = location.width;
                e.height = location.height;
            }

            @Override
            public void getRole(AccessibleControlEvent e) {
                e.detail = ACC.ROLE_TABLECELL;
            }

            @Override
            public void getValue(AccessibleControlEvent e) {
                e.result = getText(columnIndex);
            }
        });
        accessible.addAccessibleTableCellListener(new AccessibleTableCellListener() {

            @Override
            public void getColumnHeaders(AccessibleTableCellEvent e) {
                if (parent.columns.length == 0) {
                    /* The CTable is being used as a list, and there are no headers. */
                    e.accessibles = null;
                } else {
                    /* CTable cells only occupy one column. */
                    CTableColumn column = parent.columns[columnIndex];
                    e.accessibles = new Accessible[] { column.getAccessible(accessibleTable) };
                }
            }

            @Override
            public void getColumnIndex(AccessibleTableCellEvent e) {
                e.index = columnIndex;
            }

            @Override
            public void getColumnSpan(AccessibleTableCellEvent e) {
                /* CTable cells only occupy one column. */
                e.count = 1;
            }

            @Override
            public void getRowHeaders(AccessibleTableCellEvent e) {
            /* CTable does not support row headers. */
            }

            @Override
            public void getRowIndex(AccessibleTableCellEvent e) {
                e.index = index;
            }

            @Override
            public void getRowSpan(AccessibleTableCellEvent e) {
                /* CTable cells only occupy one row. */
                e.count = 1;
            }

            @Override
            public void getTable(AccessibleTableCellEvent e) {
                e.accessible = accessibleTable;
            }

            @Override
            public void isSelected(AccessibleTableCellEvent e) {
                e.isSelected = CTableItem.this.isSelected();
            }
        });
        accessibles[columnIndex] = accessible;
    }
    return accessibles[columnIndex];
}
Also used : AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) AccessibleControlAdapter(org.eclipse.swt.accessibility.AccessibleControlAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) AccessibleTableCellEvent(org.eclipse.swt.accessibility.AccessibleTableCellEvent) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) AccessibleTableCellListener(org.eclipse.swt.accessibility.AccessibleTableCellListener) Point(org.eclipse.swt.graphics.Point) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Accessible(org.eclipse.swt.accessibility.Accessible)

Aggregations

Accessible (org.eclipse.swt.accessibility.Accessible)2 AccessibleAdapter (org.eclipse.swt.accessibility.AccessibleAdapter)2 AccessibleControlAdapter (org.eclipse.swt.accessibility.AccessibleControlAdapter)2 AccessibleControlEvent (org.eclipse.swt.accessibility.AccessibleControlEvent)2 AccessibleEvent (org.eclipse.swt.accessibility.AccessibleEvent)2 AccessibleTableCellEvent (org.eclipse.swt.accessibility.AccessibleTableCellEvent)2 AccessibleTableCellListener (org.eclipse.swt.accessibility.AccessibleTableCellListener)2 Point (org.eclipse.swt.graphics.Point)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2