]> git.saurik.com Git - wxWidgets.git/blob - src/msw/ole/access.cpp
require semicolon after wxDECLARE/DEFINE_EVENT() (closes #10456)
[wxWidgets.git] / src / msw / ole / access.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/ole/access.cpp
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
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #if defined(__BORLANDC__)
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_OLE && wxUSE_ACCESSIBILITY
28
29 #include "wx/access.h"
30
31 #ifndef WX_PRECOMP
32 #include "wx/msw/wrapwin.h"
33 #include "wx/window.h"
34 #include "wx/log.h"
35 #endif
36
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
56 int wxConvertToWindowsRole(wxAccRole wxrole);
57
58 // Convert to Windows state
59 long wxConvertToWindowsState(long wxstate);
60
61 // Convert to Windows selection flag
62 int wxConvertToWindowsSelFlag(wxAccSelectionFlags sel);
63
64 // Convert from Windows selection flag
65 wxAccSelectionFlags wxConvertFromWindowsSelFlag(int sel);
66
67 #if wxUSE_VARIANT
68 // ----------------------------------------------------------------------------
69 // wxIEnumVARIANT interface implementation
70 // ----------------------------------------------------------------------------
71
72 class wxIEnumVARIANT : public IEnumVARIANT
73 {
74 public:
75 wxIEnumVARIANT(const wxVariant& variant);
76 virtual ~wxIEnumVARIANT() { }
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
86 private:
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
97 BEGIN_IID_TABLE(wxIEnumVARIANT)
98 ADD_IID(Unknown)
99 ADD_IID(EnumVARIANT)
100 END_IID_TABLE;
101
102 IMPLEMENT_IUNKNOWN_METHODS(wxIEnumVARIANT)
103
104 // wxVariant contains a list of further variants.
105 wxIEnumVARIANT::wxIEnumVARIANT(const wxVariant& variant)
106 {
107 m_variant = variant;
108 }
109
110 STDMETHODIMP 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
142 STDMETHODIMP 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
159 STDMETHODIMP wxIEnumVARIANT::Reset()
160 {
161 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumVARIANT::Reset"));
162
163 m_nCurrent = 0;
164
165 return S_OK;
166 }
167
168 STDMETHODIMP 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 #endif // wxUSE_VARIANT
180
181 // ----------------------------------------------------------------------------
182 // wxIAccessible implementation of IAccessible interface
183 // ----------------------------------------------------------------------------
184
185 class wxIAccessible : public IAccessible
186 {
187 public:
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.
197 // All visual objects support this method; sound objects do not support it.
198
199 STDMETHODIMP accHitTest(long xLeft, long yLeft, VARIANT* pVarID);
200
201 // Retrieves the specified object's current screen location. All visual objects must
202 // support this method; sound objects do not support it.
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.
213
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.
218
219 STDMETHODIMP get_accChildCount ( long* pCountChildren);
220
221 // Retrieves the IDispatch interface of the object's parent.
222 // All objects support this property.
223
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.
230
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.
235
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.
251
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.
257
258 STDMETHODIMP get_accKeyboardShortcut ( VARIANT varID, BSTR* pszKeyboardShortcut);
259
260 // Retrieves the name of the specified object.
261 // All objects support this property.
262
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.
272
273 STDMETHODIMP get_accState ( VARIANT varID, VARIANT* pVarState);
274
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.
290
291 STDMETHODIMP get_accFocus ( VARIANT* pVarID);
292
293 // Retrieves the selected children of this object. All objects
294 // selected must support this property.
295
296 STDMETHODIMP get_accSelection ( VARIANT * pVarChildren);
297
298 // Obsolete
299
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; }
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
320 STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
321 WORD wFlags, DISPPARAMS *pDispParams,
322 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
323 unsigned int *puArgErr );
324
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
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
335 private:
336 wxAccessible *m_pAccessible; // pointer to C++ class we belong to
337
338 DECLARE_NO_COPY_CLASS(wxIAccessible)
339 };
340
341 // ============================================================================
342 // Implementation
343 // ============================================================================
344
345 // ----------------------------------------------------------------------------
346 // wxIAccessible implementation
347 // ----------------------------------------------------------------------------
348 BEGIN_IID_TABLE(wxIAccessible)
349 ADD_IID(Unknown)
350 ADD_IID(Accessible)
351 ADD_IID(Dispatch)
352 END_IID_TABLE;
353
354 IMPLEMENT_IUNKNOWN_METHODS(wxIAccessible)
355
356 wxIAccessible::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.
364 // All visual objects support this method; sound objects do not support it.
365
366 STDMETHODIMP wxIAccessible::accHitTest(long xLeft, long yLeft, VARIANT* pVarID)
367 {
368 wxLogTrace(wxT("access"), wxT("accHitTest"));
369 wxASSERT (m_pAccessible != NULL);
370 if (!m_pAccessible)
371 return E_FAIL;
372
373 wxAccessible* childObject = NULL;
374 int childId = 0;
375 VariantInit(pVarID);
376
377 wxAccStatus status = m_pAccessible->HitTest(wxPoint(xLeft, yLeft), & childId, & childObject);
378
379 if (status == wxACC_FAIL)
380 return E_FAIL;
381
382 if (status == wxACC_NOT_IMPLEMENTED)
383 {
384 // Use standard interface instead.
385 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
386 if (!stdInterface)
387 return E_NOTIMPL;
388 else
389 return stdInterface->accHitTest(xLeft, yLeft, pVarID);
390 }
391
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)
404 return E_NOTIMPL;
405
406 if (childIA->QueryInterface(IID_IDispatch, (LPVOID*) & pVarID->pdispVal) != S_OK)
407 return E_FAIL;
408
409 pVarID->vt = VT_DISPATCH;
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 }
424
425 #if 0
426 // all cases above already cause some return action so below line
427 // is unreachable and cause unnecessary warning
428 return E_NOTIMPL;
429 #endif
430 }
431
432 // Retrieves the specified object's current screen location. All visual objects must
433 // support this method; sound objects do not support it.
434
435 STDMETHODIMP wxIAccessible::accLocation ( long* pxLeft, long* pyTop, long* pcxWidth, long* pcyHeight, VARIANT varID)
436 {
437 wxLogTrace(wxT("access"), wxT("accLocation"));
438 wxASSERT (m_pAccessible != NULL);
439 if (!m_pAccessible)
440 return E_FAIL;
441
442 wxRect rect;
443
444 wxAccStatus status = m_pAccessible->GetLocation(rect, varID.lVal);
445 if (status == wxACC_FAIL)
446 return E_FAIL;
447
448 if (status == wxACC_NOT_IMPLEMENTED)
449 {
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);
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
476 return E_NOTIMPL;
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
482 STDMETHODIMP wxIAccessible::accNavigate ( long navDir, VARIANT varStart, VARIANT* pVarEnd)
483 {
484 wxASSERT (m_pAccessible != NULL);
485 if (!m_pAccessible)
486 return E_FAIL;
487 wxLogTrace(wxT("access"), wxString(wxT("accNavigate for ")) + m_pAccessible->GetWindow()->GetClassInfo()->GetClassName());
488
489 if ((varStart.vt != VT_I4 && varStart.vt != VT_EMPTY)
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 )
496 {
497 wxLogTrace(wxT("access"), wxT("Invalid arg for accNavigate"));
498 return E_INVALIDARG;
499 }
500
501 wxAccessible* elementObject = NULL;
502 int elementId = 0;
503 VariantInit(pVarEnd);
504 wxNavDir navDirWX = wxNAVDIR_FIRSTCHILD;
505
506 wxString navStr;
507
508 switch (navDir)
509 {
510 case NAVDIR_DOWN:
511 navDirWX = wxNAVDIR_DOWN;
512 navStr = wxT("wxNAVDIR_DOWN");
513 break;
514
515 case NAVDIR_FIRSTCHILD:
516 navDirWX = wxNAVDIR_FIRSTCHILD;
517 navStr = wxT("wxNAVDIR_FIRSTCHILD");
518 break;
519
520 case NAVDIR_LASTCHILD:
521 navDirWX = wxNAVDIR_LASTCHILD;
522 navStr = wxT("wxNAVDIR_LASTCHILD");
523 break;
524
525 case NAVDIR_LEFT:
526 navDirWX = wxNAVDIR_LEFT;
527 navStr = wxT("wxNAVDIR_LEFT");
528 break;
529
530 case NAVDIR_NEXT:
531 navDirWX = wxNAVDIR_NEXT;
532 navStr = wxT("wxNAVDIR_NEXT");
533 break;
534
535 case NAVDIR_PREVIOUS:
536 navDirWX = wxNAVDIR_PREVIOUS;
537 navStr = wxT("wxNAVDIR_PREVIOUS");
538 break;
539
540 case NAVDIR_RIGHT:
541 navDirWX = wxNAVDIR_RIGHT;
542 navStr = wxT("wxNAVDIR_RIGHT");
543 break;
544
545 case NAVDIR_UP:
546 navDirWX = wxNAVDIR_UP;
547 navStr = wxT("wxNAVDIR_UP");
548 break;
549 default:
550 {
551 wxLogTrace(wxT("access"), wxT("Unknown NAVDIR symbol"));
552 break;
553 }
554 }
555 wxLogTrace(wxT("access"), navStr);
556
557 wxAccStatus status = m_pAccessible->Navigate(navDirWX, varStart.lVal, & elementId,
558 & elementObject);
559
560 if (status == wxACC_FAIL)
561 {
562 wxLogTrace(wxT("access"), wxT("wxAccessible::Navigate failed"));
563 return E_FAIL;
564 }
565
566 if (status == wxACC_FALSE)
567 {
568 wxLogTrace(wxT("access"), wxT("wxAccessible::Navigate found no object in this direction"));
569 return S_FALSE;
570 }
571
572 if (status == wxACC_NOT_IMPLEMENTED)
573 {
574 wxLogTrace(wxT("access"), wxT("Navigate not implemented"));
575
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);
592 }
593 else
594 {
595 if (elementObject)
596 {
597 wxLogTrace(wxT("access"), wxT("Getting wxIAccessible and calling QueryInterface for Navigate"));
598 wxIAccessible* objectIA = elementObject->GetIAccessible();
599 if (!objectIA)
600 {
601 wxLogTrace(wxT("access"), wxT("No wxIAccessible"));
602 return E_FAIL;
603 }
604
605 HRESULT hResult = objectIA->QueryInterface(IID_IDispatch, (LPVOID*) & pVarEnd->pdispVal);
606 if (hResult != S_OK)
607 {
608 wxLogTrace(wxT("access"), wxT("QueryInterface failed"));
609 return E_FAIL;
610 }
611
612 wxLogTrace(wxT("access"), wxT("Called QueryInterface for Navigate"));
613 pVarEnd->vt = VT_DISPATCH;
614 return S_OK;
615 }
616 else if (elementId > 0)
617 {
618 wxLogTrace(wxT("access"), wxT("Returning element id from Navigate"));
619 pVarEnd->vt = VT_I4;
620 pVarEnd->lVal = elementId;
621 return S_OK;
622 }
623 else
624 {
625 wxLogTrace(wxT("access"), wxT("No object in accNavigate"));
626 pVarEnd->vt = VT_EMPTY;
627 return S_FALSE;
628 }
629 }
630
631 wxLogTrace(wxT("access"), wxT("Failing Navigate"));
632 return E_NOTIMPL;
633 }
634
635 // Retrieves the address of an IDispatch interface for the specified child.
636 // All objects must support this property.
637
638 STDMETHODIMP wxIAccessible::get_accChild ( VARIANT varChildID, IDispatch** ppDispChild)
639 {
640 wxLogTrace(wxT("access"), wxT("get_accChild"));
641 wxASSERT (m_pAccessible != NULL);
642 if (!m_pAccessible)
643 return E_FAIL;
644
645 if (varChildID.vt != VT_I4)
646 {
647 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accChild"));
648 return E_INVALIDARG;
649 }
650
651 if (varChildID.lVal == CHILDID_SELF)
652 {
653 *ppDispChild = this;
654 AddRef();
655 return S_OK;
656 }
657
658 wxAccessible* child = NULL;
659
660 wxAccStatus status = m_pAccessible->GetChild(varChildID.lVal, & child);
661 if (status == wxACC_FAIL)
662 {
663 wxLogTrace(wxT("access"), wxT("GetChild failed"));
664 return E_FAIL;
665 }
666
667 if (status == wxACC_NOT_IMPLEMENTED)
668 {
669 // Use standard interface instead.
670 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
671 if (!stdInterface)
672 return E_NOTIMPL;
673 else
674 {
675 wxLogTrace(wxT("access"), wxT("Using standard interface for get_accChild"));
676 return stdInterface->get_accChild (varChildID, ppDispChild);
677 }
678 }
679 else
680 {
681 if (child)
682 {
683 wxIAccessible* objectIA = child->GetIAccessible();
684 if (!objectIA)
685 return E_NOTIMPL;
686
687 if (objectIA->QueryInterface(IID_IDispatch, (LPVOID*) ppDispChild) != S_OK)
688 {
689 wxLogTrace(wxT("access"), wxT("QueryInterface failed in get_accChild"));
690 return E_FAIL;
691 }
692
693 return S_OK;
694 }
695 else
696 {
697 wxLogTrace(wxT("access"), wxT("Not an accessible object"));
698 return S_FALSE; // Indicates it's not an accessible object
699 }
700 }
701
702 #if 0
703 // all cases above already cause some return action so below line
704 // is unreachable and cause unnecessary warning
705 return E_NOTIMPL;
706 #endif
707 }
708
709 // Retrieves the number of children that belong to this object.
710 // All objects must support this property.
711
712 STDMETHODIMP wxIAccessible::get_accChildCount ( long* pCountChildren)
713 {
714 wxLogTrace(wxT("access"), wxT("get_accChildCount"));
715 wxASSERT (m_pAccessible != NULL);
716 if (!m_pAccessible)
717 return E_FAIL;
718
719 int childCount = 0;
720 wxAccStatus status = m_pAccessible->GetChildCount(& childCount);
721 if (status == wxACC_FAIL)
722 return E_FAIL;
723
724 if (status == wxACC_NOT_IMPLEMENTED)
725 {
726 // Use standard interface instead.
727 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
728 if (!stdInterface)
729 return E_NOTIMPL;
730 else
731 {
732 wxLogTrace(wxT("access"), wxT("Using standard interface for get_accChildCount"));
733 HRESULT res = stdInterface->get_accChildCount (pCountChildren);
734 wxString str;
735 str.Printf(wxT("Number of children was %d"), (int) (*pCountChildren));
736 wxLogTrace(wxT("access"), str);
737 return res;
738 }
739 }
740 else
741 {
742 * pCountChildren = (long) childCount;
743 return S_OK;
744 }
745
746 #if 0
747 // all cases above already cause some return action so below line
748 // is unreachable and cause unnecessary warning
749 return E_NOTIMPL;
750 #endif
751 }
752
753 // Retrieves the IDispatch interface of the object's parent.
754 // All objects support this property.
755
756 STDMETHODIMP wxIAccessible::get_accParent ( IDispatch** ppDispParent)
757 {
758 wxLogTrace(wxT("access"), wxT("get_accParent"));
759 wxASSERT (m_pAccessible != NULL);
760 if (!m_pAccessible)
761 return E_FAIL;
762
763 wxAccessible* parent = NULL;
764 wxAccStatus status = m_pAccessible->GetParent(& parent);
765
766 if (status == wxACC_FAIL)
767 return E_FAIL;
768
769 // It doesn't seem acceptable to return S_FALSE with a NULL
770 // ppDispParent, so if we have no wxWidgets parent, we leave
771 // it to the standard interface.
772 if (status == wxACC_NOT_IMPLEMENTED || !parent)
773 {
774 wxLogTrace(wxT("access"), wxT("Using standard interface to get the parent."));
775 // Use standard interface instead.
776 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
777 if (!stdInterface)
778 return E_NOTIMPL;
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
790 wxLogTrace(wxT("access"), wxT("About to call QueryInterface"));
791 if (objectIA->QueryInterface(IID_IDispatch, (LPVOID*) ppDispParent) != S_OK)
792 {
793 wxLogTrace(wxT("access"), wxT("Failed QueryInterface"));
794 return E_FAIL;
795 }
796
797 wxLogTrace(wxT("access"), wxT("Returning S_OK for get_accParent"));
798 return S_OK;
799 }
800 else
801 {
802 // This doesn't seem to be allowed, despite the documentation,
803 // so we handle it higher up by using the standard interface.
804 wxLogTrace(wxT("access"), wxT("Returning NULL parent because there was none"));
805 *ppDispParent = NULL;
806 return S_FALSE;
807 }
808 }
809
810 #if 0
811 // all cases above already cause some return action so below line
812 // is unreachable and cause unnecessary warning
813 return E_NOTIMPL;
814 #endif
815 }
816
817 // Performs the object's default action. Not all objects have a default
818 // action.
819
820 STDMETHODIMP wxIAccessible::accDoDefaultAction(VARIANT varID)
821 {
822 wxLogTrace(wxT("access"), wxT("accDoDefaultAction"));
823 wxASSERT (m_pAccessible != NULL);
824 if (!m_pAccessible)
825 return E_FAIL;
826
827 if (varID.vt != VT_I4)
828 {
829 wxLogTrace(wxT("access"), wxT("Invalid arg for accDoDefaultAction"));
830 return E_INVALIDARG;
831 }
832
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;
839
840 if (status == wxACC_NOT_IMPLEMENTED)
841 {
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);
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.
864
865 STDMETHODIMP wxIAccessible::get_accDefaultAction ( VARIANT varID, BSTR* pszDefaultAction)
866 {
867 wxLogTrace(wxT("access"), wxT("get_accDefaultAction"));
868 wxASSERT (m_pAccessible != NULL);
869 if (!m_pAccessible)
870 return E_FAIL;
871
872 if (varID.vt != VT_I4)
873 {
874 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accDefaultAction"));
875 return E_INVALIDARG;
876 }
877
878 wxString defaultAction;
879 wxAccStatus status = m_pAccessible->GetDefaultAction(varID.lVal, & defaultAction);
880 if (status == wxACC_FAIL)
881 return E_FAIL;
882
883 if (status == wxACC_NOT_SUPPORTED)
884 return DISP_E_MEMBERNOTFOUND;
885
886 if (status == wxACC_NOT_IMPLEMENTED)
887 {
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);
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
925 STDMETHODIMP wxIAccessible::get_accDescription ( VARIANT varID, BSTR* pszDescription)
926 {
927 wxLogTrace(wxT("access"), wxT("get_accDescription"));
928 wxASSERT (m_pAccessible != NULL);
929 if (!m_pAccessible)
930 return E_FAIL;
931
932 if (varID.vt != VT_I4)
933 {
934 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accDescription"));
935 return E_INVALIDARG;
936 }
937
938 wxString description;
939 wxAccStatus status = m_pAccessible->GetDescription(varID.lVal, & description);
940 if (status == wxACC_FAIL)
941 return E_FAIL;
942
943 if (status == wxACC_NOT_IMPLEMENTED)
944 {
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);
961 }
962 else
963 {
964 if (description.empty())
965 {
966 * pszDescription = NULL;
967 return S_FALSE;
968 }
969 else
970 {
971 wxBasicString basicString(description);
972 * pszDescription = basicString.Get();
973 return S_OK;
974 }
975 }
976 return E_NOTIMPL;
977 }
978
979 // Retrieves an object's Help property string.
980 // Not all objects support this property.
981
982 STDMETHODIMP wxIAccessible::get_accHelp ( VARIANT varID, BSTR* pszHelp)
983 {
984 wxLogTrace(wxT("access"), wxT("get_accHelp"));
985 wxASSERT (m_pAccessible != NULL);
986 if (!m_pAccessible)
987 return E_FAIL;
988
989 if (varID.vt != VT_I4)
990 {
991 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accHelp"));
992 return E_INVALIDARG;
993 }
994
995 wxString helpString;
996 wxAccStatus status = m_pAccessible->GetHelpText(varID.lVal, & helpString);
997 if (status == wxACC_FAIL)
998 return E_FAIL;
999
1000 if (status == wxACC_NOT_IMPLEMENTED)
1001 {
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);
1018 }
1019 else
1020 {
1021 if (helpString.empty())
1022 {
1023 * pszHelp = NULL;
1024 return S_FALSE;
1025 }
1026 else
1027 {
1028 wxBasicString basicString(helpString);
1029 * pszHelp = basicString.Get();
1030 return S_OK;
1031 }
1032 }
1033 return E_NOTIMPL;
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.
1039 // NOTE: not supported by wxWidgets at this time. Use
1040 // GetHelpText instead.
1041
1042 STDMETHODIMP wxIAccessible::get_accHelpTopic ( BSTR* pszHelpFile, VARIANT varChild, long* pidTopic)
1043 {
1044 wxLogTrace(wxT("access"), wxT("get_accHelpTopic"));
1045 wxASSERT (m_pAccessible != NULL);
1046 if (!m_pAccessible)
1047 return E_FAIL;
1048
1049 if (varChild.vt != VT_I4)
1050 {
1051 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accHelpTopic"));
1052 return E_INVALIDARG;
1053 }
1054
1055 wxAccStatus status = wxACC_NOT_IMPLEMENTED;
1056 if (status == wxACC_FAIL)
1057 return E_FAIL;
1058
1059 if (status == wxACC_NOT_IMPLEMENTED)
1060 {
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);
1077 }
1078 return E_NOTIMPL;
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.
1084
1085 STDMETHODIMP wxIAccessible::get_accKeyboardShortcut ( VARIANT varID, BSTR* pszKeyboardShortcut)
1086 {
1087 wxLogTrace(wxT("access"), wxT("get_accKeyboardShortcut"));
1088 *pszKeyboardShortcut = NULL;
1089
1090 wxASSERT (m_pAccessible != NULL);
1091 if (!m_pAccessible)
1092 return E_FAIL;
1093
1094 if (varID.vt != VT_I4)
1095 {
1096 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accKeyboardShortcut"));
1097 return E_INVALIDARG;
1098 }
1099
1100 wxString keyboardShortcut;
1101 wxAccStatus status = m_pAccessible->GetKeyboardShortcut(varID.lVal, & keyboardShortcut);
1102 if (status == wxACC_FAIL)
1103 return E_FAIL;
1104
1105 if (status == wxACC_NOT_IMPLEMENTED)
1106 {
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);
1123 }
1124 else
1125 {
1126 if (keyboardShortcut.empty())
1127 {
1128 * pszKeyboardShortcut = NULL;
1129 return S_FALSE;
1130 }
1131 else
1132 {
1133 wxBasicString basicString(keyboardShortcut);
1134 * pszKeyboardShortcut = basicString.Get();
1135 return S_OK;
1136 }
1137 }
1138 return E_NOTIMPL;
1139 }
1140
1141 // Retrieves the name of the specified object.
1142 // All objects support this property.
1143
1144 STDMETHODIMP wxIAccessible::get_accName ( VARIANT varID, BSTR* pszName)
1145 {
1146 wxLogTrace(wxT("access"), wxT("get_accName"));
1147 *pszName = NULL;
1148
1149 wxASSERT (m_pAccessible != NULL);
1150 if (!m_pAccessible)
1151 return E_FAIL;
1152
1153 if (varID.vt != VT_I4)
1154 {
1155 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accName"));
1156 return E_INVALIDARG;
1157 }
1158
1159 wxString name;
1160
1161 wxAccStatus status = m_pAccessible->GetName(varID.lVal, & name);
1162
1163 if (status == wxACC_FAIL)
1164 return E_FAIL;
1165
1166 if (status == wxACC_NOT_IMPLEMENTED)
1167 {
1168 // Try to use child object directly.
1169 if (varID.lVal > 0)
1170 {
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);
1181 }
1182 else if (m_pAccessible->GetIAccessibleStd())
1183 return ((IAccessible*) m_pAccessible->GetIAccessibleStd())->get_accName (varID, pszName);
1184 }
1185 else
1186 {
1187 wxBasicString basicString(name);
1188 *pszName = basicString.Get();
1189 return S_OK;
1190 }
1191 return E_NOTIMPL;
1192 }
1193
1194 // Retrieves information that describes the role of the specified object.
1195 // All objects support this property.
1196
1197 STDMETHODIMP wxIAccessible::get_accRole ( VARIANT varID, VARIANT* pVarRole)
1198 {
1199 wxLogTrace(wxT("access"), wxT("get_accRole"));
1200 wxASSERT (m_pAccessible != NULL);
1201 if (!m_pAccessible)
1202 return E_FAIL;
1203
1204 if (varID.vt != VT_I4)
1205 {
1206 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accRole"));
1207 return E_INVALIDARG;
1208 }
1209
1210 VariantInit(pVarRole);
1211
1212 wxAccRole role = wxROLE_NONE;
1213
1214 wxAccStatus status = m_pAccessible->GetRole(varID.lVal, & role);
1215
1216 if (status == wxACC_FAIL)
1217 return E_FAIL;
1218
1219 if (status == wxACC_NOT_IMPLEMENTED)
1220 {
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);
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 }
1251 return E_NOTIMPL;
1252 }
1253
1254 // Retrieves the current state of the specified object.
1255 // All objects support this property.
1256
1257 STDMETHODIMP wxIAccessible::get_accState ( VARIANT varID, VARIANT* pVarState)
1258 {
1259 wxLogTrace(wxT("access"), wxT("get_accState"));
1260 wxASSERT (m_pAccessible != NULL);
1261 if (!m_pAccessible)
1262 return E_FAIL;
1263
1264 if (varID.vt != VT_I4 && varID.vt != VT_EMPTY)
1265 {
1266 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accState"));
1267 return E_INVALIDARG;
1268 }
1269
1270 long wxstate = 0;
1271
1272 wxAccStatus status = m_pAccessible->GetState(varID.lVal, & wxstate);
1273 if (status == wxACC_FAIL)
1274 return E_FAIL;
1275
1276 if (status == wxACC_NOT_IMPLEMENTED)
1277 {
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);
1294 }
1295 else
1296 {
1297 long state = wxConvertToWindowsState(wxstate);
1298 pVarState->lVal = state;
1299 pVarState->vt = VT_I4;
1300 return S_OK;
1301 }
1302 return E_NOTIMPL;
1303 }
1304
1305 // Retrieves the value of the specified object.
1306 // Not all objects have a value.
1307
1308 STDMETHODIMP wxIAccessible::get_accValue ( VARIANT varID, BSTR* pszValue)
1309 {
1310 wxLogTrace(wxT("access"), wxT("get_accValue"));
1311 wxASSERT (m_pAccessible != NULL);
1312 if (!m_pAccessible)
1313 return E_FAIL;
1314
1315 if (varID.vt != VT_I4)
1316 {
1317 wxLogTrace(wxT("access"), wxT("Invalid arg for get_accValue"));
1318 return E_INVALIDARG;
1319 }
1320
1321 wxString strValue;
1322
1323 wxAccStatus status = m_pAccessible->GetValue(varID.lVal, & strValue);
1324
1325 if (status == wxACC_FAIL)
1326 return E_FAIL;
1327
1328 if (status == wxACC_NOT_IMPLEMENTED)
1329 {
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);
1346 }
1347 else
1348 {
1349 wxBasicString basicString(strValue);
1350 * pszValue = basicString.Get();
1351 return S_OK;
1352 }
1353 return E_NOTIMPL;
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
1360 STDMETHODIMP wxIAccessible::accSelect ( long flagsSelect, VARIANT varID )
1361 {
1362 wxLogTrace(wxT("access"), wxT("get_accSelect"));
1363 wxASSERT (m_pAccessible != NULL);
1364 if (!m_pAccessible)
1365 return E_FAIL;
1366
1367 if (varID.vt != VT_I4 && varID.vt != VT_EMPTY)
1368 {
1369 wxLogTrace(wxT("access"), wxT("Invalid arg for accSelect"));
1370 return E_INVALIDARG;
1371 }
1372
1373 wxAccSelectionFlags wxsel = wxConvertFromWindowsSelFlag(flagsSelect);
1374
1375 wxAccStatus status = m_pAccessible->Select(varID.lVal, wxsel);
1376 if (status == wxACC_FAIL)
1377 return E_FAIL;
1378
1379 if (status == wxACC_NOT_IMPLEMENTED)
1380 {
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);
1397 }
1398 else
1399 return S_OK;
1400
1401 return E_NOTIMPL;
1402 }
1403
1404 // Retrieves the object that has the keyboard focus. All objects
1405 // that receive the keyboard focus must support this property.
1406
1407 STDMETHODIMP wxIAccessible::get_accFocus ( VARIANT* pVarID)
1408 {
1409 wxLogTrace(wxT("access"), wxT("get_accFocus"));
1410 wxASSERT (m_pAccessible != NULL);
1411 if (!m_pAccessible)
1412 return E_FAIL;
1413
1414 wxAccessible* childObject = NULL;
1415 int childId = 0;
1416 VariantInit(pVarID);
1417
1418 wxAccStatus status = m_pAccessible->GetFocus(& childId, & childObject);
1419 if (status == wxACC_FAIL)
1420 return E_FAIL;
1421
1422 if (status == wxACC_NOT_IMPLEMENTED)
1423 {
1424 // Use standard interface instead.
1425 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1426 if (!stdInterface)
1427 return E_NOTIMPL;
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;
1437 return S_OK; }
1438 else
1439 {
1440 wxIAccessible* childIA = childObject->GetIAccessible();
1441 if (!childIA)
1442 return E_NOTIMPL;
1443
1444 if (childIA->QueryInterface(IID_IDispatch, (LPVOID*) & pVarID->pdispVal) != S_OK)
1445 return E_FAIL;
1446
1447 pVarID->vt = VT_DISPATCH;
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 }
1462
1463 #if 0
1464 // all cases above already cause some return action so below line
1465 // is unreachable and cause unnecessary warning
1466 return E_NOTIMPL;
1467 #endif
1468 }
1469
1470 // Retrieves the selected children of this object. All objects
1471 // selected must support this property.
1472
1473 STDMETHODIMP wxIAccessible::get_accSelection ( VARIANT * pVarChildren)
1474 {
1475 #if wxUSE_VARIANT
1476 wxLogTrace(wxT("access"), wxT("get_accSelection"));
1477 wxASSERT (m_pAccessible != NULL);
1478 if (!m_pAccessible)
1479 return E_FAIL;
1480
1481 VariantInit(pVarChildren);
1482
1483 wxVariant selections;
1484 wxAccStatus status = m_pAccessible->GetSelections(& selections);
1485 if (status == wxACC_FAIL)
1486 return E_FAIL;
1487
1488 if (status == wxACC_NOT_IMPLEMENTED)
1489 {
1490 // Use standard interface instead.
1491 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1492 if (!stdInterface)
1493 return E_NOTIMPL;
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)
1511 return E_NOTIMPL;
1512
1513 if (childIA->QueryInterface(IID_IDispatch, (LPVOID*) & pVarChildren->pdispVal) != S_OK)
1514 return E_FAIL;
1515
1516 pVarChildren->vt = VT_DISPATCH;
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 }
1533 #else
1534 wxUnusedVar(pVarChildren);
1535 #endif // wxUSE_VARIANT
1536
1537 return E_NOTIMPL;
1538 }
1539
1540 // Get type info
1541
1542 STDMETHODIMP wxIAccessible::GetTypeInfo(unsigned int WXUNUSED(typeInfo), LCID WXUNUSED(lcid), ITypeInfo** ppTypeInfo)
1543 {
1544 *ppTypeInfo = NULL;
1545 return E_NOTIMPL;
1546 }
1547
1548 // Get type info count
1549
1550 STDMETHODIMP wxIAccessible::GetTypeInfoCount(unsigned int* typeInfoCount)
1551 {
1552 *typeInfoCount = 0;
1553 return E_NOTIMPL;
1554 }
1555
1556 // Get ids of names
1557
1558 STDMETHODIMP wxIAccessible::GetIDsOfNames(REFIID WXUNUSED(riid), OLECHAR** WXUNUSED(names), unsigned int WXUNUSED(cNames),
1559 LCID WXUNUSED(lcid), DISPID* WXUNUSED(dispId))
1560 {
1561 return E_NOTIMPL;
1562 }
1563
1564 // Invoke
1565
1566 STDMETHODIMP 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),
1569 unsigned int *WXUNUSED(puArgErr) )
1570 {
1571 return E_NOTIMPL;
1572 }
1573
1574 // Gets the standard IAccessible interface for the given child or object.
1575 // Call Release if this is non-NULL.
1576 IAccessible* 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();
1607 }
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();
1641 }
1642 }
1643 }
1644 break;
1645 }
1646 }
1647 }
1648 #endif
1649 return NULL;
1650 }
1651
1652 // Gets the IAccessible interface for the given child or object.
1653 // Call Release if this is non-NULL.
1654 IAccessible* 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();
1681 }
1682 }
1683 }
1684 return NULL;
1685 }
1686
1687 // ----------------------------------------------------------------------------
1688 // wxAccessible implementation
1689 // ----------------------------------------------------------------------------
1690
1691 // ctors
1692
1693 // common part of all ctors
1694 void wxAccessible::Init()
1695 {
1696 m_pIAccessibleStd = NULL;
1697 m_pIAccessible = new wxIAccessible(this);
1698 m_pIAccessible->AddRef();
1699 }
1700
1701 wxAccessible::wxAccessible(wxWindow* win)
1702 : wxAccessibleBase(win)
1703 {
1704 Init();
1705 }
1706
1707 wxAccessible::~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.
1715 void* wxAccessible::GetIAccessibleStd()
1716 {
1717 if (m_pIAccessibleStd)
1718 return m_pIAccessibleStd;
1719
1720 if (GetWindow())
1721 {
1722 HRESULT retCode = ::CreateStdAccessibleObject((HWND) GetWindow()->GetHWND(),
1723 OBJID_CLIENT, IID_IAccessible, (void**) & m_pIAccessibleStd);
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
1735 // Sends an event when something changes in an accessible object.
1736 void 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
1743 // Utilities
1744
1745 // Convert to Windows role
1746 int wxConvertToWindowsRole(wxAccRole wxrole)
1747 {
1748 switch (wxrole)
1749 {
1750 case wxROLE_NONE:
1751 return 0;
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
1879 long 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
1964 int wxConvertToWindowsSelFlag(wxAccSelectionFlags wxsel)
1965 {
1966 int sel = 0;
1967
1968 if (wxsel & wxACC_SEL_TAKEFOCUS)
1969 sel |= SELFLAG_TAKEFOCUS;
1970 if (wxsel & wxACC_SEL_TAKESELECTION)
1971 sel |= SELFLAG_TAKESELECTION;
1972 if (wxsel & wxACC_SEL_EXTENDSELECTION)
1973 sel |= SELFLAG_EXTENDSELECTION;
1974 if (wxsel & wxACC_SEL_ADDSELECTION)
1975 sel |= SELFLAG_ADDSELECTION;
1976 if (wxsel & wxACC_SEL_REMOVESELECTION)
1977 sel |= SELFLAG_REMOVESELECTION;
1978 return sel;
1979 }
1980
1981 // Convert from Windows selection flag
1982 wxAccSelectionFlags 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
2000 #endif // wxUSE_OLE && wxUSE_ACCESSIBILITY