Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qaccessible_base.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QACCESSIBLE_BASE_H
5#define QACCESSIBLE_BASE_H
6
7#include <QtGui/qtguiglobal.h>
8#if QT_CONFIG(accessibility)
9
10#if 0
11// QAccessible class is handled in qaccessible.h
12#pragma qt_sync_stop_processing
13#endif
14
15#include <QtCore/qobjectdefs.h>
16
17#include <cstring> // memset, memcmp
18
20
21class QAccessibleInterface;
22class QAccessibleEvent;
23class QTextCursor;
24
25class Q_GUI_EXPORT QAccessible
26{
28public:
29
30 enum Event {
31 SoundPlayed = 0x0001,
32 Alert = 0x0002,
33 ForegroundChanged = 0x0003,
34 MenuStart = 0x0004,
35 MenuEnd = 0x0005,
36 PopupMenuStart = 0x0006,
37 PopupMenuEnd = 0x0007,
38 ContextHelpStart = 0x000C,
39 ContextHelpEnd = 0x000D,
40 DragDropStart = 0x000E,
41 DragDropEnd = 0x000F,
42 DialogStart = 0x0010,
43 DialogEnd = 0x0011,
44 ScrollingStart = 0x0012,
45 ScrollingEnd = 0x0013,
46
47 MenuCommand = 0x0018,
48
49 // Values from IAccessible2
50 ActionChanged = 0x0101,
51 ActiveDescendantChanged = 0x0102,
52 AttributeChanged = 0x0103,
53 DocumentContentChanged = 0x0104,
54 DocumentLoadComplete = 0x0105,
55 DocumentLoadStopped = 0x0106,
56 DocumentReload = 0x0107,
57 HyperlinkEndIndexChanged = 0x0108,
58 HyperlinkNumberOfAnchorsChanged = 0x0109,
59 HyperlinkSelectedLinkChanged = 0x010A,
60 HypertextLinkActivated = 0x010B,
61 HypertextLinkSelected = 0x010C,
62 HyperlinkStartIndexChanged = 0x010D,
63 HypertextChanged = 0x010E,
64 HypertextNLinksChanged = 0x010F,
65 ObjectAttributeChanged = 0x0110,
66 PageChanged = 0x0111,
67 SectionChanged = 0x0112,
68 TableCaptionChanged = 0x0113,
69 TableColumnDescriptionChanged = 0x0114,
70 TableColumnHeaderChanged = 0x0115,
71 TableModelChanged = 0x0116,
72 TableRowDescriptionChanged = 0x0117,
73 TableRowHeaderChanged = 0x0118,
74 TableSummaryChanged = 0x0119,
75 TextAttributeChanged = 0x011A,
76 TextCaretMoved = 0x011B,
77 // TextChanged = 0x011C, is deprecated in IA2, use TextUpdated
78 TextColumnChanged = 0x011D,
79 TextInserted = 0x011E,
80 TextRemoved = 0x011F,
81 TextUpdated = 0x0120,
82 TextSelectionChanged = 0x0121,
83 VisibleDataChanged = 0x0122,
84
85 ObjectCreated = 0x8000,
86 ObjectDestroyed = 0x8001,
87 ObjectShow = 0x8002,
88 ObjectHide = 0x8003,
89 ObjectReorder = 0x8004,
90 Focus = 0x8005,
91 Selection = 0x8006,
92 SelectionAdd = 0x8007,
93 SelectionRemove = 0x8008,
94 SelectionWithin = 0x8009,
95 StateChanged = 0x800A,
96 LocationChanged = 0x800B,
97 NameChanged = 0x800C,
98 DescriptionChanged = 0x800D,
99 ValueChanged = 0x800E,
100 ParentChanged = 0x800F,
101 HelpChanged = 0x80A0,
102 DefaultActionChanged = 0x80B0,
103 AcceleratorChanged = 0x80C0,
104 Announcement = 0x80D0,
105
106 InvalidEvent
107 };
109
110 // 64 bit enums seem hard on some platforms (windows...)
111 // which makes using a bit field a sensible alternative
112 struct State {
113 // http://msdn.microsoft.com/en-us/library/ms697270.aspx
114 quint64 disabled : 1; // used to be Unavailable
115 quint64 selected : 1;
116 quint64 focusable : 1;
117 quint64 focused : 1;
118 quint64 pressed : 1;
119 quint64 checkable : 1;
120 quint64 checked : 1;
121 quint64 checkStateMixed : 1; // used to be Mixed
122 quint64 readOnly : 1;
123 quint64 hotTracked : 1;
124 quint64 defaultButton : 1;
125 quint64 expanded : 1;
126 quint64 collapsed : 1;
127 quint64 busy : 1;
128 quint64 expandable : 1;
129 quint64 marqueed : 1;
130 quint64 animated : 1;
131 quint64 invisible : 1;
132 quint64 offscreen : 1;
133 quint64 sizeable : 1;
134 quint64 movable : 1;
135 quint64 selfVoicing : 1;
136 quint64 selectable : 1;
137 quint64 linked : 1;
138 quint64 traversed : 1;
139 quint64 multiSelectable : 1;
140 quint64 extSelectable : 1;
141 quint64 passwordEdit : 1; // used to be Protected
142 quint64 hasPopup : 1;
143 quint64 modal : 1;
144
145 // IA2 - we chose to not add some IA2 states for now
146 // Below the ones that seem helpful
147 quint64 active : 1;
148 quint64 invalid : 1; // = defunct
149 quint64 editable : 1;
150 quint64 multiLine : 1;
151 quint64 selectableText : 1;
152 quint64 supportsAutoCompletion : 1;
153
154 quint64 searchEdit : 1;
155
156 // quint64 horizontal : 1;
157 // quint64 vertical : 1;
158 // quint64 invalidEntry : 1;
159 // quint64 managesDescendants : 1;
160 // quint64 singleLine : 1; // we have multi line, this is redundant.
161 // quint64 stale : 1;
162 // quint64 transient : 1;
163 // quint64 pinned : 1;
164
165 // Apple - see http://mattgemmell.com/2010/12/19/accessibility-for-iphone-and-ipad-apps/
166 // quint64 playsSound : 1;
167 // quint64 summaryElement : 1;
168 // quint64 updatesFrequently : 1;
169 // quint64 adjustable : 1;
170 // more and not included here: http://developer.apple.com/library/mac/#documentation/UserExperience/Reference/Accessibility_RoleAttribute_Ref/Attributes.html
171
172 // MSAA
173 // quint64 alertLow : 1;
174 // quint64 alertMedium : 1;
175 // quint64 alertHigh : 1;
176
177 State() {
178 std::memset(this, 0, sizeof(State));
179 }
180 friend inline bool operator==(const QAccessible::State &first, const QAccessible::State &second)
181 {
182 return std::memcmp(&first, &second, sizeof(QAccessible::State)) == 0;
183 }
184 };
185
186
187
188
189
190 enum Role {
191 NoRole = 0x00000000,
192 TitleBar = 0x00000001,
193 MenuBar = 0x00000002,
194 ScrollBar = 0x00000003,
195 Grip = 0x00000004,
196 Sound = 0x00000005,
197 Cursor = 0x00000006,
198 Caret = 0x00000007,
199 AlertMessage = 0x00000008,
200 Window = 0x00000009,
201 Client = 0x0000000A,
202 PopupMenu = 0x0000000B,
203 MenuItem = 0x0000000C,
204 ToolTip = 0x0000000D,
205 Application = 0x0000000E,
206 Document = 0x0000000F,
207 Pane = 0x00000010,
208 Chart = 0x00000011,
209 Dialog = 0x00000012,
210 Border = 0x00000013,
211 Grouping = 0x00000014,
212 Separator = 0x00000015,
213 ToolBar = 0x00000016,
214 StatusBar = 0x00000017,
215 Table = 0x00000018,
216 ColumnHeader = 0x00000019,
217 RowHeader = 0x0000001A,
218 Column = 0x0000001B,
219 Row = 0x0000001C,
220 Cell = 0x0000001D,
221 Link = 0x0000001E,
222 HelpBalloon = 0x0000001F,
223 Assistant = 0x00000020,
224 List = 0x00000021,
225 ListItem = 0x00000022,
226 Tree = 0x00000023,
227 TreeItem = 0x00000024,
228 PageTab = 0x00000025,
229 PropertyPage = 0x00000026,
230 Indicator = 0x00000027,
231 Graphic = 0x00000028,
232 StaticText = 0x00000029,
233 EditableText = 0x0000002A, // Editable, selectable, etc.
234 Button = 0x0000002B,
235#ifndef Q_QDOC
236 PushButton = Button, // deprecated
237#endif
238 CheckBox = 0x0000002C,
239 RadioButton = 0x0000002D,
240 ComboBox = 0x0000002E,
241 // DropList = 0x0000002F,
242 ProgressBar = 0x00000030,
243 Dial = 0x00000031,
244 HotkeyField = 0x00000032,
245 Slider = 0x00000033,
246 SpinBox = 0x00000034,
247 Canvas = 0x00000035, // MSAA: ROLE_SYSTEM_DIAGRAM - The object represents a graphical image that is used to diagram data.
248 Animation = 0x00000036,
249 Equation = 0x00000037,
250 ButtonDropDown = 0x00000038, // The object represents a button that expands a grid.
251 ButtonMenu = 0x00000039,
252 ButtonDropGrid = 0x0000003A,
253 Whitespace = 0x0000003B, // The object represents blank space between other objects.
254 PageTabList = 0x0000003C,
255 Clock = 0x0000003D,
256 Splitter = 0x0000003E,
257 // Reserved space in case MSAA roles needs to be added
258
259 // Additional Qt roles where enum value does not map directly to MSAA:
260 LayeredPane = 0x00000080,
261 Terminal = 0x00000081,
262 Desktop = 0x00000082,
263 Paragraph = 0x00000083,
264 WebDocument = 0x00000084,
265 Section = 0x00000085,
266 Notification = 0x00000086,
267
268 // IAccessible2 roles
269 // IA2_ROLE_CANVAS = 0x401, // An object that can be drawn into and to manage events from the objects drawn into it
270 // IA2_ROLE_CAPTION = 0x402,
271 // IA2_ROLE_CHECK_MENU_ITEM = 0x403,
272 ColorChooser = 0x404,
273 // IA2_ROLE_DATE_EDITOR = 0x405,
274 // IA2_ROLE_DESKTOP_ICON = 0x406,
275 // IA2_ROLE_DESKTOP_PANE = 0x407,
276 // IA2_ROLE_DIRECTORY_PANE = 0x408,
277 // IA2_ROLE_EDITBAR = 0x409,
278 // IA2_ROLE_EMBEDDED_OBJECT = 0x40A,
279 // IA2_ROLE_ENDNOTE = 0x40B,
280 // IA2_ROLE_FILE_CHOOSER = 0x40C,
281 // IA2_ROLE_FONT_CHOOSER = 0x40D,
282 Footer = 0x40E,
283 // IA2_ROLE_FOOTNOTE = 0x40F,
284 Form = 0x410,
285 // some platforms (windows and at-spi) use Frame for regular windows
286 // because window was taken for tool/dock windows by MSAA
287 // Frame = 0x411,
288 // IA2_ROLE_GLASS_PANE = 0x412,
289 // IA2_ROLE_HEADER = 0x413,
290 Heading = 0x414,
291 // IA2_ROLE_ICON = 0x415,
292 // IA2_ROLE_IMAGE_MAP = 0x416,
293 // IA2_ROLE_INPUT_METHOD_WINDOW = 0x417,
294 // IA2_ROLE_INTERNAL_FRAME = 0x418,
295 // IA2_ROLE_LABEL = 0x419,
296 // IA2_ROLE_LAYERED_PANE = 0x41A,
297 Note = 0x41B,
298 // IA2_ROLE_OPTION_PANE = 0x41C,
299 // IA2_ROLE_PAGE = 0x41D,
300 // IA2_ROLE_PARAGRAPH = 0x42E,
301 // IA2_ROLE_RADIO_MENU_ITEM = 0x41F,
302 // IA2_ROLE_REDUNDANT_OBJECT = 0x420,
303 // IA2_ROLE_ROOT_PANE = 0x421,
304 // IA2_ROLE_RULER = 0x422,
305 // IA2_ROLE_SCROLL_PANE = 0x423,
306 // IA2_ROLE_SECTION = 0x424,
307 // IA2_ROLE_SHAPE = 0x425,
308 // IA2_ROLE_SPLIT_PANE = 0x426,
309 // IA2_ROLE_TEAR_OFF_MENU = 0x427,
310 // IA2_ROLE_TERMINAL = 0x428,
311 // IA2_ROLE_TEXT_FRAME = 0x429,
312 // IA2_ROLE_TOGGLE_BUTTON = 0x42A,
313 // IA2_ROLE_VIEW_PORT = 0x42B,
314 ComplementaryContent = 0x42C,
315
316 UserRole = 0x0000ffff
317 };
318 Q_ENUM(Role)
319
320 enum Text {
321 Name = 0,
322 Description,
323 Value,
324 Help,
325 Accelerator,
326 DebugDescription,
327 UserText = 0x0000ffff
328 };
329
330 enum RelationFlag {
331 Label = 0x00000001,
332 Labelled = 0x00000002,
333 Controller = 0x00000004,
334 Controlled = 0x00000008,
335 DescriptionFor = 0x00000010,
336 Described = 0x00000020,
337 FlowsFrom = 0x00000040,
338 FlowsTo = 0x00000080,
339 AllRelations = 0xffffffff
340 };
341 Q_DECLARE_FLAGS(Relation, RelationFlag)
342
343 enum InterfaceType
344 {
345 TextInterface,
346 EditableTextInterface,
347 ValueInterface,
348 ActionInterface,
349 ImageInterface,
350 TableInterface,
351 TableCellInterface,
352 HyperlinkInterface,
353 SelectionInterface,
354 AttributesInterface,
355 };
356
357 enum TextBoundaryType {
358 CharBoundary,
359 WordBoundary,
360 SentenceBoundary,
361 ParagraphBoundary,
362 LineBoundary,
363 NoBoundary
364 };
365
366 enum class Attribute {
367 Custom,
368 Level,
369 };
370
371 enum class AnnouncementPriority {
372 Polite,
373 Assertive
374 };
375
376 typedef QAccessibleInterface*(*InterfaceFactory)(const QString &key, QObject*);
377 typedef void(*UpdateHandler)(QAccessibleEvent *event);
378 typedef void(*RootObjectHandler)(QObject*);
379
380 typedef unsigned Id;
381
382 static void installFactory(InterfaceFactory);
383 static void removeFactory(InterfaceFactory);
384 static UpdateHandler installUpdateHandler(UpdateHandler);
385 static RootObjectHandler installRootObjectHandler(RootObjectHandler);
386
387 class Q_GUI_EXPORT ActivationObserver
388 {
389 public:
390 virtual ~ActivationObserver();
391 virtual void accessibilityActiveChanged(bool active) = 0;
392 };
393 static void installActivationObserver(ActivationObserver *);
394 static void removeActivationObserver(ActivationObserver *);
395
396 static QAccessibleInterface *queryAccessibleInterface(QObject *);
397 static Id uniqueId(QAccessibleInterface *iface);
398 static QAccessibleInterface *accessibleInterface(Id uniqueId);
399 static Id registerAccessibleInterface(QAccessibleInterface *iface);
400 static void deleteAccessibleInterface(Id uniqueId);
401
402 static void updateAccessibility(QAccessibleEvent *event);
403
404 static bool isActive();
405 static void setActive(bool active);
406 static void setRootObject(QObject *object);
407
408 static void cleanup();
409
410 static QPair< int, int > qAccessibleTextBoundaryHelper(const QTextCursor &cursor, TextBoundaryType boundaryType);
411
412private:
413 static UpdateHandler updateHandler;
414 static RootObjectHandler rootObjectHandler;
415
416 QAccessible() {}
417
418 friend class QAccessibleCache;
419};
420
421Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::Relation)
422
424
425#endif // QT_CONFIG(accessibility)
426#endif // QACCESSIBLE_BASE_H
bool isActive
\inmodule QtGui
The QAccessible class provides enums and static functions related to accessibility.
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\reentrant \inmodule QtGui
Definition qtextcursor.h:30
[0]
Definition splitter.h:15
[Window class with invokable method]
Definition window.h:11
QCursor cursor
std::list< QString >::iterator Name
Definition lalr.h:28
@ Whitespace
Combined button and popup list for selecting options.
@ UserRole
@ Desktop
Definition qnamespace.h:215
@ ToolTip
Definition qnamespace.h:213
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
Button
GLuint64 key
GLint first
struct _cl_event * event
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
#define Q_ENUM(x)
#define Q_GADGET
unsigned long long quint64
Definition qtypes.h:61
#define disabled