1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QACCESSIBLE_H
|
---|
43 | #define QACCESSIBLE_H
|
---|
44 |
|
---|
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>
|
---|
53 |
|
---|
54 | QT_BEGIN_HEADER
|
---|
55 |
|
---|
56 | QT_BEGIN_NAMESPACE
|
---|
57 |
|
---|
58 | QT_MODULE(Gui)
|
---|
59 |
|
---|
60 | #ifndef QT_NO_ACCESSIBILITY
|
---|
61 |
|
---|
62 | class QAccessibleInterface;
|
---|
63 |
|
---|
64 | class Q_GUI_EXPORT QAccessible
|
---|
65 | {
|
---|
66 | public:
|
---|
67 | enum Event {
|
---|
68 | SoundPlayed = 0x0001,
|
---|
69 | Alert = 0x0002,
|
---|
70 | ForegroundChanged = 0x0003,
|
---|
71 | MenuStart = 0x0004,
|
---|
72 | MenuEnd = 0x0005,
|
---|
73 | PopupMenuStart = 0x0006,
|
---|
74 | PopupMenuEnd = 0x0007,
|
---|
75 | ContextHelpStart = 0x000C,
|
---|
76 | ContextHelpEnd = 0x000D,
|
---|
77 | DragDropStart = 0x000E,
|
---|
78 | DragDropEnd = 0x000F,
|
---|
79 | DialogStart = 0x0010,
|
---|
80 | DialogEnd = 0x0011,
|
---|
81 | ScrollingStart = 0x0012,
|
---|
82 | ScrollingEnd = 0x0013,
|
---|
83 |
|
---|
84 | MenuCommand = 0x0018,
|
---|
85 |
|
---|
86 | ObjectCreated = 0x8000,
|
---|
87 | ObjectDestroyed = 0x8001,
|
---|
88 | ObjectShow = 0x8002,
|
---|
89 | ObjectHide = 0x8003,
|
---|
90 | ObjectReorder = 0x8004,
|
---|
91 | Focus = 0x8005,
|
---|
92 | Selection = 0x8006,
|
---|
93 | SelectionAdd = 0x8007,
|
---|
94 | SelectionRemove = 0x8008,
|
---|
95 | SelectionWithin = 0x8009,
|
---|
96 | StateChanged = 0x800A,
|
---|
97 | LocationChanged = 0x800B,
|
---|
98 | NameChanged = 0x800C,
|
---|
99 | DescriptionChanged = 0x800D,
|
---|
100 | ValueChanged = 0x800E,
|
---|
101 | ParentChanged = 0x800F,
|
---|
102 | HelpChanged = 0x80A0,
|
---|
103 | DefaultActionChanged = 0x80B0,
|
---|
104 | AcceleratorChanged = 0x80C0
|
---|
105 | };
|
---|
106 |
|
---|
107 | enum StateFlag {
|
---|
108 | Normal = 0x00000000,
|
---|
109 | Unavailable = 0x00000001,
|
---|
110 | Selected = 0x00000002,
|
---|
111 | Focused = 0x00000004,
|
---|
112 | Pressed = 0x00000008,
|
---|
113 | Checked = 0x00000010,
|
---|
114 | Mixed = 0x00000020,
|
---|
115 | ReadOnly = 0x00000040,
|
---|
116 | HotTracked = 0x00000080,
|
---|
117 | DefaultButton = 0x00000100,
|
---|
118 | Expanded = 0x00000200,
|
---|
119 | Collapsed = 0x00000400,
|
---|
120 | Busy = 0x00000800,
|
---|
121 | // Floating = 0x00001000,
|
---|
122 | Marqueed = 0x00002000,
|
---|
123 | Animated = 0x00004000,
|
---|
124 | Invisible = 0x00008000,
|
---|
125 | Offscreen = 0x00010000,
|
---|
126 | Sizeable = 0x00020000,
|
---|
127 | Movable = 0x00040000,
|
---|
128 | #ifdef QT3_SUPPORT
|
---|
129 | Moveable = Movable,
|
---|
130 | #endif
|
---|
131 | SelfVoicing = 0x00080000,
|
---|
132 | Focusable = 0x00100000,
|
---|
133 | Selectable = 0x00200000,
|
---|
134 | Linked = 0x00400000,
|
---|
135 | Traversed = 0x00800000,
|
---|
136 | MultiSelectable = 0x01000000,
|
---|
137 | ExtSelectable = 0x02000000,
|
---|
138 | //AlertLow = 0x04000000,
|
---|
139 | //AlertMedium = 0x08000000,
|
---|
140 | //AlertHigh = 0x10000000, /* reused for HasInvokeExtension */
|
---|
141 | Protected = 0x20000000,
|
---|
142 | HasPopup = 0x40000000,
|
---|
143 | Modal = 0x80000000,
|
---|
144 |
|
---|
145 | HasInvokeExtension = 0x10000000 // internal
|
---|
146 | };
|
---|
147 | Q_DECLARE_FLAGS(State, StateFlag)
|
---|
148 |
|
---|
149 | enum Role {
|
---|
150 | NoRole = 0x00000000,
|
---|
151 | TitleBar = 0x00000001,
|
---|
152 | MenuBar = 0x00000002,
|
---|
153 | ScrollBar = 0x00000003,
|
---|
154 | Grip = 0x00000004,
|
---|
155 | Sound = 0x00000005,
|
---|
156 | Cursor = 0x00000006,
|
---|
157 | Caret = 0x00000007,
|
---|
158 | AlertMessage = 0x00000008,
|
---|
159 | Window = 0x00000009,
|
---|
160 | Client = 0x0000000A,
|
---|
161 | PopupMenu = 0x0000000B,
|
---|
162 | MenuItem = 0x0000000C,
|
---|
163 | ToolTip = 0x0000000D,
|
---|
164 | Application = 0x0000000E,
|
---|
165 | Document = 0x0000000F,
|
---|
166 | Pane = 0x00000010,
|
---|
167 | Chart = 0x00000011,
|
---|
168 | Dialog = 0x00000012,
|
---|
169 | Border = 0x00000013,
|
---|
170 | Grouping = 0x00000014,
|
---|
171 | Separator = 0x00000015,
|
---|
172 | ToolBar = 0x00000016,
|
---|
173 | StatusBar = 0x00000017,
|
---|
174 | Table = 0x00000018,
|
---|
175 | ColumnHeader = 0x00000019,
|
---|
176 | RowHeader = 0x0000001A,
|
---|
177 | Column = 0x0000001B,
|
---|
178 | Row = 0x0000001C,
|
---|
179 | Cell = 0x0000001D,
|
---|
180 | Link = 0x0000001E,
|
---|
181 | HelpBalloon = 0x0000001F,
|
---|
182 | Assistant = 0x00000020,
|
---|
183 | List = 0x00000021,
|
---|
184 | ListItem = 0x00000022,
|
---|
185 | Tree = 0x00000023,
|
---|
186 | TreeItem = 0x00000024,
|
---|
187 | PageTab = 0x00000025,
|
---|
188 | PropertyPage = 0x00000026,
|
---|
189 | Indicator = 0x00000027,
|
---|
190 | Graphic = 0x00000028,
|
---|
191 | StaticText = 0x00000029,
|
---|
192 | EditableText = 0x0000002A, // Editable, selectable, etc.
|
---|
193 | PushButton = 0x0000002B,
|
---|
194 | CheckBox = 0x0000002C,
|
---|
195 | RadioButton = 0x0000002D,
|
---|
196 | ComboBox = 0x0000002E,
|
---|
197 | // DropList = 0x0000002F,
|
---|
198 | ProgressBar = 0x00000030,
|
---|
199 | Dial = 0x00000031,
|
---|
200 | HotkeyField = 0x00000032,
|
---|
201 | Slider = 0x00000033,
|
---|
202 | SpinBox = 0x00000034,
|
---|
203 | Canvas = 0x00000035,
|
---|
204 | Animation = 0x00000036,
|
---|
205 | Equation = 0x00000037,
|
---|
206 | ButtonDropDown = 0x00000038,
|
---|
207 | ButtonMenu = 0x00000039,
|
---|
208 | ButtonDropGrid = 0x0000003A,
|
---|
209 | Whitespace = 0x0000003B,
|
---|
210 | PageTabList = 0x0000003C,
|
---|
211 | Clock = 0x0000003D,
|
---|
212 | Splitter = 0x0000003E,
|
---|
213 | LayeredPane = 0x0000003F,
|
---|
214 | UserRole = 0x0000ffff
|
---|
215 | };
|
---|
216 |
|
---|
217 | enum Text {
|
---|
218 | Name = 0,
|
---|
219 | Description,
|
---|
220 | Value,
|
---|
221 | Help,
|
---|
222 | Accelerator,
|
---|
223 | UserText = 0x0000ffff
|
---|
224 | };
|
---|
225 |
|
---|
226 | enum RelationFlag {
|
---|
227 | Unrelated = 0x00000000,
|
---|
228 | Self = 0x00000001,
|
---|
229 | Ancestor = 0x00000002,
|
---|
230 | Child = 0x00000004,
|
---|
231 | Descendent = 0x00000008,
|
---|
232 | Sibling = 0x00000010,
|
---|
233 | HierarchyMask = 0x000000ff,
|
---|
234 |
|
---|
235 | Up = 0x00000100,
|
---|
236 | Down = 0x00000200,
|
---|
237 | Left = 0x00000400,
|
---|
238 | Right = 0x00000800,
|
---|
239 | Covers = 0x00001000,
|
---|
240 | Covered = 0x00002000,
|
---|
241 | GeometryMask = 0x0000ff00,
|
---|
242 |
|
---|
243 | FocusChild = 0x00010000,
|
---|
244 | Label = 0x00020000,
|
---|
245 | Labelled = 0x00040000,
|
---|
246 | Controller = 0x00080000,
|
---|
247 | Controlled = 0x00100000,
|
---|
248 | LogicalMask = 0x00ff0000
|
---|
249 | };
|
---|
250 | Q_DECLARE_FLAGS(Relation, RelationFlag)
|
---|
251 |
|
---|
252 | enum Action {
|
---|
253 | DefaultAction = 0,
|
---|
254 | Press = -1,
|
---|
255 | FirstStandardAction = Press,
|
---|
256 | SetFocus = -2,
|
---|
257 | Increase = -3,
|
---|
258 | Decrease = -4,
|
---|
259 | Accept = -5,
|
---|
260 | Cancel = -6,
|
---|
261 | Select = -7,
|
---|
262 | ClearSelection = -8,
|
---|
263 | RemoveSelection = -9,
|
---|
264 | ExtendSelection = -10,
|
---|
265 | AddToSelection = -11,
|
---|
266 | LastStandardAction = AddToSelection
|
---|
267 | };
|
---|
268 |
|
---|
269 | enum Method {
|
---|
270 | ListSupportedMethods = 0,
|
---|
271 | SetCursorPosition = 1,
|
---|
272 | GetCursorPosition = 2,
|
---|
273 | ForegroundColor = 3,
|
---|
274 | BackgroundColor = 4
|
---|
275 | };
|
---|
276 |
|
---|
277 | typedef QAccessibleInterface*(*InterfaceFactory)(const QString &key, QObject*);
|
---|
278 | typedef void(*UpdateHandler)(QObject*, int who, Event reason);
|
---|
279 | typedef void(*RootObjectHandler)(QObject*);
|
---|
280 |
|
---|
281 | static void installFactory(InterfaceFactory);
|
---|
282 | static void removeFactory(InterfaceFactory);
|
---|
283 | static UpdateHandler installUpdateHandler(UpdateHandler);
|
---|
284 | static RootObjectHandler installRootObjectHandler(RootObjectHandler);
|
---|
285 |
|
---|
286 | static QAccessibleInterface *queryAccessibleInterface(QObject *);
|
---|
287 | static void updateAccessibility(QObject *, int who, Event reason);
|
---|
288 | static bool isActive();
|
---|
289 | static void setRootObject(QObject*);
|
---|
290 |
|
---|
291 | static void initialize();
|
---|
292 | static void cleanup();
|
---|
293 |
|
---|
294 | private:
|
---|
295 | static UpdateHandler updateHandler;
|
---|
296 | static RootObjectHandler rootObjectHandler;
|
---|
297 | };
|
---|
298 |
|
---|
299 | Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::State)
|
---|
300 | Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::Relation)
|
---|
301 | QT_END_NAMESPACE
|
---|
302 | Q_DECLARE_METATYPE(QSet<QAccessible::Method>)
|
---|
303 | QT_BEGIN_NAMESPACE
|
---|
304 |
|
---|
305 | namespace QAccessible2
|
---|
306 | {
|
---|
307 | enum InterfaceType
|
---|
308 | {
|
---|
309 | TextInterface,
|
---|
310 | EditableTextInterface,
|
---|
311 | ValueInterface,
|
---|
312 | TableInterface
|
---|
313 | };
|
---|
314 | }
|
---|
315 |
|
---|
316 | class QAccessible2Interface;
|
---|
317 | class QAccessibleTextInterface;
|
---|
318 | class QAccessibleEditableTextInterface;
|
---|
319 | class QAccessibleValueInterface;
|
---|
320 | class QAccessibleTableInterface;
|
---|
321 |
|
---|
322 | class Q_GUI_EXPORT QAccessibleInterface : public QAccessible
|
---|
323 | {
|
---|
324 | public:
|
---|
325 | virtual ~QAccessibleInterface() {}
|
---|
326 | // check for valid pointers
|
---|
327 | virtual bool isValid() const = 0;
|
---|
328 | virtual QObject *object() const = 0;
|
---|
329 |
|
---|
330 | // hierarchy
|
---|
331 | virtual int childCount() const = 0;
|
---|
332 | virtual int indexOfChild(const QAccessibleInterface *) const = 0;
|
---|
333 |
|
---|
334 | // relations
|
---|
335 | virtual Relation relationTo(int child, const QAccessibleInterface *other,
|
---|
336 | int otherChild) const = 0;
|
---|
337 | virtual int childAt(int x, int y) const = 0;
|
---|
338 |
|
---|
339 | // navigation
|
---|
340 | virtual int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const = 0;
|
---|
341 |
|
---|
342 | // properties and state
|
---|
343 | virtual QString text(Text t, int child) const = 0;
|
---|
344 | virtual void setText(Text t, int child, const QString &text) = 0;
|
---|
345 | virtual QRect rect(int child) const = 0;
|
---|
346 | virtual Role role(int child) const = 0;
|
---|
347 | virtual State state(int child) const = 0;
|
---|
348 |
|
---|
349 | // action
|
---|
350 | virtual int userActionCount(int child) const = 0;
|
---|
351 | virtual QString actionText(int action, Text t, int child) const = 0;
|
---|
352 | virtual bool doAction(int action, int child, const QVariantList ¶ms = QVariantList()) = 0;
|
---|
353 |
|
---|
354 | QVariant invokeMethod(Method method, int child = 0,
|
---|
355 | const QVariantList ¶ms = QVariantList());
|
---|
356 |
|
---|
357 | inline QSet<Method> supportedMethods()
|
---|
358 | { return qvariant_cast<QSet<Method> >(invokeMethod(ListSupportedMethods)); }
|
---|
359 |
|
---|
360 | inline QColor foregroundColor()
|
---|
361 | { return qvariant_cast<QColor>(invokeMethod(ForegroundColor)); }
|
---|
362 |
|
---|
363 | inline QColor backgroundColor()
|
---|
364 | { return qvariant_cast<QColor>(invokeMethod(BackgroundColor)); }
|
---|
365 |
|
---|
366 | inline QAccessibleTextInterface *textInterface()
|
---|
367 | { return reinterpret_cast<QAccessibleTextInterface *>(cast_helper(QAccessible2::TextInterface)); }
|
---|
368 |
|
---|
369 | inline QAccessibleEditableTextInterface *editableTextInterface()
|
---|
370 | { return reinterpret_cast<QAccessibleEditableTextInterface *>(cast_helper(QAccessible2::EditableTextInterface)); }
|
---|
371 |
|
---|
372 | inline QAccessibleValueInterface *valueInterface()
|
---|
373 | { return reinterpret_cast<QAccessibleValueInterface *>(cast_helper(QAccessible2::ValueInterface)); }
|
---|
374 |
|
---|
375 | inline QAccessibleTableInterface *tableInterface()
|
---|
376 | { return reinterpret_cast<QAccessibleTableInterface *>(cast_helper(QAccessible2::TableInterface)); }
|
---|
377 |
|
---|
378 | private:
|
---|
379 | QAccessible2Interface *cast_helper(QAccessible2::InterfaceType);
|
---|
380 | };
|
---|
381 |
|
---|
382 | class Q_GUI_EXPORT QAccessibleInterfaceEx: public QAccessibleInterface
|
---|
383 | {
|
---|
384 | public:
|
---|
385 | virtual QVariant invokeMethodEx(Method method, int child, const QVariantList ¶ms) = 0;
|
---|
386 | virtual QVariant virtual_hook(const QVariant &data);
|
---|
387 | virtual QAccessible2Interface *interface_cast(QAccessible2::InterfaceType)
|
---|
388 | { return 0; }
|
---|
389 | };
|
---|
390 |
|
---|
391 |
|
---|
392 | class Q_GUI_EXPORT QAccessibleEvent : public QEvent
|
---|
393 | {
|
---|
394 | public:
|
---|
395 | inline QAccessibleEvent(Type type, int child);
|
---|
396 | inline int child() const { return c; }
|
---|
397 | inline QString value() const { return val; }
|
---|
398 | inline void setValue(const QString &aText) { val = aText; }
|
---|
399 |
|
---|
400 | private:
|
---|
401 | int c;
|
---|
402 | QString val;
|
---|
403 | };
|
---|
404 |
|
---|
405 | inline QAccessibleEvent::QAccessibleEvent(Type atype, int achild)
|
---|
406 | : QEvent(atype), c(achild) {}
|
---|
407 |
|
---|
408 | #define QAccessibleInterface_iid "com.trolltech.Qt.QAccessibleInterface"
|
---|
409 | Q_DECLARE_INTERFACE(QAccessibleInterface, QAccessibleInterface_iid)
|
---|
410 |
|
---|
411 | #endif // QT_NO_ACCESSIBILITY
|
---|
412 |
|
---|
413 | QT_END_NAMESPACE
|
---|
414 |
|
---|
415 | QT_END_HEADER
|
---|
416 |
|
---|
417 | #endif // QACCESSIBLE_H
|
---|