1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/ole/access.cpp
3 // Purpose: implementation of wxIAccessible and wxAccessible
4 // Author: Julian Smart
7 // Copyright: (c) 2003 Julian Smart
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
22 #if defined(__BORLANDC__)
26 #if wxUSE_OLE && wxUSE_ACCESSIBILITY
28 #include "wx/access.h"
31 #include "wx/msw/wrapwin.h"
32 #include "wx/window.h"
36 // for some compilers, the entire ole2.h must be included, not only oleauto.h
37 #if wxUSE_NORLANDER_HEADERS || defined(__WATCOMC__)
44 #include "wx/msw/ole/oleutils.h"
47 #define CHILDID_SELF 0
51 #define OBJID_CLIENT 0xFFFFFFFC
54 // Convert to Windows role
55 int wxConvertToWindowsRole(wxAccRole wxrole
);
57 // Convert to Windows state
58 long wxConvertToWindowsState(long wxstate
);
60 // Convert to Windows selection flag
61 int wxConvertToWindowsSelFlag(wxAccSelectionFlags sel
);
63 // Convert from Windows selection flag
64 wxAccSelectionFlags
wxConvertFromWindowsSelFlag(int sel
);
67 // ----------------------------------------------------------------------------
68 // wxIEnumVARIANT interface implementation
69 // ----------------------------------------------------------------------------
71 class wxIEnumVARIANT
: public IEnumVARIANT
74 wxIEnumVARIANT(const wxVariant
& variant
);
75 virtual ~wxIEnumVARIANT() { }
77 DECLARE_IUNKNOWN_METHODS
;
80 STDMETHODIMP
Next(ULONG celt
, VARIANT
*rgelt
, ULONG
*pceltFetched
);
81 STDMETHODIMP
Skip(ULONG celt
);
83 STDMETHODIMP
Clone(IEnumVARIANT
**ppenum
);
86 wxVariant m_variant
; // List of further variants
87 int m_nCurrent
; // Current enum position
89 wxDECLARE_NO_COPY_CLASS(wxIEnumVARIANT
);
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 BEGIN_IID_TABLE(wxIEnumVARIANT
)
101 IMPLEMENT_IUNKNOWN_METHODS(wxIEnumVARIANT
)
103 // wxVariant contains a list of further variants.
104 wxIEnumVARIANT::wxIEnumVARIANT(const wxVariant
& variant
)
109 STDMETHODIMP
wxIEnumVARIANT::Next(ULONG celt
,
113 wxLogTrace(wxTRACE_OleCalls
, wxT("wxIEnumVARIANT::Next"));
116 // we only return 1 element at a time - mainly because I'm too lazy to
117 // implement something which you're never asked for anyhow
121 if (m_variant
.GetType() != wxT("list"))
124 if ( m_nCurrent
< (int) m_variant
.GetList().GetCount() ) {
125 if (!wxConvertVariantToOle(m_variant
[m_nCurrent
++], rgelt
[0]))
130 // TODO: should we AddRef if this is an object?
141 STDMETHODIMP
wxIEnumVARIANT::Skip(ULONG celt
)
143 wxLogTrace(wxTRACE_OleCalls
, wxT("wxIEnumVARIANT::Skip"));
145 if (m_variant
.GetType() != wxT("list"))
149 if ( m_nCurrent
< (int) m_variant
.GetList().GetCount() )
152 // no, can't skip this many elements
158 STDMETHODIMP
wxIEnumVARIANT::Reset()
160 wxLogTrace(wxTRACE_OleCalls
, wxT("wxIEnumVARIANT::Reset"));
167 STDMETHODIMP
wxIEnumVARIANT::Clone(IEnumVARIANT
**ppenum
)
169 wxLogTrace(wxTRACE_OleCalls
, wxT("wxIEnumVARIANT::Clone"));
171 wxIEnumVARIANT
*pNew
= new wxIEnumVARIANT(m_variant
);
178 #endif // wxUSE_VARIANT
180 // ----------------------------------------------------------------------------
181 // wxIAccessible implementation of IAccessible interface
182 // ----------------------------------------------------------------------------
184 class wxIAccessible
: public IAccessible
187 wxIAccessible(wxAccessible
*pAccessible
);
189 // Called to indicate object should prepare to be deleted.
192 DECLARE_IUNKNOWN_METHODS
;
196 // Navigation and Hierarchy
198 // Retrieves the child element or child object at a given point on the screen.
199 // All visual objects support this method; sound objects do not support it.
201 STDMETHODIMP
accHitTest(long xLeft
, long yLeft
, VARIANT
* pVarID
);
203 // Retrieves the specified object's current screen location. All visual objects must
204 // support this method; sound objects do not support it.
206 STDMETHODIMP
accLocation ( long* pxLeft
, long* pyTop
, long* pcxWidth
, long* pcyHeight
, VARIANT varID
);
208 // Traverses to another user interface element within a container and retrieves the object.
209 // All visual objects must support this method.
211 STDMETHODIMP
accNavigate ( long navDir
, VARIANT varStart
, VARIANT
* pVarEnd
);
213 // Retrieves the address of an IDispatch interface for the specified child.
214 // All objects must support this property.
216 STDMETHODIMP
get_accChild ( VARIANT varChildID
, IDispatch
** ppDispChild
);
218 // Retrieves the number of children that belong to this object.
219 // All objects must support this property.
221 STDMETHODIMP
get_accChildCount ( long* pCountChildren
);
223 // Retrieves the IDispatch interface of the object's parent.
224 // All objects support this property.
226 STDMETHODIMP
get_accParent ( IDispatch
** ppDispParent
);
228 // Descriptive Properties and Methods
230 // Performs the object's default action. Not all objects have a default
233 STDMETHODIMP
accDoDefaultAction(VARIANT varID
);
235 // Retrieves a string that describes the object's default action.
236 // Not all objects have a default action.
238 STDMETHODIMP
get_accDefaultAction ( VARIANT varID
, BSTR
* pszDefaultAction
);
240 // Retrieves a string that describes the visual appearance of the specified object.
241 // Not all objects have a description.
243 STDMETHODIMP
get_accDescription ( VARIANT varID
, BSTR
* pszDescription
);
245 // Retrieves an object's Help property string.
246 // Not all objects support this property.
248 STDMETHODIMP
get_accHelp ( VARIANT varID
, BSTR
* pszHelp
);
250 // Retrieves the full path of the WinHelp file associated with the specified
251 // object and the identifier of the appropriate topic within that file.
252 // Not all objects support this property.
254 STDMETHODIMP
get_accHelpTopic ( BSTR
* pszHelpFile
, VARIANT varChild
, long* pidTopic
);
256 // Retrieves the specified object's shortcut key or access key, also known as
257 // the mnemonic. All objects that have a shortcut key or access key support
260 STDMETHODIMP
get_accKeyboardShortcut ( VARIANT varID
, BSTR
* pszKeyboardShortcut
);
262 // Retrieves the name of the specified object.
263 // All objects support this property.
265 STDMETHODIMP
get_accName ( VARIANT varID
, BSTR
* pszName
);
267 // Retrieves information that describes the role of the specified object.
268 // All objects support this property.
270 STDMETHODIMP
get_accRole ( VARIANT varID
, VARIANT
* pVarRole
);
272 // Retrieves the current state of the specified object.
273 // All objects support this property.
275 STDMETHODIMP
get_accState ( VARIANT varID
, VARIANT
* pVarState
);
277 // Retrieves the value of the specified object.
278 // Not all objects have a value.
280 STDMETHODIMP
get_accValue ( VARIANT varID
, BSTR
* pszValue
);
282 // Selection and Focus
284 // Modifies the selection or moves the keyboard focus of the
285 // specified object. All objects that select or receive the
286 // keyboard focus must support this method.
288 STDMETHODIMP
accSelect ( long flagsSelect
, VARIANT varID
);
290 // Retrieves the object that has the keyboard focus. All objects
291 // that receive the keyboard focus must support this property.
293 STDMETHODIMP
get_accFocus ( VARIANT
* pVarID
);
295 // Retrieves the selected children of this object. All objects
296 // selected must support this property.
298 STDMETHODIMP
get_accSelection ( VARIANT
* pVarChildren
);
302 STDMETHODIMP
put_accName(VARIANT
WXUNUSED(varChild
), BSTR
WXUNUSED(szName
)) { return E_FAIL
; }
303 STDMETHODIMP
put_accValue(VARIANT
WXUNUSED(varChild
), BSTR
WXUNUSED(szName
)) { return E_FAIL
; }
309 STDMETHODIMP
GetTypeInfo(unsigned int typeInfo
, LCID lcid
, ITypeInfo
** ppTypeInfo
);
311 // Get type info count
313 STDMETHODIMP
GetTypeInfoCount(unsigned int* typeInfoCount
);
317 STDMETHODIMP
GetIDsOfNames(REFIID riid
, OLECHAR
** names
, unsigned int cNames
,
318 LCID lcid
, DISPID
* dispId
);
322 STDMETHODIMP
Invoke(DISPID dispIdMember
, REFIID riid
, LCID lcid
,
323 WORD wFlags
, DISPPARAMS
*pDispParams
,
324 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
,
325 unsigned int *puArgErr
);
329 // Gets the standard IAccessible interface for the given child or object.
330 // Call Release if this is non-NULL.
331 IAccessible
* GetChildStdAccessible(int id
);
333 // Gets the IAccessible interface for the given child or object.
334 // Call Release if this is non-NULL.
335 IAccessible
* GetChildAccessible(int id
);
338 wxAccessible
*m_pAccessible
; // pointer to C++ class we belong to
339 bool m_bQuiescing
; // Object is to be deleted
341 wxDECLARE_NO_COPY_CLASS(wxIAccessible
);
344 // ============================================================================
346 // ============================================================================
348 // ----------------------------------------------------------------------------
349 // wxIAccessible implementation
350 // ----------------------------------------------------------------------------
351 BEGIN_IID_TABLE(wxIAccessible
)
357 IMPLEMENT_IUNKNOWN_METHODS(wxIAccessible
)
359 wxIAccessible::wxIAccessible(wxAccessible
*pAccessible
)
361 wxASSERT( pAccessible
!= NULL
);
363 m_pAccessible
= pAccessible
;
364 m_bQuiescing
= false;
367 // Called to indicate object should prepare to be deleted.
369 void wxIAccessible::Quiesce()
372 m_pAccessible
= NULL
;
375 // Retrieves the child element or child object at a given point on the screen.
376 // All visual objects support this method; sound objects do not support it.
378 STDMETHODIMP
wxIAccessible::accHitTest(long xLeft
, long yLeft
, VARIANT
* pVarID
)
380 wxLogTrace(wxT("access"), wxT("accHitTest"));
381 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
385 wxAccessible
* childObject
= NULL
;
389 wxAccStatus status
= m_pAccessible
->HitTest(wxPoint(xLeft
, yLeft
), & childId
, & childObject
);
391 if (status
== wxACC_FAIL
)
394 if (status
== wxACC_NOT_IMPLEMENTED
)
396 // Use standard interface instead.
397 IAccessible
* stdInterface
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
401 return stdInterface
->accHitTest(xLeft
, yLeft
, pVarID
);
406 if (childObject
== m_pAccessible
)
409 pVarID
->lVal
= CHILDID_SELF
;
414 wxIAccessible
* childIA
= childObject
->GetIAccessible();
418 if (childIA
->QueryInterface(IID_IDispatch
, (LPVOID
*) & pVarID
->pdispVal
) != S_OK
)
421 pVarID
->vt
= VT_DISPATCH
;
425 else if (childId
> 0)
428 pVarID
->lVal
= childId
;
433 pVarID
->vt
= VT_EMPTY
;
438 // all cases above already cause some return action so below line
439 // is unreachable and cause unnecessary warning
444 // Retrieves the specified object's current screen location. All visual objects must
445 // support this method; sound objects do not support it.
447 STDMETHODIMP
wxIAccessible::accLocation ( long* pxLeft
, long* pyTop
, long* pcxWidth
, long* pcyHeight
, VARIANT varID
)
449 wxLogTrace(wxT("access"), wxT("accLocation"));
450 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
456 wxAccStatus status
= m_pAccessible
->GetLocation(rect
, varID
.lVal
);
457 if (status
== wxACC_FAIL
)
460 if (status
== wxACC_NOT_IMPLEMENTED
)
462 // Try to use child object directly.
465 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
469 HRESULT hResult
= childAccessible
->accLocation(pxLeft
, pyTop
, pcxWidth
, pcyHeight
, varID
);
470 childAccessible
->Release();
473 else if (m_pAccessible
->GetIAccessibleStd())
474 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accLocation(pxLeft
, pyTop
, pcxWidth
, pcyHeight
, varID
);
476 else if (m_pAccessible
->GetIAccessibleStd())
477 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accLocation(pxLeft
, pyTop
, pcxWidth
, pcyHeight
, varID
);
483 *pcxWidth
= rect
.width
;
484 *pcyHeight
= rect
.height
;
491 // Traverses to another user interface element within a container and retrieves the object.
492 // All visual objects must support this method.
494 STDMETHODIMP
wxIAccessible::accNavigate ( long navDir
, VARIANT varStart
, VARIANT
* pVarEnd
)
496 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
499 wxLogTrace(wxT("access"), wxString(wxT("accNavigate for ")) + m_pAccessible
->GetWindow()->GetClassInfo()->GetClassName());
501 if ((varStart
.vt
!= VT_I4
&& varStart
.vt
!= VT_EMPTY
)
503 // according to MSDN and sources varStart.vt is unsigned
504 // so below line cause warning "Condition is always false"
509 wxLogTrace(wxT("access"), wxT("Invalid arg for accNavigate"));
513 wxAccessible
* elementObject
= NULL
;
515 VariantInit(pVarEnd
);
516 wxNavDir navDirWX
= wxNAVDIR_FIRSTCHILD
;
523 navDirWX
= wxNAVDIR_DOWN
;
524 navStr
= wxT("wxNAVDIR_DOWN");
527 case NAVDIR_FIRSTCHILD
:
528 navDirWX
= wxNAVDIR_FIRSTCHILD
;
529 navStr
= wxT("wxNAVDIR_FIRSTCHILD");
532 case NAVDIR_LASTCHILD
:
533 navDirWX
= wxNAVDIR_LASTCHILD
;
534 navStr
= wxT("wxNAVDIR_LASTCHILD");
538 navDirWX
= wxNAVDIR_LEFT
;
539 navStr
= wxT("wxNAVDIR_LEFT");
543 navDirWX
= wxNAVDIR_NEXT
;
544 navStr
= wxT("wxNAVDIR_NEXT");
547 case NAVDIR_PREVIOUS
:
548 navDirWX
= wxNAVDIR_PREVIOUS
;
549 navStr
= wxT("wxNAVDIR_PREVIOUS");
553 navDirWX
= wxNAVDIR_RIGHT
;
554 navStr
= wxT("wxNAVDIR_RIGHT");
558 navDirWX
= wxNAVDIR_UP
;
559 navStr
= wxT("wxNAVDIR_UP");
563 wxLogTrace(wxT("access"), wxT("Unknown NAVDIR symbol"));
567 wxLogTrace(wxT("access"), navStr
);
569 wxAccStatus status
= m_pAccessible
->Navigate(navDirWX
, varStart
.lVal
, & elementId
,
572 if (status
== wxACC_FAIL
)
574 wxLogTrace(wxT("access"), wxT("wxAccessible::Navigate failed"));
578 if (status
== wxACC_FALSE
)
580 wxLogTrace(wxT("access"), wxT("wxAccessible::Navigate found no object in this direction"));
584 if (status
== wxACC_NOT_IMPLEMENTED
)
586 wxLogTrace(wxT("access"), wxT("Navigate not implemented"));
588 // Try to use child object directly.
589 if (varStart
.vt
== VT_I4
&& varStart
.lVal
> 0)
591 IAccessible
* childAccessible
= GetChildAccessible(varStart
.lVal
);
595 HRESULT hResult
= childAccessible
->accNavigate(navDir
, varStart
, pVarEnd
);
596 childAccessible
->Release();
599 else if (m_pAccessible
->GetIAccessibleStd())
600 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accNavigate(navDir
, varStart
, pVarEnd
);
602 else if (m_pAccessible
->GetIAccessibleStd())
603 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accNavigate(navDir
, varStart
, pVarEnd
);
609 wxLogTrace(wxT("access"), wxT("Getting wxIAccessible and calling QueryInterface for Navigate"));
610 wxIAccessible
* objectIA
= elementObject
->GetIAccessible();
613 wxLogTrace(wxT("access"), wxT("No wxIAccessible"));
617 HRESULT hResult
= objectIA
->QueryInterface(IID_IDispatch
, (LPVOID
*) & pVarEnd
->pdispVal
);
620 wxLogTrace(wxT("access"), wxT("QueryInterface failed"));
624 wxLogTrace(wxT("access"), wxT("Called QueryInterface for Navigate"));
625 pVarEnd
->vt
= VT_DISPATCH
;
628 else if (elementId
> 0)
630 wxLogTrace(wxT("access"), wxT("Returning element id from Navigate"));
632 pVarEnd
->lVal
= elementId
;
637 wxLogTrace(wxT("access"), wxT("No object in accNavigate"));
638 pVarEnd
->vt
= VT_EMPTY
;
643 wxLogTrace(wxT("access"), wxT("Failing Navigate"));
647 // Retrieves the address of an IDispatch interface for the specified child.
648 // All objects must support this property.
650 STDMETHODIMP
wxIAccessible::get_accChild ( VARIANT varChildID
, IDispatch
** ppDispChild
)
652 wxLogTrace(wxT("access"), wxT("get_accChild"));
653 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
657 if (varChildID
.vt
!= VT_I4
)
659 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accChild"));
663 if (varChildID
.lVal
== CHILDID_SELF
)
670 wxAccessible
* child
= NULL
;
672 wxAccStatus status
= m_pAccessible
->GetChild(varChildID
.lVal
, & child
);
673 if (status
== wxACC_FAIL
)
675 wxLogTrace(wxT("access"), wxT("GetChild failed"));
679 if (status
== wxACC_NOT_IMPLEMENTED
)
681 // Use standard interface instead.
682 IAccessible
* stdInterface
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
687 wxLogTrace(wxT("access"), wxT("Using standard interface for get_accChild"));
688 return stdInterface
->get_accChild (varChildID
, ppDispChild
);
695 wxIAccessible
* objectIA
= child
->GetIAccessible();
699 if (objectIA
->QueryInterface(IID_IDispatch
, (LPVOID
*) ppDispChild
) != S_OK
)
701 wxLogTrace(wxT("access"), wxT("QueryInterface failed in get_accChild"));
709 wxLogTrace(wxT("access"), wxT("Not an accessible object"));
710 return S_FALSE
; // Indicates it's not an accessible object
715 // all cases above already cause some return action so below line
716 // is unreachable and cause unnecessary warning
721 // Retrieves the number of children that belong to this object.
722 // All objects must support this property.
724 STDMETHODIMP
wxIAccessible::get_accChildCount ( long* pCountChildren
)
726 wxLogTrace(wxT("access"), wxT("get_accChildCount"));
727 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
732 wxAccStatus status
= m_pAccessible
->GetChildCount(& childCount
);
733 if (status
== wxACC_FAIL
)
736 if (status
== wxACC_NOT_IMPLEMENTED
)
738 // Use standard interface instead.
739 IAccessible
* stdInterface
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
744 wxLogTrace(wxT("access"), wxT("Using standard interface for get_accChildCount"));
745 HRESULT res
= stdInterface
->get_accChildCount (pCountChildren
);
747 str
.Printf(wxT("Number of children was %d"), (int) (*pCountChildren
));
748 wxLogTrace(wxT("access"), str
);
754 * pCountChildren
= (long) childCount
;
759 // all cases above already cause some return action so below line
760 // is unreachable and cause unnecessary warning
765 // Retrieves the IDispatch interface of the object's parent.
766 // All objects support this property.
768 STDMETHODIMP
wxIAccessible::get_accParent ( IDispatch
** ppDispParent
)
770 wxLogTrace(wxT("access"), wxT("get_accParent"));
771 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
775 wxAccessible
* parent
= NULL
;
776 wxAccStatus status
= m_pAccessible
->GetParent(& parent
);
778 if (status
== wxACC_FAIL
)
781 // It doesn't seem acceptable to return S_FALSE with a NULL
782 // ppDispParent, so if we have no wxWidgets parent, we leave
783 // it to the standard interface.
784 if (status
== wxACC_NOT_IMPLEMENTED
|| !parent
)
786 wxLogTrace(wxT("access"), wxT("Using standard interface to get the parent."));
787 // Use standard interface instead.
788 IAccessible
* stdInterface
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
792 return stdInterface
->get_accParent (ppDispParent
);
798 wxIAccessible
* objectIA
= parent
->GetIAccessible();
802 wxLogTrace(wxT("access"), wxT("About to call QueryInterface"));
803 if (objectIA
->QueryInterface(IID_IDispatch
, (LPVOID
*) ppDispParent
) != S_OK
)
805 wxLogTrace(wxT("access"), wxT("Failed QueryInterface"));
809 wxLogTrace(wxT("access"), wxT("Returning S_OK for get_accParent"));
814 // This doesn't seem to be allowed, despite the documentation,
815 // so we handle it higher up by using the standard interface.
816 wxLogTrace(wxT("access"), wxT("Returning NULL parent because there was none"));
817 *ppDispParent
= NULL
;
823 // all cases above already cause some return action so below line
824 // is unreachable and cause unnecessary warning
829 // Performs the object's default action. Not all objects have a default
832 STDMETHODIMP
wxIAccessible::accDoDefaultAction(VARIANT varID
)
834 wxLogTrace(wxT("access"), wxT("accDoDefaultAction"));
835 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
839 if (varID
.vt
!= VT_I4
)
841 wxLogTrace(wxT("access"), wxT("Invalid arg for accDoDefaultAction"));
845 wxAccStatus status
= m_pAccessible
->DoDefaultAction(varID
.lVal
);
846 if (status
== wxACC_FAIL
)
849 if (status
== wxACC_NOT_SUPPORTED
)
850 return DISP_E_MEMBERNOTFOUND
;
852 if (status
== wxACC_NOT_IMPLEMENTED
)
854 // Try to use child object directly.
857 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
861 HRESULT hResult
= childAccessible
->accDoDefaultAction(varID
);
862 childAccessible
->Release();
865 else if (m_pAccessible
->GetIAccessibleStd())
866 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accDoDefaultAction(varID
);
868 else if (m_pAccessible
->GetIAccessibleStd())
869 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accDoDefaultAction(varID
);
874 // Retrieves a string that describes the object's default action.
875 // Not all objects have a default action.
877 STDMETHODIMP
wxIAccessible::get_accDefaultAction ( VARIANT varID
, BSTR
* pszDefaultAction
)
879 wxLogTrace(wxT("access"), wxT("get_accDefaultAction"));
880 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
884 if (varID
.vt
!= VT_I4
)
886 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accDefaultAction"));
890 wxString defaultAction
;
891 wxAccStatus status
= m_pAccessible
->GetDefaultAction(varID
.lVal
, & defaultAction
);
892 if (status
== wxACC_FAIL
)
895 if (status
== wxACC_NOT_SUPPORTED
)
896 return DISP_E_MEMBERNOTFOUND
;
898 if (status
== wxACC_NOT_IMPLEMENTED
)
900 // Try to use child object directly.
903 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
907 HRESULT hResult
= childAccessible
->get_accDefaultAction(varID
, pszDefaultAction
);
908 childAccessible
->Release();
911 else if (m_pAccessible
->GetIAccessibleStd())
912 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accDefaultAction(varID
, pszDefaultAction
);
914 else if (m_pAccessible
->GetIAccessibleStd())
915 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accDefaultAction(varID
, pszDefaultAction
);
919 if (defaultAction
.IsEmpty())
921 * pszDefaultAction
= NULL
;
926 wxBasicString
basicString(defaultAction
);
927 * pszDefaultAction
= basicString
.Get();
934 // Retrieves a string that describes the visual appearance of the specified object.
935 // Not all objects have a description.
937 STDMETHODIMP
wxIAccessible::get_accDescription ( VARIANT varID
, BSTR
* pszDescription
)
939 wxLogTrace(wxT("access"), wxT("get_accDescription"));
940 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
944 if (varID
.vt
!= VT_I4
)
946 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accDescription"));
950 wxString description
;
951 wxAccStatus status
= m_pAccessible
->GetDescription(varID
.lVal
, & description
);
952 if (status
== wxACC_FAIL
)
955 if (status
== wxACC_NOT_IMPLEMENTED
)
957 // Try to use child object directly.
960 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
964 HRESULT hResult
= childAccessible
->get_accDescription(varID
, pszDescription
);
965 childAccessible
->Release();
968 else if (m_pAccessible
->GetIAccessibleStd())
969 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accDescription(varID
, pszDescription
);
971 else if (m_pAccessible
->GetIAccessibleStd())
972 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accDescription(varID
, pszDescription
);
976 if (description
.empty())
978 * pszDescription
= NULL
;
983 wxBasicString
basicString(description
);
984 * pszDescription
= basicString
.Get();
991 // Retrieves an object's Help property string.
992 // Not all objects support this property.
994 STDMETHODIMP
wxIAccessible::get_accHelp ( VARIANT varID
, BSTR
* pszHelp
)
996 wxLogTrace(wxT("access"), wxT("get_accHelp"));
997 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1001 if (varID
.vt
!= VT_I4
)
1003 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accHelp"));
1004 return E_INVALIDARG
;
1007 wxString helpString
;
1008 wxAccStatus status
= m_pAccessible
->GetHelpText(varID
.lVal
, & helpString
);
1009 if (status
== wxACC_FAIL
)
1012 if (status
== wxACC_NOT_IMPLEMENTED
)
1014 // Try to use child object directly.
1017 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1018 if (childAccessible
)
1021 HRESULT hResult
= childAccessible
->get_accHelp(varID
, pszHelp
);
1022 childAccessible
->Release();
1025 else if (m_pAccessible
->GetIAccessibleStd())
1026 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accHelp(varID
, pszHelp
);
1028 else if (m_pAccessible
->GetIAccessibleStd())
1029 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accHelp (varID
, pszHelp
);
1033 if (helpString
.empty())
1040 wxBasicString
basicString(helpString
);
1041 * pszHelp
= basicString
.Get();
1048 // Retrieves the full path of the WinHelp file associated with the specified
1049 // object and the identifier of the appropriate topic within that file.
1050 // Not all objects support this property.
1051 // NOTE: not supported by wxWidgets at this time. Use
1052 // GetHelpText instead.
1054 STDMETHODIMP
wxIAccessible::get_accHelpTopic ( BSTR
* pszHelpFile
, VARIANT varChild
, long* pidTopic
)
1056 wxLogTrace(wxT("access"), wxT("get_accHelpTopic"));
1057 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1061 if (varChild
.vt
!= VT_I4
)
1063 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accHelpTopic"));
1064 return E_INVALIDARG
;
1067 wxAccStatus status
= wxACC_NOT_IMPLEMENTED
;
1068 if (status
== wxACC_FAIL
)
1071 if (status
== wxACC_NOT_IMPLEMENTED
)
1073 // Try to use child object directly.
1074 if (varChild
.lVal
> 0)
1076 IAccessible
* childAccessible
= GetChildAccessible(varChild
.lVal
);
1077 if (childAccessible
)
1080 HRESULT hResult
= childAccessible
->get_accHelpTopic(pszHelpFile
, varChild
, pidTopic
);
1081 childAccessible
->Release();
1084 else if (m_pAccessible
->GetIAccessibleStd())
1085 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accHelpTopic(pszHelpFile
, varChild
, pidTopic
);
1087 else if (m_pAccessible
->GetIAccessibleStd())
1088 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accHelpTopic (pszHelpFile
, varChild
, pidTopic
);
1093 // Retrieves the specified object's shortcut key or access key, also known as
1094 // the mnemonic. All objects that have a shortcut key or access key support
1097 STDMETHODIMP
wxIAccessible::get_accKeyboardShortcut ( VARIANT varID
, BSTR
* pszKeyboardShortcut
)
1099 wxLogTrace(wxT("access"), wxT("get_accKeyboardShortcut"));
1100 *pszKeyboardShortcut
= NULL
;
1102 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1106 if (varID
.vt
!= VT_I4
)
1108 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accKeyboardShortcut"));
1109 return E_INVALIDARG
;
1112 wxString keyboardShortcut
;
1113 wxAccStatus status
= m_pAccessible
->GetKeyboardShortcut(varID
.lVal
, & keyboardShortcut
);
1114 if (status
== wxACC_FAIL
)
1117 if (status
== wxACC_NOT_IMPLEMENTED
)
1119 // Try to use child object directly.
1122 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1123 if (childAccessible
)
1126 HRESULT hResult
= childAccessible
->get_accKeyboardShortcut(varID
, pszKeyboardShortcut
);
1127 childAccessible
->Release();
1130 else if (m_pAccessible
->GetIAccessibleStd())
1131 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accKeyboardShortcut(varID
, pszKeyboardShortcut
);
1133 else if (m_pAccessible
->GetIAccessibleStd())
1134 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accKeyboardShortcut (varID
, pszKeyboardShortcut
);
1138 if (keyboardShortcut
.empty())
1140 * pszKeyboardShortcut
= NULL
;
1145 wxBasicString
basicString(keyboardShortcut
);
1146 * pszKeyboardShortcut
= basicString
.Get();
1153 // Retrieves the name of the specified object.
1154 // All objects support this property.
1156 STDMETHODIMP
wxIAccessible::get_accName ( VARIANT varID
, BSTR
* pszName
)
1158 wxLogTrace(wxT("access"), wxT("get_accName"));
1161 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1165 if (varID
.vt
!= VT_I4
)
1167 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accName"));
1168 return E_INVALIDARG
;
1173 wxAccStatus status
= m_pAccessible
->GetName(varID
.lVal
, & name
);
1175 if (status
== wxACC_FAIL
)
1178 if (status
== wxACC_NOT_IMPLEMENTED
)
1180 // Try to use child object directly.
1183 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1184 if (childAccessible
)
1187 HRESULT hResult
= childAccessible
->get_accName(varID
, pszName
);
1188 childAccessible
->Release();
1191 else if (m_pAccessible
->GetIAccessibleStd())
1192 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accName(varID
, pszName
);
1194 else if (m_pAccessible
->GetIAccessibleStd())
1195 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accName (varID
, pszName
);
1199 wxBasicString
basicString(name
);
1200 *pszName
= basicString
.Get();
1206 // Retrieves information that describes the role of the specified object.
1207 // All objects support this property.
1209 STDMETHODIMP
wxIAccessible::get_accRole ( VARIANT varID
, VARIANT
* pVarRole
)
1211 wxLogTrace(wxT("access"), wxT("get_accRole"));
1212 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1216 if (varID
.vt
!= VT_I4
)
1218 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accRole"));
1219 return E_INVALIDARG
;
1222 VariantInit(pVarRole
);
1224 wxAccRole role
= wxROLE_NONE
;
1226 wxAccStatus status
= m_pAccessible
->GetRole(varID
.lVal
, & role
);
1228 if (status
== wxACC_FAIL
)
1231 if (status
== wxACC_NOT_IMPLEMENTED
)
1233 // Try to use child object directly.
1236 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1237 if (childAccessible
)
1240 HRESULT hResult
= childAccessible
->get_accRole(varID
, pVarRole
);
1241 childAccessible
->Release();
1244 else if (m_pAccessible
->GetIAccessibleStd())
1245 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accRole(varID
, pVarRole
);
1247 else if (m_pAccessible
->GetIAccessibleStd())
1248 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accRole (varID
, pVarRole
);
1252 if (role
== wxROLE_NONE
)
1254 pVarRole
->vt
= VT_EMPTY
;
1258 pVarRole
->lVal
= wxConvertToWindowsRole(role
);
1259 pVarRole
->vt
= VT_I4
;
1266 // Retrieves the current state of the specified object.
1267 // All objects support this property.
1269 STDMETHODIMP
wxIAccessible::get_accState ( VARIANT varID
, VARIANT
* pVarState
)
1271 wxLogTrace(wxT("access"), wxT("get_accState"));
1272 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1276 if (varID
.vt
!= VT_I4
&& varID
.vt
!= VT_EMPTY
)
1278 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accState"));
1279 return E_INVALIDARG
;
1284 wxAccStatus status
= m_pAccessible
->GetState(varID
.lVal
, & wxstate
);
1285 if (status
== wxACC_FAIL
)
1288 if (status
== wxACC_NOT_IMPLEMENTED
)
1290 // Try to use child object directly.
1293 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1294 if (childAccessible
)
1297 HRESULT hResult
= childAccessible
->get_accState(varID
, pVarState
);
1298 childAccessible
->Release();
1301 else if (m_pAccessible
->GetIAccessibleStd())
1302 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accState(varID
, pVarState
);
1304 else if (m_pAccessible
->GetIAccessibleStd())
1305 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accState (varID
, pVarState
);
1309 long state
= wxConvertToWindowsState(wxstate
);
1310 pVarState
->lVal
= state
;
1311 pVarState
->vt
= VT_I4
;
1317 // Retrieves the value of the specified object.
1318 // Not all objects have a value.
1320 STDMETHODIMP
wxIAccessible::get_accValue ( VARIANT varID
, BSTR
* pszValue
)
1322 wxLogTrace(wxT("access"), wxT("get_accValue"));
1323 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1327 if (varID
.vt
!= VT_I4
)
1329 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accValue"));
1330 return E_INVALIDARG
;
1335 wxAccStatus status
= m_pAccessible
->GetValue(varID
.lVal
, & strValue
);
1337 if (status
== wxACC_FAIL
)
1340 if (status
== wxACC_NOT_IMPLEMENTED
)
1342 // Try to use child object directly.
1345 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1346 if (childAccessible
)
1349 HRESULT hResult
= childAccessible
->get_accValue(varID
, pszValue
);
1350 childAccessible
->Release();
1353 else if (m_pAccessible
->GetIAccessibleStd())
1354 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accValue(varID
, pszValue
);
1356 else if (m_pAccessible
->GetIAccessibleStd())
1357 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->get_accValue (varID
, pszValue
);
1361 wxBasicString
basicString(strValue
);
1362 * pszValue
= basicString
.Get();
1368 // Modifies the selection or moves the keyboard focus of the
1369 // specified object. All objects that select or receive the
1370 // keyboard focus must support this method.
1372 STDMETHODIMP
wxIAccessible::accSelect ( long flagsSelect
, VARIANT varID
)
1374 wxLogTrace(wxT("access"), wxT("get_accSelect"));
1375 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1379 if (varID
.vt
!= VT_I4
&& varID
.vt
!= VT_EMPTY
)
1381 wxLogTrace(wxT("access"), wxT("Invalid arg for accSelect"));
1382 return E_INVALIDARG
;
1385 wxAccSelectionFlags wxsel
= wxConvertFromWindowsSelFlag(flagsSelect
);
1387 wxAccStatus status
= m_pAccessible
->Select(varID
.lVal
, wxsel
);
1388 if (status
== wxACC_FAIL
)
1391 if (status
== wxACC_NOT_IMPLEMENTED
)
1393 // Try to use child object directly.
1394 if (varID
.lVal
> 0 && varID
.lVal
> 0)
1396 IAccessible
* childAccessible
= GetChildAccessible(varID
.lVal
);
1397 if (childAccessible
)
1400 HRESULT hResult
= childAccessible
->accSelect(flagsSelect
, varID
);
1401 childAccessible
->Release();
1404 else if (m_pAccessible
->GetIAccessibleStd())
1405 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accSelect(flagsSelect
, varID
);
1407 else if (m_pAccessible
->GetIAccessibleStd())
1408 return ((IAccessible
*) m_pAccessible
->GetIAccessibleStd())->accSelect(flagsSelect
, varID
);
1416 // Retrieves the object that has the keyboard focus. All objects
1417 // that receive the keyboard focus must support this property.
1419 STDMETHODIMP
wxIAccessible::get_accFocus ( VARIANT
* pVarID
)
1421 wxLogTrace(wxT("access"), wxT("get_accFocus"));
1422 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1426 wxAccessible
* childObject
= NULL
;
1428 VariantInit(pVarID
);
1430 wxAccStatus status
= m_pAccessible
->GetFocus(& childId
, & childObject
);
1431 if (status
== wxACC_FAIL
)
1434 if (status
== wxACC_NOT_IMPLEMENTED
)
1436 // Use standard interface instead.
1437 IAccessible
* stdInterface
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
1441 return stdInterface
->get_accFocus (pVarID
);
1445 if (childObject
== m_pAccessible
)
1448 pVarID
->lVal
= CHILDID_SELF
;
1452 wxIAccessible
* childIA
= childObject
->GetIAccessible();
1456 if (childIA
->QueryInterface(IID_IDispatch
, (LPVOID
*) & pVarID
->pdispVal
) != S_OK
)
1459 pVarID
->vt
= VT_DISPATCH
;
1463 else if (childId
> 0)
1466 pVarID
->lVal
= childId
;
1471 pVarID
->vt
= VT_EMPTY
;
1476 // all cases above already cause some return action so below line
1477 // is unreachable and cause unnecessary warning
1482 // Retrieves the selected children of this object. All objects
1483 // selected must support this property.
1485 STDMETHODIMP
wxIAccessible::get_accSelection ( VARIANT
* pVarChildren
)
1488 wxLogTrace(wxT("access"), wxT("get_accSelection"));
1489 wxASSERT( ( m_pAccessible
!= NULL
) || ( m_bQuiescing
== true ) );
1493 VariantInit(pVarChildren
);
1495 wxVariant selections
;
1496 wxAccStatus status
= m_pAccessible
->GetSelections(& selections
);
1497 if (status
== wxACC_FAIL
)
1500 if (status
== wxACC_NOT_IMPLEMENTED
)
1502 // Use standard interface instead.
1503 IAccessible
* stdInterface
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
1507 return stdInterface
->get_accSelection (pVarChildren
);
1511 if (selections
.GetType() == wxT("long"))
1513 pVarChildren
->vt
= VT_I4
;
1514 pVarChildren
->lVal
= selections
.GetLong();
1518 else if (selections
.GetType() == wxT("void*"))
1520 wxAccessible
* childObject
= (wxAccessible
*) selections
.GetVoidPtr();
1521 wxIAccessible
* childIA
= childObject
->GetIAccessible();
1525 if (childIA
->QueryInterface(IID_IDispatch
, (LPVOID
*) & pVarChildren
->pdispVal
) != S_OK
)
1528 pVarChildren
->vt
= VT_DISPATCH
;
1532 else if (selections
.GetType() == wxT("list"))
1534 // TODO: should we AddRef for every "void*" member??
1536 wxIEnumVARIANT
* enumVariant
= new wxIEnumVARIANT(selections
);
1537 enumVariant
->AddRef();
1539 pVarChildren
->vt
= VT_UNKNOWN
;
1540 pVarChildren
->punkVal
= enumVariant
;
1546 wxUnusedVar(pVarChildren
);
1547 #endif // wxUSE_VARIANT
1554 STDMETHODIMP
wxIAccessible::GetTypeInfo(unsigned int WXUNUSED(typeInfo
), LCID
WXUNUSED(lcid
), ITypeInfo
** ppTypeInfo
)
1560 // Get type info count
1562 STDMETHODIMP
wxIAccessible::GetTypeInfoCount(unsigned int* typeInfoCount
)
1570 STDMETHODIMP
wxIAccessible::GetIDsOfNames(REFIID
WXUNUSED(riid
), OLECHAR
** WXUNUSED(names
), unsigned int WXUNUSED(cNames
),
1571 LCID
WXUNUSED(lcid
), DISPID
* WXUNUSED(dispId
))
1578 STDMETHODIMP
wxIAccessible::Invoke(DISPID
WXUNUSED(dispIdMember
), REFIID
WXUNUSED(riid
), LCID
WXUNUSED(lcid
),
1579 WORD
WXUNUSED(wFlags
), DISPPARAMS
*WXUNUSED(pDispParams
),
1580 VARIANT
*WXUNUSED(pVarResult
), EXCEPINFO
*WXUNUSED(pExcepInfo
),
1581 unsigned int *WXUNUSED(puArgErr
) )
1586 // Gets the standard IAccessible interface for the given child or object.
1587 // Call Release if this is non-NULL.
1588 IAccessible
* wxIAccessible::GetChildStdAccessible(int id
)
1592 IAccessible
* obj
= (IAccessible
*)m_pAccessible
->GetIAccessibleStd();
1603 IDispatch
* pDispatch
= NULL
;
1604 if (S_OK
== get_accChild ( var
, & pDispatch
))
1606 IAccessible
* childAccessible
= NULL
;
1607 if (pDispatch
->QueryInterface(IID_IAccessible
, (LPVOID
*) & childAccessible
) == S_OK
)
1609 pDispatch
->Release();
1610 wxIAccessible
* c
= (wxIAccessible
*) childAccessible
;
1611 IAccessible
* stdChildAccessible
= (IAccessible
*) c
->m_pAccessible
->GetIAccessibleStd();
1612 stdChildAccessible
->AddRef();
1613 childAccessible
->Release();
1614 return stdChildAccessible
;
1618 pDispatch
->Release();
1625 // Loop until we find the right id
1627 this->get_accChildCount(& nChildren
);
1630 for (i
= 0; i
< nChildren
; i
++)
1636 if (S_OK
== AccessibleChildren(this, i
, 1, & var
, &obtained
))
1641 var
.vt
= VT_DISPATCH
;
1642 if (S_OK
== AccessibleChildren(this, i
, 1, & var
, &obtained
))
1644 IAccessible
* childAccessible
= NULL
;
1645 if (var
.pdispVal
->QueryInterface(IID_IAccessible
, (LPVOID
*) & childAccessible
) == S_OK
)
1647 var
.pdispVal
->Release();
1648 return childAccessible
;
1652 var
.pdispVal
->Release();
1664 // Gets the IAccessible interface for the given child or object.
1665 // Call Release if this is non-NULL.
1666 IAccessible
* wxIAccessible::GetChildAccessible(int id
)
1670 IAccessible
* obj
= this;
1681 IDispatch
* pDispatch
= NULL
;
1682 if (S_OK
== get_accChild ( var
, & pDispatch
))
1684 IAccessible
* childAccessible
= NULL
;
1685 if (pDispatch
->QueryInterface(IID_IAccessible
, (LPVOID
*) & childAccessible
) == S_OK
)
1687 pDispatch
->Release();
1688 return childAccessible
;
1692 pDispatch
->Release();
1699 // ----------------------------------------------------------------------------
1700 // wxAccessible implementation
1701 // ----------------------------------------------------------------------------
1705 // common part of all ctors
1706 void wxAccessible::Init()
1708 m_pIAccessibleStd
= NULL
;
1709 m_pIAccessible
= new wxIAccessible(this);
1710 m_pIAccessible
->AddRef();
1713 wxAccessible::wxAccessible(wxWindow
* win
)
1714 : wxAccessibleBase(win
)
1719 wxAccessible::~wxAccessible()
1721 m_pIAccessible
->Quiesce();
1722 m_pIAccessible
->Release();
1723 if (m_pIAccessibleStd
)
1724 ((IAccessible
*)m_pIAccessibleStd
)->Release();
1727 // Gets or creates a standard interface for this object.
1728 void* wxAccessible::GetIAccessibleStd()
1730 if (m_pIAccessibleStd
)
1731 return m_pIAccessibleStd
;
1735 HRESULT retCode
= ::CreateStdAccessibleObject((HWND
) GetWindow()->GetHWND(),
1736 OBJID_CLIENT
, IID_IAccessible
, (void**) & m_pIAccessibleStd
);
1737 if (retCode
== S_OK
)
1738 return m_pIAccessibleStd
;
1741 m_pIAccessibleStd
= NULL
;
1748 // Sends an event when something changes in an accessible object.
1749 void wxAccessible::NotifyEvent(int eventType
, wxWindow
* window
, wxAccObject objectType
,
1752 ::NotifyWinEvent((DWORD
) eventType
, (HWND
) window
->GetHWND(),
1753 (LONG
) objectType
, (LONG
) objectId
);
1758 // Convert to Windows role
1759 int wxConvertToWindowsRole(wxAccRole wxrole
)
1765 case wxROLE_SYSTEM_ALERT
:
1766 return ROLE_SYSTEM_ALERT
;
1767 case wxROLE_SYSTEM_ANIMATION
:
1768 return ROLE_SYSTEM_ANIMATION
;
1769 case wxROLE_SYSTEM_APPLICATION
:
1770 return ROLE_SYSTEM_APPLICATION
;
1771 case wxROLE_SYSTEM_BORDER
:
1772 return ROLE_SYSTEM_BORDER
;
1773 case wxROLE_SYSTEM_BUTTONDROPDOWN
:
1774 return ROLE_SYSTEM_BUTTONDROPDOWN
;
1775 case wxROLE_SYSTEM_BUTTONDROPDOWNGRID
:
1776 return ROLE_SYSTEM_BUTTONDROPDOWNGRID
;
1777 case wxROLE_SYSTEM_BUTTONMENU
:
1778 return ROLE_SYSTEM_BUTTONMENU
;
1779 case wxROLE_SYSTEM_CARET
:
1780 return ROLE_SYSTEM_CARET
;
1781 case wxROLE_SYSTEM_CELL
:
1782 return ROLE_SYSTEM_CELL
;
1783 case wxROLE_SYSTEM_CHARACTER
:
1784 return ROLE_SYSTEM_CHARACTER
;
1785 case wxROLE_SYSTEM_CHART
:
1786 return ROLE_SYSTEM_CHART
;
1787 case wxROLE_SYSTEM_CHECKBUTTON
:
1788 return ROLE_SYSTEM_CHECKBUTTON
;
1789 case wxROLE_SYSTEM_CLIENT
:
1790 return ROLE_SYSTEM_CLIENT
;
1791 case wxROLE_SYSTEM_CLOCK
:
1792 return ROLE_SYSTEM_CLOCK
;
1793 case wxROLE_SYSTEM_COLUMN
:
1794 return ROLE_SYSTEM_COLUMN
;
1795 case wxROLE_SYSTEM_COLUMNHEADER
:
1796 return ROLE_SYSTEM_COLUMNHEADER
;
1797 case wxROLE_SYSTEM_COMBOBOX
:
1798 return ROLE_SYSTEM_COMBOBOX
;
1799 case wxROLE_SYSTEM_CURSOR
:
1800 return ROLE_SYSTEM_CURSOR
;
1801 case wxROLE_SYSTEM_DIAGRAM
:
1802 return ROLE_SYSTEM_DIAGRAM
;
1803 case wxROLE_SYSTEM_DIAL
:
1804 return ROLE_SYSTEM_DIAL
;
1805 case wxROLE_SYSTEM_DIALOG
:
1806 return ROLE_SYSTEM_DIALOG
;
1807 case wxROLE_SYSTEM_DOCUMENT
:
1808 return ROLE_SYSTEM_DOCUMENT
;
1809 case wxROLE_SYSTEM_DROPLIST
:
1810 return ROLE_SYSTEM_DROPLIST
;
1811 case wxROLE_SYSTEM_EQUATION
:
1812 return ROLE_SYSTEM_EQUATION
;
1813 case wxROLE_SYSTEM_GRAPHIC
:
1814 return ROLE_SYSTEM_GRAPHIC
;
1815 case wxROLE_SYSTEM_GRIP
:
1816 return ROLE_SYSTEM_GRIP
;
1817 case wxROLE_SYSTEM_GROUPING
:
1818 return ROLE_SYSTEM_GROUPING
;
1819 case wxROLE_SYSTEM_HELPBALLOON
:
1820 return ROLE_SYSTEM_HELPBALLOON
;
1821 case wxROLE_SYSTEM_HOTKEYFIELD
:
1822 return ROLE_SYSTEM_HOTKEYFIELD
;
1823 case wxROLE_SYSTEM_INDICATOR
:
1824 return ROLE_SYSTEM_INDICATOR
;
1825 case wxROLE_SYSTEM_LINK
:
1826 return ROLE_SYSTEM_LINK
;
1827 case wxROLE_SYSTEM_LIST
:
1828 return ROLE_SYSTEM_LIST
;
1829 case wxROLE_SYSTEM_LISTITEM
:
1830 return ROLE_SYSTEM_LISTITEM
;
1831 case wxROLE_SYSTEM_MENUBAR
:
1832 return ROLE_SYSTEM_MENUBAR
;
1833 case wxROLE_SYSTEM_MENUITEM
:
1834 return ROLE_SYSTEM_MENUITEM
;
1835 case wxROLE_SYSTEM_MENUPOPUP
:
1836 return ROLE_SYSTEM_MENUPOPUP
;
1837 case wxROLE_SYSTEM_OUTLINE
:
1838 return ROLE_SYSTEM_OUTLINE
;
1839 case wxROLE_SYSTEM_OUTLINEITEM
:
1840 return ROLE_SYSTEM_OUTLINEITEM
;
1841 case wxROLE_SYSTEM_PAGETAB
:
1842 return ROLE_SYSTEM_PAGETAB
;
1843 case wxROLE_SYSTEM_PAGETABLIST
:
1844 return ROLE_SYSTEM_PAGETABLIST
;
1845 case wxROLE_SYSTEM_PANE
:
1846 return ROLE_SYSTEM_PANE
;
1847 case wxROLE_SYSTEM_PROGRESSBAR
:
1848 return ROLE_SYSTEM_PROGRESSBAR
;
1849 case wxROLE_SYSTEM_PROPERTYPAGE
:
1850 return ROLE_SYSTEM_PROPERTYPAGE
;
1851 case wxROLE_SYSTEM_PUSHBUTTON
:
1852 return ROLE_SYSTEM_PUSHBUTTON
;
1853 case wxROLE_SYSTEM_RADIOBUTTON
:
1854 return ROLE_SYSTEM_RADIOBUTTON
;
1855 case wxROLE_SYSTEM_ROW
:
1856 return ROLE_SYSTEM_ROW
;
1857 case wxROLE_SYSTEM_ROWHEADER
:
1858 return ROLE_SYSTEM_ROWHEADER
;
1859 case wxROLE_SYSTEM_SCROLLBAR
:
1860 return ROLE_SYSTEM_SCROLLBAR
;
1861 case wxROLE_SYSTEM_SEPARATOR
:
1862 return ROLE_SYSTEM_SEPARATOR
;
1863 case wxROLE_SYSTEM_SLIDER
:
1864 return ROLE_SYSTEM_SLIDER
;
1865 case wxROLE_SYSTEM_SOUND
:
1866 return ROLE_SYSTEM_SOUND
;
1867 case wxROLE_SYSTEM_SPINBUTTON
:
1868 return ROLE_SYSTEM_SPINBUTTON
;
1869 case wxROLE_SYSTEM_STATICTEXT
:
1870 return ROLE_SYSTEM_STATICTEXT
;
1871 case wxROLE_SYSTEM_STATUSBAR
:
1872 return ROLE_SYSTEM_STATUSBAR
;
1873 case wxROLE_SYSTEM_TABLE
:
1874 return ROLE_SYSTEM_TABLE
;
1875 case wxROLE_SYSTEM_TEXT
:
1876 return ROLE_SYSTEM_TEXT
;
1877 case wxROLE_SYSTEM_TITLEBAR
:
1878 return ROLE_SYSTEM_TITLEBAR
;
1879 case wxROLE_SYSTEM_TOOLBAR
:
1880 return ROLE_SYSTEM_TOOLBAR
;
1881 case wxROLE_SYSTEM_TOOLTIP
:
1882 return ROLE_SYSTEM_TOOLTIP
;
1883 case wxROLE_SYSTEM_WHITESPACE
:
1884 return ROLE_SYSTEM_WHITESPACE
;
1885 case wxROLE_SYSTEM_WINDOW
:
1886 return ROLE_SYSTEM_WINDOW
;
1891 // Convert to Windows state
1892 long wxConvertToWindowsState(long wxstate
)
1895 if (wxstate
& wxACC_STATE_SYSTEM_ALERT_HIGH
)
1896 state
|= STATE_SYSTEM_ALERT_HIGH
;
1898 if (wxstate
& wxACC_STATE_SYSTEM_ALERT_MEDIUM
)
1899 state
|= STATE_SYSTEM_ALERT_MEDIUM
;
1901 if (wxstate
& wxACC_STATE_SYSTEM_ALERT_LOW
)
1902 state
|= STATE_SYSTEM_ALERT_LOW
;
1904 if (wxstate
& wxACC_STATE_SYSTEM_ANIMATED
)
1905 state
|= STATE_SYSTEM_ANIMATED
;
1907 if (wxstate
& wxACC_STATE_SYSTEM_BUSY
)
1908 state
|= STATE_SYSTEM_BUSY
;
1910 if (wxstate
& wxACC_STATE_SYSTEM_CHECKED
)
1911 state
|= STATE_SYSTEM_CHECKED
;
1913 if (wxstate
& wxACC_STATE_SYSTEM_COLLAPSED
)
1914 state
|= STATE_SYSTEM_COLLAPSED
;
1916 if (wxstate
& wxACC_STATE_SYSTEM_DEFAULT
)
1917 state
|= STATE_SYSTEM_DEFAULT
;
1919 if (wxstate
& wxACC_STATE_SYSTEM_EXPANDED
)
1920 state
|= STATE_SYSTEM_EXPANDED
;
1922 if (wxstate
& wxACC_STATE_SYSTEM_EXTSELECTABLE
)
1923 state
|= STATE_SYSTEM_EXTSELECTABLE
;
1925 if (wxstate
& wxACC_STATE_SYSTEM_FLOATING
)
1926 state
|= STATE_SYSTEM_FLOATING
;
1928 if (wxstate
& wxACC_STATE_SYSTEM_FOCUSABLE
)
1929 state
|= STATE_SYSTEM_FOCUSABLE
;
1931 if (wxstate
& wxACC_STATE_SYSTEM_FOCUSED
)
1932 state
|= STATE_SYSTEM_FOCUSED
;
1934 if (wxstate
& wxACC_STATE_SYSTEM_HOTTRACKED
)
1935 state
|= STATE_SYSTEM_HOTTRACKED
;
1937 if (wxstate
& wxACC_STATE_SYSTEM_INVISIBLE
)
1938 state
|= STATE_SYSTEM_INVISIBLE
;
1940 if (wxstate
& wxACC_STATE_SYSTEM_INVISIBLE
)
1941 state
|= STATE_SYSTEM_INVISIBLE
;
1943 if (wxstate
& wxACC_STATE_SYSTEM_MIXED
)
1944 state
|= STATE_SYSTEM_MIXED
;
1946 if (wxstate
& wxACC_STATE_SYSTEM_MULTISELECTABLE
)
1947 state
|= STATE_SYSTEM_MULTISELECTABLE
;
1949 if (wxstate
& wxACC_STATE_SYSTEM_OFFSCREEN
)
1950 state
|= STATE_SYSTEM_OFFSCREEN
;
1952 if (wxstate
& wxACC_STATE_SYSTEM_PRESSED
)
1953 state
|= STATE_SYSTEM_PRESSED
;
1955 // if (wxstate & wxACC_STATE_SYSTEM_PROTECTED)
1956 // state |= STATE_SYSTEM_PROTECTED;
1958 if (wxstate
& wxACC_STATE_SYSTEM_READONLY
)
1959 state
|= STATE_SYSTEM_READONLY
;
1961 if (wxstate
& wxACC_STATE_SYSTEM_SELECTABLE
)
1962 state
|= STATE_SYSTEM_SELECTABLE
;
1964 if (wxstate
& wxACC_STATE_SYSTEM_SELECTED
)
1965 state
|= STATE_SYSTEM_SELECTED
;
1967 if (wxstate
& wxACC_STATE_SYSTEM_SELFVOICING
)
1968 state
|= STATE_SYSTEM_SELFVOICING
;
1970 if (wxstate
& wxACC_STATE_SYSTEM_UNAVAILABLE
)
1971 state
|= STATE_SYSTEM_UNAVAILABLE
;
1976 // Convert to Windows selection flag
1977 int wxConvertToWindowsSelFlag(wxAccSelectionFlags wxsel
)
1981 if (wxsel
& wxACC_SEL_TAKEFOCUS
)
1982 sel
|= SELFLAG_TAKEFOCUS
;
1983 if (wxsel
& wxACC_SEL_TAKESELECTION
)
1984 sel
|= SELFLAG_TAKESELECTION
;
1985 if (wxsel
& wxACC_SEL_EXTENDSELECTION
)
1986 sel
|= SELFLAG_EXTENDSELECTION
;
1987 if (wxsel
& wxACC_SEL_ADDSELECTION
)
1988 sel
|= SELFLAG_ADDSELECTION
;
1989 if (wxsel
& wxACC_SEL_REMOVESELECTION
)
1990 sel
|= SELFLAG_REMOVESELECTION
;
1994 // Convert from Windows selection flag
1995 wxAccSelectionFlags
wxConvertFromWindowsSelFlag(int sel
)
1999 if (sel
& SELFLAG_TAKEFOCUS
)
2000 wxsel
|= wxACC_SEL_TAKEFOCUS
;
2001 if (sel
& SELFLAG_TAKESELECTION
)
2002 wxsel
|= wxACC_SEL_TAKESELECTION
;
2003 if (sel
& SELFLAG_EXTENDSELECTION
)
2004 wxsel
|= wxACC_SEL_EXTENDSELECTION
;
2005 if (sel
& SELFLAG_ADDSELECTION
)
2006 wxsel
|= wxACC_SEL_ADDSELECTION
;
2007 if (sel
& SELFLAG_REMOVESELECTION
)
2008 wxsel
|= wxACC_SEL_REMOVESELECTION
;
2009 return (wxAccSelectionFlags
) wxsel
;
2013 #endif // wxUSE_OLE && wxUSE_ACCESSIBILITY