/src/qtbase/src/gui/accessible/qaccessible_base.h
Line | Count | Source |
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 | | |
19 | | QT_BEGIN_NAMESPACE |
20 | | |
21 | | class QAccessibleInterface; |
22 | | class QAccessibleEvent; |
23 | | class QTextCursor; |
24 | | |
25 | | class Q_GUI_EXPORT QAccessible |
26 | | { |
27 | | Q_GADGET |
28 | | public: |
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 | | IdentifierChanged = 0x80E0, |
106 | | RoleChanged = 0x80E1, |
107 | | |
108 | | // was declared after AcceleratorChanged, without explicit value |
109 | | InvalidEvent = AcceleratorChanged + 1, |
110 | | }; |
111 | 0 | Q_ENUM(Event) Unexecuted instantiation: qt_getEnumMetaObject(QAccessible::Event) Unexecuted instantiation: qt_getEnumName(QAccessible::Event) |
112 | 0 |
|
113 | 0 | // 64 bit enums seem hard on some platforms (windows...) |
114 | 0 | // which makes using a bit field a sensible alternative |
115 | 0 | struct State { |
116 | 0 | // http://msdn.microsoft.com/en-us/library/ms697270.aspx |
117 | 0 | quint64 disabled : 1; // used to be Unavailable |
118 | 0 | quint64 selected : 1; |
119 | 0 | quint64 focusable : 1; |
120 | 0 | quint64 focused : 1; |
121 | 0 | quint64 pressed : 1; |
122 | 0 | quint64 checkable : 1; |
123 | 0 | quint64 checked : 1; |
124 | 0 | quint64 checkStateMixed : 1; // used to be Mixed |
125 | 0 | quint64 readOnly : 1; |
126 | 0 | quint64 hotTracked : 1; |
127 | 0 | quint64 defaultButton : 1; |
128 | 0 | quint64 expanded : 1; |
129 | 0 | quint64 collapsed : 1; |
130 | 0 | quint64 busy : 1; |
131 | 0 | quint64 expandable : 1; |
132 | 0 | quint64 marqueed : 1; |
133 | 0 | quint64 animated : 1; |
134 | 0 | quint64 invisible : 1; |
135 | 0 | quint64 offscreen : 1; |
136 | 0 | quint64 sizeable : 1; |
137 | 0 | quint64 movable : 1; |
138 | 0 | quint64 selfVoicing : 1; |
139 | 0 | quint64 selectable : 1; |
140 | 0 | quint64 linked : 1; |
141 | 0 | quint64 traversed : 1; |
142 | 0 | quint64 multiSelectable : 1; |
143 | 0 | quint64 extSelectable : 1; |
144 | 0 | quint64 passwordEdit : 1; // used to be Protected |
145 | 0 | quint64 hasPopup : 1; |
146 | 0 | quint64 modal : 1; |
147 | 0 |
|
148 | 0 | // IA2 - we chose to not add some IA2 states for now |
149 | 0 | // Below the ones that seem helpful |
150 | 0 | quint64 active : 1; |
151 | 0 | quint64 invalid : 1; // = defunct |
152 | 0 | quint64 editable : 1; |
153 | 0 | quint64 multiLine : 1; |
154 | 0 | quint64 selectableText : 1; |
155 | 0 | quint64 supportsAutoCompletion : 1; |
156 | 0 |
|
157 | 0 | quint64 searchEdit : 1; |
158 | 0 |
|
159 | 0 | // quint64 invalidEntry : 1; |
160 | 0 | // quint64 managesDescendants : 1; |
161 | 0 | // quint64 singleLine : 1; // we have multi line, this is redundant. |
162 | 0 | // quint64 stale : 1; |
163 | 0 | // quint64 transient : 1; |
164 | 0 | // quint64 pinned : 1; |
165 | 0 |
|
166 | 0 | // Apple - see http://mattgemmell.com/2010/12/19/accessibility-for-iphone-and-ipad-apps/ |
167 | 0 | // quint64 playsSound : 1; |
168 | 0 | // quint64 summaryElement : 1; |
169 | 0 | // quint64 updatesFrequently : 1; |
170 | 0 | // quint64 adjustable : 1; |
171 | 0 | // more and not included here: http://developer.apple.com/library/mac/#documentation/UserExperience/Reference/Accessibility_RoleAttribute_Ref/Attributes.html |
172 | 0 |
|
173 | 0 | // MSAA |
174 | 0 | // quint64 alertLow : 1; |
175 | 0 | // quint64 alertMedium : 1; |
176 | 0 | // quint64 alertHigh : 1; |
177 | 0 |
|
178 | 0 | Q_DECL_UNUSED_MEMBER quint64 qt_reserved : 27; |
179 | 0 |
|
180 | 0 | State() { |
181 | 0 | std::memset(this, 0, sizeof(State)); |
182 | 0 | } |
183 | | friend inline bool operator==(const QAccessible::State &first, const QAccessible::State &second) |
184 | 0 | { |
185 | 0 | static_assert(std::has_unique_object_representations_v<State>, |
186 | 0 | "memcmp() cannot be used on types with padding"); |
187 | 0 | return std::memcmp(&first, &second, sizeof(QAccessible::State)) == 0; |
188 | 0 | } |
189 | | }; |
190 | | |
191 | | |
192 | | |
193 | | |
194 | | |
195 | | enum Role { |
196 | | NoRole = 0x00000000, |
197 | | TitleBar = 0x00000001, |
198 | | MenuBar = 0x00000002, |
199 | | ScrollBar = 0x00000003, |
200 | | Grip = 0x00000004, |
201 | | Sound = 0x00000005, |
202 | | Cursor = 0x00000006, |
203 | | Caret = 0x00000007, |
204 | | AlertMessage = 0x00000008, |
205 | | Window = 0x00000009, |
206 | | Client = 0x0000000A, |
207 | | PopupMenu = 0x0000000B, |
208 | | MenuItem = 0x0000000C, |
209 | | ToolTip = 0x0000000D, |
210 | | Application = 0x0000000E, |
211 | | Document = 0x0000000F, |
212 | | Pane = 0x00000010, |
213 | | Chart = 0x00000011, |
214 | | Dialog = 0x00000012, |
215 | | Border = 0x00000013, |
216 | | Grouping = 0x00000014, |
217 | | Separator = 0x00000015, |
218 | | ToolBar = 0x00000016, |
219 | | StatusBar = 0x00000017, |
220 | | Table = 0x00000018, |
221 | | ColumnHeader = 0x00000019, |
222 | | RowHeader = 0x0000001A, |
223 | | Column = 0x0000001B, |
224 | | Row = 0x0000001C, |
225 | | Cell = 0x0000001D, |
226 | | Link = 0x0000001E, |
227 | | HelpBalloon = 0x0000001F, |
228 | | Assistant = 0x00000020, |
229 | | List = 0x00000021, |
230 | | ListItem = 0x00000022, |
231 | | Tree = 0x00000023, |
232 | | TreeItem = 0x00000024, |
233 | | PageTab = 0x00000025, |
234 | | PropertyPage = 0x00000026, |
235 | | Indicator = 0x00000027, |
236 | | Graphic = 0x00000028, |
237 | | StaticText = 0x00000029, |
238 | | EditableText = 0x0000002A, // Editable, selectable, etc. |
239 | | Button = 0x0000002B, |
240 | | #ifndef Q_QDOC |
241 | | PushButton = Button, // deprecated |
242 | | #endif |
243 | | CheckBox = 0x0000002C, |
244 | | RadioButton = 0x0000002D, |
245 | | ComboBox = 0x0000002E, |
246 | | // DropList = 0x0000002F, |
247 | | ProgressBar = 0x00000030, |
248 | | Dial = 0x00000031, |
249 | | HotkeyField = 0x00000032, |
250 | | Slider = 0x00000033, |
251 | | SpinBox = 0x00000034, |
252 | | Canvas = 0x00000035, // MSAA: ROLE_SYSTEM_DIAGRAM - The object represents a graphical image that is used to diagram data. |
253 | | Animation = 0x00000036, |
254 | | Equation = 0x00000037, |
255 | | ButtonDropDown = 0x00000038, // The object represents a button that expands a grid. |
256 | | ButtonMenu = 0x00000039, |
257 | | ButtonDropGrid = 0x0000003A, |
258 | | Whitespace = 0x0000003B, // The object represents blank space between other objects. |
259 | | PageTabList = 0x0000003C, |
260 | | Clock = 0x0000003D, |
261 | | Splitter = 0x0000003E, |
262 | | // Reserved space in case MSAA roles needs to be added |
263 | | |
264 | | // Additional Qt roles where enum value does not map directly to MSAA: |
265 | | LayeredPane = 0x00000080, |
266 | | Terminal = 0x00000081, |
267 | | Desktop = 0x00000082, |
268 | | Paragraph = 0x00000083, |
269 | | WebDocument = 0x00000084, |
270 | | Section = 0x00000085, |
271 | | Notification = 0x00000086, |
272 | | Switch = 0x00000087, |
273 | | |
274 | | // IAccessible2 roles |
275 | | // IA2_ROLE_CANVAS = 0x401, // An object that can be drawn into and to manage events from the objects drawn into it |
276 | | // IA2_ROLE_CAPTION = 0x402, |
277 | | // IA2_ROLE_CHECK_MENU_ITEM = 0x403, |
278 | | ColorChooser = 0x404, |
279 | | // IA2_ROLE_DATE_EDITOR = 0x405, |
280 | | // IA2_ROLE_DESKTOP_ICON = 0x406, |
281 | | // IA2_ROLE_DESKTOP_PANE = 0x407, |
282 | | // IA2_ROLE_DIRECTORY_PANE = 0x408, |
283 | | // IA2_ROLE_EDITBAR = 0x409, |
284 | | // IA2_ROLE_EMBEDDED_OBJECT = 0x40A, |
285 | | // IA2_ROLE_ENDNOTE = 0x40B, |
286 | | // IA2_ROLE_FILE_CHOOSER = 0x40C, |
287 | | // IA2_ROLE_FONT_CHOOSER = 0x40D, |
288 | | Footer = 0x40E, |
289 | | // IA2_ROLE_FOOTNOTE = 0x40F, |
290 | | Form = 0x410, |
291 | | // some platforms (windows and at-spi) use Frame for regular windows |
292 | | // because window was taken for tool/dock windows by MSAA |
293 | | // Frame = 0x411, |
294 | | // IA2_ROLE_GLASS_PANE = 0x412, |
295 | | // IA2_ROLE_HEADER = 0x413, |
296 | | Heading = 0x414, |
297 | | // IA2_ROLE_ICON = 0x415, |
298 | | // IA2_ROLE_IMAGE_MAP = 0x416, |
299 | | // IA2_ROLE_INPUT_METHOD_WINDOW = 0x417, |
300 | | // IA2_ROLE_INTERNAL_FRAME = 0x418, |
301 | | // IA2_ROLE_LABEL = 0x419, |
302 | | // IA2_ROLE_LAYERED_PANE = 0x41A, |
303 | | Note = 0x41B, |
304 | | // IA2_ROLE_OPTION_PANE = 0x41C, |
305 | | // IA2_ROLE_PAGE = 0x41D, |
306 | | // IA2_ROLE_PARAGRAPH = 0x42E, |
307 | | // IA2_ROLE_RADIO_MENU_ITEM = 0x41F, |
308 | | // IA2_ROLE_REDUNDANT_OBJECT = 0x420, |
309 | | // IA2_ROLE_ROOT_PANE = 0x421, |
310 | | // IA2_ROLE_RULER = 0x422, |
311 | | // IA2_ROLE_SCROLL_PANE = 0x423, |
312 | | // IA2_ROLE_SECTION = 0x424, |
313 | | // IA2_ROLE_SHAPE = 0x425, |
314 | | // IA2_ROLE_SPLIT_PANE = 0x426, |
315 | | // IA2_ROLE_TEAR_OFF_MENU = 0x427, |
316 | | // IA2_ROLE_TERMINAL = 0x428, |
317 | | // IA2_ROLE_TEXT_FRAME = 0x429, |
318 | | // IA2_ROLE_TOGGLE_BUTTON = 0x42A, |
319 | | // IA2_ROLE_VIEW_PORT = 0x42B, |
320 | | ComplementaryContent = 0x42C, |
321 | | // IA2_ROLE_LANDMARK = 0x42D, |
322 | | // IA2_ROLE_LEVEL_BAR = 0x42E, |
323 | | // IA2_ROLE_CONTENT_DELETION = 0x42F, |
324 | | // IA2_ROLE_CONTENT_INSERTION = 0x430, |
325 | | BlockQuote = 0x431, |
326 | | // IA2_ROLE_MARK = 0x432, |
327 | | // IA2_ROLE_SUGGESTION = 0x433, |
328 | | // IA2_ROLE_COMMENT = = 0x434, |
329 | | |
330 | | UserRole = 0x0000ffff |
331 | | }; |
332 | 0 | Q_ENUM(Role) Unexecuted instantiation: qt_getEnumMetaObject(QAccessible::Role) Unexecuted instantiation: qt_getEnumName(QAccessible::Role) |
333 | 0 |
|
334 | 0 | enum Text { |
335 | 0 | Name = 0, |
336 | 0 | Description, |
337 | 0 | Value, |
338 | 0 | Help, |
339 | 0 | Accelerator, |
340 | 0 | DebugDescription, |
341 | 0 | Identifier, |
342 | 0 | UserText = 0x0000ffff |
343 | 0 | }; |
344 | 0 |
|
345 | 0 | enum RelationFlag { |
346 | 0 | Label = 0x00000001, |
347 | 0 | Labelled = 0x00000002, |
348 | 0 | Controller = 0x00000004, |
349 | 0 | Controlled = 0x00000008, |
350 | 0 | DescriptionFor = 0x00000010, |
351 | 0 | Described = 0x00000020, |
352 | 0 | FlowsFrom = 0x00000040, |
353 | 0 | FlowsTo = 0x00000080, |
354 | 0 | AllRelations = 0xffffffff |
355 | 0 | }; |
356 | 0 | Q_DECLARE_FLAGS(Relation, RelationFlag) |
357 | 0 |
|
358 | 0 | enum InterfaceType |
359 | 0 | { |
360 | 0 | TextInterface, |
361 | 0 | EditableTextInterface, |
362 | 0 | ValueInterface, |
363 | 0 | ActionInterface, |
364 | 0 | ImageInterface, |
365 | 0 | TableInterface, |
366 | 0 | TableCellInterface, |
367 | 0 | HyperlinkInterface, |
368 | 0 | SelectionInterface, |
369 | 0 | AttributesInterface, |
370 | 0 | }; |
371 | 0 |
|
372 | 0 | enum TextBoundaryType { |
373 | 0 | CharBoundary, |
374 | 0 | WordBoundary, |
375 | 0 | SentenceBoundary, |
376 | 0 | ParagraphBoundary, |
377 | 0 | LineBoundary, |
378 | 0 | NoBoundary |
379 | 0 | }; |
380 | 0 |
|
381 | 0 | enum class Attribute { |
382 | 0 | Custom, |
383 | 0 | Level, |
384 | 0 | Locale, |
385 | 0 | Orientation, |
386 | 0 | }; |
387 | 0 | Q_ENUM(Attribute) Unexecuted instantiation: qt_getEnumMetaObject(QAccessible::Attribute) Unexecuted instantiation: qt_getEnumName(QAccessible::Attribute) |
388 | 0 |
|
389 | 0 | enum class AnnouncementPoliteness { |
390 | 0 | Polite, |
391 | 0 | Assertive, |
392 | 0 | }; |
393 | 0 | Q_ENUM(AnnouncementPoliteness) Unexecuted instantiation: qt_getEnumMetaObject(QAccessible::AnnouncementPoliteness) Unexecuted instantiation: qt_getEnumName(QAccessible::AnnouncementPoliteness) |
394 | 0 |
|
395 | 0 | typedef QAccessibleInterface*(*InterfaceFactory)(const QString &key, QObject*); |
396 | 0 | typedef void(*UpdateHandler)(QAccessibleEvent *event); |
397 | 0 | typedef void(*RootObjectHandler)(QObject*); |
398 | 0 |
|
399 | 0 | typedef unsigned Id; |
400 | 0 |
|
401 | 0 | static void installFactory(InterfaceFactory); |
402 | 0 | static void removeFactory(InterfaceFactory); |
403 | 0 | static UpdateHandler installUpdateHandler(UpdateHandler); |
404 | 0 | static RootObjectHandler installRootObjectHandler(RootObjectHandler); |
405 | 0 |
|
406 | 0 | class Q_GUI_EXPORT ActivationObserver |
407 | 0 | { |
408 | 0 | public: |
409 | 0 | virtual ~ActivationObserver(); |
410 | 0 | virtual void accessibilityActiveChanged(bool active) = 0; |
411 | 0 | }; |
412 | 0 | static void installActivationObserver(ActivationObserver *); |
413 | 0 | static void removeActivationObserver(ActivationObserver *); |
414 | 0 |
|
415 | 0 | static QAccessibleInterface *queryAccessibleInterface(QObject *); |
416 | 0 | static Id uniqueId(QAccessibleInterface *iface); |
417 | 0 | static QAccessibleInterface *accessibleInterface(Id uniqueId); |
418 | 0 | static Id registerAccessibleInterface(QAccessibleInterface *iface); |
419 | 0 | static void deleteAccessibleInterface(Id uniqueId); |
420 | 0 |
|
421 | 0 | static void updateAccessibility(QAccessibleEvent *event); |
422 | 0 |
|
423 | 0 | static bool isActive(); |
424 | 0 | static void setActive(bool active); |
425 | 0 | static void setRootObject(QObject *object); |
426 | 0 |
|
427 | 0 | static void cleanup(); |
428 | 0 |
|
429 | 0 | static std::pair< int, int > qAccessibleTextBoundaryHelper(const QTextCursor &cursor, TextBoundaryType boundaryType); |
430 | 0 |
|
431 | 0 | private: |
432 | 0 | static UpdateHandler updateHandler; |
433 | 0 | static RootObjectHandler rootObjectHandler; |
434 | 0 |
|
435 | 0 | QAccessible() {} |
436 | | |
437 | | friend class QAccessibleCache; |
438 | | }; |
439 | | |
440 | | Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::Relation) Unexecuted instantiation: operator|(QAccessible::RelationFlag, QAccessible::RelationFlag) Unexecuted instantiation: operator|(QAccessible::RelationFlag, QFlags<QAccessible::RelationFlag>) Unexecuted instantiation: operator&(QAccessible::RelationFlag, QAccessible::RelationFlag) Unexecuted instantiation: operator&(QAccessible::RelationFlag, QFlags<QAccessible::RelationFlag>) Unexecuted instantiation: operator^(QAccessible::RelationFlag, QAccessible::RelationFlag) Unexecuted instantiation: operator^(QAccessible::RelationFlag, QFlags<QAccessible::RelationFlag>) Unexecuted instantiation: operator|(QAccessible::RelationFlag, int) |
441 | | |
442 | | QT_END_NAMESPACE |
443 | | |
444 | | #endif // QT_CONFIG(accessibility) |
445 | | #endif // QACCESSIBLE_BASE_H |