0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtGui module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
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 |
// Additional Qt roles where enum value does not map directly to MSAA:
|
|
214 |
LayeredPane = 0x0000003F,
|
|
215 |
UserRole = 0x0000ffff
|
|
216 |
};
|
|
217 |
|
|
218 |
enum Text {
|
|
219 |
Name = 0,
|
|
220 |
Description,
|
|
221 |
Value,
|
|
222 |
Help,
|
|
223 |
Accelerator,
|
|
224 |
UserText = 0x0000ffff
|
|
225 |
};
|
|
226 |
|
|
227 |
enum RelationFlag {
|
|
228 |
Unrelated = 0x00000000,
|
|
229 |
Self = 0x00000001,
|
|
230 |
Ancestor = 0x00000002,
|
|
231 |
Child = 0x00000004,
|
|
232 |
Descendent = 0x00000008,
|
|
233 |
Sibling = 0x00000010,
|
|
234 |
HierarchyMask = 0x000000ff,
|
|
235 |
|
|
236 |
Up = 0x00000100,
|
|
237 |
Down = 0x00000200,
|
|
238 |
Left = 0x00000400,
|
|
239 |
Right = 0x00000800,
|
|
240 |
Covers = 0x00001000,
|
|
241 |
Covered = 0x00002000,
|
|
242 |
GeometryMask = 0x0000ff00,
|
|
243 |
|
|
244 |
FocusChild = 0x00010000,
|
|
245 |
Label = 0x00020000,
|
|
246 |
Labelled = 0x00040000,
|
|
247 |
Controller = 0x00080000,
|
|
248 |
Controlled = 0x00100000,
|
|
249 |
LogicalMask = 0x00ff0000
|
|
250 |
};
|
|
251 |
Q_DECLARE_FLAGS(Relation, RelationFlag)
|
|
252 |
|
|
253 |
enum Action {
|
|
254 |
DefaultAction = 0,
|
|
255 |
Press = -1,
|
|
256 |
FirstStandardAction = Press,
|
|
257 |
SetFocus = -2,
|
|
258 |
Increase = -3,
|
|
259 |
Decrease = -4,
|
|
260 |
Accept = -5,
|
|
261 |
Cancel = -6,
|
|
262 |
Select = -7,
|
|
263 |
ClearSelection = -8,
|
|
264 |
RemoveSelection = -9,
|
|
265 |
ExtendSelection = -10,
|
|
266 |
AddToSelection = -11,
|
|
267 |
LastStandardAction = AddToSelection
|
|
268 |
};
|
|
269 |
|
|
270 |
enum Method {
|
|
271 |
ListSupportedMethods = 0,
|
|
272 |
SetCursorPosition = 1,
|
|
273 |
GetCursorPosition = 2,
|
|
274 |
ForegroundColor = 3,
|
|
275 |
BackgroundColor = 4
|
|
276 |
};
|
|
277 |
|
|
278 |
typedef QAccessibleInterface*(*InterfaceFactory)(const QString &key, QObject*);
|
|
279 |
typedef void(*UpdateHandler)(QObject*, int who, Event reason);
|
|
280 |
typedef void(*RootObjectHandler)(QObject*);
|
|
281 |
|
|
282 |
static void installFactory(InterfaceFactory);
|
|
283 |
static void removeFactory(InterfaceFactory);
|
|
284 |
static UpdateHandler installUpdateHandler(UpdateHandler);
|
|
285 |
static RootObjectHandler installRootObjectHandler(RootObjectHandler);
|
|
286 |
|
|
287 |
static QAccessibleInterface *queryAccessibleInterface(QObject *);
|
|
288 |
static void updateAccessibility(QObject *, int who, Event reason);
|
|
289 |
static bool isActive();
|
|
290 |
static void setRootObject(QObject*);
|
|
291 |
|
|
292 |
static void initialize();
|
|
293 |
static void cleanup();
|
|
294 |
|
|
295 |
private:
|
|
296 |
static UpdateHandler updateHandler;
|
|
297 |
static RootObjectHandler rootObjectHandler;
|
|
298 |
};
|
|
299 |
|
|
300 |
Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::State)
|
|
301 |
Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::Relation)
|
|
302 |
QT_END_NAMESPACE
|
|
303 |
Q_DECLARE_METATYPE(QSet<QAccessible::Method>)
|
|
304 |
QT_BEGIN_NAMESPACE
|
|
305 |
|
|
306 |
namespace QAccessible2
|
|
307 |
{
|
|
308 |
enum InterfaceType
|
|
309 |
{
|
|
310 |
TextInterface,
|
|
311 |
EditableTextInterface,
|
|
312 |
ValueInterface,
|
|
313 |
TableInterface,
|
|
314 |
ActionInterface
|
|
315 |
};
|
|
316 |
}
|
|
317 |
|
|
318 |
class QAccessible2Interface;
|
|
319 |
class QAccessibleTextInterface;
|
|
320 |
class QAccessibleEditableTextInterface;
|
|
321 |
class QAccessibleValueInterface;
|
|
322 |
class QAccessibleTableInterface;
|
|
323 |
class QAccessibleActionInterface;
|
|
324 |
|
|
325 |
class Q_GUI_EXPORT QAccessibleInterface : public QAccessible
|
|
326 |
{
|
|
327 |
public:
|
|
328 |
virtual ~QAccessibleInterface() {}
|
|
329 |
// check for valid pointers
|
|
330 |
virtual bool isValid() const = 0;
|
|
331 |
virtual QObject *object() const = 0;
|
|
332 |
|
|
333 |
// hierarchy
|
|
334 |
virtual int childCount() const = 0;
|
|
335 |
virtual int indexOfChild(const QAccessibleInterface *) const = 0;
|
|
336 |
|
|
337 |
// relations
|
|
338 |
virtual Relation relationTo(int child, const QAccessibleInterface *other,
|
|
339 |
int otherChild) const = 0;
|
|
340 |
virtual int childAt(int x, int y) const = 0;
|
|
341 |
|
|
342 |
// navigation
|
|
343 |
virtual int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const = 0;
|
|
344 |
|
|
345 |
// properties and state
|
|
346 |
virtual QString text(Text t, int child) const = 0;
|
|
347 |
virtual void setText(Text t, int child, const QString &text) = 0;
|
|
348 |
virtual QRect rect(int child) const = 0;
|
|
349 |
virtual Role role(int child) const = 0;
|
|
350 |
virtual State state(int child) const = 0;
|
|
351 |
|
|
352 |
// action
|
|
353 |
virtual int userActionCount(int child) const = 0;
|
|
354 |
virtual QString actionText(int action, Text t, int child) const = 0;
|
|
355 |
virtual bool doAction(int action, int child, const QVariantList ¶ms = QVariantList()) = 0;
|
|
356 |
|
|
357 |
QVariant invokeMethod(Method method, int child = 0,
|
|
358 |
const QVariantList ¶ms = QVariantList());
|
|
359 |
|
|
360 |
inline QSet<Method> supportedMethods()
|
|
361 |
{ return qvariant_cast<QSet<Method> >(invokeMethod(ListSupportedMethods)); }
|
|
362 |
|
|
363 |
inline QColor foregroundColor()
|
|
364 |
{ return qvariant_cast<QColor>(invokeMethod(ForegroundColor)); }
|
|
365 |
|
|
366 |
inline QColor backgroundColor()
|
|
367 |
{ return qvariant_cast<QColor>(invokeMethod(BackgroundColor)); }
|
|
368 |
|
|
369 |
inline QAccessibleTextInterface *textInterface()
|
|
370 |
{ return reinterpret_cast<QAccessibleTextInterface *>(cast_helper(QAccessible2::TextInterface)); }
|
|
371 |
|
|
372 |
inline QAccessibleEditableTextInterface *editableTextInterface()
|
|
373 |
{ return reinterpret_cast<QAccessibleEditableTextInterface *>(cast_helper(QAccessible2::EditableTextInterface)); }
|
|
374 |
|
|
375 |
inline QAccessibleValueInterface *valueInterface()
|
|
376 |
{ return reinterpret_cast<QAccessibleValueInterface *>(cast_helper(QAccessible2::ValueInterface)); }
|
|
377 |
|
|
378 |
inline QAccessibleTableInterface *tableInterface()
|
|
379 |
{ return reinterpret_cast<QAccessibleTableInterface *>(cast_helper(QAccessible2::TableInterface)); }
|
|
380 |
|
|
381 |
inline QAccessibleActionInterface *actionInterface()
|
|
382 |
{ return reinterpret_cast<QAccessibleActionInterface *>(cast_helper(QAccessible2::ActionInterface)); }
|
|
383 |
|
|
384 |
private:
|
|
385 |
QAccessible2Interface *cast_helper(QAccessible2::InterfaceType);
|
|
386 |
};
|
|
387 |
|
|
388 |
class Q_GUI_EXPORT QAccessibleInterfaceEx: public QAccessibleInterface
|
|
389 |
{
|
|
390 |
public:
|
|
391 |
virtual QVariant invokeMethodEx(Method method, int child, const QVariantList ¶ms) = 0;
|
|
392 |
virtual QVariant virtual_hook(const QVariant &data);
|
|
393 |
virtual QAccessible2Interface *interface_cast(QAccessible2::InterfaceType)
|
|
394 |
{ return 0; }
|
|
395 |
};
|
|
396 |
|
|
397 |
|
|
398 |
class Q_GUI_EXPORT QAccessibleEvent : public QEvent
|
|
399 |
{
|
|
400 |
public:
|
|
401 |
inline QAccessibleEvent(Type type, int child);
|
|
402 |
inline int child() const { return c; }
|
|
403 |
inline QString value() const { return val; }
|
|
404 |
inline void setValue(const QString &aText) { val = aText; }
|
|
405 |
|
|
406 |
private:
|
|
407 |
int c;
|
|
408 |
QString val;
|
|
409 |
};
|
|
410 |
|
|
411 |
inline QAccessibleEvent::QAccessibleEvent(Type atype, int achild)
|
|
412 |
: QEvent(atype), c(achild) {}
|
|
413 |
|
|
414 |
#define QAccessibleInterface_iid "com.trolltech.Qt.QAccessibleInterface"
|
|
415 |
Q_DECLARE_INTERFACE(QAccessibleInterface, QAccessibleInterface_iid)
|
|
416 |
|
|
417 |
#endif // QT_NO_ACCESSIBILITY
|
|
418 |
|
|
419 |
QT_END_NAMESPACE
|
|
420 |
|
|
421 |
QT_END_HEADER
|
|
422 |
|
|
423 |
#endif // QACCESSIBLE_H
|