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,
312 typedef QAccessibleInterface*(*InterfaceFactory)(const QString &key, QObject*);
313 typedef void(*UpdateHandler)(QObject*, int who, Event reason);
314 typedef void(*RootObjectHandler)(QObject*);
316 static void installFactory(InterfaceFactory);
317 static void removeFactory(InterfaceFactory);
318 static UpdateHandler installUpdateHandler(UpdateHandler);
319 static RootObjectHandler installRootObjectHandler(RootObjectHandler);
321 static QAccessibleInterface *queryAccessibleInterface(QObject *);
322 static void updateAccessibility(QObject *, int who, Event reason);
323 static bool isActive();
324 static void setRootObject(QObject*);
326 static void cleanup();
329 static UpdateHandler updateHandler;
330 static RootObjectHandler rootObjectHandler;
333 Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::State)
334 Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::Relation)
336 Q_DECLARE_METATYPE(QSet<QAccessible::Method>)
339 namespace QAccessible2
344 EditableTextInterface,
353 class QAccessible2Interface;
354 class QAccessibleTextInterface;
355 class QAccessibleEditableTextInterface;
356 class QAccessibleValueInterface;
357 class QAccessibleTableInterface;
358 class QAccessibleActionInterface;
359 class QAccessibleImageInterface;
360 class QAccessibleTable2Interface;
362 class Q_GUI_EXPORT QAccessibleInterface : public QAccessible
365 virtual ~QAccessibleInterface() {}
366 // check for valid pointers
367 virtual bool isValid() const = 0;
368 virtual QObject *object() const = 0;
369 virtual QWindow *window() const;
372 virtual Relation relationTo(const QAccessibleInterface *other) const;
373 virtual QVector<QPair<QAccessibleInterface*, Relation> > relations() const;
375 virtual int childAt(int x, int y) const = 0;
377 // navigation, hierarchy
378 virtual QAccessibleInterface *parent() const = 0;
379 virtual QAccessibleInterface *child(int index) const = 0;
380 virtual int childCount() const = 0;
381 virtual int indexOfChild(const QAccessibleInterface *) const = 0;
382 virtual int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const = 0;
384 // properties and state
385 virtual QString text(Text t) const = 0;
386 virtual void setText(Text t, const QString &text) = 0;
387 virtual QRect rect() const = 0;
388 virtual Role role() const = 0;
389 virtual State state() const = 0;
391 virtual QColor foregroundColor() const;
392 virtual QColor backgroundColor() const;
394 virtual QVariant invokeMethod(Method method, const QVariantList ¶ms = QVariantList());
396 inline QSet<Method> supportedMethods()
397 { return qvariant_cast<QSet<Method> >(invokeMethod(ListSupportedMethods)); }
399 inline QAccessibleTextInterface *textInterface()
400 { return reinterpret_cast<QAccessibleTextInterface *>(cast_helper(QAccessible2::TextInterface)); }
402 inline QAccessibleEditableTextInterface *editableTextInterface()
403 { return reinterpret_cast<QAccessibleEditableTextInterface *>(cast_helper(QAccessible2::EditableTextInterface)); }
405 inline QAccessibleValueInterface *valueInterface()
406 { return reinterpret_cast<QAccessibleValueInterface *>(cast_helper(QAccessible2::ValueInterface)); }
408 inline QAccessibleTableInterface *tableInterface()
409 { return reinterpret_cast<QAccessibleTableInterface *>(cast_helper(QAccessible2::TableInterface)); }
411 inline QAccessibleActionInterface *actionInterface()
412 { return reinterpret_cast<QAccessibleActionInterface *>(cast_helper(QAccessible2::ActionInterface)); }
414 inline QAccessibleImageInterface *imageInterface()
415 { return reinterpret_cast<QAccessibleImageInterface *>(cast_helper(QAccessible2::ImageInterface)); }
417 inline QAccessibleTable2Interface *table2Interface()
418 { return reinterpret_cast<QAccessibleTable2Interface *>(cast_helper(QAccessible2::Table2Interface)); }
421 virtual QVariant virtual_hook(const QVariant &data);
422 virtual QAccessible2Interface *interface_cast(QAccessible2::InterfaceType)
426 QAccessible2Interface *cast_helper(QAccessible2::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