[129] | 1 | /****************************************************************************
|
---|
| 2 | ** $Id: qaccessible.cpp 131 2006-09-21 20:55:26Z dmik $
|
---|
| 3 | **
|
---|
| 4 | ** Implementation of QAccessible and QAccessibleObject classes
|
---|
| 5 | **
|
---|
| 6 | ** Copyright (C) 2000-2001 Trolltech AS. All rights reserved.
|
---|
| 7 | **
|
---|
| 8 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
| 9 | **
|
---|
| 10 | ** This file may be distributed under the terms of the Q Public License
|
---|
| 11 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
| 12 | ** LICENSE.QPL included in the packaging of this file.
|
---|
| 13 | **
|
---|
| 14 | ** This file may be distributed and/or modified under the terms of the
|
---|
| 15 | ** GNU General Public License version 2 as published by the Free Software
|
---|
| 16 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 17 | ** packaging of this file.
|
---|
| 18 | **
|
---|
| 19 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
| 20 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
| 21 | ** Agreement provided with the Software.
|
---|
| 22 | **
|
---|
| 23 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
| 24 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
| 25 | **
|
---|
| 26 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
| 27 | ** information about Qt Commercial License Agreements.
|
---|
| 28 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
| 29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
| 30 | **
|
---|
| 31 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
| 32 | ** not clear to you.
|
---|
| 33 | **
|
---|
| 34 | **********************************************************************/
|
---|
| 35 |
|
---|
| 36 | #include "qaccessible.h"
|
---|
| 37 |
|
---|
| 38 | #if defined(QT_ACCESSIBILITY_SUPPORT)
|
---|
| 39 |
|
---|
| 40 | #include "qptrdict.h"
|
---|
| 41 | #include "qmetaobject.h"
|
---|
| 42 | #include <private/qpluginmanager_p.h>
|
---|
| 43 | #include "qapplication.h"
|
---|
| 44 | #include <stdlib.h>
|
---|
| 45 |
|
---|
| 46 | /*!
|
---|
| 47 | \class QAccessible qaccessible.h
|
---|
| 48 | \brief The QAccessible class provides enums and static functions
|
---|
| 49 | relating to accessibility.
|
---|
| 50 |
|
---|
| 51 | \ingroup misc
|
---|
| 52 |
|
---|
| 53 | Accessibility clients use implementations of the
|
---|
| 54 | QAccessibleInterface to read the information an accessible object
|
---|
| 55 | exposes, or to call functions to manipulate the accessible object.
|
---|
| 56 |
|
---|
| 57 | \omit
|
---|
| 58 | Qt provides implementations of the QAccessibleInterface for most
|
---|
| 59 | widget classes in a plugin. This plugin is located in the \e
|
---|
| 60 | accessibility subdirectory of the plugins installation directory.
|
---|
| 61 | The default installation directory for plugins is \c INSTALL/plugins,
|
---|
| 62 | where \c INSTALL is the directory where Qt was installed. Calling
|
---|
| 63 | queryAccessibleInterface( QObject *object, QAccessibleInterface
|
---|
| 64 | **iface ) will ask all plugins located in this directory for an
|
---|
| 65 | implementation that exposes the information for objects of the
|
---|
| 66 | class of \e object.
|
---|
| 67 |
|
---|
| 68 | To make a Qt application accessible you have to distribute the
|
---|
| 69 | accessibility plugin provded with Qt together with your
|
---|
| 70 | application. Simply add the plugins created in
|
---|
| 71 | INSTALL/plugins/accessibility to your distribution process. Use \l
|
---|
| 72 | QApplication::addLibraryPath() to specify a plugin directory for
|
---|
| 73 | your application, and copy the files into an \e accessibility
|
---|
| 74 | subdirectory of one of those plugin directories. Qt's
|
---|
| 75 | accessibility framework will load the plugins upon request and use
|
---|
| 76 | the implementations provided to expose an object's accessibility
|
---|
| 77 | information.
|
---|
| 78 | \endomit
|
---|
| 79 |
|
---|
| 80 | See the \link plugins-howto.html plugin documentation \endlink for
|
---|
| 81 | more details about how to redistribute Qt plugins.
|
---|
| 82 | */
|
---|
| 83 |
|
---|
| 84 | /*!
|
---|
| 85 | \enum QAccessible::State
|
---|
| 86 |
|
---|
| 87 | This enum type defines bitflags that can be combined to indicate
|
---|
| 88 | the state of the accessible object. The values are:
|
---|
| 89 |
|
---|
| 90 | \value Normal
|
---|
| 91 | \value Unavailable
|
---|
| 92 | \value Selected
|
---|
| 93 | \value Focused
|
---|
| 94 | \value Pressed
|
---|
| 95 | \value Checked
|
---|
| 96 | \value Mixed
|
---|
| 97 | \value ReadOnly
|
---|
| 98 | \value HotTracked
|
---|
| 99 | \value Default
|
---|
| 100 | \value Expanded
|
---|
| 101 | \value Collapsed
|
---|
| 102 | \value Busy
|
---|
| 103 | \value Floating
|
---|
| 104 | \value Marqueed
|
---|
| 105 | \value Animated
|
---|
| 106 | \value Invisible
|
---|
| 107 | \value Offscreen
|
---|
| 108 | \value Sizeable
|
---|
| 109 | \value Moveable
|
---|
| 110 | \value SelfVoicing
|
---|
| 111 | \value Focusable
|
---|
| 112 | \value Selectable
|
---|
| 113 | \value Linked
|
---|
| 114 | \value Traversed
|
---|
| 115 | \value MultiSelectable
|
---|
| 116 | \value ExtSelectable
|
---|
| 117 | \value AlertLow
|
---|
| 118 | \value AlertMedium
|
---|
| 119 | \value AlertHigh
|
---|
| 120 | \value Protected
|
---|
| 121 | \value Valid
|
---|
| 122 | */
|
---|
| 123 |
|
---|
| 124 | /*!
|
---|
| 125 | \enum QAccessible::Event
|
---|
| 126 |
|
---|
| 127 | This enum type defines event types when the state of the
|
---|
| 128 | accessible object has changed. The event types are:
|
---|
| 129 |
|
---|
| 130 | \value SoundPlayed
|
---|
| 131 | \value Alert
|
---|
| 132 | \value ForegroundChanged
|
---|
| 133 | \value MenuStart
|
---|
| 134 | \value MenuEnd
|
---|
| 135 | \value PopupMenuStart
|
---|
| 136 | \value PopupMenuEnd
|
---|
| 137 | \value ContextHelpStart
|
---|
| 138 | \value ContextHelpEnd
|
---|
| 139 | \value DragDropStart
|
---|
| 140 | \value DragDropEnd
|
---|
| 141 | \value DialogStart
|
---|
| 142 | \value DialogEnd
|
---|
| 143 | \value ScrollingStart
|
---|
| 144 | \value ScrollingEnd
|
---|
| 145 | \value ObjectCreated
|
---|
| 146 | \value ObjectDestroyed
|
---|
| 147 | \value ObjectShow
|
---|
| 148 | \value ObjectHide
|
---|
| 149 | \value ObjectReorder
|
---|
| 150 | \value Focus
|
---|
| 151 | \value Selection
|
---|
| 152 | \value SelectionAdd
|
---|
| 153 | \value SelectionRemove
|
---|
| 154 | \value SelectionWithin
|
---|
| 155 | \value StateChanged
|
---|
| 156 | \value LocationChanged
|
---|
| 157 | \value NameChanged
|
---|
| 158 | \value DescriptionChanged
|
---|
| 159 | \value ValueChanged
|
---|
| 160 | \value ParentChanged
|
---|
| 161 | \value HelpChanged
|
---|
| 162 | \value DefaultActionChanged
|
---|
| 163 | \value AcceleratorChanged
|
---|
| 164 | \value MenuCommand
|
---|
| 165 | */
|
---|
| 166 |
|
---|
| 167 | /*!
|
---|
| 168 | \enum QAccessible::Role
|
---|
| 169 |
|
---|
| 170 | This enum defines a number of roles an accessible object can have.
|
---|
| 171 | The roles are:
|
---|
| 172 |
|
---|
| 173 | \value NoRole
|
---|
| 174 | \value TitleBar
|
---|
| 175 | \value MenuBar
|
---|
| 176 | \value ScrollBar
|
---|
| 177 | \value Grip
|
---|
| 178 | \value Sound
|
---|
| 179 | \value Cursor
|
---|
| 180 | \value Caret
|
---|
| 181 | \value AlertMessage
|
---|
| 182 | \value Window
|
---|
| 183 | \value Client
|
---|
| 184 | \value PopupMenu
|
---|
| 185 | \value MenuItem
|
---|
| 186 | \value ToolTip
|
---|
| 187 | \value Application
|
---|
| 188 | \value Document
|
---|
| 189 | \value Pane
|
---|
| 190 | \value Chart
|
---|
| 191 | \value Dialog
|
---|
| 192 | \value Border
|
---|
| 193 | \value Grouping
|
---|
| 194 | \value Separator
|
---|
| 195 | \value ToolBar
|
---|
| 196 | \value StatusBar
|
---|
| 197 | \value Table
|
---|
| 198 | \value ColumnHeader
|
---|
| 199 | \value RowHeader
|
---|
| 200 | \value Column
|
---|
| 201 | \value Row
|
---|
| 202 | \value Cell
|
---|
| 203 | \value Link
|
---|
| 204 | \value HelpBalloon
|
---|
| 205 | \value Character
|
---|
| 206 | \value List
|
---|
| 207 | \value ListItem
|
---|
| 208 | \value Outline
|
---|
| 209 | \value OutlineItem
|
---|
| 210 | \value PageTab
|
---|
| 211 | \value PropertyPage
|
---|
| 212 | \value Indicator
|
---|
| 213 | \value Graphic
|
---|
| 214 | \value StaticText
|
---|
| 215 | \value EditableText
|
---|
| 216 | \value PushButton
|
---|
| 217 | \value CheckBox
|
---|
| 218 | \value RadioButton
|
---|
| 219 | \value ComboBox
|
---|
| 220 | \value DropLest
|
---|
| 221 | \value ProgressBar
|
---|
| 222 | \value Dial
|
---|
| 223 | \value HotkeyField
|
---|
| 224 | \value Slider
|
---|
| 225 | \value SpinBox
|
---|
| 226 | \value Diagram
|
---|
| 227 | \value Animation
|
---|
| 228 | \value Equation
|
---|
| 229 | \value ButtonDropDown
|
---|
| 230 | \value ButtonMenu
|
---|
| 231 | \value ButtonDropGrid
|
---|
| 232 | \value Whitespace
|
---|
| 233 | \value PageTabList
|
---|
| 234 | \value Clock
|
---|
| 235 | */
|
---|
| 236 |
|
---|
| 237 | /*!
|
---|
| 238 | \enum QAccessible::NavDirection
|
---|
| 239 |
|
---|
| 240 | This enum specifies which item to move to when navigating.
|
---|
| 241 |
|
---|
| 242 | \value NavUp sibling above
|
---|
| 243 | \value NavDown sibling below
|
---|
| 244 | \value NavLeft left sibling
|
---|
| 245 | \value NavRight right sibling
|
---|
| 246 | \value NavNext next sibling
|
---|
| 247 | \value NavPrevious previous sibling
|
---|
| 248 | \value NavFirstChild first child
|
---|
| 249 | \value NavLastChild last child
|
---|
| 250 | \value NavFocusChild child with focus
|
---|
| 251 | */
|
---|
| 252 |
|
---|
| 253 | /*!
|
---|
| 254 | \enum QAccessible::Text
|
---|
| 255 |
|
---|
| 256 | This enum specifies string information that an accessible object
|
---|
| 257 | returns.
|
---|
| 258 |
|
---|
| 259 | \value Name The name of the object
|
---|
| 260 | \value Description A short text describing the object
|
---|
| 261 | \value Value The value of the object
|
---|
| 262 | \value Help A longer text giving information about how
|
---|
| 263 | to use the object
|
---|
| 264 | \value DefaultAction The default method to interact with the object
|
---|
| 265 | \value Accelerator The keyboard shortcut that executes the
|
---|
| 266 | default action
|
---|
| 267 | */
|
---|
| 268 |
|
---|
| 269 | /*!
|
---|
| 270 | \fn static void QAccessible::updateAccessibility( QObject *object, int control, Event reason )
|
---|
| 271 |
|
---|
| 272 | Notifies accessibility clients about a change in \a object's
|
---|
| 273 | accessibility information.
|
---|
| 274 |
|
---|
| 275 | \a reason specifies the cause of the change, for example,
|
---|
| 276 | ValueChange when the position of a slider has been changed. \a
|
---|
| 277 | control is the ID of the child element that has changed. When \a
|
---|
| 278 | control is 0, the object itself has changed.
|
---|
| 279 |
|
---|
| 280 | Call this function whenever the state of your accessible object or
|
---|
| 281 | one of it's sub-elements has been changed either programmatically
|
---|
| 282 | (e.g. by calling QLabel::setText()) or by user interaction.
|
---|
| 283 |
|
---|
| 284 | If there are no accessibility tools listening to this event, the
|
---|
| 285 | performance penalty for calling this function is minor, but if determining
|
---|
| 286 | the parameters of the call is expensive you can use isActive() to
|
---|
| 287 | avoid unnecessary performance penalties if no client is listening.
|
---|
| 288 | */
|
---|
| 289 |
|
---|
| 290 | static QPluginManager<QAccessibleFactoryInterface> *qAccessibleManager = 0;
|
---|
| 291 | static QPtrDict<QAccessibleInterface> *qAccessibleInterface = 0;
|
---|
| 292 | static bool cleanupAdded = FALSE;
|
---|
| 293 |
|
---|
| 294 | static void qAccessibleCleanup()
|
---|
| 295 | {
|
---|
| 296 | if ( qAccessibleInterface && qAccessibleInterface->count() && qAccessibleManager )
|
---|
| 297 | qAccessibleManager->setAutoUnload( FALSE );
|
---|
| 298 |
|
---|
| 299 | delete qAccessibleInterface;
|
---|
| 300 | qAccessibleInterface = 0;
|
---|
| 301 | delete qAccessibleManager;
|
---|
| 302 | qAccessibleManager = 0;
|
---|
| 303 | }
|
---|
| 304 |
|
---|
| 305 | #ifdef Q_WS_MAC
|
---|
| 306 | QObject *QAccessible::queryAccessibleObject(QAccessibleInterface *o)
|
---|
| 307 | {
|
---|
| 308 | if(qAccessibleInterface) {
|
---|
| 309 | for(QPtrDictIterator<QAccessibleInterface> it(*qAccessibleInterface); it.current(); ++it) {
|
---|
| 310 | if(it.current() == o)
|
---|
| 311 | return (QObject*)it.currentKey();
|
---|
| 312 | }
|
---|
| 313 | }
|
---|
| 314 | return NULL;
|
---|
| 315 | }
|
---|
| 316 | #endif
|
---|
| 317 |
|
---|
| 318 | /*!
|
---|
| 319 | Sets \a iface to point to the implementation of the
|
---|
| 320 | QAccessibleInterface for \a object, and returns \c QS_OK if
|
---|
| 321 | successfull, or sets \a iface to 0 and returns \c QE_NOCOMPONENT if
|
---|
| 322 | no accessibility implementation for \a object exists.
|
---|
| 323 |
|
---|
| 324 | The function uses the \link QObject::className() classname
|
---|
| 325 | \endlink of \a object to find a suitable implementation. If no
|
---|
| 326 | implementation for the object's class is available the function
|
---|
| 327 | tries to find an implementation for the object's parent class.
|
---|
| 328 |
|
---|
| 329 | This function is called to answer an accessibility client's
|
---|
| 330 | request for object information. You should never need to call this
|
---|
| 331 | function yourself.
|
---|
| 332 | */
|
---|
| 333 | QRESULT QAccessible::queryAccessibleInterface( QObject *object, QAccessibleInterface **iface )
|
---|
| 334 | {
|
---|
| 335 | *iface = 0;
|
---|
| 336 | if ( !object )
|
---|
| 337 | return QE_INVALIDARG;
|
---|
| 338 |
|
---|
| 339 | if ( qAccessibleInterface ) {
|
---|
| 340 | *iface = qAccessibleInterface->find( object );
|
---|
| 341 | if ( *iface ) {
|
---|
| 342 | (*iface)->addRef();
|
---|
| 343 | return QS_OK;
|
---|
| 344 | }
|
---|
| 345 | }
|
---|
| 346 |
|
---|
| 347 | if ( !qAccessibleManager ) {
|
---|
| 348 | qAccessibleManager = new QPluginManager<QAccessibleFactoryInterface>( IID_QAccessibleFactory, QApplication::libraryPaths(), "/accessible" );
|
---|
| 349 | if ( !cleanupAdded ) {
|
---|
| 350 | qAddPostRoutine( qAccessibleCleanup );
|
---|
| 351 | cleanupAdded = TRUE;
|
---|
| 352 | }
|
---|
| 353 | }
|
---|
| 354 |
|
---|
| 355 | QInterfacePtr<QAccessibleFactoryInterface> factory = 0;
|
---|
| 356 | QMetaObject *mo = object->metaObject();
|
---|
| 357 | while ( mo ) {
|
---|
| 358 | qAccessibleManager->queryInterface( mo->className(), &factory );
|
---|
| 359 | if ( factory )
|
---|
| 360 | break;
|
---|
| 361 | mo = mo->superClass();
|
---|
| 362 | }
|
---|
| 363 | if ( factory )
|
---|
| 364 | return factory->createAccessibleInterface( mo->className(), object, iface );
|
---|
| 365 |
|
---|
| 366 | return QE_NOCOMPONENT;
|
---|
| 367 | }
|
---|
| 368 |
|
---|
| 369 | /*!
|
---|
| 370 | Returns TRUE if an accessibility implementation has been requested,
|
---|
| 371 | during the runtime of the application, otherwise returns FALSE.
|
---|
| 372 |
|
---|
| 373 | Use this function to prevent potentially expensive notifications via
|
---|
| 374 | updateAccessibility().
|
---|
| 375 |
|
---|
| 376 | \omit
|
---|
| 377 | QListView uses this function to prevent index-lookups for item based
|
---|
| 378 | notifications.
|
---|
| 379 | \endomit
|
---|
| 380 | */
|
---|
| 381 | bool QAccessible::isActive()
|
---|
| 382 | {
|
---|
| 383 | return qAccessibleManager != 0;
|
---|
| 384 | }
|
---|
| 385 |
|
---|
| 386 | /*!
|
---|
| 387 | \class QAccessibleInterface qaccessible.h
|
---|
| 388 | \brief The QAccessibleInterface class defines an interface that exposes information about accessible objects.
|
---|
| 389 |
|
---|
| 390 | \ingroup misc
|
---|
| 391 | */
|
---|
| 392 |
|
---|
| 393 | /*!
|
---|
| 394 | \fn bool QAccessibleInterface::isValid() const
|
---|
| 395 |
|
---|
| 396 | Returns TRUE if all the data necessary to use this interface
|
---|
| 397 | implementation is valid (e.g. all pointers are non-null),
|
---|
| 398 | otherwise returns FALSE.
|
---|
| 399 | */
|
---|
| 400 |
|
---|
| 401 | /*!
|
---|
| 402 | \fn int QAccessibleInterface::childCount() const
|
---|
| 403 |
|
---|
| 404 | Returns the number of children that belong to this object. A child
|
---|
| 405 | can provide accessibility information on it's own (e.g. a child
|
---|
| 406 | widget), or be a sub-element of this accessible object.
|
---|
| 407 |
|
---|
| 408 | All objects provide this information.
|
---|
| 409 |
|
---|
| 410 | \sa queryChild()
|
---|
| 411 | */
|
---|
| 412 |
|
---|
| 413 | /*!
|
---|
| 414 | \fn QRESULT QAccessibleInterface::queryChild( int control, QAccessibleInterface **iface ) const
|
---|
| 415 |
|
---|
| 416 | Sets \a iface to point to the implementation of the
|
---|
| 417 | QAccessibleInterface for the child specified with \a control. If
|
---|
| 418 | the child doesn't provide accessibility information on it's own,
|
---|
| 419 | the value of \a iface is set to 0. For those elements, this
|
---|
| 420 | object is responsible for exposing the child's properties.
|
---|
| 421 |
|
---|
| 422 | All objects provide this information.
|
---|
| 423 |
|
---|
| 424 | \sa childCount(), queryParent()
|
---|
| 425 | */
|
---|
| 426 |
|
---|
| 427 | /*!
|
---|
| 428 | \fn QRESULT QAccessibleInterface::queryParent( QAccessibleInterface **iface ) const
|
---|
| 429 |
|
---|
| 430 | Sets \a iface to point to the implementation of the
|
---|
| 431 | QAccessibleInterface for the parent object, or to 0 if there is
|
---|
| 432 | no such implementation or object.
|
---|
| 433 |
|
---|
| 434 | All objects provide this information.
|
---|
| 435 |
|
---|
| 436 | \sa queryChild()
|
---|
| 437 | */
|
---|
| 438 |
|
---|
| 439 | /*!
|
---|
| 440 | \fn int QAccessibleInterface::controlAt( int x, int y ) const
|
---|
| 441 |
|
---|
| 442 | Returns the ID of the child that contains the screen coordinates
|
---|
| 443 | (\a x, \a y). This function returns 0 if the point is positioned
|
---|
| 444 | on the object itself. If the tested point is outside the
|
---|
| 445 | boundaries of the object this function returns -1.
|
---|
| 446 |
|
---|
| 447 | All visual objects provide this information.
|
---|
| 448 | */
|
---|
| 449 |
|
---|
| 450 | /*!
|
---|
| 451 | \fn QRect QAccessibleInterface::rect( int control ) const
|
---|
| 452 |
|
---|
| 453 | Returns the location of the child specified with \a control in
|
---|
| 454 | screen coordinates. This function returns the location of the
|
---|
| 455 | object itself if \a control is 0.
|
---|
| 456 |
|
---|
| 457 | All visual objects provide this information.
|
---|
| 458 | */
|
---|
| 459 |
|
---|
| 460 | /*!
|
---|
| 461 | \fn int QAccessibleInterface::navigate( NavDirection direction, int startControl ) const
|
---|
| 462 |
|
---|
| 463 | This function traverses to another object, or to a sub-element of
|
---|
| 464 | the current object. \a direction specifies in which direction to
|
---|
| 465 | navigate, and \a startControl specifies the start point of the
|
---|
| 466 | navigation, which is either 0 if the navigation starts at the
|
---|
| 467 | object itself, or an ID of one of the object's sub-elements.
|
---|
| 468 |
|
---|
| 469 | The function returns the ID of the sub-element located in the \a
|
---|
| 470 | direction specified. If there is nothing in the navigated \a
|
---|
| 471 | direction, this function returns -1.
|
---|
| 472 |
|
---|
| 473 | All objects support navigation.
|
---|
| 474 | */
|
---|
| 475 |
|
---|
| 476 | /*!
|
---|
| 477 | \fn QString QAccessibleInterface::text( Text t, int control ) const
|
---|
| 478 |
|
---|
| 479 | Returns a string property \a t of the child object specified by \a
|
---|
| 480 | control, or the string property of the object itself if \a control
|
---|
| 481 | is 0.
|
---|
| 482 |
|
---|
| 483 | The \e Name is a string used by clients to identify, find or
|
---|
| 484 | announce an accessible object for the user. All objects must have
|
---|
| 485 | a name that is unique within their container.
|
---|
| 486 |
|
---|
| 487 | An accessible object's \e Description provides textual information
|
---|
| 488 | about an object's visual appearance. The description is primarily
|
---|
| 489 | used to provide greater context for low-vision or blind users, but
|
---|
| 490 | is also used for context searching or other applications. Not all
|
---|
| 491 | objects have a description. An "OK" button would not need a
|
---|
| 492 | description, but a toolbutton that shows a picture of a smiley
|
---|
| 493 | would.
|
---|
| 494 |
|
---|
| 495 | The \e Value of an accessible object represents visual information
|
---|
| 496 | contained by the object, e.g. the text in a line edit. Usually,
|
---|
| 497 | the value can be modified by the user. Not all objects have a
|
---|
| 498 | value, e.g. static text labels don't, and some objects have a
|
---|
| 499 | state that already is the value, e.g. toggle buttons.
|
---|
| 500 |
|
---|
| 501 | The \e Help text provides information about the function and
|
---|
| 502 | usage of an accessible object. Not all objects provide this
|
---|
| 503 | information.
|
---|
| 504 |
|
---|
| 505 | An accessible object's \e DefaultAction describes the object's
|
---|
| 506 | primary method of manipulation, and should be a verb or a short
|
---|
| 507 | phrase, e.g. "Press" for a button.
|
---|
| 508 |
|
---|
| 509 | The accelerator is a keyboard shortcut that activates the default
|
---|
| 510 | action of the object. A keyboard shortcut is the underlined
|
---|
| 511 | character in the text of a menu, menu item or control, and is
|
---|
| 512 | either the character itself, or a combination of this character
|
---|
| 513 | and a modifier key like ALT, CTRL or SHIFT. Command controls like
|
---|
| 514 | tool buttons also have shortcut keys and usually display them in
|
---|
| 515 | their tooltip.
|
---|
| 516 |
|
---|
| 517 | \sa role(), state(), selection()
|
---|
| 518 | */
|
---|
| 519 |
|
---|
| 520 | /*!
|
---|
| 521 | \fn void QAccessibleInterface::setText( Text t, int control, const QString &text )
|
---|
| 522 |
|
---|
| 523 | Sets the text property \a t of the child object \a control to \a
|
---|
| 524 | text. If \a control is 0, the text property of the object itself
|
---|
| 525 | is set.
|
---|
| 526 | */
|
---|
| 527 |
|
---|
| 528 | /*!
|
---|
| 529 | \fn QAccessible::Role QAccessibleInterface::role( int control ) const
|
---|
| 530 |
|
---|
| 531 | Returns the role of the object if \a control is 0, or the role of
|
---|
| 532 | the object's sub-element with ID \a control. The role of an object
|
---|
| 533 | is usually static. All accessible objects have a role.
|
---|
| 534 |
|
---|
| 535 | \sa text(), state(), selection()
|
---|
| 536 | */
|
---|
| 537 |
|
---|
| 538 | /*!
|
---|
| 539 | \fn QAccessible::State QAccessibleInterface::state( int control ) const
|
---|
| 540 |
|
---|
| 541 | Returns the current state of the object if \a control is 0, or the
|
---|
| 542 | state of the object's sub-element element with ID \a control. All
|
---|
| 543 | objects have a state.
|
---|
| 544 |
|
---|
| 545 | \sa text(), role(), selection()
|
---|
| 546 | */
|
---|
| 547 |
|
---|
| 548 | /*!
|
---|
| 549 | \fn QMemArray<int> QAccessibleInterface::selection() const
|
---|
| 550 |
|
---|
| 551 | Returns the list of all the element IDs that are selected.
|
---|
| 552 |
|
---|
| 553 | \sa text(), role(), state()
|
---|
| 554 | */
|
---|
| 555 |
|
---|
| 556 | /*!
|
---|
| 557 | \fn bool QAccessibleInterface::doDefaultAction( int control )
|
---|
| 558 |
|
---|
| 559 | Calling this function performs the default action of the child
|
---|
| 560 | object specified by \a control, or the default action of the
|
---|
| 561 | object itself if \a control is 0.
|
---|
| 562 | */
|
---|
| 563 |
|
---|
| 564 | /*!
|
---|
| 565 | \fn bool QAccessibleInterface::setFocus( int control )
|
---|
| 566 |
|
---|
| 567 | Gives the focus to the child object specified by \a control, or to
|
---|
| 568 | the object itself if \a control is 0.
|
---|
| 569 |
|
---|
| 570 | Returns TRUE if the focus could be set; otherwise returns FALSE.
|
---|
| 571 | */
|
---|
| 572 |
|
---|
| 573 | /*!
|
---|
| 574 | \fn bool QAccessibleInterface::setSelected( int control, bool on, bool extend )
|
---|
| 575 |
|
---|
| 576 | Sets the selection of the child object with ID \a control to \a
|
---|
| 577 | on. If \a extend is TRUE, all child elements between the focused
|
---|
| 578 | item and the specified child object have their selection set to \a
|
---|
| 579 | on.
|
---|
| 580 |
|
---|
| 581 | Returns TRUE if the selection could be set; otherwise returns
|
---|
| 582 | FALSE.
|
---|
| 583 |
|
---|
| 584 | \sa setFocus(), clearSelection()
|
---|
| 585 | */
|
---|
| 586 |
|
---|
| 587 | /*!
|
---|
| 588 | \fn void QAccessibleInterface::clearSelection()
|
---|
| 589 |
|
---|
| 590 | Removes any selection from the object.
|
---|
| 591 |
|
---|
| 592 | \sa setSelected()
|
---|
| 593 | */
|
---|
| 594 |
|
---|
| 595 |
|
---|
| 596 |
|
---|
| 597 | /*!
|
---|
| 598 | \class QAccessibleObject qaccessible.h
|
---|
| 599 | \brief The QAccessibleObject class implements parts of the
|
---|
| 600 | QAccessibleInterface for QObjects.
|
---|
| 601 |
|
---|
| 602 | \ingroup misc
|
---|
| 603 |
|
---|
| 604 | This class is mainly provided for convenience. All subclasses of
|
---|
| 605 | the QAccessibleInterface should use this class as the base class.
|
---|
| 606 | */
|
---|
| 607 |
|
---|
| 608 | /*!
|
---|
| 609 | Creates a QAccessibleObject for \a object.
|
---|
| 610 | */
|
---|
| 611 | QAccessibleObject::QAccessibleObject( QObject *object )
|
---|
| 612 | : object_(object)
|
---|
| 613 | {
|
---|
| 614 | if ( !qAccessibleInterface ) {
|
---|
| 615 | qAccessibleInterface = new QPtrDict<QAccessibleInterface>( 73 );
|
---|
| 616 | if ( !cleanupAdded ) {
|
---|
| 617 | qAddPostRoutine( qAccessibleCleanup );
|
---|
| 618 | cleanupAdded = TRUE;
|
---|
| 619 | }
|
---|
| 620 | }
|
---|
| 621 |
|
---|
| 622 | qAccessibleInterface->insert( object, this );
|
---|
| 623 | }
|
---|
| 624 |
|
---|
| 625 | /*!
|
---|
| 626 | Destroys the QAccessibleObject.
|
---|
| 627 |
|
---|
| 628 | This only happens when a call to release() decrements the internal
|
---|
| 629 | reference counter to zero.
|
---|
| 630 | */
|
---|
| 631 | QAccessibleObject::~QAccessibleObject()
|
---|
| 632 | {
|
---|
| 633 | if ( qAccessibleInterface ) {
|
---|
| 634 | qAccessibleInterface->remove( object_ );
|
---|
| 635 | if ( !qAccessibleInterface->count() ) {
|
---|
| 636 | delete qAccessibleInterface;
|
---|
| 637 | qAccessibleInterface = 0;
|
---|
| 638 | }
|
---|
| 639 | }
|
---|
| 640 | }
|
---|
| 641 |
|
---|
| 642 | /*!
|
---|
| 643 | \reimp
|
---|
| 644 | */
|
---|
| 645 | QRESULT QAccessibleObject::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
|
---|
| 646 | {
|
---|
| 647 | *iface = 0;
|
---|
| 648 | if ( uuid == IID_QAccessible )
|
---|
| 649 | *iface = (QAccessibleInterface*)this;
|
---|
| 650 | else if ( uuid == IID_QUnknown )
|
---|
| 651 | *iface = (QUnknownInterface*)this;
|
---|
| 652 | else
|
---|
| 653 | return QE_NOINTERFACE;
|
---|
| 654 |
|
---|
| 655 | (*iface)->addRef();
|
---|
| 656 | return QS_OK;
|
---|
| 657 | }
|
---|
| 658 |
|
---|
| 659 | /*!
|
---|
| 660 | Returns the QObject for which this QAccessibleInterface
|
---|
| 661 | implementation provides information. Use isValid() to make sure
|
---|
| 662 | the object pointer is safe to use.
|
---|
| 663 | */
|
---|
| 664 | QObject *QAccessibleObject::object() const
|
---|
| 665 | {
|
---|
| 666 | #if defined(QT_CHECK_RANGE)
|
---|
| 667 | if ( !isValid() )
|
---|
| 668 | qWarning( "QAccessibleInterface is invalid. Crash pending..." );
|
---|
| 669 | #endif
|
---|
| 670 | return object_;
|
---|
| 671 | }
|
---|
| 672 |
|
---|
| 673 | /*!
|
---|
| 674 | \reimp
|
---|
| 675 | */
|
---|
| 676 | bool QAccessibleObject::isValid() const
|
---|
| 677 | {
|
---|
| 678 | return !object_.isNull();
|
---|
| 679 | }
|
---|
| 680 |
|
---|
| 681 | #endif
|
---|