1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/ole/access.cpp
3 // Purpose: implementation of wxIAccessible and wxAccessible
4 // Author: Julian Smart
8 // Copyright: (c) 2003 Julian Smart
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
23 #if defined(__BORLANDC__)
27 #if wxUSE_OLE && wxUSE_ACCESSIBILITY
29 #include "wx/access.h"
32 #include "wx/msw/wrapwin.h"
33 #include "wx/window.h"
37 // for some compilers, the entire ole2.h must be included, not only oleauto.h
38 #if wxUSE_NORLANDER_HEADERS || defined(__WATCOMC__)
45 #include "wx/msw/ole/oleutils.h"
48 #define CHILDID_SELF 0
52 #define OBJID_CLIENT 0xFFFFFFFC
55 // Convert to Windows role
56 int wxConvertToWindowsRole(wxAccRole wxrole
);
58 // Convert to Windows state
59 long wxConvertToWindowsState(long wxstate
);
61 // Convert to Windows selection flag
62 int wxConvertToWindowsSelFlag(wxAccSelectionFlags sel
);
64 // Convert from Windows selection flag
65 wxAccSelectionFlags
wxConvertFromWindowsSelFlag(int sel
);
68 // ----------------------------------------------------------------------------
69 // wxIEnumVARIANT interface implementation
70 // ----------------------------------------------------------------------------
72 class wxIEnumVARIANT
: public IEnumVARIANT
75 wxIEnumVARIANT(const wxVariant
& variant
);
76 virtual ~wxIEnumVARIANT() { }
78 DECLARE_IUNKNOWN_METHODS
;
81 STDMETHODIMP
Next(ULONG celt
, VARIANT
*rgelt
, ULONG
*pceltFetched
);
82 STDMETHODIMP
Skip(ULONG celt
);
84 STDMETHODIMP
Clone(IEnumVARIANT
**ppenum
);
87 wxVariant m_variant
; // List of further variants
88 int m_nCurrent
; // Current enum position
90 wxDECLARE_NO_COPY_CLASS(wxIEnumVARIANT
);
93 // ----------------------------------------------------------------------------
95 // ----------------------------------------------------------------------------
97 BEGIN_IID_TABLE(wxIEnumVARIANT
)
102 IMPLEMENT_IUNKNOWN_METHODS(wxIEnumVARIANT
)
104 // wxVariant contains a list of further variants.
105 wxIEnumVARIANT::wxIEnumVARIANT(const wxVariant
& variant
)
110 STDMETHODIMP
wxIEnumVARIANT::Next(ULONG celt
,
114 wxLogTrace(wxTRACE_OleCalls
, wxT("wxIEnumVARIANT::Next"));
117 // we only return 1 element at a time - mainly because I'm too lazy to
118 // implement something which you're never asked for anyhow
122 if (m_variant
.GetType() != wxT("list"))
125 if ( m_nCurrent
< (int) m_variant
.GetList().GetCount() ) {
126 if (!wxConvertVariantToOle(m_variant
[m_nCurrent
++], rgelt
[0]))
131 // TODO: should we AddRef if this is an object?
142 STDMETHODIMP
wxIEnumVARIANT::Skip(ULONG celt
)
144 wxLogTrace(wxTRACE_OleCalls
, wxT("wxIEnumVARIANT::Skip"));
146 if (m_variant
.GetType() != wxT("list"))
150 if ( m_nCurrent
< (int) m_variant
.GetList().GetCount() )
153 // no, can't skip this many elements
159 STDMETHODIMP
wxIEnumVARIANT::Reset()
161 wxLogTrace(wxTRACE_OleCalls
, wxT("wxIEnumVARIANT::Reset"));
168 STDMETHODIMP
wxIEnumVARIANT::Clone(IEnumVARIANT
**ppenum
)
170 wxLogTrace(wxTRACE_OleCalls
, wxT("wxIEnumVARIANT::Clone"));
172 wxIEnumVARIANT
*pNew
= new wxIEnumVARIANT(m_variant
);
179 #endif // wxUSE_VARIANT
181 // ----------------------------------------------------------------------------
182 // wxIAccessible implementation of IAccessible interface
183 // ----------------------------------------------------------------------------
185 class wxIAccessible
: public IAccessible
188 wxIAccessible(wxAccessible
*pAccessible
);
190 // Called to indicate object should prepare to be deleted.
193 DECLARE_IUNKNOWN_METHODS
;
197 // Navigation and Hierarchy
199 // Retrieves the child element or child object at a given point on the screen.
200 // All visual objects support this method; sound objects do not support it.
202 STDMETHODIMP
accHitTest(long xLeft
, long yLeft
, VARIANT
* pVarID
);
204 // Retrieves the specified object's current screen location. All visual objects must
205 // support this method; sound objects do not support it.
207 STDMETHODIMP
accLocation ( long* pxLeft
, long* pyTop
, long* pcxWidth
, long* pcyHeight
, VARIANT varID
);
209 // Traverses to another user interface element within a container and retrieves the object.
210 // All visual objects must support this method.
212 STDMETHODIMP
accNavigate ( long navDir
, VARIANT varStart
, VARIANT
* pVarEnd
);
214 // Retrieves the address of an IDispatch interface for the specified child.
215 // All objects must support this property.
217 STDMETHODIMP
get_accChild ( VARIANT varChildID
, IDispatch
** ppDispChild
);
219 // Retrieves the number of children that belong to this object.
220 // All objects must support this property.
222 STDMETHODIMP
get_accChildCount ( long* pCountChildren
);
224 // Retrieves the IDispatch interface of the object's parent.
225 // All objects support this property.
227 STDMETHODIMP
get_accParent ( IDispatch
** ppDispParent
);
229 // Descriptive Properties and Methods
231 // Performs the object's default action. Not all objects have a default
234 STDMETHODIMP
accDoDefaultAction(VARIANT varID
);
236 // Retrieves a string that describes the object's default action.
237 // Not all objects have a default action.
239 STDMETHODIMP
get_accDefaultAction ( VARIANT varID
, BSTR
* pszDefaultAction
);
241 // Retrieves a string that describes the visual appearance of the specified object.
242 // Not all objects have a description.
244 STDMETHODIMP
get_accDescription ( VARIANT varID
, BSTR
* pszDescription
);
246 // Retrieves an object's Help property string.
247 // Not all objects support this property.
249 STDMETHODIMP
get_accHelp ( VARIANT varID
, BSTR
* pszHelp
);
251 // Retrieves the full path of the WinHelp file associated with the specified
252 // object and the identifier of the appropriate topic within that file.
253 // Not all objects support this property.
255 STDMETHODIMP
get_accHelpTopic ( BSTR
* pszHelpFile
, VARIANT varChild
, long* pidTopic
);
257 // Retrieves the specified object's shortcut key or access key, also known as
258 // the mnemonic. All objects that have a shortcut key or access key support
261 STDMETHODIMP
get_accKeyboardShortcut ( VARIANT varID
, BSTR
* pszKeyboardShortcut
);
263 // Retrieves the name of the specified object.
264 // All objects support this property.
266 STDMETHODIMP
get_accName ( VARIANT varID
, BSTR
* pszName
);
268 // Retrieves information that describes the role of the specified object.
269 // All objects support this property.
271 STDMETHODIMP
get_accRole ( VARIANT varID
, VARIANT
* pVarRole
);
273 // Retrieves the current state of the specified object.
274 // All objects support this property.
276 STDMETHODIMP
get_accState ( VARIANT varID
, VARIANT
* pVarState
);
278 // Retrieves the value of the specified object.
279 // Not all objects have a value.
281 STDMETHODIMP
get_accValue ( VARIANT varID
, BSTR
* pszValue
);
283 // Selection and Focus
285 // Modifies the selection or moves the keyboard focus of the
286 // specified object. All objects that select or receive the
287 // keyboard focus must support this method.
289 STDMETHODIMP
accSelect ( long flagsSelect
, VARIANT varID
);
291 // Retrieves the object that has the keyboard focus. All objects
292 // that receive the keyboard focus must support this property.
294 STDMETHODIMP
get_accFocus ( VARIANT
* pVarID
);
296 // Retrieves the selected children of this object. All objects
297 // selected must support this property.
299 STDMETHODIMP
get_accSelection ( VARIANT
* pVarChildren
);
303 STDMETHODIMP
put_accName(VARIANT
WXUNUSED(varChild
), BSTR
WXUNUSED(szName
)) { return E_FAIL
; }
304 STDMETHODIMP
put_accValue(VARIANT
WXUNUSED(varChild
), BSTR
WXUNUSED(szName
)) { return E_FAIL
; }
310 STDMETHODIMP
GetTypeInfo(unsigned int typeInfo
, LCID lcid
, ITypeInfo
** ppTypeInfo
);
312 // Get type info count
314 STDMETHODIMP
GetTypeInfoCount(unsigned int* typeInfoCount
);
318 STDMETHODIMP
GetIDsOfNames(REFIID riid
, OLECHAR
** names
, unsigned int cNames
,
319 LCID lcid
, DISPID
* dispId
);
323 STDMETHODIMP
Invoke(DISPID dispIdMember
, REFIID riid
, LCID lcid
,
324 WORD wFlags
, DISPPARAMS
*pDispParams
,
325 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
,
326 unsigned int *puArgErr
);
330 // Gets the standard IAccessible interface for the given child or object.
331 // Call Release if this is non-NULL.
332 IAccessible
* GetChildStdAccessible(int id
);
334 // Gets the IAccessible interface for the given child or object.
335 // Call Release if this is non-NULL.
336 IAccessible
* GetChildAccessible(int id
);
339 wxAccessible
*m_pAccessible
; // pointer to C++ class we belong to
340 bool m_bQuiescing
; // Object is to be deleted
342 wxDECLARE_NO_COPY_CLASS(wxIAccessible
);
345 // ============================================================================
347 // ============================================================================
349 // ----------------------------------------------------------------------------
350 // wxIAccessible implementation
351 // ----------------------------------------------------------------------------
352 BEGIN_IID_TABLE(wxIAccessible
)
358 IMPLEMENT_IUNKNOWN_METHODS(wxIAccessible
)
360 wxIAccessible::wxIAccessible(wxAccessible
*pAccessible
)
362 wxASSERT( pAccessible
!= NULL
);
364 m_pAccessible
= pAccessible
;
365 m_bQuiescing
= false;
368 // Called to indicate object should prepare to be deleted.
370 void wxIAccessible::Quiesce()
373 m_pAccessible
= NULL
;
376 // Retrieves the child element or child object at a given point on the screen.
377 // All visual objects support this method; sound objects do not support it.
379 STDMETHODIMP
wxIAccessible::accHitTest(long xLeft
, long yLeft
, VARIANT
* pVarID
)
381 wxLogTrace(wxT("access"), wxT("accHitTest"));
382 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
386 wxAccessible
* childObject
= NULL
;
390 wxAccStatus status
= m_pAccessible
->HitTest(wxPoint(xLeft
, yLeft
), & childId
, & childObject
);
392 if (status
== wxACC_FAIL
)
395 if (status
== wxACC_NOT_IMPLEMENTED
)
397 // Use standard interface instead.
398 IAccessible
* stdInterface
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
402 return stdInterface
->accHitTest(xLeft
, yLeft
, pVarID
);
407 if (childObject
== m_pAccessible
)
410 pVarID
->lVal
= CHILDID_SELF
;
415 wxIAccessible
* childIA
= childObject
->GetIAccessible();
419 if (childIA
->QueryInterface(IID_IDispatch
, (LPVOID
*) & pVarID
->pdispVal
) != S_OK
)
422 pVarID
->vt
= VT_DISPATCH
;
426 else if (childId
> 0)
429 pVarID
->lVal
= childId
;
434 pVarID
->vt
= VT_EMPTY
;
439 // all cases above already cause some return action so below line
440 // is unreachable and cause unnecessary warning
445 // Retrieves the specified object's current screen location. All visual objects must
446 // support this method; sound objects do not support it.
448 STDMETHODIMP
wxIAccessible::accLocation ( long* pxLeft
, long* pyTop
, long* pcxWidth
, long* pcyHeight
, VARIANT varID
)
450 wxLogTrace(wxT("access"), wxT("accLocation"));
451 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
457 wxAccStatus status
= m_pAccessible
->GetLocation(rect
, varID
.lVal
);
458 if (status
== wxACC_FAIL
)
461 if (status
== wxACC_NOT_IMPLEMENTED
)
463 // Try to use child object directly.
466 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
470 HRESULT hResult
= childAccessible
->accLocation(pxLeft
, pyTop
, pcxWidth
, pcyHeight
, varID
);
471 childAccessible
->Release();
474 else if (m_pAccessible
->GetIAccessibleStd())
475 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accLocation(pxLeft
, pyTop
, pcxWidth
, pcyHeight
, varID
);
477 else if (m_pAccessible
->GetIAccessibleStd())
478 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accLocation(pxLeft
, pyTop
, pcxWidth
, pcyHeight
, varID
);
484 *pcxWidth
= rect
.width
;
485 *pcyHeight
= rect
.height
;
492 // Traverses to another user interface element within a container and retrieves the object.
493 // All visual objects must support this method.
495 STDMETHODIMP
wxIAccessible::accNavigate ( long navDir
, VARIANT varStart
, VARIANT
* pVarEnd
)
497 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
500 wxLogTrace(wxT("access"), wxString(wxT("accNavigate for ")) + m_pAccessible
->GetWindow()->GetClassInfo()->GetClassName());
502 if ((varStart
.vt
!= VT_I4
&& varStart
.vt
!= VT_EMPTY
)
504 // according to MSDN and sources varStart.vt is unsigned
505 // so below line cause warning "Condition is always false"
510 wxLogTrace(wxT("access"), wxT("Invalid arg for accNavigate"));
514 wxAccessible
* elementObject
= NULL
;
516 VariantInit(pVarEnd
);
517 wxNavDir navDirWX
= wxNAVDIR_FIRSTCHILD
;
524 navDirWX
= wxNAVDIR_DOWN
;
525 navStr
= wxT("wxNAVDIR_DOWN");
528 case NAVDIR_FIRSTCHILD
:
529 navDirWX
= wxNAVDIR_FIRSTCHILD
;
530 navStr
= wxT("wxNAVDIR_FIRSTCHILD");
533 case NAVDIR_LASTCHILD
:
534 navDirWX
= wxNAVDIR_LASTCHILD
;
535 navStr
= wxT("wxNAVDIR_LASTCHILD");
539 navDirWX
= wxNAVDIR_LEFT
;
540 navStr
= wxT("wxNAVDIR_LEFT");
544 navDirWX
= wxNAVDIR_NEXT
;
545 navStr
= wxT("wxNAVDIR_NEXT");
548 case NAVDIR_PREVIOUS
:
549 navDirWX
= wxNAVDIR_PREVIOUS
;
550 navStr
= wxT("wxNAVDIR_PREVIOUS");
554 navDirWX
= wxNAVDIR_RIGHT
;
555 navStr
= wxT("wxNAVDIR_RIGHT");
559 navDirWX
= wxNAVDIR_UP
;
560 navStr
= wxT("wxNAVDIR_UP");
564 wxLogTrace(wxT("access"), wxT("Unknown NAVDIR symbol"));
568 wxLogTrace(wxT("access"), navStr
);
570 wxAccStatus status
= m_pAccessible
->Navigate(navDirWX
, varStart
.lVal
, & elementId
,
573 if (status
== wxACC_FAIL
)
575 wxLogTrace(wxT("access"), wxT("wxAccessible::Navigate failed"));
579 if (status
== wxACC_FALSE
)
581 wxLogTrace(wxT("access"), wxT("wxAccessible::Navigate found no object in this direction"));
585 if (status
== wxACC_NOT_IMPLEMENTED
)
587 wxLogTrace(wxT("access"), wxT("Navigate not implemented"));
589 // Try to use child object directly.
590 if (varStart
.vt
== VT_I4
&& varStart
.lVal
> 0)
592 IAccessible
* childAccessible
= GetChildAccessible(varStart
.lVal
);
596 HRESULT hResult
= childAccessible
->accNavigate(navDir
, varStart
, pVarEnd
);
597 childAccessible
->Release();
600 else if (m_pAccessible
->GetIAccessibleStd())
601 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accNavigate(navDir
, varStart
, pVarEnd
);
603 else if (m_pAccessible
->GetIAccessibleStd())
604 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accNavigate(navDir
, varStart
, pVarEnd
);
610 wxLogTrace(wxT("access"), wxT("Getting wxIAccessible and calling QueryInterface for Navigate"));
611 wxIAccessible
* objectIA
= elementObject
->GetIAccessible();
614 wxLogTrace(wxT("access"), wxT("No wxIAccessible"));
618 HRESULT hResult
= objectIA
->QueryInterface(IID_IDispatch
, (LPVOID
*) & pVarEnd
->pdispVal
);
621 wxLogTrace(wxT("access"), wxT("QueryInterface failed"));
625 wxLogTrace(wxT("access"), wxT("Called QueryInterface for Navigate"));
626 pVarEnd
->vt
= VT_DISPATCH
;
629 else if (elementId
> 0)
631 wxLogTrace(wxT("access"), wxT("Returning element id from Navigate"));
633 pVarEnd
->lVal
= elementId
;
638 wxLogTrace(wxT("access"), wxT("No object in accNavigate"));
639 pVarEnd
->vt
= VT_EMPTY
;
644 wxLogTrace(wxT("access"), wxT("Failing Navigate"));
648 // Retrieves the address of an IDispatch interface for the specified child.
649 // All objects must support this property.
651 STDMETHODIMP
wxIAccessible::get_accChild ( VARIANT varChildID
, IDispatch
** ppDispChild
)
653 wxLogTrace(wxT("access"), wxT("get_accChild"));
654 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
658 if (varChildID
.vt
!= VT_I4
)
660 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accChild"));
664 if (varChildID
.lVal
== CHILDID_SELF
)
671 wxAccessible
* child
= NULL
;
673 wxAccStatus status
= m_pAccessible
->GetChild(varChildID
.lVal
, & child
);
674 if (status
== wxACC_FAIL
)
676 wxLogTrace(wxT("access"), wxT("GetChild failed"));
680 if (status
== wxACC_NOT_IMPLEMENTED
)
682 // Use standard interface instead.
683 IAccessible
* stdInterface
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
688 wxLogTrace(wxT("access"), wxT("Using standard interface for get_accChild"));
689 return stdInterface
->get_accChild (varChildID
, ppDispChild
);
696 wxIAccessible
* objectIA
= child
->GetIAccessible();
700 if (objectIA
->QueryInterface(IID_IDispatch
, (LPVOID
*) ppDispChild
) != S_OK
)
702 wxLogTrace(wxT("access"), wxT("QueryInterface failed in get_accChild"));
710 wxLogTrace(wxT("access"), wxT("Not an accessible object"));
711 return S_FALSE
; // Indicates it's not an accessible object
716 // all cases above already cause some return action so below line
717 // is unreachable and cause unnecessary warning
722 // Retrieves the number of children that belong to this object.
723 // All objects must support this property.
725 STDMETHODIMP
wxIAccessible::get_accChildCount ( long* pCountChildren
)
727 wxLogTrace(wxT("access"), wxT("get_accChildCount"));
728 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
733 wxAccStatus status
= m_pAccessible
->GetChildCount(& childCount
);
734 if (status
== wxACC_FAIL
)
737 if (status
== wxACC_NOT_IMPLEMENTED
)
739 // Use standard interface instead.
740 IAccessible
* stdInterface
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
745 wxLogTrace(wxT("access"), wxT("Using standard interface for get_accChildCount"));
746 HRESULT res
= stdInterface
->get_accChildCount (pCountChildren
);
748 str
.Printf(wxT("Number of children was %d"), (int) (*pCountChildren
));
749 wxLogTrace(wxT("access"), str
);
755 * pCountChildren
= (long) childCount
;
760 // all cases above already cause some return action so below line
761 // is unreachable and cause unnecessary warning
766 // Retrieves the IDispatch interface of the object's parent.
767 // All objects support this property.
769 STDMETHODIMP
wxIAccessible::get_accParent ( IDispatch
** ppDispParent
)
771 wxLogTrace(wxT("access"), wxT("get_accParent"));
772 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
776 wxAccessible
* parent
= NULL
;
777 wxAccStatus status
= m_pAccessible
->GetParent(& parent
);
779 if (status
== wxACC_FAIL
)
782 // It doesn't seem acceptable to return S_FALSE with a NULL
783 // ppDispParent, so if we have no wxWidgets parent, we leave
784 // it to the standard interface.
785 if (status
== wxACC_NOT_IMPLEMENTED
|| !parent
)
787 wxLogTrace(wxT("access"), wxT("Using standard interface to get the parent."));
788 // Use standard interface instead.
789 IAccessible
* stdInterface
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
793 return stdInterface
->get_accParent (ppDispParent
);
799 wxIAccessible
* objectIA
= parent
->GetIAccessible();
803 wxLogTrace(wxT("access"), wxT("About to call QueryInterface"));
804 if (objectIA
->QueryInterface(IID_IDispatch
, (LPVOID
*) ppDispParent
) != S_OK
)
806 wxLogTrace(wxT("access"), wxT("Failed QueryInterface"));
810 wxLogTrace(wxT("access"), wxT("Returning S_OK for get_accParent"));
815 // This doesn't seem to be allowed, despite the documentation,
816 // so we handle it higher up by using the standard interface.
817 wxLogTrace(wxT("access"), wxT("Returning NULL parent because there was none"));
818 *ppDispParent
= NULL
;
824 // all cases above already cause some return action so below line
825 // is unreachable and cause unnecessary warning
830 // Performs the object's default action. Not all objects have a default
833 STDMETHODIMP
wxIAccessible::accDoDefaultAction(VARIANT varID
)
835 wxLogTrace(wxT("access"), wxT("accDoDefaultAction"));
836 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
840 if (varID
.vt
!= VT_I4
)
842 wxLogTrace(wxT("access"), wxT("Invalid arg for accDoDefaultAction"));
846 wxAccStatus status
= m_pAccessible
->DoDefaultAction(varID
.lVal
);
847 if (status
== wxACC_FAIL
)
850 if (status
== wxACC_NOT_SUPPORTED
)
851 return DISP_E_MEMBERNOTFOUND
;
853 if (status
== wxACC_NOT_IMPLEMENTED
)
855 // Try to use child object directly.
858 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
862 HRESULT hResult
= childAccessible
->accDoDefaultAction(varID
);
863 childAccessible
->Release();
866 else if (m_pAccessible
->GetIAccessibleStd())
867 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accDoDefaultAction(varID
);
869 else if (m_pAccessible
->GetIAccessibleStd())
870 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accDoDefaultAction(varID
);
875 // Retrieves a string that describes the object's default action.
876 // Not all objects have a default action.
878 STDMETHODIMP
wxIAccessible::get_accDefaultAction ( VARIANT varID
, BSTR
* pszDefaultAction
)
880 wxLogTrace(wxT("access"), wxT("get_accDefaultAction"));
881 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
885 if (varID
.vt
!= VT_I4
)
887 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accDefaultAction"));
891 wxString defaultAction
;
892 wxAccStatus status
= m_pAccessible
->GetDefaultAction(varID
.lVal
, & defaultAction
);
893 if (status
== wxACC_FAIL
)
896 if (status
== wxACC_NOT_SUPPORTED
)
897 return DISP_E_MEMBERNOTFOUND
;
899 if (status
== wxACC_NOT_IMPLEMENTED
)
901 // Try to use child object directly.
904 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
908 HRESULT hResult
= childAccessible
->get_accDefaultAction(varID
, pszDefaultAction
);
909 childAccessible
->Release();
912 else if (m_pAccessible
->GetIAccessibleStd())
913 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accDefaultAction(varID
, pszDefaultAction
);
915 else if (m_pAccessible
->GetIAccessibleStd())
916 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accDefaultAction(varID
, pszDefaultAction
);
920 if (defaultAction
.IsEmpty())
922 * pszDefaultAction
= NULL
;
927 wxBasicString
basicString(defaultAction
);
928 * pszDefaultAction
= basicString
.Get();
935 // Retrieves a string that describes the visual appearance of the specified object.
936 // Not all objects have a description.
938 STDMETHODIMP
wxIAccessible::get_accDescription ( VARIANT varID
, BSTR
* pszDescription
)
940 wxLogTrace(wxT("access"), wxT("get_accDescription"));
941 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
945 if (varID
.vt
!= VT_I4
)
947 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accDescription"));
951 wxString description
;
952 wxAccStatus status
= m_pAccessible
->GetDescription(varID
.lVal
, & description
);
953 if (status
== wxACC_FAIL
)
956 if (status
== wxACC_NOT_IMPLEMENTED
)
958 // Try to use child object directly.
961 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
965 HRESULT hResult
= childAccessible
->get_accDescription(varID
, pszDescription
);
966 childAccessible
->Release();
969 else if (m_pAccessible
->GetIAccessibleStd())
970 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accDescription(varID
, pszDescription
);
972 else if (m_pAccessible
->GetIAccessibleStd())
973 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accDescription(varID
, pszDescription
);
977 if (description
.empty())
979 * pszDescription
= NULL
;
984 wxBasicString
basicString(description
);
985 * pszDescription
= basicString
.Get();
992 // Retrieves an object's Help property string.
993 // Not all objects support this property.
995 STDMETHODIMP
wxIAccessible::get_accHelp ( VARIANT varID
, BSTR
* pszHelp
)
997 wxLogTrace(wxT("access"), wxT("get_accHelp"));
998 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1002 if (varID
.vt
!= VT_I4
)
1004 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accHelp"));
1005 return E_INVALIDARG
;
1008 wxString helpString
;
1009 wxAccStatus status
= m_pAccessible
->GetHelpText(varID
.lVal
, & helpString
);
1010 if (status
== wxACC_FAIL
)
1013 if (status
== wxACC_NOT_IMPLEMENTED
)
1015 // Try to use child object directly.
1018 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1019 if (childAccessible
)
1022 HRESULT hResult
= childAccessible
->get_accHelp(varID
, pszHelp
);
1023 childAccessible
->Release();
1026 else if (m_pAccessible
->GetIAccessibleStd())
1027 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accHelp(varID
, pszHelp
);
1029 else if (m_pAccessible
->GetIAccessibleStd())
1030 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accHelp (varID
, pszHelp
);
1034 if (helpString
.empty())
1041 wxBasicString
basicString(helpString
);
1042 * pszHelp
= basicString
.Get();
1049 // Retrieves the full path of the WinHelp file associated with the specified
1050 // object and the identifier of the appropriate topic within that file.
1051 // Not all objects support this property.
1052 // NOTE: not supported by wxWidgets at this time. Use
1053 // GetHelpText instead.
1055 STDMETHODIMP
wxIAccessible::get_accHelpTopic ( BSTR
* pszHelpFile
, VARIANT varChild
, long* pidTopic
)
1057 wxLogTrace(wxT("access"), wxT("get_accHelpTopic"));
1058 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1062 if (varChild
.vt
!= VT_I4
)
1064 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accHelpTopic"));
1065 return E_INVALIDARG
;
1068 wxAccStatus status
= wxACC_NOT_IMPLEMENTED
;
1069 if (status
== wxACC_FAIL
)
1072 if (status
== wxACC_NOT_IMPLEMENTED
)
1074 // Try to use child object directly.
1075 if (varChild
.lVal
> 0)
1077 IAccessible
* childAccessible
= GetChildAccessible(varChild
.lVal
);
1078 if (childAccessible
)
1081 HRESULT hResult
= childAccessible
->get_accHelpTopic(pszHelpFile
, varChild
, pidTopic
);
1082 childAccessible
->Release();
1085 else if (m_pAccessible
->GetIAccessibleStd())
1086 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accHelpTopic(pszHelpFile
, varChild
, pidTopic
);
1088 else if (m_pAccessible
->GetIAccessibleStd())
1089 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accHelpTopic (pszHelpFile
, varChild
, pidTopic
);
1094 // Retrieves the specified object's shortcut key or access key, also known as
1095 // the mnemonic. All objects that have a shortcut key or access key support
1098 STDMETHODIMP
wxIAccessible::get_accKeyboardShortcut ( VARIANT varID
, BSTR
* pszKeyboardShortcut
)
1100 wxLogTrace(wxT("access"), wxT("get_accKeyboardShortcut"));
1101 *pszKeyboardShortcut
= NULL
;
1103 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1107 if (varID
.vt
!= VT_I4
)
1109 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accKeyboardShortcut"));
1110 return E_INVALIDARG
;
1113 wxString keyboardShortcut
;
1114 wxAccStatus status
= m_pAccessible
->GetKeyboardShortcut(varID
.lVal
, & keyboardShortcut
);
1115 if (status
== wxACC_FAIL
)
1118 if (status
== wxACC_NOT_IMPLEMENTED
)
1120 // Try to use child object directly.
1123 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1124 if (childAccessible
)
1127 HRESULT hResult
= childAccessible
->get_accKeyboardShortcut(varID
, pszKeyboardShortcut
);
1128 childAccessible
->Release();
1131 else if (m_pAccessible
->GetIAccessibleStd())
1132 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accKeyboardShortcut(varID
, pszKeyboardShortcut
);
1134 else if (m_pAccessible
->GetIAccessibleStd())
1135 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accKeyboardShortcut (varID
, pszKeyboardShortcut
);
1139 if (keyboardShortcut
.empty())
1141 * pszKeyboardShortcut
= NULL
;
1146 wxBasicString
basicString(keyboardShortcut
);
1147 * pszKeyboardShortcut
= basicString
.Get();
1154 // Retrieves the name of the specified object.
1155 // All objects support this property.
1157 STDMETHODIMP
wxIAccessible::get_accName ( VARIANT varID
, BSTR
* pszName
)
1159 wxLogTrace(wxT("access"), wxT("get_accName"));
1162 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1166 if (varID
.vt
!= VT_I4
)
1168 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accName"));
1169 return E_INVALIDARG
;
1174 wxAccStatus status
= m_pAccessible
->GetName(varID
.lVal
, & name
);
1176 if (status
== wxACC_FAIL
)
1179 if (status
== wxACC_NOT_IMPLEMENTED
)
1181 // Try to use child object directly.
1184 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1185 if (childAccessible
)
1188 HRESULT hResult
= childAccessible
->get_accName(varID
, pszName
);
1189 childAccessible
->Release();
1192 else if (m_pAccessible
->GetIAccessibleStd())
1193 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accName(varID
, pszName
);
1195 else if (m_pAccessible
->GetIAccessibleStd())
1196 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accName (varID
, pszName
);
1200 wxBasicString
basicString(name
);
1201 *pszName
= basicString
.Get();
1207 // Retrieves information that describes the role of the specified object.
1208 // All objects support this property.
1210 STDMETHODIMP
wxIAccessible::get_accRole ( VARIANT varID
, VARIANT
* pVarRole
)
1212 wxLogTrace(wxT("access"), wxT("get_accRole"));
1213 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1217 if (varID
.vt
!= VT_I4
)
1219 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accRole"));
1220 return E_INVALIDARG
;
1223 VariantInit(pVarRole
);
1225 wxAccRole role
= wxROLE_NONE
;
1227 wxAccStatus status
= m_pAccessible
->GetRole(varID
.lVal
, & role
);
1229 if (status
== wxACC_FAIL
)
1232 if (status
== wxACC_NOT_IMPLEMENTED
)
1234 // Try to use child object directly.
1237 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1238 if (childAccessible
)
1241 HRESULT hResult
= childAccessible
->get_accRole(varID
, pVarRole
);
1242 childAccessible
->Release();
1245 else if (m_pAccessible
->GetIAccessibleStd())
1246 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accRole(varID
, pVarRole
);
1248 else if (m_pAccessible
->GetIAccessibleStd())
1249 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accRole (varID
, pVarRole
);
1253 if (role
== wxROLE_NONE
)
1255 pVarRole
->vt
= VT_EMPTY
;
1259 pVarRole
->lVal
= wxConvertToWindowsRole(role
);
1260 pVarRole
->vt
= VT_I4
;
1267 // Retrieves the current state of the specified object.
1268 // All objects support this property.
1270 STDMETHODIMP
wxIAccessible::get_accState ( VARIANT varID
, VARIANT
* pVarState
)
1272 wxLogTrace(wxT("access"), wxT("get_accState"));
1273 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1277 if (varID
.vt
!= VT_I4
&& varID
.vt
!= VT_EMPTY
)
1279 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accState"));
1280 return E_INVALIDARG
;
1285 wxAccStatus status
= m_pAccessible
->GetState(varID
.lVal
, & wxstate
);
1286 if (status
== wxACC_FAIL
)
1289 if (status
== wxACC_NOT_IMPLEMENTED
)
1291 // Try to use child object directly.
1294 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1295 if (childAccessible
)
1298 HRESULT hResult
= childAccessible
->get_accState(varID
, pVarState
);
1299 childAccessible
->Release();
1302 else if (m_pAccessible
->GetIAccessibleStd())
1303 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accState(varID
, pVarState
);
1305 else if (m_pAccessible
->GetIAccessibleStd())
1306 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accState (varID
, pVarState
);
1310 long state
= wxConvertToWindowsState(wxstate
);
1311 pVarState
->lVal
= state
;
1312 pVarState
->vt
= VT_I4
;
1318 // Retrieves the value of the specified object.
1319 // Not all objects have a value.
1321 STDMETHODIMP
wxIAccessible::get_accValue ( VARIANT varID
, BSTR
* pszValue
)
1323 wxLogTrace(wxT("access"), wxT("get_accValue"));
1324 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1328 if (varID
.vt
!= VT_I4
)
1330 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accValue"));
1331 return E_INVALIDARG
;
1336 wxAccStatus status
= m_pAccessible
->GetValue(varID
.lVal
, & strValue
);
1338 if (status
== wxACC_FAIL
)
1341 if (status
== wxACC_NOT_IMPLEMENTED
)
1343 // Try to use child object directly.
1346 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1347 if (childAccessible
)
1350 HRESULT hResult
= childAccessible
->get_accValue(varID
, pszValue
);
1351 childAccessible
->Release();
1354 else if (m_pAccessible
->GetIAccessibleStd())
1355 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accValue(varID
, pszValue
);
1357 else if (m_pAccessible
->GetIAccessibleStd())
1358 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accValue (varID
, pszValue
);
1362 wxBasicString
basicString(strValue
);
1363 * pszValue
= basicString
.Get();
1369 // Modifies the selection or moves the keyboard focus of the
1370 // specified object. All objects that select or receive the
1371 // keyboard focus must support this method.
1373 STDMETHODIMP
wxIAccessible::accSelect ( long flagsSelect
, VARIANT varID
)
1375 wxLogTrace(wxT("access"), wxT("get_accSelect"));
1376 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1380 if (varID
.vt
!= VT_I4
&& varID
.vt
!= VT_EMPTY
)
1382 wxLogTrace(wxT("access"), wxT("Invalid arg for accSelect"));
1383 return E_INVALIDARG
;
1386 wxAccSelectionFlags wxsel
= wxConvertFromWindowsSelFlag(flagsSelect
);
1388 wxAccStatus status
= m_pAccessible
->Select(varID
.lVal
, wxsel
);
1389 if (status
== wxACC_FAIL
)
1392 if (status
== wxACC_NOT_IMPLEMENTED
)
1394 // Try to use child object directly.
1395 if (varID
.lVal
> 0 && varID
.lVal
> 0)
1397 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1398 if (childAccessible
)
1401 HRESULT hResult
= childAccessible
->accSelect(flagsSelect
, varID
);
1402 childAccessible
->Release();
1405 else if (m_pAccessible
->GetIAccessibleStd())
1406 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accSelect(flagsSelect
, varID
);
1408 else if (m_pAccessible
->GetIAccessibleStd())
1409 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accSelect(flagsSelect
, varID
);
1417 // Retrieves the object that has the keyboard focus. All objects
1418 // that receive the keyboard focus must support this property.
1420 STDMETHODIMP
wxIAccessible::get_accFocus ( VARIANT
* pVarID
)
1422 wxLogTrace(wxT("access"), wxT("get_accFocus"));
1423 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1427 wxAccessible
* childObject
= NULL
;
1429 VariantInit(pVarID
);
1431 wxAccStatus status
= m_pAccessible
->GetFocus(& childId
, & childObject
);
1432 if (status
== wxACC_FAIL
)
1435 if (status
== wxACC_NOT_IMPLEMENTED
)
1437 // Use standard interface instead.
1438 IAccessible
* stdInterface
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
1442 return stdInterface
->get_accFocus (pVarID
);
1446 if (childObject
== m_pAccessible
)
1449 pVarID
->lVal
= CHILDID_SELF
;
1453 wxIAccessible
* childIA
= childObject
->GetIAccessible();
1457 if (childIA
->QueryInterface(IID_IDispatch
, (LPVOID
*) & pVarID
->pdispVal
) != S_OK
)
1460 pVarID
->vt
= VT_DISPATCH
;
1464 else if (childId
> 0)
1467 pVarID
->lVal
= childId
;
1472 pVarID
->vt
= VT_EMPTY
;
1477 // all cases above already cause some return action so below line
1478 // is unreachable and cause unnecessary warning
1483 // Retrieves the selected children of this object. All objects
1484 // selected must support this property.
1486 STDMETHODIMP
wxIAccessible::get_accSelection ( VARIANT
* pVarChildren
)
1489 wxLogTrace(wxT("access"), wxT("get_accSelection"));
1490 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1494 VariantInit(pVarChildren
);
1496 wxVariant selections
;
1497 wxAccStatus status
= m_pAccessible
->GetSelections(& selections
);
1498 if (status
== wxACC_FAIL
)
1501 if (status
== wxACC_NOT_IMPLEMENTED
)
1503 // Use standard interface instead.
1504 IAccessible
* stdInterface
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
1508 return stdInterface
->get_accSelection (pVarChildren
);
1512 if (selections
.GetType() == wxT("long"))
1514 pVarChildren
->vt
= VT_I4
;
1515 pVarChildren
->lVal
= selections
.GetLong();
1519 else if (selections
.GetType() == wxT("void*"))
1521 wxAccessible
* childObject
= (wxAccessible
*) selections
.GetVoidPtr();
1522 wxIAccessible
* childIA
= childObject
->GetIAccessible();
1526 if (childIA
->QueryInterface(IID_IDispatch
, (LPVOID
*) & pVarChildren
->pdispVal
) != S_OK
)
1529 pVarChildren
->vt
= VT_DISPATCH
;
1533 else if (selections
.GetType() == wxT("list"))
1535 // TODO: should we AddRef for every "void*" member??
1537 wxIEnumVARIANT
* enumVariant
= new wxIEnumVARIANT(selections
);
1538 enumVariant
->AddRef();
1540 pVarChildren
->vt
= VT_UNKNOWN
;
1541 pVarChildren
->punkVal
= enumVariant
;
1547 wxUnusedVar(pVarChildren
);
1548 #endif // wxUSE_VARIANT
1555 STDMETHODIMP
wxIAccessible::GetTypeInfo(unsigned int WXUNUSED(typeInfo
), LCID
WXUNUSED(lcid
), ITypeInfo
** ppTypeInfo
)
1561 // Get type info count
1563 STDMETHODIMP
wxIAccessible::GetTypeInfoCount(unsigned int* typeInfoCount
)
1571 STDMETHODIMP
wxIAccessible::GetIDsOfNames(REFIID
WXUNUSED(riid
), OLECHAR
** WXUNUSED(names
), unsigned int WXUNUSED(cNames
),
1572 LCID
WXUNUSED(lcid
), DISPID
* WXUNUSED(dispId
))
1579 STDMETHODIMP
wxIAccessible::Invoke(DISPID
WXUNUSED(dispIdMember
), REFIID
WXUNUSED(riid
), LCID
WXUNUSED(lcid
),
1580 WORD
WXUNUSED(wFlags
), DISPPARAMS
*WXUNUSED(pDispParams
),
1581 VARIANT
*WXUNUSED(pVarResult
), EXCEPINFO
*WXUNUSED(pExcepInfo
),
1582 unsigned int *WXUNUSED(puArgErr
) )
1587 // Gets the standard IAccessible interface for the given child or object.
1588 // Call Release if this is non-NULL.
1589 IAccessible
* wxIAccessible::GetChildStdAccessible(int id
)
1593 IAccessible
* obj
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
1604 IDispatch
* pDispatch
= NULL
;
1605 if (S_OK
== get_accChild ( var
, & pDispatch
))
1607 IAccessible
* childAccessible
= NULL
;
1608 if (pDispatch
->QueryInterface(IID_IAccessible
, (LPVOID
*) & childAccessible
) == S_OK
)
1610 pDispatch
->Release();
1611 wxIAccessible
* c
= (wxIAccessible
*) childAccessible
;
1612 IAccessible
* stdChildAccessible
= (IAccessible
*) c
->m_pAccessible
->GetIAccessibleStd();
1613 stdChildAccessible
->AddRef();
1614 childAccessible
->Release();
1615 return stdChildAccessible
;
1619 pDispatch
->Release();
1626 // Loop until we find the right id
1628 this->get_accChildCount(& nChildren
);
1631 for (i
= 0; i
< nChildren
; i
++)
1637 if (S_OK
== AccessibleChildren(this, i
, 1, & var
, &obtained
))
1642 var
.vt
= VT_DISPATCH
;
1643 if (S_OK
== AccessibleChildren(this, i
, 1, & var
, &obtained
))
1645 IAccessible
* childAccessible
= NULL
;
1646 if (var
.pdispVal
->QueryInterface(IID_IAccessible
, (LPVOID
*) & childAccessible
) == S_OK
)
1648 var
.pdispVal
->Release();
1649 return childAccessible
;
1653 var
.pdispVal
->Release();
1665 // Gets the IAccessible interface for the given child or object.
1666 // Call Release if this is non-NULL.
1667 IAccessible
* wxIAccessible::GetChildAccessible(int id
)
1671 IAccessible
* obj
= this;
1682 IDispatch
* pDispatch
= NULL
;
1683 if (S_OK
== get_accChild ( var
, & pDispatch
))
1685 IAccessible
* childAccessible
= NULL
;
1686 if (pDispatch
->QueryInterface(IID_IAccessible
, (LPVOID
*) & childAccessible
) == S_OK
)
1688 pDispatch
->Release();
1689 return childAccessible
;
1693 pDispatch
->Release();
1700 // ----------------------------------------------------------------------------
1701 // wxAccessible implementation
1702 // ----------------------------------------------------------------------------
1706 // common part of all ctors
1707 void wxAccessible::Init()
1709 m_pIAccessibleStd
= NULL
;
1710 m_pIAccessible
= new wxIAccessible(this);
1711 m_pIAccessible
->AddRef();
1714 wxAccessible::wxAccessible(wxWindow
* win
)
1715 : wxAccessibleBase(win
)
1720 wxAccessible::~wxAccessible()
1722 m_pIAccessible
->Quiesce();
1723 m_pIAccessible
->Release();
1724 if (m_pIAccessibleStd
)
1725 ((IAccessible
*)m_pIAccessibleStd
)->Release();
1728 // Gets or creates a standard interface for this object.
1729 void* wxAccessible::GetIAccessibleStd()
1731 if (m_pIAccessibleStd
)
1732 return m_pIAccessibleStd
;
1736 HRESULT retCode
= ::CreateStdAccessibleObject((HWND
) GetWindow()->GetHWND(),
1737 OBJID_CLIENT
, IID_IAccessible
, (void**) & m_pIAccessibleStd
);
1738 if (retCode
== S_OK
)
1739 return m_pIAccessibleStd
;
1742 m_pIAccessibleStd
= NULL
;
1749 // Sends an event when something changes in an accessible object.
1750 void wxAccessible::NotifyEvent(int eventType
, wxWindow
* window
, wxAccObject objectType
,
1753 ::NotifyWinEvent((DWORD
) eventType
, (HWND
) window
->GetHWND(),
1754 (LONG
) objectType
, (LONG
) objectId
);
1759 // Convert to Windows role
1760 int wxConvertToWindowsRole(wxAccRole wxrole
)
1766 case wxROLE_SYSTEM_ALERT
:
1767 return ROLE_SYSTEM_ALERT
;
1768 case wxROLE_SYSTEM_ANIMATION
:
1769 return ROLE_SYSTEM_ANIMATION
;
1770 case wxROLE_SYSTEM_APPLICATION
:
1771 return ROLE_SYSTEM_APPLICATION
;
1772 case wxROLE_SYSTEM_BORDER
:
1773 return ROLE_SYSTEM_BORDER
;
1774 case wxROLE_SYSTEM_BUTTONDROPDOWN
:
1775 return ROLE_SYSTEM_BUTTONDROPDOWN
;
1776 case wxROLE_SYSTEM_BUTTONDROPDOWNGRID
:
1777 return ROLE_SYSTEM_BUTTONDROPDOWNGRID
;
1778 case wxROLE_SYSTEM_BUTTONMENU
:
1779 return ROLE_SYSTEM_BUTTONMENU
;
1780 case wxROLE_SYSTEM_CARET
:
1781 return ROLE_SYSTEM_CARET
;
1782 case wxROLE_SYSTEM_CELL
:
1783 return ROLE_SYSTEM_CELL
;
1784 case wxROLE_SYSTEM_CHARACTER
:
1785 return ROLE_SYSTEM_CHARACTER
;
1786 case wxROLE_SYSTEM_CHART
:
1787 return ROLE_SYSTEM_CHART
;
1788 case wxROLE_SYSTEM_CHECKBUTTON
:
1789 return ROLE_SYSTEM_CHECKBUTTON
;
1790 case wxROLE_SYSTEM_CLIENT
:
1791 return ROLE_SYSTEM_CLIENT
;
1792 case wxROLE_SYSTEM_CLOCK
:
1793 return ROLE_SYSTEM_CLOCK
;
1794 case wxROLE_SYSTEM_COLUMN
:
1795 return ROLE_SYSTEM_COLUMN
;
1796 case wxROLE_SYSTEM_COLUMNHEADER
:
1797 return ROLE_SYSTEM_COLUMNHEADER
;
1798 case wxROLE_SYSTEM_COMBOBOX
:
1799 return ROLE_SYSTEM_COMBOBOX
;
1800 case wxROLE_SYSTEM_CURSOR
:
1801 return ROLE_SYSTEM_CURSOR
;
1802 case wxROLE_SYSTEM_DIAGRAM
:
1803 return ROLE_SYSTEM_DIAGRAM
;
1804 case wxROLE_SYSTEM_DIAL
:
1805 return ROLE_SYSTEM_DIAL
;
1806 case wxROLE_SYSTEM_DIALOG
:
1807 return ROLE_SYSTEM_DIALOG
;
1808 case wxROLE_SYSTEM_DOCUMENT
:
1809 return ROLE_SYSTEM_DOCUMENT
;
1810 case wxROLE_SYSTEM_DROPLIST
:
1811 return ROLE_SYSTEM_DROPLIST
;
1812 case wxROLE_SYSTEM_EQUATION
:
1813 return ROLE_SYSTEM_EQUATION
;
1814 case wxROLE_SYSTEM_GRAPHIC
:
1815 return ROLE_SYSTEM_GRAPHIC
;
1816 case wxROLE_SYSTEM_GRIP
:
1817 return ROLE_SYSTEM_GRIP
;
1818 case wxROLE_SYSTEM_GROUPING
:
1819 return ROLE_SYSTEM_GROUPING
;
1820 case wxROLE_SYSTEM_HELPBALLOON
:
1821 return ROLE_SYSTEM_HELPBALLOON
;
1822 case wxROLE_SYSTEM_HOTKEYFIELD
:
1823 return ROLE_SYSTEM_HOTKEYFIELD
;
1824 case wxROLE_SYSTEM_INDICATOR
:
1825 return ROLE_SYSTEM_INDICATOR
;
1826 case wxROLE_SYSTEM_LINK
:
1827 return ROLE_SYSTEM_LINK
;
1828 case wxROLE_SYSTEM_LIST
:
1829 return ROLE_SYSTEM_LIST
;
1830 case wxROLE_SYSTEM_LISTITEM
:
1831 return ROLE_SYSTEM_LISTITEM
;
1832 case wxROLE_SYSTEM_MENUBAR
:
1833 return ROLE_SYSTEM_MENUBAR
;
1834 case wxROLE_SYSTEM_MENUITEM
:
1835 return ROLE_SYSTEM_MENUITEM
;
1836 case wxROLE_SYSTEM_MENUPOPUP
:
1837 return ROLE_SYSTEM_MENUPOPUP
;
1838 case wxROLE_SYSTEM_OUTLINE
:
1839 return ROLE_SYSTEM_OUTLINE
;
1840 case wxROLE_SYSTEM_OUTLINEITEM
:
1841 return ROLE_SYSTEM_OUTLINEITEM
;
1842 case wxROLE_SYSTEM_PAGETAB
:
1843 return ROLE_SYSTEM_PAGETAB
;
1844 case wxROLE_SYSTEM_PAGETABLIST
:
1845 return ROLE_SYSTEM_PAGETABLIST
;
1846 case wxROLE_SYSTEM_PANE
:
1847 return ROLE_SYSTEM_PANE
;
1848 case wxROLE_SYSTEM_PROGRESSBAR
:
1849 return ROLE_SYSTEM_PROGRESSBAR
;
1850 case wxROLE_SYSTEM_PROPERTYPAGE
:
1851 return ROLE_SYSTEM_PROPERTYPAGE
;
1852 case wxROLE_SYSTEM_PUSHBUTTON
:
1853 return ROLE_SYSTEM_PUSHBUTTON
;
1854 case wxROLE_SYSTEM_RADIOBUTTON
:
1855 return ROLE_SYSTEM_RADIOBUTTON
;
1856 case wxROLE_SYSTEM_ROW
:
1857 return ROLE_SYSTEM_ROW
;
1858 case wxROLE_SYSTEM_ROWHEADER
:
1859 return ROLE_SYSTEM_ROWHEADER
;
1860 case wxROLE_SYSTEM_SCROLLBAR
:
1861 return ROLE_SYSTEM_SCROLLBAR
;
1862 case wxROLE_SYSTEM_SEPARATOR
:
1863 return ROLE_SYSTEM_SEPARATOR
;
1864 case wxROLE_SYSTEM_SLIDER
:
1865 return ROLE_SYSTEM_SLIDER
;
1866 case wxROLE_SYSTEM_SOUND
:
1867 return ROLE_SYSTEM_SOUND
;
1868 case wxROLE_SYSTEM_SPINBUTTON
:
1869 return ROLE_SYSTEM_SPINBUTTON
;
1870 case wxROLE_SYSTEM_STATICTEXT
:
1871 return ROLE_SYSTEM_STATICTEXT
;
1872 case wxROLE_SYSTEM_STATUSBAR
:
1873 return ROLE_SYSTEM_STATUSBAR
;
1874 case wxROLE_SYSTEM_TABLE
:
1875 return ROLE_SYSTEM_TABLE
;
1876 case wxROLE_SYSTEM_TEXT
:
1877 return ROLE_SYSTEM_TEXT
;
1878 case wxROLE_SYSTEM_TITLEBAR
:
1879 return ROLE_SYSTEM_TITLEBAR
;
1880 case wxROLE_SYSTEM_TOOLBAR
:
1881 return ROLE_SYSTEM_TOOLBAR
;
1882 case wxROLE_SYSTEM_TOOLTIP
:
1883 return ROLE_SYSTEM_TOOLTIP
;
1884 case wxROLE_SYSTEM_WHITESPACE
:
1885 return ROLE_SYSTEM_WHITESPACE
;
1886 case wxROLE_SYSTEM_WINDOW
:
1887 return ROLE_SYSTEM_WINDOW
;
1892 // Convert to Windows state
1893 long wxConvertToWindowsState(long wxstate
)
1896 if (wxstate
& wxACC_STATE_SYSTEM_ALERT_HIGH
)
1897 state
|= STATE_SYSTEM_ALERT_HIGH
;
1899 if (wxstate
& wxACC_STATE_SYSTEM_ALERT_MEDIUM
)
1900 state
|= STATE_SYSTEM_ALERT_MEDIUM
;
1902 if (wxstate
& wxACC_STATE_SYSTEM_ALERT_LOW
)
1903 state
|= STATE_SYSTEM_ALERT_LOW
;
1905 if (wxstate
& wxACC_STATE_SYSTEM_ANIMATED
)
1906 state
|= STATE_SYSTEM_ANIMATED
;
1908 if (wxstate
& wxACC_STATE_SYSTEM_BUSY
)
1909 state
|= STATE_SYSTEM_BUSY
;
1911 if (wxstate
& wxACC_STATE_SYSTEM_CHECKED
)
1912 state
|= STATE_SYSTEM_CHECKED
;
1914 if (wxstate
& wxACC_STATE_SYSTEM_COLLAPSED
)
1915 state
|= STATE_SYSTEM_COLLAPSED
;
1917 if (wxstate
& wxACC_STATE_SYSTEM_DEFAULT
)
1918 state
|= STATE_SYSTEM_DEFAULT
;
1920 if (wxstate
& wxACC_STATE_SYSTEM_EXPANDED
)
1921 state
|= STATE_SYSTEM_EXPANDED
;
1923 if (wxstate
& wxACC_STATE_SYSTEM_EXTSELECTABLE
)
1924 state
|= STATE_SYSTEM_EXTSELECTABLE
;
1926 if (wxstate
& wxACC_STATE_SYSTEM_FLOATING
)
1927 state
|= STATE_SYSTEM_FLOATING
;
1929 if (wxstate
& wxACC_STATE_SYSTEM_FOCUSABLE
)
1930 state
|= STATE_SYSTEM_FOCUSABLE
;
1932 if (wxstate
& wxACC_STATE_SYSTEM_FOCUSED
)
1933 state
|= STATE_SYSTEM_FOCUSED
;
1935 if (wxstate
& wxACC_STATE_SYSTEM_HOTTRACKED
)
1936 state
|= STATE_SYSTEM_HOTTRACKED
;
1938 if (wxstate
& wxACC_STATE_SYSTEM_INVISIBLE
)
1939 state
|= STATE_SYSTEM_INVISIBLE
;
1941 if (wxstate
& wxACC_STATE_SYSTEM_INVISIBLE
)
1942 state
|= STATE_SYSTEM_INVISIBLE
;
1944 if (wxstate
& wxACC_STATE_SYSTEM_MIXED
)
1945 state
|= STATE_SYSTEM_MIXED
;
1947 if (wxstate
& wxACC_STATE_SYSTEM_MULTISELECTABLE
)
1948 state
|= STATE_SYSTEM_MULTISELECTABLE
;
1950 if (wxstate
& wxACC_STATE_SYSTEM_OFFSCREEN
)
1951 state
|= STATE_SYSTEM_OFFSCREEN
;
1953 if (wxstate
& wxACC_STATE_SYSTEM_PRESSED
)
1954 state
|= STATE_SYSTEM_PRESSED
;
1956 // if (wxstate & wxACC_STATE_SYSTEM_PROTECTED)
1957 // state |= STATE_SYSTEM_PROTECTED;
1959 if (wxstate
& wxACC_STATE_SYSTEM_READONLY
)
1960 state
|= STATE_SYSTEM_READONLY
;
1962 if (wxstate
& wxACC_STATE_SYSTEM_SELECTABLE
)
1963 state
|= STATE_SYSTEM_SELECTABLE
;
1965 if (wxstate
& wxACC_STATE_SYSTEM_SELECTED
)
1966 state
|= STATE_SYSTEM_SELECTED
;
1968 if (wxstate
& wxACC_STATE_SYSTEM_SELFVOICING
)
1969 state
|= STATE_SYSTEM_SELFVOICING
;
1971 if (wxstate
& wxACC_STATE_SYSTEM_UNAVAILABLE
)
1972 state
|= STATE_SYSTEM_UNAVAILABLE
;
1977 // Convert to Windows selection flag
1978 int wxConvertToWindowsSelFlag(wxAccSelectionFlags wxsel
)
1982 if (wxsel
& wxACC_SEL_TAKEFOCUS
)
1983 sel
|= SELFLAG_TAKEFOCUS
;
1984 if (wxsel
& wxACC_SEL_TAKESELECTION
)
1985 sel
|= SELFLAG_TAKESELECTION
;
1986 if (wxsel
& wxACC_SEL_EXTENDSELECTION
)
1987 sel
|= SELFLAG_EXTENDSELECTION
;
1988 if (wxsel
& wxACC_SEL_ADDSELECTION
)
1989 sel
|= SELFLAG_ADDSELECTION
;
1990 if (wxsel
& wxACC_SEL_REMOVESELECTION
)
1991 sel
|= SELFLAG_REMOVESELECTION
;
1995 // Convert from Windows selection flag
1996 wxAccSelectionFlags
wxConvertFromWindowsSelFlag(int sel
)
2000 if (sel
& SELFLAG_TAKEFOCUS
)
2001 wxsel
|= wxACC_SEL_TAKEFOCUS
;
2002 if (sel
& SELFLAG_TAKESELECTION
)
2003 wxsel
|= wxACC_SEL_TAKESELECTION
;
2004 if (sel
& SELFLAG_EXTENDSELECTION
)
2005 wxsel
|= wxACC_SEL_EXTENDSELECTION
;
2006 if (sel
& SELFLAG_ADDSELECTION
)
2007 wxsel
|= wxACC_SEL_ADDSELECTION
;
2008 if (sel
& SELFLAG_REMOVESELECTION
)
2009 wxsel
|= wxACC_SEL_REMOVESELECTION
;
2010 return (wxAccSelectionFlags
) wxsel
;
2014 #endif // wxUSE_OLE && wxUSE_ACCESSIBILITY