]> git.saurik.com Git - wxWidgets.git/blame - src/msw/ole/access.cpp
Apply patch [ 1554736 ] wxXmlDocument::DetachRoot
[wxWidgets.git] / src / msw / ole / access.cpp
CommitLineData
ed5317e5 1///////////////////////////////////////////////////////////////////////////////
521bf4ff 2// Name: src/msw/ole/access.cpp
ed5317e5
JS
3// Purpose: implementation of wxIAccessible and wxAccessible
4// Author: Julian Smart
5// Modified by:
6// Created: 2003-02-12
7// RCS-ID: $Id$
8// Copyright: (c) 2003 Julian Smart
65571936 9// Licence: wxWindows licence
ed5317e5
JS
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
ed5317e5
JS
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#if defined(__BORLANDC__)
24 #pragma hdrstop
25#endif
521bf4ff 26
ed5317e5
JS
27#if wxUSE_OLE && wxUSE_ACCESSIBILITY
28
ed5317e5
JS
29#include "wx/access.h"
30
e4db172a 31#ifndef WX_PRECOMP
57bd4c60 32 #include "wx/msw/wrapwin.h"
e4db172a
WS
33 #include "wx/window.h"
34 #include "wx/log.h"
35#endif
36
ed5317e5
JS
37// for some compilers, the entire ole2.h must be included, not only oleauto.h
38#if wxUSE_NORLANDER_HEADERS || defined(__WATCOMC__)
39 #include <ole2.h>
40#endif
41
42#include <oleauto.h>
43#include <oleacc.h>
507db85d 44#include <winable.h>
ed5317e5
JS
45
46#include "wx/msw/ole/oleutils.h"
47
48#ifndef CHILDID_SELF
49#define CHILDID_SELF 0
50#endif
51
52#ifndef OBJID_CLIENT
53#define OBJID_CLIENT 0xFFFFFFFC
54#endif
55
56// Convert to Windows role
57int wxConvertToWindowsRole(wxAccRole wxrole);
58
59// Convert to Windows state
60long wxConvertToWindowsState(long wxstate);
61
62// Convert to Windows selection flag
63int wxConvertToWindowsSelFlag(wxAccSelectionFlags sel);
64
65// Convert from Windows selection flag
66wxAccSelectionFlags wxConvertFromWindowsSelFlag(int sel);
67
68// ----------------------------------------------------------------------------
69// wxIEnumVARIANT interface implementation
70// ----------------------------------------------------------------------------
71
72class wxIEnumVARIANT : public IEnumVARIANT
73{
74public:
75 wxIEnumVARIANT(const wxVariant& variant);
29d0a26e 76 virtual ~wxIEnumVARIANT() { }
ed5317e5
JS
77
78 DECLARE_IUNKNOWN_METHODS;
79
80 // IEnumVARIANT
81 STDMETHODIMP Next(ULONG celt, VARIANT *rgelt, ULONG *pceltFetched);
82 STDMETHODIMP Skip(ULONG celt);
83 STDMETHODIMP Reset();
84 STDMETHODIMP Clone(IEnumVARIANT **ppenum);
85
86private:
87 wxVariant m_variant; // List of further variants
88 int m_nCurrent; // Current enum position
89
90 DECLARE_NO_COPY_CLASS(wxIEnumVARIANT)
91};
92
93// ----------------------------------------------------------------------------
94// wxIEnumVARIANT
95// ----------------------------------------------------------------------------
96
97BEGIN_IID_TABLE(wxIEnumVARIANT)
98 ADD_IID(Unknown)
99 ADD_IID(EnumVARIANT)
100END_IID_TABLE;
101
102IMPLEMENT_IUNKNOWN_METHODS(wxIEnumVARIANT)
103
104// wxVariant contains a list of further variants.
105wxIEnumVARIANT::wxIEnumVARIANT(const wxVariant& variant)
106{
107 m_variant = variant;
108}
109
110STDMETHODIMP wxIEnumVARIANT::Next(ULONG celt,
111 VARIANT *rgelt,
112 ULONG *pceltFetched)
113{
114 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumVARIANT::Next"));
115
116 if ( celt > 1 ) {
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
119 return S_FALSE;
120 }
121
122 if (m_variant.GetType() != wxT("list"))
123 return S_FALSE;
124
125 if ( m_nCurrent < (int) m_variant.GetList().GetCount() ) {
126 if (!wxConvertVariantToOle(m_variant[m_nCurrent++], rgelt[0]))
127 {
128 return S_FALSE;
129 }
130
131 // TODO: should we AddRef if this is an object?
132
133 * pceltFetched = 1;
134 return S_OK;
135 }
136 else {
137 // bad index
138 return S_FALSE;
139 }
140}
141
142STDMETHODIMP wxIEnumVARIANT::Skip(ULONG celt)
143{
144 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumVARIANT::Skip"));
145
146 if (m_variant.GetType() != wxT("list"))
147 return S_FALSE;
148
149 m_nCurrent += celt;
150 if ( m_nCurrent < (int) m_variant.GetList().GetCount() )
151 return S_OK;
152
153 // no, can't skip this many elements
154 m_nCurrent -= celt;
155
156 return S_FALSE;
157}
158
159STDMETHODIMP wxIEnumVARIANT::Reset()
160{
161 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumVARIANT::Reset"));
162
163 m_nCurrent = 0;
164
165 return S_OK;
166}
167
168STDMETHODIMP wxIEnumVARIANT::Clone(IEnumVARIANT **ppenum)
169{
170 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumVARIANT::Clone"));
171
172 wxIEnumVARIANT *pNew = new wxIEnumVARIANT(m_variant);
173 pNew->AddRef();
174 *ppenum = pNew;
175
176 return S_OK;
177}
178
179
180// ----------------------------------------------------------------------------
181// wxIAccessible implementation of IAccessible interface
182// ----------------------------------------------------------------------------
183
184class wxIAccessible : public IAccessible
185{
186public:
187 wxIAccessible(wxAccessible *pAccessible);
188
189 DECLARE_IUNKNOWN_METHODS;
190
191// IAccessible
192
193// Navigation and Hierarchy
194
195 // Retrieves the child element or child object at a given point on the screen.
0a0e6a5b 196 // All visual objects support this method; sound objects do not support it.
ed5317e5
JS
197
198 STDMETHODIMP accHitTest(long xLeft, long yLeft, VARIANT* pVarID);
199
200 // Retrieves the specified object's current screen location. All visual objects must
0a0e6a5b 201 // support this method; sound objects do not support it.
ed5317e5
JS
202
203 STDMETHODIMP accLocation ( long* pxLeft, long* pyTop, long* pcxWidth, long* pcyHeight, VARIANT varID);
204
205 // Traverses to another user interface element within a container and retrieves the object.
206 // All visual objects must support this method.
207
208 STDMETHODIMP accNavigate ( long navDir, VARIANT varStart, VARIANT* pVarEnd);
209
210 // Retrieves the address of an IDispatch interface for the specified child.
211 // All objects must support this property.
0a0e6a5b 212
ed5317e5
JS
213 STDMETHODIMP get_accChild ( VARIANT varChildID, IDispatch** ppDispChild);
214
215 // Retrieves the number of children that belong to this object.
216 // All objects must support this property.
0a0e6a5b 217
ed5317e5
JS
218 STDMETHODIMP get_accChildCount ( long* pCountChildren);
219
220 // Retrieves the IDispatch interface of the object's parent.
221 // All objects support this property.
0a0e6a5b 222
ed5317e5
JS
223 STDMETHODIMP get_accParent ( IDispatch** ppDispParent);
224
225// Descriptive Properties and Methods
226
227 // Performs the object's default action. Not all objects have a default
228 // action.
0a0e6a5b 229
ed5317e5
JS
230 STDMETHODIMP accDoDefaultAction(VARIANT varID);
231
232 // Retrieves a string that describes the object's default action.
233 // Not all objects have a default action.
0a0e6a5b 234
ed5317e5
JS
235 STDMETHODIMP get_accDefaultAction ( VARIANT varID, BSTR* pszDefaultAction);
236
237 // Retrieves a string that describes the visual appearance of the specified object.
238 // Not all objects have a description.
239
240 STDMETHODIMP get_accDescription ( VARIANT varID, BSTR* pszDescription);
241
242 // Retrieves an object's Help property string.
243 // Not all objects support this property.
244
245 STDMETHODIMP get_accHelp ( VARIANT varID, BSTR* pszHelp);
246
247 // Retrieves the full path of the WinHelp file associated with the specified
248 // object and the identifier of the appropriate topic within that file.
249 // Not all objects support this property.
0a0e6a5b 250
ed5317e5
JS
251 STDMETHODIMP get_accHelpTopic ( BSTR* pszHelpFile, VARIANT varChild, long* pidTopic);
252
253 // Retrieves the specified object's shortcut key or access key, also known as
254 // the mnemonic. All objects that have a shortcut key or access key support
255 // this property.
0a0e6a5b 256
ed5317e5
JS
257 STDMETHODIMP get_accKeyboardShortcut ( VARIANT varID, BSTR* pszKeyboardShortcut);
258
259 // Retrieves the name of the specified object.
260 // All objects support this property.
0a0e6a5b 261
ed5317e5
JS
262 STDMETHODIMP get_accName ( VARIANT varID, BSTR* pszName);
263
264 // Retrieves information that describes the role of the specified object.
265 // All objects support this property.
266
267 STDMETHODIMP get_accRole ( VARIANT varID, VARIANT* pVarRole);
268
269 // Retrieves the current state of the specified object.
270 // All objects support this property.
0a0e6a5b 271
ed5317e5 272 STDMETHODIMP get_accState ( VARIANT varID, VARIANT* pVarState);
0a0e6a5b 273
ed5317e5
JS
274 // Retrieves the value of the specified object.
275 // Not all objects have a value.
276
277 STDMETHODIMP get_accValue ( VARIANT varID, BSTR* pszValue);
278
279// Selection and Focus
280
281 // Modifies the selection or moves the keyboard focus of the
282 // specified object. All objects that select or receive the
283 // keyboard focus must support this method.
284
285 STDMETHODIMP accSelect ( long flagsSelect, VARIANT varID );
286
287 // Retrieves the object that has the keyboard focus. All objects
288 // that receive the keyboard focus must support this property.
0a0e6a5b 289
ed5317e5
JS
290 STDMETHODIMP get_accFocus ( VARIANT* pVarID);
291
292 // Retrieves the selected children of this object. All objects
293 // selected must support this property.
0a0e6a5b 294
ed5317e5
JS
295 STDMETHODIMP get_accSelection ( VARIANT * pVarChildren);
296
297// Obsolete
298
f30f25b5
WS
299 STDMETHODIMP put_accName(VARIANT WXUNUSED(varChild), BSTR WXUNUSED(szName)) { return E_FAIL; }
300 STDMETHODIMP put_accValue(VARIANT WXUNUSED(varChild), BSTR WXUNUSED(szName)) { return E_FAIL; }
ed5317e5
JS
301
302// IDispatch
303
304 // Get type info
305
306 STDMETHODIMP GetTypeInfo(unsigned int typeInfo, LCID lcid, ITypeInfo** ppTypeInfo);
307
308 // Get type info count
309
310 STDMETHODIMP GetTypeInfoCount(unsigned int* typeInfoCount);
311
312 // Get ids of names
313
314 STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** names, unsigned int cNames,
315 LCID lcid, DISPID* dispId);
316
317 // Invoke
318
0a0e6a5b
WS
319 STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
320 WORD wFlags, DISPPARAMS *pDispParams,
321 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
ed5317e5
JS
322 unsigned int *puArgErr );
323
c6e2af45
JS
324// Helpers
325
326 // Gets the standard IAccessible interface for the given child or object.
327 // Call Release if this is non-NULL.
328 IAccessible* GetChildStdAccessible(int id);
329
2aefc528
JS
330 // Gets the IAccessible interface for the given child or object.
331 // Call Release if this is non-NULL.
332 IAccessible* GetChildAccessible(int id);
333
ed5317e5
JS
334private:
335 wxAccessible *m_pAccessible; // pointer to C++ class we belong to
336
337 DECLARE_NO_COPY_CLASS(wxIAccessible)
338};
339
340// ============================================================================
341// Implementation
342// ============================================================================
343
344// ----------------------------------------------------------------------------
345// wxIAccessible implementation
346// ----------------------------------------------------------------------------
347BEGIN_IID_TABLE(wxIAccessible)
348 ADD_IID(Unknown)
349 ADD_IID(Accessible)
350 ADD_IID(Dispatch)
351END_IID_TABLE;
352
353IMPLEMENT_IUNKNOWN_METHODS(wxIAccessible)
354
355wxIAccessible::wxIAccessible(wxAccessible *pAccessible)
356{
357 wxASSERT( pAccessible != NULL );
358
359 m_pAccessible = pAccessible;
360}
361
362// Retrieves the child element or child object at a given point on the screen.
0a0e6a5b 363// All visual objects support this method; sound objects do not support it.
ed5317e5
JS
364
365STDMETHODIMP wxIAccessible::accHitTest(long xLeft, long yLeft, VARIANT* pVarID)
366{
ecd6e7ea 367 wxLogTrace(wxT("access"), wxT("accHitTest"));
ed5317e5
JS
368 wxASSERT (m_pAccessible != NULL);
369 if (!m_pAccessible)
370 return E_FAIL;
0a0e6a5b 371
ed5317e5
JS
372 wxAccessible* childObject = NULL;
373 int childId = 0;
374 VariantInit(pVarID);
0a0e6a5b 375
ed5317e5 376 wxAccStatus status = m_pAccessible->HitTest(wxPoint(xLeft, yLeft), & childId, & childObject);
0a0e6a5b 377
ed5317e5
JS
378 if (status == wxACC_FAIL)
379 return E_FAIL;
0a0e6a5b 380
ed5317e5
JS
381 if (status == wxACC_NOT_IMPLEMENTED)
382 {
383 // Use standard interface instead.
384 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
385 if (!stdInterface)
2aefc528 386 return E_NOTIMPL;
ed5317e5
JS
387 else
388 return stdInterface->accHitTest(xLeft, yLeft, pVarID);
389 }
0a0e6a5b 390
ed5317e5
JS
391 if (childObject)
392 {
393 if (childObject == m_pAccessible)
394 {
395 pVarID->vt = VT_I4;
396 pVarID->lVal = CHILDID_SELF;
397 return S_OK;
398 }
399 else
400 {
401 wxIAccessible* childIA = childObject->GetIAccessible();
402 if (!childIA)
2aefc528 403 return E_NOTIMPL;
ed5317e5 404
0a0e6a5b
WS
405 if (childIA->QueryInterface(IID_IDispatch, (LPVOID*) & pVarID->pdispVal) != S_OK)
406 return E_FAIL;
407
ed5317e5 408 pVarID->vt = VT_DISPATCH;
ed5317e5
JS
409 return S_OK;
410 }
411 }
412 else if (childId > 0)
413 {
414 pVarID->vt = VT_I4;
415 pVarID->lVal = childId;
416 return S_OK;
417 }
418 else
419 {
420 pVarID->vt = VT_EMPTY;
421 return S_FALSE;
422 }
0a0e6a5b
WS
423
424 #if 0
66b9ec3d
JS
425 // all cases above already cause some return action so below line
426 // is unreachable and cause unnecessary warning
2aefc528 427 return E_NOTIMPL;
66b9ec3d 428 #endif
ed5317e5
JS
429}
430
431// Retrieves the specified object's current screen location. All visual objects must
0a0e6a5b 432// support this method; sound objects do not support it.
ed5317e5
JS
433
434STDMETHODIMP wxIAccessible::accLocation ( long* pxLeft, long* pyTop, long* pcxWidth, long* pcyHeight, VARIANT varID)
435{
ecd6e7ea 436 wxLogTrace(wxT("access"), wxT("accLocation"));
ed5317e5
JS
437 wxASSERT (m_pAccessible != NULL);
438 if (!m_pAccessible)
439 return E_FAIL;
0a0e6a5b 440
ed5317e5
JS
441 wxRect rect;
442
443 wxAccStatus status = m_pAccessible->GetLocation(rect, varID.lVal);
444 if (status == wxACC_FAIL)
445 return E_FAIL;
0a0e6a5b 446
ed5317e5
JS
447 if (status == wxACC_NOT_IMPLEMENTED)
448 {
2aefc528
JS
449 // Try to use child object directly.
450 if (varID.lVal > 0)
451 {
452 IAccessible* childAccessible = GetChildAccessible(varID.lVal);
453 if (childAccessible)
454 {
455 varID.lVal = 0;
456 HRESULT hResult = childAccessible->accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, varID);
457 childAccessible->Release();
458 return hResult;
459 }
460 else if (m_pAccessible->GetIAccessibleStd())
461 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, varID);
462 }
463 else if (m_pAccessible->GetIAccessibleStd())
464 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, varID);
ed5317e5
JS
465 }
466 else
467 {
468 *pxLeft = rect.x;
469 *pyTop = rect.y;
470 *pcxWidth = rect.width;
471 *pcyHeight = rect.height;
472 return S_OK;
473 }
474
2aefc528 475 return E_NOTIMPL;
ed5317e5
JS
476}
477
478// Traverses to another user interface element within a container and retrieves the object.
479// All visual objects must support this method.
480
481STDMETHODIMP wxIAccessible::accNavigate ( long navDir, VARIANT varStart, VARIANT* pVarEnd)
482{
483 wxASSERT (m_pAccessible != NULL);
484 if (!m_pAccessible)
485 return E_FAIL;
f77e1e5d 486 wxLogTrace(wxT("access"), wxString(wxT("accNavigate for ")) + m_pAccessible->GetWindow()->GetClassInfo()->GetClassName());
ed5317e5 487
0a0e6a5b 488 if ((varStart.vt != VT_I4 && varStart.vt != VT_EMPTY)
66b9ec3d
JS
489 #if 0
490 // according to MSDN and sources varStart.vt is unsigned
491 // so below line cause warning "Condition is always false"
492 || varStart.vt < 0
493 #endif
494 )
c6e2af45 495 {
ecd6e7ea 496 wxLogTrace(wxT("access"), wxT("Invalid arg for accNavigate"));
ed5317e5 497 return E_INVALIDARG;
c6e2af45 498 }
0a0e6a5b 499
ed5317e5
JS
500 wxAccessible* elementObject = NULL;
501 int elementId = 0;
502 VariantInit(pVarEnd);
503 wxNavDir navDirWX = wxNAVDIR_FIRSTCHILD;
504
c6e2af45
JS
505 wxString navStr;
506
ed5317e5
JS
507 switch (navDir)
508 {
509 case NAVDIR_DOWN:
510 navDirWX = wxNAVDIR_DOWN;
c6e2af45 511 navStr = wxT("wxNAVDIR_DOWN");
ed5317e5
JS
512 break;
513
514 case NAVDIR_FIRSTCHILD:
515 navDirWX = wxNAVDIR_FIRSTCHILD;
c6e2af45 516 navStr = wxT("wxNAVDIR_FIRSTCHILD");
ed5317e5
JS
517 break;
518
519 case NAVDIR_LASTCHILD:
520 navDirWX = wxNAVDIR_LASTCHILD;
c6e2af45 521 navStr = wxT("wxNAVDIR_LASTCHILD");
ed5317e5
JS
522 break;
523
524 case NAVDIR_LEFT:
525 navDirWX = wxNAVDIR_LEFT;
c6e2af45 526 navStr = wxT("wxNAVDIR_LEFT");
ed5317e5
JS
527 break;
528
529 case NAVDIR_NEXT:
530 navDirWX = wxNAVDIR_NEXT;
c6e2af45 531 navStr = wxT("wxNAVDIR_NEXT");
ed5317e5
JS
532 break;
533
534 case NAVDIR_PREVIOUS:
535 navDirWX = wxNAVDIR_PREVIOUS;
c6e2af45 536 navStr = wxT("wxNAVDIR_PREVIOUS");
ed5317e5
JS
537 break;
538
539 case NAVDIR_RIGHT:
540 navDirWX = wxNAVDIR_RIGHT;
c6e2af45 541 navStr = wxT("wxNAVDIR_RIGHT");
ed5317e5
JS
542 break;
543
544 case NAVDIR_UP:
545 navDirWX = wxNAVDIR_UP;
c6e2af45 546 navStr = wxT("wxNAVDIR_UP");
ed5317e5 547 break;
c6e2af45
JS
548 default:
549 {
f77e1e5d 550 wxLogTrace(wxT("access"), wxT("Unknown NAVDIR symbol"));
c6e2af45
JS
551 break;
552 }
ed5317e5 553 }
f77e1e5d 554 wxLogTrace(wxT("access"), navStr);
0a0e6a5b 555
ed5317e5
JS
556 wxAccStatus status = m_pAccessible->Navigate(navDirWX, varStart.lVal, & elementId,
557 & elementObject);
558
559 if (status == wxACC_FAIL)
c6e2af45 560 {
ecd6e7ea 561 wxLogTrace(wxT("access"), wxT("wxAccessible::Navigate failed"));
ed5317e5 562 return E_FAIL;
c6e2af45 563 }
0a0e6a5b 564
c6e2af45
JS
565 if (status == wxACC_FALSE)
566 {
ecd6e7ea 567 wxLogTrace(wxT("access"), wxT("wxAccessible::Navigate found no object in this direction"));
c6e2af45
JS
568 return S_FALSE;
569 }
0a0e6a5b 570
ed5317e5
JS
571 if (status == wxACC_NOT_IMPLEMENTED)
572 {
ecd6e7ea 573 wxLogTrace(wxT("access"), wxT("Navigate not implemented"));
c6e2af45 574
2aefc528
JS
575 // Try to use child object directly.
576 if (varStart.vt == VT_I4 && varStart.lVal > 0)
577 {
578 IAccessible* childAccessible = GetChildAccessible(varStart.lVal);
579 if (childAccessible)
580 {
581 varStart.lVal = 0;
582 HRESULT hResult = childAccessible->accNavigate(navDir, varStart, pVarEnd);
583 childAccessible->Release();
584 return hResult;
585 }
586 else if (m_pAccessible->GetIAccessibleStd())
587 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->accNavigate(navDir, varStart, pVarEnd);
588 }
589 else if (m_pAccessible->GetIAccessibleStd())
590 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->accNavigate(navDir, varStart, pVarEnd);
ed5317e5
JS
591 }
592 else
593 {
594 if (elementObject)
595 {
ecd6e7ea 596 wxLogTrace(wxT("access"), wxT("Getting wxIAccessible and calling QueryInterface for Navigate"));
ed5317e5
JS
597 wxIAccessible* objectIA = elementObject->GetIAccessible();
598 if (!objectIA)
c6e2af45 599 {
ecd6e7ea 600 wxLogTrace(wxT("access"), wxT("No wxIAccessible"));
ed5317e5 601 return E_FAIL;
c6e2af45 602 }
ed5317e5 603
0a0e6a5b 604 HRESULT hResult = objectIA->QueryInterface(IID_IDispatch, (LPVOID*) & pVarEnd->pdispVal);
c6e2af45
JS
605 if (hResult != S_OK)
606 {
ecd6e7ea 607 wxLogTrace(wxT("access"), wxT("QueryInterface failed"));
0a0e6a5b 608 return E_FAIL;
c6e2af45 609 }
0a0e6a5b 610
ecd6e7ea 611 wxLogTrace(wxT("access"), wxT("Called QueryInterface for Navigate"));
ed5317e5 612 pVarEnd->vt = VT_DISPATCH;
ed5317e5
JS
613 return S_OK;
614 }
615 else if (elementId > 0)
616 {
ecd6e7ea 617 wxLogTrace(wxT("access"), wxT("Returning element id from Navigate"));
ed5317e5
JS
618 pVarEnd->vt = VT_I4;
619 pVarEnd->lVal = elementId;
620 return S_OK;
621 }
622 else
623 {
ecd6e7ea 624 wxLogTrace(wxT("access"), wxT("No object in accNavigate"));
ed5317e5
JS
625 pVarEnd->vt = VT_EMPTY;
626 return S_FALSE;
627 }
628 }
629
ecd6e7ea 630 wxLogTrace(wxT("access"), wxT("Failing Navigate"));
2aefc528 631 return E_NOTIMPL;
ed5317e5
JS
632}
633
634// Retrieves the address of an IDispatch interface for the specified child.
635// All objects must support this property.
0a0e6a5b 636
ed5317e5
JS
637STDMETHODIMP wxIAccessible::get_accChild ( VARIANT varChildID, IDispatch** ppDispChild)
638{
ecd6e7ea 639 wxLogTrace(wxT("access"), wxT("get_accChild"));
ed5317e5
JS
640 wxASSERT (m_pAccessible != NULL);
641 if (!m_pAccessible)
642 return E_FAIL;
0a0e6a5b 643
ed5317e5 644 if (varChildID.vt != VT_I4)
c6e2af45 645 {
ecd6e7ea 646 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accChild"));
ed5317e5 647 return E_INVALIDARG;
c6e2af45 648 }
ed5317e5
JS
649
650 if (varChildID.lVal == CHILDID_SELF)
651 {
652 *ppDispChild = this;
653 AddRef();
654 return S_OK;
655 }
0a0e6a5b 656
ed5317e5
JS
657 wxAccessible* child = NULL;
658
659 wxAccStatus status = m_pAccessible->GetChild(varChildID.lVal, & child);
660 if (status == wxACC_FAIL)
c6e2af45 661 {
ecd6e7ea 662 wxLogTrace(wxT("access"), wxT("GetChild failed"));
ed5317e5 663 return E_FAIL;
c6e2af45 664 }
0a0e6a5b 665
ed5317e5
JS
666 if (status == wxACC_NOT_IMPLEMENTED)
667 {
668 // Use standard interface instead.
669 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
670 if (!stdInterface)
2aefc528 671 return E_NOTIMPL;
ed5317e5 672 else
c6e2af45 673 {
ecd6e7ea 674 wxLogTrace(wxT("access"), wxT("Using standard interface for get_accChild"));
ed5317e5 675 return stdInterface->get_accChild (varChildID, ppDispChild);
c6e2af45 676 }
ed5317e5
JS
677 }
678 else
679 {
680 if (child)
681 {
682 wxIAccessible* objectIA = child->GetIAccessible();
683 if (!objectIA)
2aefc528 684 return E_NOTIMPL;
e0496eaa 685
0a0e6a5b 686 if (objectIA->QueryInterface(IID_IDispatch, (LPVOID*) ppDispChild) != S_OK)
c6e2af45 687 {
ecd6e7ea 688 wxLogTrace(wxT("access"), wxT("QueryInterface failed in get_accChild"));
0a0e6a5b 689 return E_FAIL;
c6e2af45 690 }
0a0e6a5b 691
ed5317e5
JS
692 return S_OK;
693 }
694 else
c6e2af45 695 {
ecd6e7ea 696 wxLogTrace(wxT("access"), wxT("Not an accessible object"));
ed5317e5 697 return S_FALSE; // Indicates it's not an accessible object
c6e2af45 698 }
ed5317e5
JS
699 }
700
0a0e6a5b 701 #if 0
66b9ec3d
JS
702 // all cases above already cause some return action so below line
703 // is unreachable and cause unnecessary warning
2aefc528 704 return E_NOTIMPL;
66b9ec3d 705 #endif
ed5317e5
JS
706}
707
708// Retrieves the number of children that belong to this object.
709// All objects must support this property.
0a0e6a5b 710
ed5317e5
JS
711STDMETHODIMP wxIAccessible::get_accChildCount ( long* pCountChildren)
712{
ecd6e7ea 713 wxLogTrace(wxT("access"), wxT("get_accChildCount"));
ed5317e5
JS
714 wxASSERT (m_pAccessible != NULL);
715 if (!m_pAccessible)
716 return E_FAIL;
0a0e6a5b 717
ed5317e5
JS
718 int childCount = 0;
719 wxAccStatus status = m_pAccessible->GetChildCount(& childCount);
720 if (status == wxACC_FAIL)
721 return E_FAIL;
0a0e6a5b 722
ed5317e5
JS
723 if (status == wxACC_NOT_IMPLEMENTED)
724 {
725 // Use standard interface instead.
726 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
727 if (!stdInterface)
2aefc528 728 return E_NOTIMPL;
ed5317e5 729 else
c6e2af45 730 {
ecd6e7ea 731 wxLogTrace(wxT("access"), wxT("Using standard interface for get_accChildCount"));
c6e2af45
JS
732 HRESULT res = stdInterface->get_accChildCount (pCountChildren);
733 wxString str;
734 str.Printf(wxT("Number of children was %d"), (int) (*pCountChildren));
f77e1e5d 735 wxLogTrace(wxT("access"), str);
c6e2af45
JS
736 return res;
737 }
ed5317e5
JS
738 }
739 else
740 {
741 * pCountChildren = (long) childCount;
742 return S_OK;
743 }
744
0a0e6a5b 745 #if 0
66b9ec3d
JS
746 // all cases above already cause some return action so below line
747 // is unreachable and cause unnecessary warning
2aefc528 748 return E_NOTIMPL;
66b9ec3d 749 #endif
ed5317e5
JS
750}
751
752// Retrieves the IDispatch interface of the object's parent.
753// All objects support this property.
0a0e6a5b 754
ed5317e5
JS
755STDMETHODIMP wxIAccessible::get_accParent ( IDispatch** ppDispParent)
756{
ecd6e7ea 757 wxLogTrace(wxT("access"), wxT("get_accParent"));
ed5317e5
JS
758 wxASSERT (m_pAccessible != NULL);
759 if (!m_pAccessible)
760 return E_FAIL;
0a0e6a5b 761
ed5317e5
JS
762 wxAccessible* parent = NULL;
763 wxAccStatus status = m_pAccessible->GetParent(& parent);
c6e2af45 764
ed5317e5
JS
765 if (status == wxACC_FAIL)
766 return E_FAIL;
c6e2af45
JS
767
768 // It doesn't seem acceptable to return S_FALSE with a NULL
77ffb593 769 // ppDispParent, so if we have no wxWidgets parent, we leave
c6e2af45
JS
770 // it to the standard interface.
771 if (status == wxACC_NOT_IMPLEMENTED || !parent)
ed5317e5 772 {
ecd6e7ea 773 wxLogTrace(wxT("access"), wxT("Using standard interface to get the parent."));
ed5317e5
JS
774 // Use standard interface instead.
775 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
776 if (!stdInterface)
2aefc528 777 return E_NOTIMPL;
ed5317e5
JS
778 else
779 return stdInterface->get_accParent (ppDispParent);
780 }
781 else
782 {
783 if (parent)
784 {
785 wxIAccessible* objectIA = parent->GetIAccessible();
786 if (!objectIA)
787 return E_FAIL;
788
ecd6e7ea 789 wxLogTrace(wxT("access"), wxT("About to call QueryInterface"));
0a0e6a5b 790 if (objectIA->QueryInterface(IID_IDispatch, (LPVOID*) ppDispParent) != S_OK)
c6e2af45 791 {
ecd6e7ea 792 wxLogTrace(wxT("access"), wxT("Failed QueryInterface"));
0a0e6a5b 793 return E_FAIL;
c6e2af45 794 }
0a0e6a5b 795
ecd6e7ea 796 wxLogTrace(wxT("access"), wxT("Returning S_OK for get_accParent"));
ed5317e5 797 return S_OK;
ed5317e5
JS
798 }
799 else
800 {
c6e2af45
JS
801 // This doesn't seem to be allowed, despite the documentation,
802 // so we handle it higher up by using the standard interface.
ecd6e7ea 803 wxLogTrace(wxT("access"), wxT("Returning NULL parent because there was none"));
ed5317e5 804 *ppDispParent = NULL;
c6e2af45 805 return S_FALSE;
ed5317e5
JS
806 }
807 }
808
0a0e6a5b 809 #if 0
66b9ec3d
JS
810 // all cases above already cause some return action so below line
811 // is unreachable and cause unnecessary warning
2aefc528 812 return E_NOTIMPL;
66b9ec3d 813 #endif
ed5317e5
JS
814}
815
816// Performs the object's default action. Not all objects have a default
817// action.
0a0e6a5b 818
ed5317e5
JS
819STDMETHODIMP wxIAccessible::accDoDefaultAction(VARIANT varID)
820{
ecd6e7ea 821 wxLogTrace(wxT("access"), wxT("accDoDefaultAction"));
ed5317e5
JS
822 wxASSERT (m_pAccessible != NULL);
823 if (!m_pAccessible)
824 return E_FAIL;
0a0e6a5b 825
ed5317e5 826 if (varID.vt != VT_I4)
c6e2af45 827 {
ecd6e7ea 828 wxLogTrace(wxT("access"), wxT("Invalid arg for accDoDefaultAction"));
ed5317e5 829 return E_INVALIDARG;
c6e2af45 830 }
0a0e6a5b 831
ed5317e5
JS
832 wxAccStatus status = m_pAccessible->DoDefaultAction(varID.lVal);
833 if (status == wxACC_FAIL)
834 return E_FAIL;
835
836 if (status == wxACC_NOT_SUPPORTED)
837 return DISP_E_MEMBERNOTFOUND;
0a0e6a5b 838
ed5317e5
JS
839 if (status == wxACC_NOT_IMPLEMENTED)
840 {
2aefc528
JS
841 // Try to use child object directly.
842 if (varID.lVal > 0)
843 {
844 IAccessible* childAccessible = GetChildAccessible(varID.lVal);
845 if (childAccessible)
846 {
847 varID.lVal = 0;
848 HRESULT hResult = childAccessible->accDoDefaultAction(varID);
849 childAccessible->Release();
850 return hResult;
851 }
852 else if (m_pAccessible->GetIAccessibleStd())
853 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->accDoDefaultAction(varID);
854 }
855 else if (m_pAccessible->GetIAccessibleStd())
856 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->accDoDefaultAction(varID);
ed5317e5
JS
857 }
858 return E_FAIL;
859}
860
861// Retrieves a string that describes the object's default action.
862// Not all objects have a default action.
0a0e6a5b 863
ed5317e5
JS
864STDMETHODIMP wxIAccessible::get_accDefaultAction ( VARIANT varID, BSTR* pszDefaultAction)
865{
ecd6e7ea 866 wxLogTrace(wxT("access"), wxT("get_accDefaultAction"));
ed5317e5
JS
867 wxASSERT (m_pAccessible != NULL);
868 if (!m_pAccessible)
869 return E_FAIL;
0a0e6a5b 870
ed5317e5 871 if (varID.vt != VT_I4)
c6e2af45 872 {
ecd6e7ea 873 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accDefaultAction"));
ed5317e5 874 return E_INVALIDARG;
c6e2af45 875 }
0a0e6a5b 876
ed5317e5
JS
877 wxString defaultAction;
878 wxAccStatus status = m_pAccessible->GetDefaultAction(varID.lVal, & defaultAction);
879 if (status == wxACC_FAIL)
880 return E_FAIL;
0a0e6a5b 881
ed5317e5
JS
882 if (status == wxACC_NOT_SUPPORTED)
883 return DISP_E_MEMBERNOTFOUND;
0a0e6a5b 884
ed5317e5
JS
885 if (status == wxACC_NOT_IMPLEMENTED)
886 {
2aefc528
JS
887 // Try to use child object directly.
888 if (varID.lVal > 0)
889 {
890 IAccessible* childAccessible = GetChildAccessible(varID.lVal);
891 if (childAccessible)
892 {
893 varID.lVal = 0;
894 HRESULT hResult = childAccessible->get_accDefaultAction(varID, pszDefaultAction);
895 childAccessible->Release();
896 return hResult;
897 }
898 else if (m_pAccessible->GetIAccessibleStd())
899 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accDefaultAction(varID, pszDefaultAction);
900 }
901 else if (m_pAccessible->GetIAccessibleStd())
902 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accDefaultAction(varID, pszDefaultAction);
ed5317e5
JS
903 }
904 else
905 {
906 if (defaultAction.IsEmpty())
907 {
908 * pszDefaultAction = NULL;
909 return S_FALSE;
910 }
911 else
912 {
913 wxBasicString basicString(defaultAction);
914 * pszDefaultAction = basicString.Get();
915 return S_OK;
916 }
917 }
918 return E_FAIL;
919}
920
921// Retrieves a string that describes the visual appearance of the specified object.
922// Not all objects have a description.
923
924STDMETHODIMP wxIAccessible::get_accDescription ( VARIANT varID, BSTR* pszDescription)
925{
ecd6e7ea 926 wxLogTrace(wxT("access"), wxT("get_accDescription"));
ed5317e5
JS
927 wxASSERT (m_pAccessible != NULL);
928 if (!m_pAccessible)
929 return E_FAIL;
0a0e6a5b 930
ed5317e5 931 if (varID.vt != VT_I4)
c6e2af45 932 {
ecd6e7ea 933 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accDescription"));
ed5317e5 934 return E_INVALIDARG;
c6e2af45 935 }
0a0e6a5b 936
ed5317e5
JS
937 wxString description;
938 wxAccStatus status = m_pAccessible->GetDescription(varID.lVal, & description);
939 if (status == wxACC_FAIL)
940 return E_FAIL;
0a0e6a5b 941
ed5317e5
JS
942 if (status == wxACC_NOT_IMPLEMENTED)
943 {
2aefc528
JS
944 // Try to use child object directly.
945 if (varID.lVal > 0)
946 {
947 IAccessible* childAccessible = GetChildAccessible(varID.lVal);
948 if (childAccessible)
949 {
950 varID.lVal = 0;
951 HRESULT hResult = childAccessible->get_accDescription(varID, pszDescription);
952 childAccessible->Release();
953 return hResult;
954 }
955 else if (m_pAccessible->GetIAccessibleStd())
956 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accDescription(varID, pszDescription);
957 }
958 else if (m_pAccessible->GetIAccessibleStd())
959 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accDescription(varID, pszDescription);
ed5317e5
JS
960 }
961 else
962 {
521bf4ff 963 if (description.empty())
ed5317e5
JS
964 {
965 * pszDescription = NULL;
966 return S_FALSE;
967 }
968 else
969 {
970 wxBasicString basicString(description);
971 * pszDescription = basicString.Get();
972 return S_OK;
0a0e6a5b 973 }
ed5317e5 974 }
2aefc528 975 return E_NOTIMPL;
ed5317e5
JS
976}
977
978// Retrieves an object's Help property string.
979// Not all objects support this property.
980
981STDMETHODIMP wxIAccessible::get_accHelp ( VARIANT varID, BSTR* pszHelp)
982{
ecd6e7ea 983 wxLogTrace(wxT("access"), wxT("get_accHelp"));
ed5317e5
JS
984 wxASSERT (m_pAccessible != NULL);
985 if (!m_pAccessible)
986 return E_FAIL;
0a0e6a5b 987
ed5317e5 988 if (varID.vt != VT_I4)
c6e2af45 989 {
ecd6e7ea 990 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accHelp"));
ed5317e5 991 return E_INVALIDARG;
c6e2af45 992 }
0a0e6a5b 993
ed5317e5
JS
994 wxString helpString;
995 wxAccStatus status = m_pAccessible->GetHelpText(varID.lVal, & helpString);
996 if (status == wxACC_FAIL)
997 return E_FAIL;
0a0e6a5b 998
ed5317e5
JS
999 if (status == wxACC_NOT_IMPLEMENTED)
1000 {
2aefc528
JS
1001 // Try to use child object directly.
1002 if (varID.lVal > 0)
1003 {
1004 IAccessible* childAccessible = GetChildAccessible(varID.lVal);
1005 if (childAccessible)
1006 {
1007 varID.lVal = 0;
1008 HRESULT hResult = childAccessible->get_accHelp(varID, pszHelp);
1009 childAccessible->Release();
1010 return hResult;
1011 }
1012 else if (m_pAccessible->GetIAccessibleStd())
1013 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accHelp(varID, pszHelp);
1014 }
1015 else if (m_pAccessible->GetIAccessibleStd())
1016 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accHelp (varID, pszHelp);
ed5317e5
JS
1017 }
1018 else
1019 {
521bf4ff 1020 if (helpString.empty())
ed5317e5
JS
1021 {
1022 * pszHelp = NULL;
1023 return S_FALSE;
1024 }
1025 else
1026 {
1027 wxBasicString basicString(helpString);
1028 * pszHelp = basicString.Get();
1029 return S_OK;
0a0e6a5b 1030 }
ed5317e5 1031 }
2aefc528 1032 return E_NOTIMPL;
ed5317e5
JS
1033}
1034
1035// Retrieves the full path of the WinHelp file associated with the specified
1036// object and the identifier of the appropriate topic within that file.
1037// Not all objects support this property.
77ffb593 1038// NOTE: not supported by wxWidgets at this time. Use
ed5317e5 1039// GetHelpText instead.
0a0e6a5b 1040
ed5317e5
JS
1041STDMETHODIMP wxIAccessible::get_accHelpTopic ( BSTR* pszHelpFile, VARIANT varChild, long* pidTopic)
1042{
ecd6e7ea 1043 wxLogTrace(wxT("access"), wxT("get_accHelpTopic"));
ed5317e5
JS
1044 wxASSERT (m_pAccessible != NULL);
1045 if (!m_pAccessible)
1046 return E_FAIL;
0a0e6a5b 1047
ed5317e5 1048 if (varChild.vt != VT_I4)
c6e2af45 1049 {
ecd6e7ea 1050 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accHelpTopic"));
ed5317e5 1051 return E_INVALIDARG;
c6e2af45 1052 }
0a0e6a5b 1053
ed5317e5
JS
1054 wxAccStatus status = wxACC_NOT_IMPLEMENTED;
1055 if (status == wxACC_FAIL)
1056 return E_FAIL;
0a0e6a5b 1057
ed5317e5
JS
1058 if (status == wxACC_NOT_IMPLEMENTED)
1059 {
2aefc528
JS
1060 // Try to use child object directly.
1061 if (varChild.lVal > 0)
1062 {
1063 IAccessible* childAccessible = GetChildAccessible(varChild.lVal);
1064 if (childAccessible)
1065 {
1066 varChild.lVal = 0;
1067 HRESULT hResult = childAccessible->get_accHelpTopic(pszHelpFile, varChild, pidTopic);
1068 childAccessible->Release();
1069 return hResult;
1070 }
1071 else if (m_pAccessible->GetIAccessibleStd())
1072 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accHelpTopic(pszHelpFile, varChild, pidTopic);
1073 }
1074 else if (m_pAccessible->GetIAccessibleStd())
1075 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accHelpTopic (pszHelpFile, varChild, pidTopic);
ed5317e5 1076 }
2aefc528 1077 return E_NOTIMPL;
ed5317e5
JS
1078}
1079
1080// Retrieves the specified object's shortcut key or access key, also known as
1081// the mnemonic. All objects that have a shortcut key or access key support
1082// this property.
0a0e6a5b 1083
ed5317e5
JS
1084STDMETHODIMP wxIAccessible::get_accKeyboardShortcut ( VARIANT varID, BSTR* pszKeyboardShortcut)
1085{
ecd6e7ea 1086 wxLogTrace(wxT("access"), wxT("get_accKeyboardShortcut"));
ed5317e5
JS
1087 *pszKeyboardShortcut = NULL;
1088
1089 wxASSERT (m_pAccessible != NULL);
1090 if (!m_pAccessible)
1091 return E_FAIL;
0a0e6a5b 1092
ed5317e5 1093 if (varID.vt != VT_I4)
c6e2af45 1094 {
ecd6e7ea 1095 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accKeyboardShortcut"));
ed5317e5 1096 return E_INVALIDARG;
c6e2af45 1097 }
0a0e6a5b 1098
ed5317e5 1099 wxString keyboardShortcut;
a37e4a07 1100 wxAccStatus status = m_pAccessible->GetKeyboardShortcut(varID.lVal, & keyboardShortcut);
ed5317e5
JS
1101 if (status == wxACC_FAIL)
1102 return E_FAIL;
0a0e6a5b 1103
ed5317e5
JS
1104 if (status == wxACC_NOT_IMPLEMENTED)
1105 {
2aefc528
JS
1106 // Try to use child object directly.
1107 if (varID.lVal > 0)
1108 {
1109 IAccessible* childAccessible = GetChildAccessible(varID.lVal);
1110 if (childAccessible)
1111 {
1112 varID.lVal = 0;
1113 HRESULT hResult = childAccessible->get_accKeyboardShortcut(varID, pszKeyboardShortcut);
1114 childAccessible->Release();
1115 return hResult;
1116 }
1117 else if (m_pAccessible->GetIAccessibleStd())
1118 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accKeyboardShortcut(varID, pszKeyboardShortcut);
1119 }
1120 else if (m_pAccessible->GetIAccessibleStd())
1121 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accKeyboardShortcut (varID, pszKeyboardShortcut);
ed5317e5
JS
1122 }
1123 else
1124 {
521bf4ff 1125 if (keyboardShortcut.empty())
ed5317e5
JS
1126 {
1127 * pszKeyboardShortcut = NULL;
1128 return S_FALSE;
1129 }
1130 else
1131 {
1132 wxBasicString basicString(keyboardShortcut);
1133 * pszKeyboardShortcut = basicString.Get();
1134 return S_OK;
0a0e6a5b 1135 }
ed5317e5 1136 }
2aefc528 1137 return E_NOTIMPL;
ed5317e5
JS
1138}
1139
1140// Retrieves the name of the specified object.
1141// All objects support this property.
0a0e6a5b 1142
ed5317e5
JS
1143STDMETHODIMP wxIAccessible::get_accName ( VARIANT varID, BSTR* pszName)
1144{
ecd6e7ea 1145 wxLogTrace(wxT("access"), wxT("get_accName"));
ed5317e5
JS
1146 *pszName = NULL;
1147
1148 wxASSERT (m_pAccessible != NULL);
1149 if (!m_pAccessible)
1150 return E_FAIL;
1151
1152 if (varID.vt != VT_I4)
c6e2af45 1153 {
ecd6e7ea 1154 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accName"));
ed5317e5 1155 return E_INVALIDARG;
c6e2af45 1156 }
0a0e6a5b 1157
ed5317e5 1158 wxString name;
0a0e6a5b 1159
ed5317e5 1160 wxAccStatus status = m_pAccessible->GetName(varID.lVal, & name);
0a0e6a5b 1161
ed5317e5
JS
1162 if (status == wxACC_FAIL)
1163 return E_FAIL;
0a0e6a5b 1164
ed5317e5
JS
1165 if (status == wxACC_NOT_IMPLEMENTED)
1166 {
2aefc528
JS
1167 // Try to use child object directly.
1168 if (varID.lVal > 0)
c6e2af45 1169 {
2aefc528
JS
1170 IAccessible* childAccessible = GetChildAccessible(varID.lVal);
1171 if (childAccessible)
1172 {
1173 varID.lVal = 0;
1174 HRESULT hResult = childAccessible->get_accName(varID, pszName);
1175 childAccessible->Release();
1176 return hResult;
1177 }
1178 else if (m_pAccessible->GetIAccessibleStd())
1179 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accName(varID, pszName);
c6e2af45 1180 }
2aefc528
JS
1181 else if (m_pAccessible->GetIAccessibleStd())
1182 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accName (varID, pszName);
ed5317e5
JS
1183 }
1184 else
1185 {
1186 wxBasicString basicString(name);
1187 *pszName = basicString.Get();
1188 return S_OK;
1189 }
2aefc528 1190 return E_NOTIMPL;
ed5317e5
JS
1191}
1192
1193// Retrieves information that describes the role of the specified object.
1194// All objects support this property.
1195
1196STDMETHODIMP wxIAccessible::get_accRole ( VARIANT varID, VARIANT* pVarRole)
1197{
ecd6e7ea 1198 wxLogTrace(wxT("access"), wxT("get_accRole"));
ed5317e5
JS
1199 wxASSERT (m_pAccessible != NULL);
1200 if (!m_pAccessible)
1201 return E_FAIL;
0a0e6a5b 1202
ed5317e5 1203 if (varID.vt != VT_I4)
c6e2af45 1204 {
ecd6e7ea 1205 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accRole"));
ed5317e5 1206 return E_INVALIDARG;
c6e2af45 1207 }
0a0e6a5b 1208
ed5317e5
JS
1209 VariantInit(pVarRole);
1210
1211 wxAccRole role = wxROLE_NONE;
0a0e6a5b 1212
ed5317e5 1213 wxAccStatus status = m_pAccessible->GetRole(varID.lVal, & role);
0a0e6a5b 1214
ed5317e5
JS
1215 if (status == wxACC_FAIL)
1216 return E_FAIL;
0a0e6a5b 1217
ed5317e5
JS
1218 if (status == wxACC_NOT_IMPLEMENTED)
1219 {
2aefc528
JS
1220 // Try to use child object directly.
1221 if (varID.lVal > 0)
1222 {
1223 IAccessible* childAccessible = GetChildAccessible(varID.lVal);
1224 if (childAccessible)
1225 {
1226 varID.lVal = 0;
1227 HRESULT hResult = childAccessible->get_accRole(varID, pVarRole);
1228 childAccessible->Release();
1229 return hResult;
1230 }
1231 else if (m_pAccessible->GetIAccessibleStd())
1232 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accRole(varID, pVarRole);
1233 }
1234 else if (m_pAccessible->GetIAccessibleStd())
1235 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accRole (varID, pVarRole);
ed5317e5
JS
1236 }
1237 else
1238 {
1239 if (role == wxROLE_NONE)
1240 {
1241 pVarRole->vt = VT_EMPTY;
1242 return S_OK;
1243 }
1244
1245 pVarRole->lVal = wxConvertToWindowsRole(role);
1246 pVarRole->vt = VT_I4;
1247
1248 return S_OK;
1249 }
2aefc528 1250 return E_NOTIMPL;
ed5317e5
JS
1251}
1252
1253// Retrieves the current state of the specified object.
1254// All objects support this property.
0a0e6a5b 1255
ed5317e5
JS
1256STDMETHODIMP wxIAccessible::get_accState ( VARIANT varID, VARIANT* pVarState)
1257{
ecd6e7ea 1258 wxLogTrace(wxT("access"), wxT("get_accState"));
ed5317e5
JS
1259 wxASSERT (m_pAccessible != NULL);
1260 if (!m_pAccessible)
1261 return E_FAIL;
0a0e6a5b 1262
2aefc528 1263 if (varID.vt != VT_I4 && varID.vt != VT_EMPTY)
c6e2af45 1264 {
ecd6e7ea 1265 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accState"));
ed5317e5 1266 return E_INVALIDARG;
c6e2af45 1267 }
ed5317e5
JS
1268
1269 long wxstate = 0;
0a0e6a5b 1270
ed5317e5
JS
1271 wxAccStatus status = m_pAccessible->GetState(varID.lVal, & wxstate);
1272 if (status == wxACC_FAIL)
1273 return E_FAIL;
0a0e6a5b 1274
ed5317e5
JS
1275 if (status == wxACC_NOT_IMPLEMENTED)
1276 {
2aefc528
JS
1277 // Try to use child object directly.
1278 if (varID.lVal > 0)
1279 {
1280 IAccessible* childAccessible = GetChildAccessible(varID.lVal);
1281 if (childAccessible)
1282 {
1283 varID.lVal = 0;
1284 HRESULT hResult = childAccessible->get_accState(varID, pVarState);
1285 childAccessible->Release();
1286 return hResult;
1287 }
1288 else if (m_pAccessible->GetIAccessibleStd())
1289 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accState(varID, pVarState);
1290 }
1291 else if (m_pAccessible->GetIAccessibleStd())
1292 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accState (varID, pVarState);
ed5317e5
JS
1293 }
1294 else
1295 {
1296 long state = wxConvertToWindowsState(wxstate);
1297 pVarState->lVal = state;
1298 pVarState->vt = VT_I4;
1299 return S_OK;
1300 }
2aefc528 1301 return E_NOTIMPL;
ed5317e5 1302}
0a0e6a5b 1303
ed5317e5
JS
1304// Retrieves the value of the specified object.
1305// Not all objects have a value.
1306
1307STDMETHODIMP wxIAccessible::get_accValue ( VARIANT varID, BSTR* pszValue)
1308{
ecd6e7ea 1309 wxLogTrace(wxT("access"), wxT("get_accValue"));
ed5317e5
JS
1310 wxASSERT (m_pAccessible != NULL);
1311 if (!m_pAccessible)
1312 return E_FAIL;
0a0e6a5b 1313
ed5317e5 1314 if (varID.vt != VT_I4)
c6e2af45 1315 {
ecd6e7ea 1316 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accValue"));
ed5317e5 1317 return E_INVALIDARG;
c6e2af45 1318 }
0a0e6a5b 1319
ed5317e5 1320 wxString strValue;
0a0e6a5b 1321
ed5317e5 1322 wxAccStatus status = m_pAccessible->GetValue(varID.lVal, & strValue);
0a0e6a5b 1323
ed5317e5
JS
1324 if (status == wxACC_FAIL)
1325 return E_FAIL;
0a0e6a5b 1326
ed5317e5
JS
1327 if (status == wxACC_NOT_IMPLEMENTED)
1328 {
2aefc528
JS
1329 // Try to use child object directly.
1330 if (varID.lVal > 0)
1331 {
1332 IAccessible* childAccessible = GetChildAccessible(varID.lVal);
1333 if (childAccessible)
1334 {
1335 varID.lVal = 0;
1336 HRESULT hResult = childAccessible->get_accValue(varID, pszValue);
1337 childAccessible->Release();
1338 return hResult;
1339 }
1340 else if (m_pAccessible->GetIAccessibleStd())
1341 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accValue(varID, pszValue);
1342 }
1343 else if (m_pAccessible->GetIAccessibleStd())
1344 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accValue (varID, pszValue);
ed5317e5
JS
1345 }
1346 else
1347 {
1348 wxBasicString basicString(strValue);
1349 * pszValue = basicString.Get();
1350 return S_OK;
1351 }
2aefc528 1352 return E_NOTIMPL;
ed5317e5
JS
1353}
1354
1355// Modifies the selection or moves the keyboard focus of the
1356// specified object. All objects that select or receive the
1357// keyboard focus must support this method.
1358
1359STDMETHODIMP wxIAccessible::accSelect ( long flagsSelect, VARIANT varID )
1360{
ecd6e7ea 1361 wxLogTrace(wxT("access"), wxT("get_accSelect"));
ed5317e5
JS
1362 wxASSERT (m_pAccessible != NULL);
1363 if (!m_pAccessible)
1364 return E_FAIL;
0a0e6a5b 1365
c6e2af45
JS
1366 if (varID.vt != VT_I4 && varID.vt != VT_EMPTY)
1367 {
ecd6e7ea 1368 wxLogTrace(wxT("access"), wxT("Invalid arg for accSelect"));
ed5317e5 1369 return E_INVALIDARG;
c6e2af45 1370 }
0a0e6a5b 1371
ed5317e5
JS
1372 wxAccSelectionFlags wxsel = wxConvertFromWindowsSelFlag(flagsSelect);
1373
1374 wxAccStatus status = m_pAccessible->Select(varID.lVal, wxsel);
1375 if (status == wxACC_FAIL)
1376 return E_FAIL;
0a0e6a5b 1377
ed5317e5
JS
1378 if (status == wxACC_NOT_IMPLEMENTED)
1379 {
2aefc528
JS
1380 // Try to use child object directly.
1381 if (varID.lVal > 0 && varID.lVal > 0)
1382 {
1383 IAccessible* childAccessible = GetChildAccessible(varID.lVal);
1384 if (childAccessible)
1385 {
1386 varID.lVal = 0;
1387 HRESULT hResult = childAccessible->accSelect(flagsSelect, varID);
1388 childAccessible->Release();
1389 return hResult;
1390 }
1391 else if (m_pAccessible->GetIAccessibleStd())
1392 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->accSelect(flagsSelect, varID);
1393 }
1394 else if (m_pAccessible->GetIAccessibleStd())
1395 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->accSelect(flagsSelect, varID);
ed5317e5
JS
1396 }
1397 else
1398 return S_OK;
1399
2aefc528 1400 return E_NOTIMPL;
ed5317e5
JS
1401}
1402
1403// Retrieves the object that has the keyboard focus. All objects
1404// that receive the keyboard focus must support this property.
0a0e6a5b 1405
ed5317e5
JS
1406STDMETHODIMP wxIAccessible::get_accFocus ( VARIANT* pVarID)
1407{
ecd6e7ea 1408 wxLogTrace(wxT("access"), wxT("get_accFocus"));
ed5317e5
JS
1409 wxASSERT (m_pAccessible != NULL);
1410 if (!m_pAccessible)
1411 return E_FAIL;
0a0e6a5b 1412
ed5317e5
JS
1413 wxAccessible* childObject = NULL;
1414 int childId = 0;
1415 VariantInit(pVarID);
0a0e6a5b 1416
ed5317e5
JS
1417 wxAccStatus status = m_pAccessible->GetFocus(& childId, & childObject);
1418 if (status == wxACC_FAIL)
1419 return E_FAIL;
0a0e6a5b 1420
ed5317e5
JS
1421 if (status == wxACC_NOT_IMPLEMENTED)
1422 {
1423 // Use standard interface instead.
1424 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1425 if (!stdInterface)
2aefc528 1426 return E_NOTIMPL;
ed5317e5
JS
1427 else
1428 return stdInterface->get_accFocus (pVarID);
1429 }
1430 if (childObject)
1431 {
1432 if (childObject == m_pAccessible)
1433 {
1434 pVarID->vt = VT_I4;
1435 pVarID->lVal = CHILDID_SELF;
c6e2af45 1436 return S_OK; }
ed5317e5
JS
1437 else
1438 {
1439 wxIAccessible* childIA = childObject->GetIAccessible();
1440 if (!childIA)
2aefc528 1441 return E_NOTIMPL;
ed5317e5 1442
0a0e6a5b
WS
1443 if (childIA->QueryInterface(IID_IDispatch, (LPVOID*) & pVarID->pdispVal) != S_OK)
1444 return E_FAIL;
1445
ed5317e5 1446 pVarID->vt = VT_DISPATCH;
ed5317e5
JS
1447 return S_OK;
1448 }
1449 }
1450 else if (childId > 0)
1451 {
1452 pVarID->vt = VT_I4;
1453 pVarID->lVal = childId;
1454 return S_OK;
1455 }
1456 else
1457 {
1458 pVarID->vt = VT_EMPTY;
1459 return S_FALSE;
1460 }
0a0e6a5b
WS
1461
1462 #if 0
66b9ec3d
JS
1463 // all cases above already cause some return action so below line
1464 // is unreachable and cause unnecessary warning
2aefc528 1465 return E_NOTIMPL;
66b9ec3d 1466 #endif
ed5317e5
JS
1467}
1468
1469// Retrieves the selected children of this object. All objects
1470// selected must support this property.
0a0e6a5b 1471
ed5317e5
JS
1472STDMETHODIMP wxIAccessible::get_accSelection ( VARIANT * pVarChildren)
1473{
ecd6e7ea 1474 wxLogTrace(wxT("access"), wxT("get_accSelection"));
ed5317e5
JS
1475 wxASSERT (m_pAccessible != NULL);
1476 if (!m_pAccessible)
1477 return E_FAIL;
1478
1479 VariantInit(pVarChildren);
0a0e6a5b 1480
ed5317e5
JS
1481 wxVariant selections;
1482 wxAccStatus status = m_pAccessible->GetSelections(& selections);
1483 if (status == wxACC_FAIL)
1484 return E_FAIL;
0a0e6a5b 1485
ed5317e5
JS
1486 if (status == wxACC_NOT_IMPLEMENTED)
1487 {
1488 // Use standard interface instead.
1489 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1490 if (!stdInterface)
2aefc528 1491 return E_NOTIMPL;
ed5317e5
JS
1492 else
1493 return stdInterface->get_accSelection (pVarChildren);
1494 }
1495 else
1496 {
1497 if (selections.GetType() == wxT("long"))
1498 {
1499 pVarChildren->vt = VT_I4;
1500 pVarChildren->lVal = selections.GetLong();
1501
1502 return S_OK;
1503 }
1504 else if (selections.GetType() == wxT("void*"))
1505 {
1506 wxAccessible* childObject = (wxAccessible*) selections.GetVoidPtr();
1507 wxIAccessible* childIA = childObject->GetIAccessible();
1508 if (!childIA)
2aefc528 1509 return E_NOTIMPL;
ed5317e5 1510
0a0e6a5b
WS
1511 if (childIA->QueryInterface(IID_IDispatch, (LPVOID*) & pVarChildren->pdispVal) != S_OK)
1512 return E_FAIL;
1513
ed5317e5 1514 pVarChildren->vt = VT_DISPATCH;
ed5317e5
JS
1515
1516 return S_OK;
1517 }
1518 else if (selections.GetType() == wxT("list"))
1519 {
1520 // TODO: should we AddRef for every "void*" member??
1521
1522 wxIEnumVARIANT* enumVariant = new wxIEnumVARIANT(selections);
1523 enumVariant->AddRef();
1524
1525 pVarChildren->vt = VT_UNKNOWN;
1526 pVarChildren->punkVal = enumVariant;
1527
1528 return S_OK;
1529 }
1530 }
1531
2aefc528 1532 return E_NOTIMPL;
ed5317e5
JS
1533}
1534
1535// Get type info
1536
66b9ec3d 1537STDMETHODIMP wxIAccessible::GetTypeInfo(unsigned int WXUNUSED(typeInfo), LCID WXUNUSED(lcid), ITypeInfo** ppTypeInfo)
ed5317e5
JS
1538{
1539 *ppTypeInfo = NULL;
1540 return E_NOTIMPL;
1541}
1542
1543// Get type info count
1544
1545STDMETHODIMP wxIAccessible::GetTypeInfoCount(unsigned int* typeInfoCount)
1546{
1547 *typeInfoCount = 0;
1548 return E_NOTIMPL;
1549}
1550
1551// Get ids of names
1552
66b9ec3d
JS
1553STDMETHODIMP wxIAccessible::GetIDsOfNames(REFIID WXUNUSED(riid), OLECHAR** WXUNUSED(names), unsigned int WXUNUSED(cNames),
1554 LCID WXUNUSED(lcid), DISPID* WXUNUSED(dispId))
ed5317e5
JS
1555{
1556 return E_NOTIMPL;
1557}
1558
1559// Invoke
1560
0a0e6a5b
WS
1561STDMETHODIMP wxIAccessible::Invoke(DISPID WXUNUSED(dispIdMember), REFIID WXUNUSED(riid), LCID WXUNUSED(lcid),
1562 WORD WXUNUSED(wFlags), DISPPARAMS *WXUNUSED(pDispParams),
1563 VARIANT *WXUNUSED(pVarResult), EXCEPINFO *WXUNUSED(pExcepInfo),
66b9ec3d 1564 unsigned int *WXUNUSED(puArgErr) )
ed5317e5
JS
1565{
1566 return E_NOTIMPL;
1567}
1568
2aefc528 1569// Gets the standard IAccessible interface for the given child or object.
c6e2af45
JS
1570// Call Release if this is non-NULL.
1571IAccessible* wxIAccessible::GetChildStdAccessible(int id)
1572{
1573 if (id == 0)
1574 {
1575 IAccessible* obj = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1576
1577 obj->AddRef();
1578 return obj;
1579 }
1580 else
1581 {
1582 VARIANT var;
1583 VariantInit(& var);
1584 var.vt = VT_I4;
1585 var.lVal = id;
1586 IDispatch* pDispatch = NULL;
1587 if (S_OK == get_accChild ( var, & pDispatch))
1588 {
1589 IAccessible* childAccessible = NULL;
1590 if (pDispatch->QueryInterface(IID_IAccessible, (LPVOID*) & childAccessible) == S_OK)
1591 {
1592 pDispatch->Release();
1593 wxIAccessible* c = (wxIAccessible*) childAccessible;
1594 IAccessible* stdChildAccessible = (IAccessible*) c->m_pAccessible->GetIAccessibleStd();
1595 stdChildAccessible->AddRef();
1596 childAccessible->Release();
1597 return stdChildAccessible;
1598 }
1599 else
1600 {
1601 pDispatch->Release();
0a0e6a5b 1602 }
c6e2af45
JS
1603 }
1604 }
1605
1606#if 0
1607 {
1608 // Loop until we find the right id
1609 long nChildren = 0;
1610 this->get_accChildCount(& nChildren);
1611
1612 int i;
1613 for (i = 0; i < nChildren; i++)
1614 {
1615 long obtained = 0;
1616 VARIANT var;
1617 VariantInit(& var);
1618 var.vt = VT_I4;
1619 if (S_OK == AccessibleChildren(this, i, 1, & var, &obtained))
1620 {
1621 if (var.lVal == id)
1622 {
1623 VariantInit(& var);
1624 var.vt = VT_DISPATCH;
1625 if (S_OK == AccessibleChildren(this, i, 1, & var, &obtained))
1626 {
1627 IAccessible* childAccessible = NULL;
1628 if (var.pdispVal->QueryInterface(IID_IAccessible, (LPVOID*) & childAccessible) == S_OK)
1629 {
1630 var.pdispVal->Release();
1631 return childAccessible;
1632 }
1633 else
1634 {
1635 var.pdispVal->Release();
0a0e6a5b 1636 }
c6e2af45
JS
1637 }
1638 }
1639 break;
1640 }
1641 }
1642 }
1643#endif
1644 return NULL;
1645}
1646
2aefc528
JS
1647// Gets the IAccessible interface for the given child or object.
1648// Call Release if this is non-NULL.
1649IAccessible* wxIAccessible::GetChildAccessible(int id)
1650{
1651 if (id == 0)
1652 {
1653 IAccessible* obj = this;
1654
1655 obj->AddRef();
1656 return obj;
1657 }
1658 else
1659 {
1660 VARIANT var;
1661 VariantInit(& var);
1662 var.vt = VT_I4;
1663 var.lVal = id;
1664 IDispatch* pDispatch = NULL;
1665 if (S_OK == get_accChild ( var, & pDispatch))
1666 {
1667 IAccessible* childAccessible = NULL;
1668 if (pDispatch->QueryInterface(IID_IAccessible, (LPVOID*) & childAccessible) == S_OK)
1669 {
1670 pDispatch->Release();
1671 return childAccessible;
1672 }
1673 else
1674 {
1675 pDispatch->Release();
0a0e6a5b 1676 }
2aefc528
JS
1677 }
1678 }
1679 return NULL;
1680}
c6e2af45 1681
ed5317e5
JS
1682// ----------------------------------------------------------------------------
1683// wxAccessible implementation
1684// ----------------------------------------------------------------------------
1685
1686// ctors
1687
1688// common part of all ctors
1689void wxAccessible::Init()
1690{
1691 m_pIAccessibleStd = NULL;
1692 m_pIAccessible = new wxIAccessible(this);
1693 m_pIAccessible->AddRef();
1694}
1695
1696wxAccessible::wxAccessible(wxWindow* win)
1697 : wxAccessibleBase(win)
1698{
1699 Init();
1700}
1701
1702wxAccessible::~wxAccessible()
1703{
1704 m_pIAccessible->Release();
1705 if (m_pIAccessibleStd)
1706 ((IAccessible*)m_pIAccessibleStd)->Release();
1707}
1708
1709// Gets or creates a standard interface for this object.
1710void* wxAccessible::GetIAccessibleStd()
1711{
1712 if (m_pIAccessibleStd)
1713 return m_pIAccessibleStd;
1714
1715 if (GetWindow())
1716 {
ed5317e5
JS
1717 HRESULT retCode = ::CreateStdAccessibleObject((HWND) GetWindow()->GetHWND(),
1718 OBJID_CLIENT, IID_IAccessible, (void**) & m_pIAccessibleStd);
ed5317e5
JS
1719 if (retCode == S_OK)
1720 return m_pIAccessibleStd;
1721 else
1722 {
1723 m_pIAccessibleStd = NULL;
1724 return NULL;
1725 }
1726 }
1727 return NULL;
1728}
1729
6c9a19aa
JS
1730// Sends an event when something changes in an accessible object.
1731void wxAccessible::NotifyEvent(int eventType, wxWindow* window, wxAccObject objectType,
1732 int objectId)
1733{
1734 ::NotifyWinEvent((DWORD) eventType, (HWND) window->GetHWND(),
1735 (LONG) objectType, (LONG) objectId);
1736}
1737
ed5317e5
JS
1738// Utilities
1739
1740// Convert to Windows role
1741int wxConvertToWindowsRole(wxAccRole wxrole)
1742{
1743 switch (wxrole)
1744 {
1745 case wxROLE_SYSTEM_ALERT:
1746 return ROLE_SYSTEM_ALERT;
1747 case wxROLE_SYSTEM_ANIMATION:
1748 return ROLE_SYSTEM_ANIMATION;
1749 case wxROLE_SYSTEM_APPLICATION:
1750 return ROLE_SYSTEM_APPLICATION;
1751 case wxROLE_SYSTEM_BORDER:
1752 return ROLE_SYSTEM_BORDER;
1753 case wxROLE_SYSTEM_BUTTONDROPDOWN:
1754 return ROLE_SYSTEM_BUTTONDROPDOWN;
1755 case wxROLE_SYSTEM_BUTTONDROPDOWNGRID:
1756 return ROLE_SYSTEM_BUTTONDROPDOWNGRID;
1757 case wxROLE_SYSTEM_BUTTONMENU:
1758 return ROLE_SYSTEM_BUTTONMENU;
1759 case wxROLE_SYSTEM_CARET:
1760 return ROLE_SYSTEM_CARET;
1761 case wxROLE_SYSTEM_CELL:
1762 return ROLE_SYSTEM_CELL;
1763 case wxROLE_SYSTEM_CHARACTER:
1764 return ROLE_SYSTEM_CHARACTER;
1765 case wxROLE_SYSTEM_CHART:
1766 return ROLE_SYSTEM_CHART;
1767 case wxROLE_SYSTEM_CHECKBUTTON:
1768 return ROLE_SYSTEM_CHECKBUTTON;
1769 case wxROLE_SYSTEM_CLIENT:
1770 return ROLE_SYSTEM_CLIENT;
1771 case wxROLE_SYSTEM_CLOCK:
1772 return ROLE_SYSTEM_CLOCK;
1773 case wxROLE_SYSTEM_COLUMN:
1774 return ROLE_SYSTEM_COLUMN;
1775 case wxROLE_SYSTEM_COLUMNHEADER:
1776 return ROLE_SYSTEM_COLUMNHEADER;
1777 case wxROLE_SYSTEM_COMBOBOX:
1778 return ROLE_SYSTEM_COMBOBOX;
1779 case wxROLE_SYSTEM_CURSOR:
1780 return ROLE_SYSTEM_CURSOR;
1781 case wxROLE_SYSTEM_DIAGRAM:
1782 return ROLE_SYSTEM_DIAGRAM;
1783 case wxROLE_SYSTEM_DIAL:
1784 return ROLE_SYSTEM_DIAL;
1785 case wxROLE_SYSTEM_DIALOG:
1786 return ROLE_SYSTEM_DIALOG;
1787 case wxROLE_SYSTEM_DOCUMENT:
1788 return ROLE_SYSTEM_DOCUMENT;
1789 case wxROLE_SYSTEM_DROPLIST:
1790 return ROLE_SYSTEM_DROPLIST;
1791 case wxROLE_SYSTEM_EQUATION:
1792 return ROLE_SYSTEM_EQUATION;
1793 case wxROLE_SYSTEM_GRAPHIC:
1794 return ROLE_SYSTEM_GRAPHIC;
1795 case wxROLE_SYSTEM_GRIP:
1796 return ROLE_SYSTEM_GRIP;
1797 case wxROLE_SYSTEM_GROUPING:
1798 return ROLE_SYSTEM_GROUPING;
1799 case wxROLE_SYSTEM_HELPBALLOON:
1800 return ROLE_SYSTEM_HELPBALLOON;
1801 case wxROLE_SYSTEM_HOTKEYFIELD:
1802 return ROLE_SYSTEM_HOTKEYFIELD;
1803 case wxROLE_SYSTEM_INDICATOR:
1804 return ROLE_SYSTEM_INDICATOR;
1805 case wxROLE_SYSTEM_LINK:
1806 return ROLE_SYSTEM_LINK;
1807 case wxROLE_SYSTEM_LIST:
1808 return ROLE_SYSTEM_LIST;
1809 case wxROLE_SYSTEM_LISTITEM:
1810 return ROLE_SYSTEM_LISTITEM;
1811 case wxROLE_SYSTEM_MENUBAR:
1812 return ROLE_SYSTEM_MENUBAR;
1813 case wxROLE_SYSTEM_MENUITEM:
1814 return ROLE_SYSTEM_MENUITEM;
1815 case wxROLE_SYSTEM_MENUPOPUP:
1816 return ROLE_SYSTEM_MENUPOPUP;
1817 case wxROLE_SYSTEM_OUTLINE:
1818 return ROLE_SYSTEM_OUTLINE;
1819 case wxROLE_SYSTEM_OUTLINEITEM:
1820 return ROLE_SYSTEM_OUTLINEITEM;
1821 case wxROLE_SYSTEM_PAGETAB:
1822 return ROLE_SYSTEM_PAGETAB;
1823 case wxROLE_SYSTEM_PAGETABLIST:
1824 return ROLE_SYSTEM_PAGETABLIST;
1825 case wxROLE_SYSTEM_PANE:
1826 return ROLE_SYSTEM_PANE;
1827 case wxROLE_SYSTEM_PROGRESSBAR:
1828 return ROLE_SYSTEM_PROGRESSBAR;
1829 case wxROLE_SYSTEM_PROPERTYPAGE:
1830 return ROLE_SYSTEM_PROPERTYPAGE;
1831 case wxROLE_SYSTEM_PUSHBUTTON:
1832 return ROLE_SYSTEM_PUSHBUTTON;
1833 case wxROLE_SYSTEM_RADIOBUTTON:
1834 return ROLE_SYSTEM_RADIOBUTTON;
1835 case wxROLE_SYSTEM_ROW:
1836 return ROLE_SYSTEM_ROW;
1837 case wxROLE_SYSTEM_ROWHEADER:
1838 return ROLE_SYSTEM_ROWHEADER;
1839 case wxROLE_SYSTEM_SCROLLBAR:
1840 return ROLE_SYSTEM_SCROLLBAR;
1841 case wxROLE_SYSTEM_SEPARATOR:
1842 return ROLE_SYSTEM_SEPARATOR;
1843 case wxROLE_SYSTEM_SLIDER:
1844 return ROLE_SYSTEM_SLIDER;
1845 case wxROLE_SYSTEM_SOUND:
1846 return ROLE_SYSTEM_SOUND;
1847 case wxROLE_SYSTEM_SPINBUTTON:
1848 return ROLE_SYSTEM_SPINBUTTON;
1849 case wxROLE_SYSTEM_STATICTEXT:
1850 return ROLE_SYSTEM_STATICTEXT;
1851 case wxROLE_SYSTEM_STATUSBAR:
1852 return ROLE_SYSTEM_STATUSBAR;
1853 case wxROLE_SYSTEM_TABLE:
1854 return ROLE_SYSTEM_TABLE;
1855 case wxROLE_SYSTEM_TEXT:
1856 return ROLE_SYSTEM_TEXT;
1857 case wxROLE_SYSTEM_TITLEBAR:
1858 return ROLE_SYSTEM_TITLEBAR;
1859 case wxROLE_SYSTEM_TOOLBAR:
1860 return ROLE_SYSTEM_TOOLBAR;
1861 case wxROLE_SYSTEM_TOOLTIP:
1862 return ROLE_SYSTEM_TOOLTIP;
1863 case wxROLE_SYSTEM_WHITESPACE:
1864 return ROLE_SYSTEM_WHITESPACE;
1865 case wxROLE_SYSTEM_WINDOW:
1866 return ROLE_SYSTEM_WINDOW;
1867 }
1868 return 0;
1869}
1870
1871// Convert to Windows state
1872long wxConvertToWindowsState(long wxstate)
1873{
1874 long state = 0;
1875 if (wxstate & wxACC_STATE_SYSTEM_ALERT_HIGH)
1876 state |= STATE_SYSTEM_ALERT_HIGH;
1877
1878 if (wxstate & wxACC_STATE_SYSTEM_ALERT_MEDIUM)
1879 state |= STATE_SYSTEM_ALERT_MEDIUM;
1880
1881 if (wxstate & wxACC_STATE_SYSTEM_ALERT_LOW)
1882 state |= STATE_SYSTEM_ALERT_LOW;
1883
1884 if (wxstate & wxACC_STATE_SYSTEM_ANIMATED)
1885 state |= STATE_SYSTEM_ANIMATED;
1886
1887 if (wxstate & wxACC_STATE_SYSTEM_BUSY)
1888 state |= STATE_SYSTEM_BUSY;
1889
1890 if (wxstate & wxACC_STATE_SYSTEM_CHECKED)
1891 state |= STATE_SYSTEM_CHECKED;
1892
1893 if (wxstate & wxACC_STATE_SYSTEM_COLLAPSED)
1894 state |= STATE_SYSTEM_COLLAPSED;
1895
1896 if (wxstate & wxACC_STATE_SYSTEM_DEFAULT)
1897 state |= STATE_SYSTEM_DEFAULT;
1898
1899 if (wxstate & wxACC_STATE_SYSTEM_EXPANDED)
1900 state |= STATE_SYSTEM_EXPANDED;
1901
1902 if (wxstate & wxACC_STATE_SYSTEM_EXTSELECTABLE)
1903 state |= STATE_SYSTEM_EXTSELECTABLE;
1904
1905 if (wxstate & wxACC_STATE_SYSTEM_FLOATING)
1906 state |= STATE_SYSTEM_FLOATING;
1907
1908 if (wxstate & wxACC_STATE_SYSTEM_FOCUSABLE)
1909 state |= STATE_SYSTEM_FOCUSABLE;
1910
1911 if (wxstate & wxACC_STATE_SYSTEM_FOCUSED)
1912 state |= STATE_SYSTEM_FOCUSED;
1913
1914 if (wxstate & wxACC_STATE_SYSTEM_HOTTRACKED)
1915 state |= STATE_SYSTEM_HOTTRACKED;
1916
1917 if (wxstate & wxACC_STATE_SYSTEM_INVISIBLE)
1918 state |= STATE_SYSTEM_INVISIBLE;
1919
1920 if (wxstate & wxACC_STATE_SYSTEM_INVISIBLE)
1921 state |= STATE_SYSTEM_INVISIBLE;
1922
1923 if (wxstate & wxACC_STATE_SYSTEM_MIXED)
1924 state |= STATE_SYSTEM_MIXED;
1925
1926 if (wxstate & wxACC_STATE_SYSTEM_MULTISELECTABLE)
1927 state |= STATE_SYSTEM_MULTISELECTABLE;
1928
1929 if (wxstate & wxACC_STATE_SYSTEM_OFFSCREEN)
1930 state |= STATE_SYSTEM_OFFSCREEN;
1931
1932 if (wxstate & wxACC_STATE_SYSTEM_PRESSED)
1933 state |= STATE_SYSTEM_PRESSED;
1934
1935// if (wxstate & wxACC_STATE_SYSTEM_PROTECTED)
1936// state |= STATE_SYSTEM_PROTECTED;
1937
1938 if (wxstate & wxACC_STATE_SYSTEM_READONLY)
1939 state |= STATE_SYSTEM_READONLY;
1940
1941 if (wxstate & wxACC_STATE_SYSTEM_SELECTABLE)
1942 state |= STATE_SYSTEM_SELECTABLE;
1943
1944 if (wxstate & wxACC_STATE_SYSTEM_SELECTED)
1945 state |= STATE_SYSTEM_SELECTED;
1946
1947 if (wxstate & wxACC_STATE_SYSTEM_SELFVOICING)
1948 state |= STATE_SYSTEM_SELFVOICING;
1949
1950 if (wxstate & wxACC_STATE_SYSTEM_UNAVAILABLE)
1951 state |= STATE_SYSTEM_UNAVAILABLE;
1952
1953 return state;
1954}
1955
1956// Convert to Windows selection flag
1957int wxConvertToWindowsSelFlag(wxAccSelectionFlags wxsel)
1958{
1959 int sel = 0;
1960
66b9ec3d 1961 if (wxsel & wxACC_SEL_TAKEFOCUS)
ed5317e5 1962 sel |= SELFLAG_TAKEFOCUS;
66b9ec3d 1963 if (wxsel & wxACC_SEL_TAKESELECTION)
ed5317e5 1964 sel |= SELFLAG_TAKESELECTION;
66b9ec3d 1965 if (wxsel & wxACC_SEL_EXTENDSELECTION)
ed5317e5 1966 sel |= SELFLAG_EXTENDSELECTION;
66b9ec3d 1967 if (wxsel & wxACC_SEL_ADDSELECTION)
ed5317e5 1968 sel |= SELFLAG_ADDSELECTION;
66b9ec3d 1969 if (wxsel & wxACC_SEL_REMOVESELECTION)
ed5317e5
JS
1970 sel |= SELFLAG_REMOVESELECTION;
1971 return sel;
1972}
1973
1974// Convert from Windows selection flag
1975wxAccSelectionFlags wxConvertFromWindowsSelFlag(int sel)
1976{
1977 int wxsel = 0;
1978
1979 if (sel & SELFLAG_TAKEFOCUS)
1980 wxsel |= wxACC_SEL_TAKEFOCUS;
1981 if (sel & SELFLAG_TAKESELECTION)
1982 wxsel |= wxACC_SEL_TAKESELECTION;
1983 if (sel & SELFLAG_EXTENDSELECTION)
1984 wxsel |= wxACC_SEL_EXTENDSELECTION;
1985 if (sel & SELFLAG_ADDSELECTION)
1986 wxsel |= wxACC_SEL_ADDSELECTION;
1987 if (sel & SELFLAG_REMOVESELECTION)
1988 wxsel |= wxACC_SEL_REMOVESELECTION;
1989 return (wxAccSelectionFlags) wxsel;
1990}
1991
1992
e4db172a 1993#endif // wxUSE_OLE && wxUSE_ACCESSIBILITY