]> git.saurik.com Git - wxWidgets.git/blob - src/msw/ole/access.cpp
Added start at accessibility sample
[wxWidgets.git] / src / msw / ole / access.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #ifdef __GNUG__
21 #pragma implementation "access.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #if defined(__BORLANDC__)
28 #pragma hdrstop
29 #endif
30 #ifndef WX_PRECOMP
31 #include "wx/window.h"
32 #endif
33
34 #include "wx/setup.h"
35
36 #if wxUSE_OLE && wxUSE_ACCESSIBILITY
37
38 #include "wx/log.h"
39 #include "wx/access.h"
40
41 #include <windows.h>
42
43 // for some compilers, the entire ole2.h must be included, not only oleauto.h
44 #if wxUSE_NORLANDER_HEADERS || defined(__WATCOMC__)
45 #include <ole2.h>
46 #endif
47
48 #include <oleauto.h>
49 #include <oleacc.h>
50
51 #include "wx/msw/ole/oleutils.h"
52
53 #ifndef CHILDID_SELF
54 #define CHILDID_SELF 0
55 #endif
56
57 #ifndef OBJID_CLIENT
58 #define OBJID_CLIENT 0xFFFFFFFC
59 #endif
60
61 // Convert to Windows role
62 int wxConvertToWindowsRole(wxAccRole wxrole);
63
64 // Convert to Windows state
65 long wxConvertToWindowsState(long wxstate);
66
67 // Convert to Windows selection flag
68 int wxConvertToWindowsSelFlag(wxAccSelectionFlags sel);
69
70 // Convert from Windows selection flag
71 wxAccSelectionFlags wxConvertFromWindowsSelFlag(int sel);
72
73 // ----------------------------------------------------------------------------
74 // wxIEnumVARIANT interface implementation
75 // ----------------------------------------------------------------------------
76
77 class wxIEnumVARIANT : public IEnumVARIANT
78 {
79 public:
80 wxIEnumVARIANT(const wxVariant& variant);
81 ~wxIEnumVARIANT() { }
82
83 DECLARE_IUNKNOWN_METHODS;
84
85 // IEnumVARIANT
86 STDMETHODIMP Next(ULONG celt, VARIANT *rgelt, ULONG *pceltFetched);
87 STDMETHODIMP Skip(ULONG celt);
88 STDMETHODIMP Reset();
89 STDMETHODIMP Clone(IEnumVARIANT **ppenum);
90
91 private:
92 wxVariant m_variant; // List of further variants
93 int m_nCurrent; // Current enum position
94
95 DECLARE_NO_COPY_CLASS(wxIEnumVARIANT)
96 };
97
98 // ----------------------------------------------------------------------------
99 // wxIEnumVARIANT
100 // ----------------------------------------------------------------------------
101
102 BEGIN_IID_TABLE(wxIEnumVARIANT)
103 ADD_IID(Unknown)
104 ADD_IID(EnumVARIANT)
105 END_IID_TABLE;
106
107 IMPLEMENT_IUNKNOWN_METHODS(wxIEnumVARIANT)
108
109 // wxVariant contains a list of further variants.
110 wxIEnumVARIANT::wxIEnumVARIANT(const wxVariant& variant)
111 {
112 m_variant = variant;
113 }
114
115 STDMETHODIMP wxIEnumVARIANT::Next(ULONG celt,
116 VARIANT *rgelt,
117 ULONG *pceltFetched)
118 {
119 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumVARIANT::Next"));
120
121 if ( celt > 1 ) {
122 // we only return 1 element at a time - mainly because I'm too lazy to
123 // implement something which you're never asked for anyhow
124 return S_FALSE;
125 }
126
127 if (m_variant.GetType() != wxT("list"))
128 return S_FALSE;
129
130 if ( m_nCurrent < (int) m_variant.GetList().GetCount() ) {
131 if (!wxConvertVariantToOle(m_variant[m_nCurrent++], rgelt[0]))
132 {
133 return S_FALSE;
134 }
135
136 // TODO: should we AddRef if this is an object?
137
138 * pceltFetched = 1;
139 return S_OK;
140 }
141 else {
142 // bad index
143 return S_FALSE;
144 }
145 }
146
147 STDMETHODIMP wxIEnumVARIANT::Skip(ULONG celt)
148 {
149 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumVARIANT::Skip"));
150
151 if (m_variant.GetType() != wxT("list"))
152 return S_FALSE;
153
154 m_nCurrent += celt;
155 if ( m_nCurrent < (int) m_variant.GetList().GetCount() )
156 return S_OK;
157
158 // no, can't skip this many elements
159 m_nCurrent -= celt;
160
161 return S_FALSE;
162 }
163
164 STDMETHODIMP wxIEnumVARIANT::Reset()
165 {
166 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumVARIANT::Reset"));
167
168 m_nCurrent = 0;
169
170 return S_OK;
171 }
172
173 STDMETHODIMP wxIEnumVARIANT::Clone(IEnumVARIANT **ppenum)
174 {
175 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumVARIANT::Clone"));
176
177 wxIEnumVARIANT *pNew = new wxIEnumVARIANT(m_variant);
178 pNew->AddRef();
179 *ppenum = pNew;
180
181 return S_OK;
182 }
183
184
185 // ----------------------------------------------------------------------------
186 // wxIAccessible implementation of IAccessible interface
187 // ----------------------------------------------------------------------------
188
189 class wxIAccessible : public IAccessible
190 {
191 public:
192 wxIAccessible(wxAccessible *pAccessible);
193
194 DECLARE_IUNKNOWN_METHODS;
195
196 // IAccessible
197
198 // Navigation and Hierarchy
199
200 // Retrieves the child element or child object at a given point on the screen.
201 // All visual objects support this method; sound objects do not support it.
202
203 STDMETHODIMP accHitTest(long xLeft, long yLeft, VARIANT* pVarID);
204
205 // Retrieves the specified object's current screen location. All visual objects must
206 // support this method; sound objects do not support it.
207
208 STDMETHODIMP accLocation ( long* pxLeft, long* pyTop, long* pcxWidth, long* pcyHeight, VARIANT varID);
209
210 // Traverses to another user interface element within a container and retrieves the object.
211 // All visual objects must support this method.
212
213 STDMETHODIMP accNavigate ( long navDir, VARIANT varStart, VARIANT* pVarEnd);
214
215 // Retrieves the address of an IDispatch interface for the specified child.
216 // All objects must support this property.
217
218 STDMETHODIMP get_accChild ( VARIANT varChildID, IDispatch** ppDispChild);
219
220 // Retrieves the number of children that belong to this object.
221 // All objects must support this property.
222
223 STDMETHODIMP get_accChildCount ( long* pCountChildren);
224
225 // Retrieves the IDispatch interface of the object's parent.
226 // All objects support this property.
227
228 STDMETHODIMP get_accParent ( IDispatch** ppDispParent);
229
230 // Descriptive Properties and Methods
231
232 // Performs the object's default action. Not all objects have a default
233 // action.
234
235 STDMETHODIMP accDoDefaultAction(VARIANT varID);
236
237 // Retrieves a string that describes the object's default action.
238 // Not all objects have a default action.
239
240 STDMETHODIMP get_accDefaultAction ( VARIANT varID, BSTR* pszDefaultAction);
241
242 // Retrieves a string that describes the visual appearance of the specified object.
243 // Not all objects have a description.
244
245 STDMETHODIMP get_accDescription ( VARIANT varID, BSTR* pszDescription);
246
247 // Retrieves an object's Help property string.
248 // Not all objects support this property.
249
250 STDMETHODIMP get_accHelp ( VARIANT varID, BSTR* pszHelp);
251
252 // Retrieves the full path of the WinHelp file associated with the specified
253 // object and the identifier of the appropriate topic within that file.
254 // Not all objects support this property.
255
256 STDMETHODIMP get_accHelpTopic ( BSTR* pszHelpFile, VARIANT varChild, long* pidTopic);
257
258 // Retrieves the specified object's shortcut key or access key, also known as
259 // the mnemonic. All objects that have a shortcut key or access key support
260 // this property.
261
262 STDMETHODIMP get_accKeyboardShortcut ( VARIANT varID, BSTR* pszKeyboardShortcut);
263
264 // Retrieves the name of the specified object.
265 // All objects support this property.
266
267 STDMETHODIMP get_accName ( VARIANT varID, BSTR* pszName);
268
269 // Retrieves information that describes the role of the specified object.
270 // All objects support this property.
271
272 STDMETHODIMP get_accRole ( VARIANT varID, VARIANT* pVarRole);
273
274 // Retrieves the current state of the specified object.
275 // All objects support this property.
276
277 STDMETHODIMP get_accState ( VARIANT varID, VARIANT* pVarState);
278
279 // Retrieves the value of the specified object.
280 // Not all objects have a value.
281
282 STDMETHODIMP get_accValue ( VARIANT varID, BSTR* pszValue);
283
284 // Selection and Focus
285
286 // Modifies the selection or moves the keyboard focus of the
287 // specified object. All objects that select or receive the
288 // keyboard focus must support this method.
289
290 STDMETHODIMP accSelect ( long flagsSelect, VARIANT varID );
291
292 // Retrieves the object that has the keyboard focus. All objects
293 // that receive the keyboard focus must support this property.
294
295 STDMETHODIMP get_accFocus ( VARIANT* pVarID);
296
297 // Retrieves the selected children of this object. All objects
298 // selected must support this property.
299
300 STDMETHODIMP get_accSelection ( VARIANT * pVarChildren);
301
302 // Obsolete
303
304 STDMETHODIMP put_accName(VARIANT varChild, BSTR szName) { return E_FAIL; }
305 STDMETHODIMP put_accValue(VARIANT varChild, BSTR szName) { return E_FAIL; }
306
307 // IDispatch
308
309 // Get type info
310
311 STDMETHODIMP GetTypeInfo(unsigned int typeInfo, LCID lcid, ITypeInfo** ppTypeInfo);
312
313 // Get type info count
314
315 STDMETHODIMP GetTypeInfoCount(unsigned int* typeInfoCount);
316
317 // Get ids of names
318
319 STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** names, unsigned int cNames,
320 LCID lcid, DISPID* dispId);
321
322 // Invoke
323
324 STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
325 WORD wFlags, DISPPARAMS *pDispParams,
326 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
327 unsigned int *puArgErr );
328
329 private:
330 wxAccessible *m_pAccessible; // pointer to C++ class we belong to
331
332 DECLARE_NO_COPY_CLASS(wxIAccessible)
333 };
334
335 // ============================================================================
336 // Implementation
337 // ============================================================================
338
339 // ----------------------------------------------------------------------------
340 // wxIAccessible implementation
341 // ----------------------------------------------------------------------------
342 BEGIN_IID_TABLE(wxIAccessible)
343 ADD_IID(Unknown)
344 ADD_IID(Accessible)
345 ADD_IID(Dispatch)
346 END_IID_TABLE;
347
348 IMPLEMENT_IUNKNOWN_METHODS(wxIAccessible)
349
350 wxIAccessible::wxIAccessible(wxAccessible *pAccessible)
351 {
352 wxASSERT( pAccessible != NULL );
353
354 m_pAccessible = pAccessible;
355 }
356
357 // Retrieves the child element or child object at a given point on the screen.
358 // All visual objects support this method; sound objects do not support it.
359
360 STDMETHODIMP wxIAccessible::accHitTest(long xLeft, long yLeft, VARIANT* pVarID)
361 {
362 wxASSERT (m_pAccessible != NULL);
363 if (!m_pAccessible)
364 return E_FAIL;
365
366 wxAccessible* childObject = NULL;
367 int childId = 0;
368 VariantInit(pVarID);
369
370 wxAccStatus status = m_pAccessible->HitTest(wxPoint(xLeft, yLeft), & childId, & childObject);
371
372 if (status == wxACC_FAIL)
373 return E_FAIL;
374
375 if (status == wxACC_NOT_IMPLEMENTED)
376 {
377 // Use standard interface instead.
378 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
379 if (!stdInterface)
380 return E_FAIL;
381 else
382 return stdInterface->accHitTest(xLeft, yLeft, pVarID);
383 }
384
385 if (childObject)
386 {
387 if (childObject == m_pAccessible)
388 {
389 pVarID->vt = VT_I4;
390 pVarID->lVal = CHILDID_SELF;
391 return S_OK;
392 }
393 else
394 {
395 wxIAccessible* childIA = childObject->GetIAccessible();
396 if (!childIA)
397 return E_FAIL;
398
399 if (childIA->QueryInterface(IID_IDispatch, (LPVOID*) pVarID->pdispVal) != S_OK)
400 return E_FAIL;
401
402 pVarID->vt = VT_DISPATCH;
403 pVarID->pdispVal->AddRef();
404 return S_OK;
405 }
406 }
407 else if (childId > 0)
408 {
409 pVarID->vt = VT_I4;
410 pVarID->lVal = childId;
411 return S_OK;
412 }
413 else
414 {
415 pVarID->vt = VT_EMPTY;
416 return S_FALSE;
417 }
418
419 return E_FAIL;
420 }
421
422 // Retrieves the specified object's current screen location. All visual objects must
423 // support this method; sound objects do not support it.
424
425 STDMETHODIMP wxIAccessible::accLocation ( long* pxLeft, long* pyTop, long* pcxWidth, long* pcyHeight, VARIANT varID)
426 {
427 wxASSERT (m_pAccessible != NULL);
428 if (!m_pAccessible)
429 return E_FAIL;
430
431 wxRect rect;
432
433 wxAccStatus status = m_pAccessible->GetLocation(rect, varID.lVal);
434 if (status == wxACC_FAIL)
435 return E_FAIL;
436
437 if (status == wxACC_NOT_IMPLEMENTED)
438 {
439 // Use standard interface instead.
440 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
441 if (!stdInterface)
442 return E_FAIL;
443 else
444 return stdInterface->accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, varID);
445 }
446 else
447 {
448 *pxLeft = rect.x;
449 *pyTop = rect.y;
450 *pcxWidth = rect.width;
451 *pcyHeight = rect.height;
452 return S_OK;
453 }
454
455 return E_FAIL;
456 }
457
458 // Traverses to another user interface element within a container and retrieves the object.
459 // All visual objects must support this method.
460
461 STDMETHODIMP wxIAccessible::accNavigate ( long navDir, VARIANT varStart, VARIANT* pVarEnd)
462 {
463 wxASSERT (m_pAccessible != NULL);
464 if (!m_pAccessible)
465 return E_FAIL;
466
467 if (varStart.vt != VT_I4)
468 return E_INVALIDARG;
469
470 wxAccessible* elementObject = NULL;
471 int elementId = 0;
472 VariantInit(pVarEnd);
473 wxNavDir navDirWX = wxNAVDIR_FIRSTCHILD;
474
475 switch (navDir)
476 {
477 case NAVDIR_DOWN:
478 navDirWX = wxNAVDIR_DOWN;
479 break;
480
481 case NAVDIR_FIRSTCHILD:
482 navDirWX = wxNAVDIR_FIRSTCHILD;
483 break;
484
485 case NAVDIR_LASTCHILD:
486 navDirWX = wxNAVDIR_LASTCHILD;
487 break;
488
489 case NAVDIR_LEFT:
490 navDirWX = wxNAVDIR_LEFT;
491 break;
492
493 case NAVDIR_NEXT:
494 navDirWX = wxNAVDIR_NEXT;
495 break;
496
497 case NAVDIR_PREVIOUS:
498 navDirWX = wxNAVDIR_PREVIOUS;
499 break;
500
501 case NAVDIR_RIGHT:
502 navDirWX = wxNAVDIR_RIGHT;
503 break;
504
505 case NAVDIR_UP:
506 navDirWX = wxNAVDIR_UP;
507 break;
508 }
509
510 wxAccStatus status = m_pAccessible->Navigate(navDirWX, varStart.lVal, & elementId,
511 & elementObject);
512
513 if (status == wxACC_FAIL)
514 return E_FAIL;
515
516 if (status == wxACC_NOT_IMPLEMENTED)
517 {
518 // Use standard interface instead.
519 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
520 if (!stdInterface)
521 return E_FAIL;
522 else
523 return stdInterface->accNavigate ( navDir, varStart, pVarEnd);
524 }
525 else
526 {
527 if (elementObject)
528 {
529 wxIAccessible* objectIA = elementObject->GetIAccessible();
530 if (!objectIA)
531 return E_FAIL;
532
533 if (objectIA->QueryInterface(IID_IDispatch, (LPVOID*) pVarEnd->pdispVal) != S_OK)
534 return E_FAIL;
535
536 pVarEnd->vt = VT_DISPATCH;
537 pVarEnd->pdispVal->AddRef();
538 return S_OK;
539 }
540 else if (elementId > 0)
541 {
542 pVarEnd->vt = VT_I4;
543 pVarEnd->lVal = elementId;
544 return S_OK;
545 }
546 else
547 {
548 pVarEnd->vt = VT_EMPTY;
549 return S_FALSE;
550 }
551 }
552
553 return E_FAIL;
554 }
555
556 // Retrieves the address of an IDispatch interface for the specified child.
557 // All objects must support this property.
558
559 STDMETHODIMP wxIAccessible::get_accChild ( VARIANT varChildID, IDispatch** ppDispChild)
560 {
561 wxASSERT (m_pAccessible != NULL);
562 if (!m_pAccessible)
563 return E_FAIL;
564
565 if (varChildID.vt != VT_I4)
566 return E_INVALIDARG;
567
568 if (varChildID.lVal == CHILDID_SELF)
569 {
570 *ppDispChild = this;
571 AddRef();
572 return S_OK;
573 }
574
575 wxAccessible* child = NULL;
576
577 wxAccStatus status = m_pAccessible->GetChild(varChildID.lVal, & child);
578 if (status == wxACC_FAIL)
579 return E_FAIL;
580
581 if (status == wxACC_NOT_IMPLEMENTED)
582 {
583 // Use standard interface instead.
584 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
585 if (!stdInterface)
586 return E_FAIL;
587 else
588 return stdInterface->get_accChild (varChildID, ppDispChild);
589 }
590 else
591 {
592 if (child)
593 {
594 wxIAccessible* objectIA = child->GetIAccessible();
595 if (!objectIA)
596 return E_FAIL;
597 *ppDispChild = objectIA;
598 objectIA->AddRef();
599 return S_OK;
600 }
601 else
602 return S_FALSE; // Indicates it's not an accessible object
603 }
604
605 return E_FAIL;
606 }
607
608 // Retrieves the number of children that belong to this object.
609 // All objects must support this property.
610
611 STDMETHODIMP wxIAccessible::get_accChildCount ( long* pCountChildren)
612 {
613 wxASSERT (m_pAccessible != NULL);
614 if (!m_pAccessible)
615 return E_FAIL;
616
617 int childCount = 0;
618 wxAccStatus status = m_pAccessible->GetChildCount(& childCount);
619 if (status == wxACC_FAIL)
620 return E_FAIL;
621
622 if (status == wxACC_NOT_IMPLEMENTED)
623 {
624 // Use standard interface instead.
625 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
626 if (!stdInterface)
627 return E_FAIL;
628 else
629 return stdInterface->get_accChildCount (pCountChildren);
630 }
631 else
632 {
633 * pCountChildren = (long) childCount;
634 return S_OK;
635 }
636
637 return E_FAIL;
638 }
639
640 // Retrieves the IDispatch interface of the object's parent.
641 // All objects support this property.
642
643 STDMETHODIMP wxIAccessible::get_accParent ( IDispatch** ppDispParent)
644 {
645 wxASSERT (m_pAccessible != NULL);
646 if (!m_pAccessible)
647 return E_FAIL;
648
649 wxAccessible* parent = NULL;
650 wxAccStatus status = m_pAccessible->GetParent(& parent);
651 if (status == wxACC_FAIL)
652 return E_FAIL;
653
654 if (status == wxACC_NOT_IMPLEMENTED)
655 {
656 // Use standard interface instead.
657 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
658 if (!stdInterface)
659 return E_FAIL;
660 else
661 return stdInterface->get_accParent (ppDispParent);
662 }
663 else
664 {
665 if (parent)
666 {
667 wxIAccessible* objectIA = parent->GetIAccessible();
668 if (!objectIA)
669 return E_FAIL;
670
671 if (objectIA->QueryInterface(IID_IDispatch, (LPVOID*) ppDispParent) != S_OK)
672 return E_FAIL;
673
674 (*ppDispParent)->AddRef();
675 return S_OK;
676 /*
677 wxIAccessible* objectIA = parent->GetIAccessible();
678 if (!objectIA)
679 return E_FAIL;
680 objectIA->AddRef();
681 *ppDispParent = objectIA;
682 return S_OK;
683 */
684 }
685 else
686 {
687 *ppDispParent = NULL;
688 return S_OK;
689 }
690 }
691
692 return E_FAIL;
693 }
694
695 // Performs the object's default action. Not all objects have a default
696 // action.
697
698 STDMETHODIMP wxIAccessible::accDoDefaultAction(VARIANT varID)
699 {
700 wxASSERT (m_pAccessible != NULL);
701 if (!m_pAccessible)
702 return E_FAIL;
703
704 if (varID.vt != VT_I4)
705 return E_INVALIDARG;
706
707 wxAccStatus status = m_pAccessible->DoDefaultAction(varID.lVal);
708 if (status == wxACC_FAIL)
709 return E_FAIL;
710
711 if (status == wxACC_NOT_SUPPORTED)
712 return DISP_E_MEMBERNOTFOUND;
713
714 if (status == wxACC_NOT_IMPLEMENTED)
715 {
716 // Use standard interface instead.
717 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
718 if (!stdInterface)
719 return E_FAIL;
720 else
721 return stdInterface->accDoDefaultAction(varID);
722 }
723 return E_FAIL;
724 }
725
726 // Retrieves a string that describes the object's default action.
727 // Not all objects have a default action.
728
729 STDMETHODIMP wxIAccessible::get_accDefaultAction ( VARIANT varID, BSTR* pszDefaultAction)
730 {
731 wxASSERT (m_pAccessible != NULL);
732 if (!m_pAccessible)
733 return E_FAIL;
734
735 if (varID.vt != VT_I4)
736 return E_INVALIDARG;
737
738 wxString defaultAction;
739 wxAccStatus status = m_pAccessible->GetDefaultAction(varID.lVal, & defaultAction);
740 if (status == wxACC_FAIL)
741 return E_FAIL;
742
743 if (status == wxACC_NOT_SUPPORTED)
744 return DISP_E_MEMBERNOTFOUND;
745
746 if (status == wxACC_NOT_IMPLEMENTED)
747 {
748 // Use standard interface instead.
749 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
750 if (!stdInterface)
751 return E_FAIL;
752 else
753 return stdInterface->get_accDefaultAction (varID, pszDefaultAction);
754 }
755 else
756 {
757 if (defaultAction.IsEmpty())
758 {
759 * pszDefaultAction = NULL;
760 return S_FALSE;
761 }
762 else
763 {
764 wxBasicString basicString(defaultAction);
765 * pszDefaultAction = basicString.Get();
766 return S_OK;
767 }
768 }
769 return E_FAIL;
770 }
771
772 // Retrieves a string that describes the visual appearance of the specified object.
773 // Not all objects have a description.
774
775 STDMETHODIMP wxIAccessible::get_accDescription ( VARIANT varID, BSTR* pszDescription)
776 {
777 wxASSERT (m_pAccessible != NULL);
778 if (!m_pAccessible)
779 return E_FAIL;
780
781 if (varID.vt != VT_I4)
782 return E_INVALIDARG;
783
784 wxString description;
785 wxAccStatus status = m_pAccessible->GetDescription(varID.lVal, & description);
786 if (status == wxACC_FAIL)
787 return E_FAIL;
788
789 if (status == wxACC_NOT_IMPLEMENTED)
790 {
791 // Use standard interface instead.
792 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
793 if (!stdInterface)
794 return E_FAIL;
795 else
796 return stdInterface->get_accDescription (varID, pszDescription);
797 }
798 else
799 {
800 if (description.IsEmpty())
801 {
802 * pszDescription = NULL;
803 return S_FALSE;
804 }
805 else
806 {
807 wxBasicString basicString(description);
808 * pszDescription = basicString.Get();
809 return S_OK;
810 }
811 }
812 return E_FAIL;
813 }
814
815 // Retrieves an object's Help property string.
816 // Not all objects support this property.
817
818 STDMETHODIMP wxIAccessible::get_accHelp ( VARIANT varID, BSTR* pszHelp)
819 {
820 wxASSERT (m_pAccessible != NULL);
821 if (!m_pAccessible)
822 return E_FAIL;
823
824 if (varID.vt != VT_I4)
825 return E_INVALIDARG;
826
827 wxString helpString;
828 wxAccStatus status = m_pAccessible->GetHelpText(varID.lVal, & helpString);
829 if (status == wxACC_FAIL)
830 return E_FAIL;
831
832 if (status == wxACC_NOT_IMPLEMENTED)
833 {
834 // Use standard interface instead.
835 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
836 if (!stdInterface)
837 return E_FAIL;
838 else
839 return stdInterface->get_accHelp (varID, pszHelp);
840 }
841 else
842 {
843 if (helpString.IsEmpty())
844 {
845 * pszHelp = NULL;
846 return S_FALSE;
847 }
848 else
849 {
850 wxBasicString basicString(helpString);
851 * pszHelp = basicString.Get();
852 return S_OK;
853 }
854 }
855 return E_FAIL;
856 }
857
858 // Retrieves the full path of the WinHelp file associated with the specified
859 // object and the identifier of the appropriate topic within that file.
860 // Not all objects support this property.
861 // NOTE: not supported by wxWindows at this time. Use
862 // GetHelpText instead.
863
864 STDMETHODIMP wxIAccessible::get_accHelpTopic ( BSTR* pszHelpFile, VARIANT varChild, long* pidTopic)
865 {
866 wxASSERT (m_pAccessible != NULL);
867 if (!m_pAccessible)
868 return E_FAIL;
869
870 if (varChild.vt != VT_I4)
871 return E_INVALIDARG;
872
873 wxAccStatus status = wxACC_NOT_IMPLEMENTED;
874 if (status == wxACC_FAIL)
875 return E_FAIL;
876
877 if (status == wxACC_NOT_IMPLEMENTED)
878 {
879 // Use standard interface instead.
880 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
881 if (!stdInterface)
882 return E_FAIL;
883 else
884 return stdInterface->get_accHelpTopic (pszHelpFile, varChild, pidTopic);
885 }
886 return E_FAIL;
887 }
888
889 // Retrieves the specified object's shortcut key or access key, also known as
890 // the mnemonic. All objects that have a shortcut key or access key support
891 // this property.
892
893 STDMETHODIMP wxIAccessible::get_accKeyboardShortcut ( VARIANT varID, BSTR* pszKeyboardShortcut)
894 {
895 *pszKeyboardShortcut = NULL;
896
897 wxASSERT (m_pAccessible != NULL);
898 if (!m_pAccessible)
899 return E_FAIL;
900
901 if (varID.vt != VT_I4)
902 return E_INVALIDARG;
903
904 wxString keyboardShortcut;
905 wxAccStatus status = m_pAccessible->GetHelpText(varID.lVal, & keyboardShortcut);
906 if (status == wxACC_FAIL)
907 return E_FAIL;
908
909 if (status == wxACC_NOT_IMPLEMENTED)
910 {
911 // Use standard interface instead.
912 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
913 if (!stdInterface)
914 return E_FAIL;
915 else
916 return stdInterface->get_accKeyboardShortcut(varID, pszKeyboardShortcut);
917 }
918 else
919 {
920 if (keyboardShortcut.IsEmpty())
921 {
922 * pszKeyboardShortcut = NULL;
923 return S_FALSE;
924 }
925 else
926 {
927 wxBasicString basicString(keyboardShortcut);
928 * pszKeyboardShortcut = basicString.Get();
929 return S_OK;
930 }
931 }
932 return E_FAIL;
933 }
934
935 // Retrieves the name of the specified object.
936 // All objects support this property.
937
938 STDMETHODIMP wxIAccessible::get_accName ( VARIANT varID, BSTR* pszName)
939 {
940 *pszName = NULL;
941
942 wxASSERT (m_pAccessible != NULL);
943 if (!m_pAccessible)
944 return E_FAIL;
945
946 if (varID.vt != VT_I4)
947 return E_INVALIDARG;
948
949 wxString name;
950
951 wxAccStatus status = m_pAccessible->GetName(varID.lVal, & name);
952
953 if (status == wxACC_FAIL)
954 return E_FAIL;
955
956 if (status == wxACC_NOT_IMPLEMENTED)
957 {
958 // Use standard interface instead.
959 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
960 if (!stdInterface)
961 return E_FAIL;
962 else
963 return stdInterface->get_accName (varID, pszName);
964 }
965 else
966 {
967 wxBasicString basicString(name);
968 *pszName = basicString.Get();
969 return S_OK;
970 }
971 return E_FAIL;
972 }
973
974 // Retrieves information that describes the role of the specified object.
975 // All objects support this property.
976
977 STDMETHODIMP wxIAccessible::get_accRole ( VARIANT varID, VARIANT* pVarRole)
978 {
979 wxASSERT (m_pAccessible != NULL);
980 if (!m_pAccessible)
981 return E_FAIL;
982
983 if (varID.vt != VT_I4)
984 return E_INVALIDARG;
985
986 VariantInit(pVarRole);
987
988 wxAccRole role = wxROLE_NONE;
989
990 wxAccStatus status = m_pAccessible->GetRole(varID.lVal, & role);
991
992 if (status == wxACC_FAIL)
993 return E_FAIL;
994
995 if (status == wxACC_NOT_IMPLEMENTED)
996 {
997 // Use standard interface instead.
998 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
999 if (!stdInterface)
1000 return E_FAIL;
1001 else
1002 return stdInterface->get_accRole (varID, pVarRole);
1003 }
1004 else
1005 {
1006 if (role == wxROLE_NONE)
1007 {
1008 pVarRole->vt = VT_EMPTY;
1009 return S_OK;
1010 }
1011
1012 pVarRole->lVal = wxConvertToWindowsRole(role);
1013 pVarRole->vt = VT_I4;
1014
1015 return S_OK;
1016 }
1017 return E_FAIL;
1018 }
1019
1020 // Retrieves the current state of the specified object.
1021 // All objects support this property.
1022
1023 STDMETHODIMP wxIAccessible::get_accState ( VARIANT varID, VARIANT* pVarState)
1024 {
1025 wxASSERT (m_pAccessible != NULL);
1026 if (!m_pAccessible)
1027 return E_FAIL;
1028
1029 if (varID.vt != VT_I4)
1030 return E_INVALIDARG;
1031
1032 long wxstate = 0;
1033
1034 wxAccStatus status = m_pAccessible->GetState(varID.lVal, & wxstate);
1035 if (status == wxACC_FAIL)
1036 return E_FAIL;
1037
1038 if (status == wxACC_NOT_IMPLEMENTED)
1039 {
1040 // Use standard interface instead.
1041 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1042 if (!stdInterface)
1043 return E_FAIL;
1044 else
1045 return stdInterface->get_accState (varID, pVarState);
1046 }
1047 else
1048 {
1049 long state = wxConvertToWindowsState(wxstate);
1050 pVarState->lVal = state;
1051 pVarState->vt = VT_I4;
1052 return S_OK;
1053 }
1054 return E_FAIL;
1055 }
1056
1057 // Retrieves the value of the specified object.
1058 // Not all objects have a value.
1059
1060 STDMETHODIMP wxIAccessible::get_accValue ( VARIANT varID, BSTR* pszValue)
1061 {
1062 wxASSERT (m_pAccessible != NULL);
1063 if (!m_pAccessible)
1064 return E_FAIL;
1065
1066 if (varID.vt != VT_I4)
1067 return E_INVALIDARG;
1068
1069 wxString strValue;
1070
1071 wxAccStatus status = m_pAccessible->GetValue(varID.lVal, & strValue);
1072
1073 if (status == wxACC_FAIL)
1074 return E_FAIL;
1075
1076 if (status == wxACC_NOT_IMPLEMENTED)
1077 {
1078 // Use standard interface instead.
1079 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1080 if (!stdInterface)
1081 return E_FAIL;
1082 else
1083 return stdInterface->get_accValue (varID, pszValue);
1084 }
1085 else
1086 {
1087 wxBasicString basicString(strValue);
1088 * pszValue = basicString.Get();
1089 return S_OK;
1090 }
1091 return E_FAIL;
1092 }
1093
1094 // Modifies the selection or moves the keyboard focus of the
1095 // specified object. All objects that select or receive the
1096 // keyboard focus must support this method.
1097
1098 STDMETHODIMP wxIAccessible::accSelect ( long flagsSelect, VARIANT varID )
1099 {
1100 wxASSERT (m_pAccessible != NULL);
1101 if (!m_pAccessible)
1102 return E_FAIL;
1103
1104 if (varID.vt != VT_I4)
1105 return E_INVALIDARG;
1106
1107 wxAccSelectionFlags wxsel = wxConvertFromWindowsSelFlag(flagsSelect);
1108
1109 wxAccStatus status = m_pAccessible->Select(varID.lVal, wxsel);
1110 if (status == wxACC_FAIL)
1111 return E_FAIL;
1112
1113 if (status == wxACC_NOT_IMPLEMENTED)
1114 {
1115 // Use standard interface instead.
1116 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1117 if (!stdInterface)
1118 return E_FAIL;
1119 else
1120 return stdInterface->accSelect ( flagsSelect, varID );
1121 }
1122 else
1123 return S_OK;
1124
1125 return E_FAIL;
1126 }
1127
1128 // Retrieves the object that has the keyboard focus. All objects
1129 // that receive the keyboard focus must support this property.
1130
1131 STDMETHODIMP wxIAccessible::get_accFocus ( VARIANT* pVarID)
1132 {
1133 wxASSERT (m_pAccessible != NULL);
1134 if (!m_pAccessible)
1135 return E_FAIL;
1136
1137 wxAccessible* childObject = NULL;
1138 int childId = 0;
1139 VariantInit(pVarID);
1140
1141 wxAccStatus status = m_pAccessible->GetFocus(& childId, & childObject);
1142 if (status == wxACC_FAIL)
1143 return E_FAIL;
1144
1145 if (status == wxACC_NOT_IMPLEMENTED)
1146 {
1147 // Use standard interface instead.
1148 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1149 if (!stdInterface)
1150 return E_FAIL;
1151 else
1152 return stdInterface->get_accFocus (pVarID);
1153 }
1154 if (childObject)
1155 {
1156 if (childObject == m_pAccessible)
1157 {
1158 pVarID->vt = VT_I4;
1159 pVarID->lVal = CHILDID_SELF;
1160 return S_OK;
1161 }
1162 else
1163 {
1164 wxIAccessible* childIA = childObject->GetIAccessible();
1165 if (!childIA)
1166 return E_FAIL;
1167
1168 if (childIA->QueryInterface(IID_IDispatch, (LPVOID*) pVarID->pdispVal) != S_OK)
1169 return E_FAIL;
1170
1171 pVarID->vt = VT_DISPATCH;
1172 pVarID->pdispVal->AddRef();
1173 return S_OK;
1174 }
1175 }
1176 else if (childId > 0)
1177 {
1178 pVarID->vt = VT_I4;
1179 pVarID->lVal = childId;
1180 return S_OK;
1181 }
1182 else
1183 {
1184 pVarID->vt = VT_EMPTY;
1185 return S_FALSE;
1186 }
1187
1188 return E_FAIL;
1189 }
1190
1191 // Retrieves the selected children of this object. All objects
1192 // selected must support this property.
1193
1194 STDMETHODIMP wxIAccessible::get_accSelection ( VARIANT * pVarChildren)
1195 {
1196 wxASSERT (m_pAccessible != NULL);
1197 if (!m_pAccessible)
1198 return E_FAIL;
1199
1200 VariantInit(pVarChildren);
1201
1202 wxVariant selections;
1203 wxAccStatus status = m_pAccessible->GetSelections(& selections);
1204 if (status == wxACC_FAIL)
1205 return E_FAIL;
1206
1207 if (status == wxACC_NOT_IMPLEMENTED)
1208 {
1209 // Use standard interface instead.
1210 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1211 if (!stdInterface)
1212 return E_FAIL;
1213 else
1214 return stdInterface->get_accSelection (pVarChildren);
1215 }
1216 else
1217 {
1218 if (selections.GetType() == wxT("long"))
1219 {
1220 pVarChildren->vt = VT_I4;
1221 pVarChildren->lVal = selections.GetLong();
1222
1223 return S_OK;
1224 }
1225 else if (selections.GetType() == wxT("void*"))
1226 {
1227 wxAccessible* childObject = (wxAccessible*) selections.GetVoidPtr();
1228 wxIAccessible* childIA = childObject->GetIAccessible();
1229 if (!childIA)
1230 return E_FAIL;
1231
1232 if (childIA->QueryInterface(IID_IDispatch, (LPVOID*) pVarChildren->pdispVal) != S_OK)
1233 return E_FAIL;
1234
1235 pVarChildren->vt = VT_DISPATCH;
1236 pVarChildren->pdispVal->AddRef();
1237
1238 return S_OK;
1239 }
1240 else if (selections.GetType() == wxT("list"))
1241 {
1242 // TODO: should we AddRef for every "void*" member??
1243
1244 wxIEnumVARIANT* enumVariant = new wxIEnumVARIANT(selections);
1245 enumVariant->AddRef();
1246
1247 pVarChildren->vt = VT_UNKNOWN;
1248 pVarChildren->punkVal = enumVariant;
1249
1250 return S_OK;
1251 }
1252 }
1253
1254 return E_FAIL;
1255 }
1256
1257 // Get type info
1258
1259 STDMETHODIMP wxIAccessible::GetTypeInfo(unsigned int typeInfo, LCID lcid, ITypeInfo** ppTypeInfo)
1260 {
1261 *ppTypeInfo = NULL;
1262 return E_NOTIMPL;
1263 }
1264
1265 // Get type info count
1266
1267 STDMETHODIMP wxIAccessible::GetTypeInfoCount(unsigned int* typeInfoCount)
1268 {
1269 *typeInfoCount = 0;
1270 return E_NOTIMPL;
1271 }
1272
1273 // Get ids of names
1274
1275 STDMETHODIMP wxIAccessible::GetIDsOfNames(REFIID riid, OLECHAR** names, unsigned int cNames,
1276 LCID lcid, DISPID* dispId)
1277 {
1278 return E_NOTIMPL;
1279 }
1280
1281 // Invoke
1282
1283 STDMETHODIMP wxIAccessible::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
1284 WORD wFlags, DISPPARAMS *pDispParams,
1285 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
1286 unsigned int *puArgErr )
1287 {
1288 return E_NOTIMPL;
1289 }
1290
1291 // ----------------------------------------------------------------------------
1292 // wxAccessible implementation
1293 // ----------------------------------------------------------------------------
1294
1295 // ctors
1296
1297 // common part of all ctors
1298 void wxAccessible::Init()
1299 {
1300 m_pIAccessibleStd = NULL;
1301 m_pIAccessible = new wxIAccessible(this);
1302 m_pIAccessible->AddRef();
1303 }
1304
1305 wxAccessible::wxAccessible(wxWindow* win)
1306 : wxAccessibleBase(win)
1307 {
1308 Init();
1309 }
1310
1311 wxAccessible::~wxAccessible()
1312 {
1313 m_pIAccessible->Release();
1314 if (m_pIAccessibleStd)
1315 ((IAccessible*)m_pIAccessibleStd)->Release();
1316 }
1317
1318 // Gets or creates a standard interface for this object.
1319 void* wxAccessible::GetIAccessibleStd()
1320 {
1321 if (m_pIAccessibleStd)
1322 return m_pIAccessibleStd;
1323
1324 if (GetWindow())
1325 {
1326 #if 0
1327 HRESULT retCode = ::CreateStdAccessibleProxy((HWND) GetWindow()->GetHWND(),
1328 wxT("wxWindowClass"), OBJID_CLIENT, IID_IAccessible, (void**) & m_pIAccessibleStd);
1329 #else
1330 HRESULT retCode = ::CreateStdAccessibleObject((HWND) GetWindow()->GetHWND(),
1331 OBJID_CLIENT, IID_IAccessible, (void**) & m_pIAccessibleStd);
1332 #endif
1333 if (retCode == S_OK)
1334 return m_pIAccessibleStd;
1335 else
1336 {
1337 m_pIAccessibleStd = NULL;
1338 return NULL;
1339 }
1340 }
1341 return NULL;
1342 }
1343
1344 // Utilities
1345
1346 // Convert to Windows role
1347 int wxConvertToWindowsRole(wxAccRole wxrole)
1348 {
1349 switch (wxrole)
1350 {
1351 case wxROLE_SYSTEM_ALERT:
1352 return ROLE_SYSTEM_ALERT;
1353 case wxROLE_SYSTEM_ANIMATION:
1354 return ROLE_SYSTEM_ANIMATION;
1355 case wxROLE_SYSTEM_APPLICATION:
1356 return ROLE_SYSTEM_APPLICATION;
1357 case wxROLE_SYSTEM_BORDER:
1358 return ROLE_SYSTEM_BORDER;
1359 case wxROLE_SYSTEM_BUTTONDROPDOWN:
1360 return ROLE_SYSTEM_BUTTONDROPDOWN;
1361 case wxROLE_SYSTEM_BUTTONDROPDOWNGRID:
1362 return ROLE_SYSTEM_BUTTONDROPDOWNGRID;
1363 case wxROLE_SYSTEM_BUTTONMENU:
1364 return ROLE_SYSTEM_BUTTONMENU;
1365 case wxROLE_SYSTEM_CARET:
1366 return ROLE_SYSTEM_CARET;
1367 case wxROLE_SYSTEM_CELL:
1368 return ROLE_SYSTEM_CELL;
1369 case wxROLE_SYSTEM_CHARACTER:
1370 return ROLE_SYSTEM_CHARACTER;
1371 case wxROLE_SYSTEM_CHART:
1372 return ROLE_SYSTEM_CHART;
1373 case wxROLE_SYSTEM_CHECKBUTTON:
1374 return ROLE_SYSTEM_CHECKBUTTON;
1375 case wxROLE_SYSTEM_CLIENT:
1376 return ROLE_SYSTEM_CLIENT;
1377 case wxROLE_SYSTEM_CLOCK:
1378 return ROLE_SYSTEM_CLOCK;
1379 case wxROLE_SYSTEM_COLUMN:
1380 return ROLE_SYSTEM_COLUMN;
1381 case wxROLE_SYSTEM_COLUMNHEADER:
1382 return ROLE_SYSTEM_COLUMNHEADER;
1383 case wxROLE_SYSTEM_COMBOBOX:
1384 return ROLE_SYSTEM_COMBOBOX;
1385 case wxROLE_SYSTEM_CURSOR:
1386 return ROLE_SYSTEM_CURSOR;
1387 case wxROLE_SYSTEM_DIAGRAM:
1388 return ROLE_SYSTEM_DIAGRAM;
1389 case wxROLE_SYSTEM_DIAL:
1390 return ROLE_SYSTEM_DIAL;
1391 case wxROLE_SYSTEM_DIALOG:
1392 return ROLE_SYSTEM_DIALOG;
1393 case wxROLE_SYSTEM_DOCUMENT:
1394 return ROLE_SYSTEM_DOCUMENT;
1395 case wxROLE_SYSTEM_DROPLIST:
1396 return ROLE_SYSTEM_DROPLIST;
1397 case wxROLE_SYSTEM_EQUATION:
1398 return ROLE_SYSTEM_EQUATION;
1399 case wxROLE_SYSTEM_GRAPHIC:
1400 return ROLE_SYSTEM_GRAPHIC;
1401 case wxROLE_SYSTEM_GRIP:
1402 return ROLE_SYSTEM_GRIP;
1403 case wxROLE_SYSTEM_GROUPING:
1404 return ROLE_SYSTEM_GROUPING;
1405 case wxROLE_SYSTEM_HELPBALLOON:
1406 return ROLE_SYSTEM_HELPBALLOON;
1407 case wxROLE_SYSTEM_HOTKEYFIELD:
1408 return ROLE_SYSTEM_HOTKEYFIELD;
1409 case wxROLE_SYSTEM_INDICATOR:
1410 return ROLE_SYSTEM_INDICATOR;
1411 case wxROLE_SYSTEM_LINK:
1412 return ROLE_SYSTEM_LINK;
1413 case wxROLE_SYSTEM_LIST:
1414 return ROLE_SYSTEM_LIST;
1415 case wxROLE_SYSTEM_LISTITEM:
1416 return ROLE_SYSTEM_LISTITEM;
1417 case wxROLE_SYSTEM_MENUBAR:
1418 return ROLE_SYSTEM_MENUBAR;
1419 case wxROLE_SYSTEM_MENUITEM:
1420 return ROLE_SYSTEM_MENUITEM;
1421 case wxROLE_SYSTEM_MENUPOPUP:
1422 return ROLE_SYSTEM_MENUPOPUP;
1423 case wxROLE_SYSTEM_OUTLINE:
1424 return ROLE_SYSTEM_OUTLINE;
1425 case wxROLE_SYSTEM_OUTLINEITEM:
1426 return ROLE_SYSTEM_OUTLINEITEM;
1427 case wxROLE_SYSTEM_PAGETAB:
1428 return ROLE_SYSTEM_PAGETAB;
1429 case wxROLE_SYSTEM_PAGETABLIST:
1430 return ROLE_SYSTEM_PAGETABLIST;
1431 case wxROLE_SYSTEM_PANE:
1432 return ROLE_SYSTEM_PANE;
1433 case wxROLE_SYSTEM_PROGRESSBAR:
1434 return ROLE_SYSTEM_PROGRESSBAR;
1435 case wxROLE_SYSTEM_PROPERTYPAGE:
1436 return ROLE_SYSTEM_PROPERTYPAGE;
1437 case wxROLE_SYSTEM_PUSHBUTTON:
1438 return ROLE_SYSTEM_PUSHBUTTON;
1439 case wxROLE_SYSTEM_RADIOBUTTON:
1440 return ROLE_SYSTEM_RADIOBUTTON;
1441 case wxROLE_SYSTEM_ROW:
1442 return ROLE_SYSTEM_ROW;
1443 case wxROLE_SYSTEM_ROWHEADER:
1444 return ROLE_SYSTEM_ROWHEADER;
1445 case wxROLE_SYSTEM_SCROLLBAR:
1446 return ROLE_SYSTEM_SCROLLBAR;
1447 case wxROLE_SYSTEM_SEPARATOR:
1448 return ROLE_SYSTEM_SEPARATOR;
1449 case wxROLE_SYSTEM_SLIDER:
1450 return ROLE_SYSTEM_SLIDER;
1451 case wxROLE_SYSTEM_SOUND:
1452 return ROLE_SYSTEM_SOUND;
1453 case wxROLE_SYSTEM_SPINBUTTON:
1454 return ROLE_SYSTEM_SPINBUTTON;
1455 case wxROLE_SYSTEM_STATICTEXT:
1456 return ROLE_SYSTEM_STATICTEXT;
1457 case wxROLE_SYSTEM_STATUSBAR:
1458 return ROLE_SYSTEM_STATUSBAR;
1459 case wxROLE_SYSTEM_TABLE:
1460 return ROLE_SYSTEM_TABLE;
1461 case wxROLE_SYSTEM_TEXT:
1462 return ROLE_SYSTEM_TEXT;
1463 case wxROLE_SYSTEM_TITLEBAR:
1464 return ROLE_SYSTEM_TITLEBAR;
1465 case wxROLE_SYSTEM_TOOLBAR:
1466 return ROLE_SYSTEM_TOOLBAR;
1467 case wxROLE_SYSTEM_TOOLTIP:
1468 return ROLE_SYSTEM_TOOLTIP;
1469 case wxROLE_SYSTEM_WHITESPACE:
1470 return ROLE_SYSTEM_WHITESPACE;
1471 case wxROLE_SYSTEM_WINDOW:
1472 return ROLE_SYSTEM_WINDOW;
1473 }
1474 return 0;
1475 }
1476
1477 // Convert to Windows state
1478 long wxConvertToWindowsState(long wxstate)
1479 {
1480 long state = 0;
1481 if (wxstate & wxACC_STATE_SYSTEM_ALERT_HIGH)
1482 state |= STATE_SYSTEM_ALERT_HIGH;
1483
1484 if (wxstate & wxACC_STATE_SYSTEM_ALERT_MEDIUM)
1485 state |= STATE_SYSTEM_ALERT_MEDIUM;
1486
1487 if (wxstate & wxACC_STATE_SYSTEM_ALERT_LOW)
1488 state |= STATE_SYSTEM_ALERT_LOW;
1489
1490 if (wxstate & wxACC_STATE_SYSTEM_ANIMATED)
1491 state |= STATE_SYSTEM_ANIMATED;
1492
1493 if (wxstate & wxACC_STATE_SYSTEM_BUSY)
1494 state |= STATE_SYSTEM_BUSY;
1495
1496 if (wxstate & wxACC_STATE_SYSTEM_CHECKED)
1497 state |= STATE_SYSTEM_CHECKED;
1498
1499 if (wxstate & wxACC_STATE_SYSTEM_COLLAPSED)
1500 state |= STATE_SYSTEM_COLLAPSED;
1501
1502 if (wxstate & wxACC_STATE_SYSTEM_DEFAULT)
1503 state |= STATE_SYSTEM_DEFAULT;
1504
1505 if (wxstate & wxACC_STATE_SYSTEM_EXPANDED)
1506 state |= STATE_SYSTEM_EXPANDED;
1507
1508 if (wxstate & wxACC_STATE_SYSTEM_EXTSELECTABLE)
1509 state |= STATE_SYSTEM_EXTSELECTABLE;
1510
1511 if (wxstate & wxACC_STATE_SYSTEM_FLOATING)
1512 state |= STATE_SYSTEM_FLOATING;
1513
1514 if (wxstate & wxACC_STATE_SYSTEM_FOCUSABLE)
1515 state |= STATE_SYSTEM_FOCUSABLE;
1516
1517 if (wxstate & wxACC_STATE_SYSTEM_FOCUSED)
1518 state |= STATE_SYSTEM_FOCUSED;
1519
1520 if (wxstate & wxACC_STATE_SYSTEM_HOTTRACKED)
1521 state |= STATE_SYSTEM_HOTTRACKED;
1522
1523 if (wxstate & wxACC_STATE_SYSTEM_INVISIBLE)
1524 state |= STATE_SYSTEM_INVISIBLE;
1525
1526 if (wxstate & wxACC_STATE_SYSTEM_INVISIBLE)
1527 state |= STATE_SYSTEM_INVISIBLE;
1528
1529 if (wxstate & wxACC_STATE_SYSTEM_MIXED)
1530 state |= STATE_SYSTEM_MIXED;
1531
1532 if (wxstate & wxACC_STATE_SYSTEM_MULTISELECTABLE)
1533 state |= STATE_SYSTEM_MULTISELECTABLE;
1534
1535 if (wxstate & wxACC_STATE_SYSTEM_OFFSCREEN)
1536 state |= STATE_SYSTEM_OFFSCREEN;
1537
1538 if (wxstate & wxACC_STATE_SYSTEM_PRESSED)
1539 state |= STATE_SYSTEM_PRESSED;
1540
1541 // if (wxstate & wxACC_STATE_SYSTEM_PROTECTED)
1542 // state |= STATE_SYSTEM_PROTECTED;
1543
1544 if (wxstate & wxACC_STATE_SYSTEM_READONLY)
1545 state |= STATE_SYSTEM_READONLY;
1546
1547 if (wxstate & wxACC_STATE_SYSTEM_SELECTABLE)
1548 state |= STATE_SYSTEM_SELECTABLE;
1549
1550 if (wxstate & wxACC_STATE_SYSTEM_SELECTED)
1551 state |= STATE_SYSTEM_SELECTED;
1552
1553 if (wxstate & wxACC_STATE_SYSTEM_SELFVOICING)
1554 state |= STATE_SYSTEM_SELFVOICING;
1555
1556 if (wxstate & wxACC_STATE_SYSTEM_UNAVAILABLE)
1557 state |= STATE_SYSTEM_UNAVAILABLE;
1558
1559 return state;
1560 }
1561
1562 // Convert to Windows selection flag
1563 int wxConvertToWindowsSelFlag(wxAccSelectionFlags wxsel)
1564 {
1565 int sel = 0;
1566
1567 if (sel & wxACC_SEL_TAKEFOCUS)
1568 sel |= SELFLAG_TAKEFOCUS;
1569 if (sel & wxACC_SEL_TAKESELECTION)
1570 sel |= SELFLAG_TAKESELECTION;
1571 if (sel & wxACC_SEL_EXTENDSELECTION)
1572 sel |= SELFLAG_EXTENDSELECTION;
1573 if (sel & wxACC_SEL_ADDSELECTION)
1574 sel |= SELFLAG_ADDSELECTION;
1575 if (sel & wxACC_SEL_REMOVESELECTION)
1576 sel |= SELFLAG_REMOVESELECTION;
1577 return sel;
1578 }
1579
1580 // Convert from Windows selection flag
1581 wxAccSelectionFlags wxConvertFromWindowsSelFlag(int sel)
1582 {
1583 int wxsel = 0;
1584
1585 if (sel & SELFLAG_TAKEFOCUS)
1586 wxsel |= wxACC_SEL_TAKEFOCUS;
1587 if (sel & SELFLAG_TAKESELECTION)
1588 wxsel |= wxACC_SEL_TAKESELECTION;
1589 if (sel & SELFLAG_EXTENDSELECTION)
1590 wxsel |= wxACC_SEL_EXTENDSELECTION;
1591 if (sel & SELFLAG_ADDSELECTION)
1592 wxsel |= wxACC_SEL_ADDSELECTION;
1593 if (sel & SELFLAG_REMOVESELECTION)
1594 wxsel |= wxACC_SEL_REMOVESELECTION;
1595 return (wxAccSelectionFlags) wxsel;
1596 }
1597
1598
1599 #endif //USE_ACCESSIBILITY