1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 #include <QtCore/qglobal.h>
46 #include <QtCore/qobject.h>
47 #include <QtCore/qrect.h>
48 #include <QtCore/qset.h>
49 #include <QtCore/qvector.h>
50 #include <QtCore/qvariant.h>
51 #include <QtGui/qcolor.h>
52 #include <QtGui/qevent.h>
60 #ifndef QT_NO_ACCESSIBILITY
62 class QAccessibleInterface;
65 class Q_GUI_EXPORT QAccessible
71 ForegroundChanged = 0x0003,
74 PopupMenuStart = 0x0006,
75 PopupMenuEnd = 0x0007,
76 ContextHelpStart = 0x000C,
77 ContextHelpEnd = 0x000D,
78 DragDropStart = 0x000E,
82 ScrollingStart = 0x0012,
83 ScrollingEnd = 0x0013,
87 // Values from IAccessible2
88 ActionChanged = 0x0101,
89 ActiveDescendantChanged = 0x0102,
90 AttributeChanged = 0x0103,
91 DocumentContentChanged = 0x0104,
92 DocumentLoadComplete = 0x0105,
93 DocumentLoadStopped = 0x0106,
94 DocumentReload = 0x0107,
95 HyperlinkEndIndexChanged = 0x0108,
96 HyperlinkNumberOfAnchorsChanged = 0x0109,
97 HyperlinkSelectedLinkChanged = 0x010A,
98 HypertextLinkActivated = 0x010B,
99 HypertextLinkSelected = 0x010C,
100 HyperlinkStartIndexChanged = 0x010D,
101 HypertextChanged = 0x010E,
102 HypertextNLinksChanged = 0x010F,
103 ObjectAttributeChanged = 0x0110,
104 PageChanged = 0x0111,
105 SectionChanged = 0x0112,
106 TableCaptionChanged = 0x0113,
107 TableColumnDescriptionChanged = 0x0114,
108 TableColumnHeaderChanged = 0x0115,
109 TableModelChanged = 0x0116,
110 TableRowDescriptionChanged = 0x0117,
111 TableRowHeaderChanged = 0x0118,
112 TableSummaryChanged = 0x0119,
113 TextAttributeChanged = 0x011A,
114 TextCaretMoved = 0x011B,
115 // TextChanged = 0x011C, is deprecated in IA2, use TextUpdated
116 TextColumnChanged = 0x011D,
117 TextInserted = 0x011E,
118 TextRemoved = 0x011F,
119 TextUpdated = 0x0120,
120 TextSelectionChanged = 0x0121,
121 VisibleDataChanged = 0x0122,
123 ObjectCreated = 0x8000,
124 ObjectDestroyed = 0x8001,
127 ObjectReorder = 0x8004,
130 SelectionAdd = 0x8007,
131 SelectionRemove = 0x8008,
132 SelectionWithin = 0x8009,
133 StateChanged = 0x800A,
134 LocationChanged = 0x800B,
135 NameChanged = 0x800C,
136 DescriptionChanged = 0x800D,
137 ValueChanged = 0x800E,
138 ParentChanged = 0x800F,
139 HelpChanged = 0x80A0,
140 DefaultActionChanged = 0x80B0,
141 AcceleratorChanged = 0x80C0
146 Unavailable = 0x00000001,
147 Selected = 0x00000002,
148 Focused = 0x00000004,
149 Pressed = 0x00000008,
150 Checked = 0x00000010,
152 ReadOnly = 0x00000040,
153 HotTracked = 0x00000080,
154 DefaultButton = 0x00000100,
155 // #### Qt5 Expandable
156 Expanded = 0x00000200,
157 Collapsed = 0x00000400,
159 // Floating = 0x00001000,
160 Marqueed = 0x00002000,
161 Animated = 0x00004000,
162 Invisible = 0x00008000,
163 Offscreen = 0x00010000,
164 Sizeable = 0x00020000,
165 Movable = 0x00040000,
166 SelfVoicing = 0x00080000,
167 Focusable = 0x00100000,
168 Selectable = 0x00200000,
170 Traversed = 0x00800000,
171 MultiSelectable = 0x01000000,
172 ExtSelectable = 0x02000000,
173 //AlertLow = 0x04000000,
174 //AlertMedium = 0x08000000,
175 //AlertHigh = 0x10000000, /* reused for HasInvokeExtension */
176 Protected = 0x20000000,
177 HasPopup = 0x40000000,
181 Q_DECLARE_FLAGS(State, StateFlag)
185 TitleBar = 0x00000001,
186 MenuBar = 0x00000002,
187 ScrollBar = 0x00000003,
192 AlertMessage = 0x00000008,
195 PopupMenu = 0x0000000B,
196 MenuItem = 0x0000000C,
197 ToolTip = 0x0000000D,
198 Application = 0x0000000E,
199 Document = 0x0000000F,
204 Grouping = 0x00000014,
205 Separator = 0x00000015,
206 ToolBar = 0x00000016,
207 StatusBar = 0x00000017,
209 ColumnHeader = 0x00000019,
210 RowHeader = 0x0000001A,
215 HelpBalloon = 0x0000001F,
216 Assistant = 0x00000020,
218 ListItem = 0x00000022,
220 TreeItem = 0x00000024,
221 PageTab = 0x00000025,
222 PropertyPage = 0x00000026,
223 Indicator = 0x00000027,
224 Graphic = 0x00000028,
225 StaticText = 0x00000029,
226 EditableText = 0x0000002A, // Editable, selectable, etc.
227 PushButton = 0x0000002B,
228 CheckBox = 0x0000002C,
229 RadioButton = 0x0000002D,
230 ComboBox = 0x0000002E,
231 // DropList = 0x0000002F,
232 ProgressBar = 0x00000030,
234 HotkeyField = 0x00000032,
236 SpinBox = 0x00000034,
238 Animation = 0x00000036,
239 Equation = 0x00000037,
240 ButtonDropDown = 0x00000038,
241 ButtonMenu = 0x00000039,
242 ButtonDropGrid = 0x0000003A,
243 Whitespace = 0x0000003B,
244 PageTabList = 0x0000003C,
246 Splitter = 0x0000003E,
247 // Additional Qt roles where enum value does not map directly to MSAA:
248 LayeredPane = 0x0000003F,
249 UserRole = 0x0000ffff
258 UserText = 0x0000ffff
262 Unrelated = 0x00000000,
264 Ancestor = 0x00000002,
266 Descendent = 0x00000008,
267 Sibling = 0x00000010,
268 HierarchyMask = 0x000000ff,
275 Covered = 0x00002000,
276 GeometryMask = 0x0000ff00,
278 FocusChild = 0x00010000,
280 Labelled = 0x00040000,
281 Controller = 0x00080000,
282 Controlled = 0x00100000,
283 LogicalMask = 0x00ff0000
285 Q_DECLARE_FLAGS(Relation, RelationFlag)
290 FirstStandardAction = Press,
298 RemoveSelection = -9,
299 ExtendSelection = -10,
300 AddToSelection = -11,
301 LastStandardAction = AddToSelection
305 ListSupportedMethods = 0,
306 SetCursorPosition = 1,
307 GetCursorPosition = 2,
315 EditableTextInterface,
324 typedef QAccessibleInterface*(*InterfaceFactory)(const QString &key, QObject*);
325 typedef void(*UpdateHandler)(QObject*, int who, Event reason);
326 typedef void(*RootObjectHandler)(QObject*);
328 static void installFactory(InterfaceFactory);
329 static void removeFactory(InterfaceFactory);
330 static UpdateHandler installUpdateHandler(UpdateHandler);
331 static RootObjectHandler installRootObjectHandler(RootObjectHandler);
333 static QAccessibleInterface *queryAccessibleInterface(QObject *);
334 static void updateAccessibility(QObject *, int who, Event reason);
335 static bool isActive();
336 static void setRootObject(QObject*);
338 static void cleanup();
341 static UpdateHandler updateHandler;
342 static RootObjectHandler rootObjectHandler;
345 Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::State)
346 Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::Relation)
348 Q_DECLARE_METATYPE(QSet<QAccessible::Method>)
351 class QAccessible2Interface;
352 class QAccessibleTextInterface;
353 class QAccessibleEditableTextInterface;
354 class QAccessibleValueInterface;
355 class QAccessibleTableInterface;
356 class QAccessibleActionInterface;
357 class QAccessibleImageInterface;
358 class QAccessibleTable2Interface;
359 class QAccessibleTable2CellInterface;
361 class Q_GUI_EXPORT QAccessibleInterface : public QAccessible
364 virtual ~QAccessibleInterface() {}
365 // check for valid pointers
366 virtual bool isValid() const = 0;
367 virtual QObject *object() const = 0;
368 virtual QWindow *window() const;
371 virtual Relation relationTo(const QAccessibleInterface *other) const;
372 virtual QVector<QPair<QAccessibleInterface*, Relation> > relations() const;
374 virtual int childAt(int x, int y) const = 0;
376 // navigation, hierarchy
377 virtual QAccessibleInterface *parent() const = 0;
378 virtual QAccessibleInterface *child(int index) const = 0;
379 virtual int childCount() const = 0;
380 virtual int indexOfChild(const QAccessibleInterface *) const = 0;
381 virtual int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const = 0;
383 // properties and state
384 virtual QString text(Text t) const = 0;
385 virtual void setText(Text t, const QString &text) = 0;
386 virtual QRect rect() const = 0;
387 virtual Role role() const = 0;
388 virtual State state() const = 0;
390 virtual QColor foregroundColor() const;
391 virtual QColor backgroundColor() const;
393 virtual QVariant invokeMethod(Method method, const QVariantList ¶ms = QVariantList());
395 inline QSet<Method> supportedMethods()
396 { return qvariant_cast<QSet<Method> >(invokeMethod(ListSupportedMethods)); }
398 inline QAccessibleTextInterface *textInterface()
399 { return reinterpret_cast<QAccessibleTextInterface *>(interface_cast(QAccessible::TextInterface)); }
401 inline QAccessibleEditableTextInterface *editableTextInterface()
402 { return reinterpret_cast<QAccessibleEditableTextInterface *>(interface_cast(QAccessible::EditableTextInterface)); }
404 inline QAccessibleValueInterface *valueInterface()
405 { return reinterpret_cast<QAccessibleValueInterface *>(interface_cast(QAccessible::ValueInterface)); }
407 inline QAccessibleTableInterface *tableInterface()
408 { return reinterpret_cast<QAccessibleTableInterface *>(interface_cast(QAccessible::TableInterface)); }
410 inline QAccessibleActionInterface *actionInterface()
411 { return reinterpret_cast<QAccessibleActionInterface *>(interface_cast(QAccessible::ActionInterface)); }
413 inline QAccessibleImageInterface *imageInterface()
414 { return reinterpret_cast<QAccessibleImageInterface *>(interface_cast(QAccessible::ImageInterface)); }
416 inline QAccessibleTable2Interface *table2Interface()
417 { return reinterpret_cast<QAccessibleTable2Interface *>(interface_cast(QAccessible::Table2Interface)); }
419 inline QAccessibleTable2CellInterface *table2CellInterface()
420 { return reinterpret_cast<QAccessibleTable2CellInterface *>(interface_cast(QAccessible::Table2CellInterface)); }
423 virtual QVariant virtual_hook(const QVariant &data);
424 virtual void *interface_cast(QAccessible::InterfaceType)
429 class QAccessibleEvent : public QEvent
432 inline QAccessibleEvent(Type type);
433 inline QString value() const { return val; }
434 inline void setValue(const QString &aText) { val = aText; }
440 inline QAccessibleEvent::QAccessibleEvent(Type atype)
443 #define QAccessibleInterface_iid "com.trolltech.Qt.QAccessibleInterface"
444 Q_DECLARE_INTERFACE(QAccessibleInterface, QAccessibleInterface_iid)
446 #ifndef QT_NO_DEBUG_STREAM
447 Q_GUI_EXPORT QDebug operator<<(QDebug d, const QAccessibleInterface *iface);
450 #endif // QT_NO_ACCESSIBILITY
456 #endif // QACCESSIBLE_H