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