File indexing completed on 2025-01-18 10:07:57
0001
0002
0003
0004
0005 #if 0
0006
0007
0008 #pragma qt_class(QAccessible)
0009 #endif
0010
0011 #ifndef QACCESSIBLE_H
0012 #define QACCESSIBLE_H
0013 #include <QtGui/qtguiglobal.h>
0014
0015 #if QT_CONFIG(accessibility)
0016
0017 #include <QtCore/qcoreapplication.h>
0018 #include <QtCore/qdebug.h>
0019 #include <QtCore/qglobal.h>
0020 #include <QtCore/qlist.h>
0021 #include <QtCore/qobject.h>
0022 #include <QtCore/qrect.h>
0023 #include <QtCore/qset.h>
0024 #include <QtCore/qvariant.h>
0025 #include <QtGui/qcolor.h>
0026 #include <QtGui/qevent.h>
0027 #include <QtGui/qaccessible_base.h>
0028
0029 QT_BEGIN_NAMESPACE
0030
0031 class QAccessibleInterface;
0032 class QAccessibleEvent;
0033 class QWindow;
0034 class QTextCursor;
0035
0036 class QAccessible2Interface;
0037 class QAccessibleTextInterface;
0038 class QAccessibleEditableTextInterface;
0039 class QAccessibleValueInterface;
0040 class QAccessibleActionInterface;
0041 class QAccessibleImageInterface;
0042 class QAccessibleTableInterface;
0043 class QAccessibleTableCellInterface;
0044 class QAccessibleHyperlinkInterface;
0045 class QAccessibleSelectionInterface;
0046 class QAccessibleTableModelChangeEvent;
0047
0048 class Q_GUI_EXPORT QAccessibleInterface
0049 {
0050 protected:
0051 virtual ~QAccessibleInterface();
0052
0053 public:
0054
0055 virtual bool isValid() const = 0;
0056 virtual QObject *object() const = 0;
0057 virtual QWindow *window() const;
0058
0059
0060 virtual QList<QPair<QAccessibleInterface *, QAccessible::Relation>>
0061 relations(QAccessible::Relation match = QAccessible::AllRelations) const;
0062 virtual QAccessibleInterface *focusChild() const;
0063
0064 virtual QAccessibleInterface *childAt(int x, int y) const = 0;
0065
0066
0067 virtual QAccessibleInterface *parent() const = 0;
0068 virtual QAccessibleInterface *child(int index) const = 0;
0069 virtual int childCount() const = 0;
0070 virtual int indexOfChild(const QAccessibleInterface *) const = 0;
0071
0072
0073 virtual QString text(QAccessible::Text t) const = 0;
0074 virtual void setText(QAccessible::Text t, const QString &text) = 0;
0075 virtual QRect rect() const = 0;
0076 virtual QAccessible::Role role() const = 0;
0077 virtual QAccessible::State state() const = 0;
0078
0079 virtual QColor foregroundColor() const;
0080 virtual QColor backgroundColor() const;
0081
0082 inline QAccessibleTextInterface *textInterface()
0083 { return reinterpret_cast<QAccessibleTextInterface *>(interface_cast(QAccessible::TextInterface)); }
0084
0085 inline QAccessibleEditableTextInterface *editableTextInterface()
0086 { return reinterpret_cast<QAccessibleEditableTextInterface *>(interface_cast(QAccessible::EditableTextInterface)); }
0087
0088 inline QAccessibleValueInterface *valueInterface()
0089 { return reinterpret_cast<QAccessibleValueInterface *>(interface_cast(QAccessible::ValueInterface)); }
0090
0091 inline QAccessibleActionInterface *actionInterface()
0092 { return reinterpret_cast<QAccessibleActionInterface *>(interface_cast(QAccessible::ActionInterface)); }
0093
0094 inline QAccessibleImageInterface *imageInterface()
0095 { return reinterpret_cast<QAccessibleImageInterface *>(interface_cast(QAccessible::ImageInterface)); }
0096
0097 inline QAccessibleTableInterface *tableInterface()
0098 { return reinterpret_cast<QAccessibleTableInterface *>(interface_cast(QAccessible::TableInterface)); }
0099
0100 inline QAccessibleTableCellInterface *tableCellInterface()
0101 { return reinterpret_cast<QAccessibleTableCellInterface *>(interface_cast(QAccessible::TableCellInterface)); }
0102
0103 inline QAccessibleHyperlinkInterface *hyperlinkInterface()
0104 { return reinterpret_cast<QAccessibleHyperlinkInterface *>(interface_cast(QAccessible::HyperlinkInterface)); }
0105
0106 inline QAccessibleSelectionInterface *selectionInterface()
0107 { return reinterpret_cast<QAccessibleSelectionInterface *>(interface_cast(QAccessible::SelectionInterface)); }
0108
0109 virtual void virtual_hook(int id, void *data);
0110
0111 virtual void *interface_cast(QAccessible::InterfaceType)
0112 { return nullptr; }
0113
0114 protected:
0115 friend class QAccessibleCache;
0116 };
0117
0118 class Q_GUI_EXPORT QAccessibleTextInterface
0119 {
0120 public:
0121 virtual ~QAccessibleTextInterface();
0122
0123 virtual void selection(int selectionIndex, int *startOffset, int *endOffset) const = 0;
0124 virtual int selectionCount() const = 0;
0125 virtual void addSelection(int startOffset, int endOffset) = 0;
0126 virtual void removeSelection(int selectionIndex) = 0;
0127 virtual void setSelection(int selectionIndex, int startOffset, int endOffset) = 0;
0128
0129
0130 virtual int cursorPosition() const = 0;
0131 virtual void setCursorPosition(int position) = 0;
0132
0133
0134 virtual QString text(int startOffset, int endOffset) const = 0;
0135 virtual QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType,
0136 int *startOffset, int *endOffset) const;
0137 virtual QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType,
0138 int *startOffset, int *endOffset) const;
0139 virtual QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType,
0140 int *startOffset, int *endOffset) const;
0141 virtual int characterCount() const = 0;
0142
0143
0144 virtual QRect characterRect(int offset) const = 0;
0145 virtual int offsetAtPoint(const QPoint &point) const = 0;
0146
0147 virtual void scrollToSubstring(int startIndex, int endIndex) = 0;
0148 virtual QString attributes(int offset, int *startOffset, int *endOffset) const = 0;
0149 };
0150
0151 class Q_GUI_EXPORT QAccessibleEditableTextInterface
0152 {
0153 public:
0154 virtual ~QAccessibleEditableTextInterface();
0155
0156 virtual void deleteText(int startOffset, int endOffset) = 0;
0157 virtual void insertText(int offset, const QString &text) = 0;
0158 virtual void replaceText(int startOffset, int endOffset, const QString &text) = 0;
0159 };
0160
0161 class Q_GUI_EXPORT QAccessibleValueInterface
0162 {
0163 public:
0164 virtual ~QAccessibleValueInterface();
0165
0166 virtual QVariant currentValue() const = 0;
0167 virtual void setCurrentValue(const QVariant &value) = 0;
0168 virtual QVariant maximumValue() const = 0;
0169 virtual QVariant minimumValue() const = 0;
0170 virtual QVariant minimumStepSize() const = 0;
0171 };
0172
0173 class Q_GUI_EXPORT QAccessibleTableCellInterface
0174 {
0175 public:
0176 virtual ~QAccessibleTableCellInterface();
0177
0178 virtual bool isSelected() const = 0;
0179
0180 virtual QList<QAccessibleInterface*> columnHeaderCells() const = 0;
0181 virtual QList<QAccessibleInterface*> rowHeaderCells() const = 0;
0182 virtual int columnIndex() const = 0;
0183 virtual int rowIndex() const = 0;
0184 virtual int columnExtent() const = 0;
0185 virtual int rowExtent() const = 0;
0186
0187 virtual QAccessibleInterface* table() const = 0;
0188 };
0189
0190 class Q_GUI_EXPORT QAccessibleTableInterface
0191 {
0192 public:
0193 virtual ~QAccessibleTableInterface();
0194
0195 virtual QAccessibleInterface *caption() const = 0;
0196 virtual QAccessibleInterface *summary() const = 0;
0197
0198 virtual QAccessibleInterface *cellAt (int row, int column) const = 0;
0199 virtual int selectedCellCount() const = 0;
0200 virtual QList<QAccessibleInterface*> selectedCells() const = 0;
0201
0202 virtual QString columnDescription(int column) const = 0;
0203 virtual QString rowDescription(int row) const = 0;
0204 virtual int selectedColumnCount() const = 0;
0205 virtual int selectedRowCount() const = 0;
0206 virtual int columnCount() const = 0;
0207 virtual int rowCount() const = 0;
0208 virtual QList<int> selectedColumns() const = 0;
0209 virtual QList<int> selectedRows() const = 0;
0210 virtual bool isColumnSelected(int column) const = 0;
0211 virtual bool isRowSelected(int row) const = 0;
0212 virtual bool selectRow(int row) = 0;
0213 virtual bool selectColumn(int column) = 0;
0214 virtual bool unselectRow(int row) = 0;
0215 virtual bool unselectColumn(int column) = 0;
0216
0217 virtual void modelChange(QAccessibleTableModelChangeEvent *event) = 0;
0218
0219 protected:
0220 friend class QAbstractItemView;
0221 friend class QAbstractItemViewPrivate;
0222 };
0223
0224 class Q_GUI_EXPORT QAccessibleActionInterface
0225 {
0226 Q_DECLARE_TR_FUNCTIONS(QAccessibleActionInterface)
0227 public:
0228 virtual ~QAccessibleActionInterface();
0229
0230 virtual QStringList actionNames() const = 0;
0231 virtual QString localizedActionName(const QString &name) const;
0232 virtual QString localizedActionDescription(const QString &name) const;
0233 virtual void doAction(const QString &actionName) = 0;
0234 virtual QStringList keyBindingsForAction(const QString &actionName) const = 0;
0235
0236 static const QString &pressAction();
0237 static const QString &increaseAction();
0238 static const QString &decreaseAction();
0239 static const QString &showMenuAction();
0240 static const QString &setFocusAction();
0241 static const QString &toggleAction();
0242 static QString scrollLeftAction();
0243 static QString scrollRightAction();
0244 static QString scrollUpAction();
0245 static QString scrollDownAction();
0246 static QString nextPageAction();
0247 static QString previousPageAction();
0248 };
0249
0250 class Q_GUI_EXPORT QAccessibleImageInterface
0251 {
0252 public:
0253 virtual ~QAccessibleImageInterface();
0254
0255 virtual QString imageDescription() const = 0;
0256 virtual QSize imageSize() const = 0;
0257 virtual QPoint imagePosition() const = 0;
0258 };
0259
0260 class Q_GUI_EXPORT QAccessibleHyperlinkInterface
0261 {
0262 public:
0263 virtual ~QAccessibleHyperlinkInterface();
0264
0265 virtual QString anchor() const = 0;
0266 virtual QString anchorTarget() const = 0;
0267 virtual int startIndex() const = 0;
0268 virtual int endIndex() const = 0;
0269 virtual bool isValid() const = 0;
0270 };
0271
0272 class Q_GUI_EXPORT QAccessibleSelectionInterface
0273 {
0274 public:
0275 virtual ~QAccessibleSelectionInterface();
0276
0277 virtual int selectedItemCount() const = 0;
0278 virtual QList<QAccessibleInterface*> selectedItems() const = 0;
0279 virtual QAccessibleInterface* selectedItem(int selectionIndex) const;
0280 virtual bool isSelected(QAccessibleInterface *childItem) const;
0281 virtual bool select(QAccessibleInterface *childItem) = 0;
0282 virtual bool unselect(QAccessibleInterface *childItem) = 0;
0283 virtual bool selectAll() = 0;
0284 virtual bool clear() = 0;
0285 };
0286
0287 class Q_GUI_EXPORT QAccessibleEvent
0288 {
0289 Q_DISABLE_COPY(QAccessibleEvent)
0290 public:
0291
0292 inline QAccessibleEvent(QObject *obj, QAccessible::Event typ)
0293 : m_type(typ), m_object(obj), m_child(-1)
0294 {
0295 Q_ASSERT(obj);
0296
0297
0298 Q_ASSERT(m_type != QAccessible::ValueChanged);
0299 Q_ASSERT(m_type != QAccessible::StateChanged);
0300 Q_ASSERT(m_type != QAccessible::TextCaretMoved);
0301 Q_ASSERT(m_type != QAccessible::TextSelectionChanged);
0302 Q_ASSERT(m_type != QAccessible::TextInserted);
0303 Q_ASSERT(m_type != QAccessible::TextRemoved);
0304 Q_ASSERT(m_type != QAccessible::TextUpdated);
0305 Q_ASSERT(m_type != QAccessible::TableModelChanged);
0306 }
0307
0308 inline QAccessibleEvent(QAccessibleInterface *iface, QAccessible::Event typ)
0309 : m_type(typ)
0310 {
0311 Q_ASSERT(iface);
0312 Q_ASSERT(m_type != QAccessible::ValueChanged);
0313 Q_ASSERT(m_type != QAccessible::StateChanged);
0314 Q_ASSERT(m_type != QAccessible::TextCaretMoved);
0315 Q_ASSERT(m_type != QAccessible::TextSelectionChanged);
0316 Q_ASSERT(m_type != QAccessible::TextInserted);
0317 Q_ASSERT(m_type != QAccessible::TextRemoved);
0318 Q_ASSERT(m_type != QAccessible::TextUpdated);
0319 Q_ASSERT(m_type != QAccessible::TableModelChanged);
0320 m_uniqueId = QAccessible::uniqueId(iface);
0321 m_object = iface->object();
0322 }
0323
0324 virtual ~QAccessibleEvent();
0325
0326 QAccessible::Event type() const { return m_type; }
0327 QObject *object() const { return m_object; }
0328 QAccessible::Id uniqueId() const;
0329
0330 void setChild(int chld) { m_child = chld; }
0331 int child() const { return m_child; }
0332
0333 virtual QAccessibleInterface *accessibleInterface() const;
0334
0335 protected:
0336 QAccessible::Event m_type;
0337 QObject *m_object;
0338 union {
0339 int m_child;
0340 QAccessible::Id m_uniqueId;
0341 };
0342
0343 friend class QTestAccessibility;
0344 };
0345
0346 class Q_GUI_EXPORT QAccessibleStateChangeEvent :public QAccessibleEvent
0347 {
0348 public:
0349 inline QAccessibleStateChangeEvent(QObject *obj, QAccessible::State state)
0350 : QAccessibleEvent(obj, QAccessible::InvalidEvent), m_changedStates(state)
0351 {
0352 m_type = QAccessible::StateChanged;
0353 }
0354 inline QAccessibleStateChangeEvent(QAccessibleInterface *iface, QAccessible::State state)
0355 : QAccessibleEvent(iface, QAccessible::InvalidEvent), m_changedStates(state)
0356 {
0357 m_type = QAccessible::StateChanged;
0358 }
0359 ~QAccessibleStateChangeEvent();
0360
0361 QAccessible::State changedStates() const {
0362 return m_changedStates;
0363 }
0364
0365 protected:
0366 QAccessible::State m_changedStates;
0367 };
0368
0369
0370 class Q_GUI_EXPORT QAccessibleTextCursorEvent : public QAccessibleEvent
0371 {
0372 public:
0373 inline QAccessibleTextCursorEvent(QObject *obj, int cursorPos)
0374 : QAccessibleEvent(obj, QAccessible::InvalidEvent)
0375 , m_cursorPosition(cursorPos)
0376 {
0377 m_type = QAccessible::TextCaretMoved;
0378 }
0379 inline QAccessibleTextCursorEvent(QAccessibleInterface *iface, int cursorPos)
0380 : QAccessibleEvent(iface, QAccessible::InvalidEvent)
0381 , m_cursorPosition(cursorPos)
0382 {
0383 m_type = QAccessible::TextCaretMoved;
0384 }
0385
0386 ~QAccessibleTextCursorEvent();
0387
0388 void setCursorPosition(int position) { m_cursorPosition = position; }
0389 int cursorPosition() const { return m_cursorPosition; }
0390
0391 protected:
0392 int m_cursorPosition;
0393 };
0394
0395
0396 class Q_GUI_EXPORT QAccessibleTextSelectionEvent : public QAccessibleTextCursorEvent
0397 {
0398 public:
0399 inline QAccessibleTextSelectionEvent(QObject *obj, int start, int end)
0400 : QAccessibleTextCursorEvent(obj, (start == -1) ? 0 : end)
0401 , m_selectionStart(start), m_selectionEnd(end)
0402 {
0403 m_type = QAccessible::TextSelectionChanged;
0404 }
0405 inline QAccessibleTextSelectionEvent(QAccessibleInterface *iface, int start, int end)
0406 : QAccessibleTextCursorEvent(iface, (start == -1) ? 0 : end)
0407 , m_selectionStart(start), m_selectionEnd(end)
0408 {
0409 m_type = QAccessible::TextSelectionChanged;
0410 }
0411
0412 ~QAccessibleTextSelectionEvent();
0413
0414 void setSelection(int start, int end) {
0415 m_selectionStart = start;
0416 m_selectionEnd = end;
0417 }
0418
0419 int selectionStart() const { return m_selectionStart; }
0420 int selectionEnd() const { return m_selectionEnd; }
0421
0422 protected:
0423 int m_selectionStart;
0424 int m_selectionEnd;
0425 };
0426
0427 class Q_GUI_EXPORT QAccessibleTextInsertEvent : public QAccessibleTextCursorEvent
0428 {
0429 public:
0430 inline QAccessibleTextInsertEvent(QObject *obj, int position, const QString &text)
0431 : QAccessibleTextCursorEvent(obj, position + int(text.size()))
0432 , m_position(position), m_text(text)
0433 {
0434 m_type = QAccessible::TextInserted;
0435 }
0436 inline QAccessibleTextInsertEvent(QAccessibleInterface *iface, int position, const QString &text)
0437 : QAccessibleTextCursorEvent(iface, position + int(text.size()))
0438 , m_position(position), m_text(text)
0439 {
0440 m_type = QAccessible::TextInserted;
0441 }
0442
0443 ~QAccessibleTextInsertEvent();
0444
0445 QString textInserted() const {
0446 return m_text;
0447 }
0448 int changePosition() const {
0449 return m_position;
0450 }
0451
0452 protected:
0453 int m_position;
0454 QString m_text;
0455 };
0456
0457 class Q_GUI_EXPORT QAccessibleTextRemoveEvent : public QAccessibleTextCursorEvent
0458 {
0459 public:
0460 inline QAccessibleTextRemoveEvent(QObject *obj, int position, const QString &text)
0461 : QAccessibleTextCursorEvent(obj, position)
0462 , m_position(position), m_text(text)
0463 {
0464 m_type = QAccessible::TextRemoved;
0465 }
0466 inline QAccessibleTextRemoveEvent(QAccessibleInterface *iface, int position, const QString &text)
0467 : QAccessibleTextCursorEvent(iface, position)
0468 , m_position(position), m_text(text)
0469 {
0470 m_type = QAccessible::TextRemoved;
0471 }
0472
0473 ~QAccessibleTextRemoveEvent();
0474
0475 QString textRemoved() const {
0476 return m_text;
0477 }
0478 int changePosition() const {
0479 return m_position;
0480 }
0481
0482 protected:
0483 int m_position;
0484 QString m_text;
0485 };
0486
0487 class Q_GUI_EXPORT QAccessibleTextUpdateEvent : public QAccessibleTextCursorEvent
0488 {
0489 public:
0490 inline QAccessibleTextUpdateEvent(QObject *obj, int position, const QString &oldText, const QString &text)
0491 : QAccessibleTextCursorEvent(obj, position + int(text.size()))
0492 , m_position(position), m_oldText(oldText), m_text(text)
0493 {
0494 m_type = QAccessible::TextUpdated;
0495 }
0496 inline QAccessibleTextUpdateEvent(QAccessibleInterface *iface, int position, const QString &oldText, const QString &text)
0497 : QAccessibleTextCursorEvent(iface, position + int(text.size()))
0498 , m_position(position), m_oldText(oldText), m_text(text)
0499 {
0500 m_type = QAccessible::TextUpdated;
0501 }
0502
0503 ~QAccessibleTextUpdateEvent();
0504
0505 QString textRemoved() const {
0506 return m_oldText;
0507 }
0508 QString textInserted() const {
0509 return m_text;
0510 }
0511 int changePosition() const {
0512 return m_position;
0513 }
0514
0515 protected:
0516 int m_position;
0517 QString m_oldText;
0518 QString m_text;
0519 };
0520
0521 class Q_GUI_EXPORT QAccessibleValueChangeEvent : public QAccessibleEvent
0522 {
0523 public:
0524 inline QAccessibleValueChangeEvent(QObject *obj, const QVariant &val)
0525 : QAccessibleEvent(obj, QAccessible::InvalidEvent)
0526 , m_value(val)
0527 {
0528 m_type = QAccessible::ValueChanged;
0529 }
0530 inline QAccessibleValueChangeEvent(QAccessibleInterface *iface, const QVariant &val)
0531 : QAccessibleEvent(iface, QAccessible::InvalidEvent)
0532 , m_value(val)
0533 {
0534 m_type = QAccessible::ValueChanged;
0535 }
0536
0537 ~QAccessibleValueChangeEvent();
0538
0539 void setValue(const QVariant & val) { m_value= val; }
0540 QVariant value() const { return m_value; }
0541
0542 protected:
0543 QVariant m_value;
0544 };
0545
0546 class Q_GUI_EXPORT QAccessibleTableModelChangeEvent : public QAccessibleEvent
0547 {
0548 public:
0549 enum ModelChangeType {
0550 ModelReset,
0551 DataChanged,
0552 RowsInserted,
0553 ColumnsInserted,
0554 RowsRemoved,
0555 ColumnsRemoved
0556 };
0557
0558 inline QAccessibleTableModelChangeEvent(QObject *obj, ModelChangeType changeType)
0559 : QAccessibleEvent(obj, QAccessible::InvalidEvent)
0560 , m_modelChangeType(changeType)
0561 , m_firstRow(-1), m_firstColumn(-1), m_lastRow(-1), m_lastColumn(-1)
0562 {
0563 m_type = QAccessible::TableModelChanged;
0564 }
0565 inline QAccessibleTableModelChangeEvent(QAccessibleInterface *iface, ModelChangeType changeType)
0566 : QAccessibleEvent(iface, QAccessible::InvalidEvent)
0567 , m_modelChangeType(changeType)
0568 , m_firstRow(-1), m_firstColumn(-1), m_lastRow(-1), m_lastColumn(-1)
0569 {
0570 m_type = QAccessible::TableModelChanged;
0571 }
0572
0573 ~QAccessibleTableModelChangeEvent();
0574
0575 void setModelChangeType(ModelChangeType changeType) { m_modelChangeType = changeType; }
0576 ModelChangeType modelChangeType() const { return m_modelChangeType; }
0577
0578 void setFirstRow(int row) { m_firstRow = row; }
0579 void setFirstColumn(int col) { m_firstColumn = col; }
0580 void setLastRow(int row) { m_lastRow = row; }
0581 void setLastColumn(int col) { m_lastColumn = col; }
0582 int firstRow() const { return m_firstRow; }
0583 int firstColumn() const { return m_firstColumn; }
0584 int lastRow() const { return m_lastRow; }
0585 int lastColumn() const { return m_lastColumn; }
0586
0587 protected:
0588 ModelChangeType m_modelChangeType;
0589 int m_firstRow;
0590 int m_firstColumn;
0591 int m_lastRow;
0592 int m_lastColumn;
0593 };
0594
0595 #ifndef Q_QDOC
0596 #define QAccessibleInterface_iid "org.qt-project.Qt.QAccessibleInterface"
0597 Q_DECLARE_INTERFACE(QAccessibleInterface, QAccessibleInterface_iid)
0598 #endif
0599
0600 Q_GUI_EXPORT const char *qAccessibleRoleString(QAccessible::Role role);
0601 Q_GUI_EXPORT const char *qAccessibleEventString(QAccessible::Event event);
0602 Q_GUI_EXPORT QString qAccessibleLocalizedActionDescription(const QString &actionName);
0603
0604 #ifndef QT_NO_DEBUG_STREAM
0605 Q_GUI_EXPORT QDebug operator<<(QDebug d, const QAccessibleInterface *iface);
0606 Q_GUI_EXPORT QDebug operator<<(QDebug d, const QAccessibleEvent &ev);
0607 #endif
0608
0609 QT_END_NAMESPACE
0610
0611 #endif
0612 #endif