]> git.saurik.com Git - wxWidgets.git/blob - src/msw/ole/access.cpp
7c1e16e3f192e254bf7376bb6f2a85f7be5d5a20
[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
598 if (objectIA->QueryInterface(IID_IDispatch, (LPVOID*) ppDispChild) != S_OK)
599 return E_FAIL;
600
601 (*ppDispChild)->AddRef();
602 return S_OK;
603 }
604 else
605 return S_FALSE; // Indicates it's not an accessible object
606 }
607
608 return E_FAIL;
609 }
610
611 // Retrieves the number of children that belong to this object.
612 // All objects must support this property.
613
614 STDMETHODIMP wxIAccessible::get_accChildCount ( long* pCountChildren)
615 {
616 wxASSERT (m_pAccessible != NULL);
617 if (!m_pAccessible)
618 return E_FAIL;
619
620 int childCount = 0;
621 wxAccStatus status = m_pAccessible->GetChildCount(& childCount);
622 if (status == wxACC_FAIL)
623 return E_FAIL;
624
625 if (status == wxACC_NOT_IMPLEMENTED)
626 {
627 // Use standard interface instead.
628 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
629 if (!stdInterface)
630 return E_FAIL;
631 else
632 return stdInterface->get_accChildCount (pCountChildren);
633 }
634 else
635 {
636 * pCountChildren = (long) childCount;
637 return S_OK;
638 }
639
640 return E_FAIL;
641 }
642
643 // Retrieves the IDispatch interface of the object's parent.
644 // All objects support this property.
645
646 STDMETHODIMP wxIAccessible::get_accParent ( IDispatch** ppDispParent)
647 {
648 wxASSERT (m_pAccessible != NULL);
649 if (!m_pAccessible)
650 return E_FAIL;
651
652 wxAccessible* parent = NULL;
653 wxAccStatus status = m_pAccessible->GetParent(& parent);
654 if (status == wxACC_FAIL)
655 return E_FAIL;
656
657 if (status == wxACC_NOT_IMPLEMENTED)
658 {
659 // Use standard interface instead.
660 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
661 if (!stdInterface)
662 return E_FAIL;
663 else
664 return stdInterface->get_accParent (ppDispParent);
665 }
666 else
667 {
668 if (parent)
669 {
670 wxIAccessible* objectIA = parent->GetIAccessible();
671 if (!objectIA)
672 return E_FAIL;
673
674 if (objectIA->QueryInterface(IID_IDispatch, (LPVOID*) ppDispParent) != S_OK)
675 return E_FAIL;
676
677 (*ppDispParent)->AddRef();
678 return S_OK;
679 /*
680 wxIAccessible* objectIA = parent->GetIAccessible();
681 if (!objectIA)
682 return E_FAIL;
683 objectIA->AddRef();
684 *ppDispParent = objectIA;
685 return S_OK;
686 */
687 }
688 else
689 {
690 *ppDispParent = NULL;
691 return S_OK;
692 }
693 }
694
695 return E_FAIL;
696 }
697
698 // Performs the object's default action. Not all objects have a default
699 // action.
700
701 STDMETHODIMP wxIAccessible::accDoDefaultAction(VARIANT varID)
702 {
703 wxASSERT (m_pAccessible != NULL);
704 if (!m_pAccessible)
705 return E_FAIL;
706
707 if (varID.vt != VT_I4)
708 return E_INVALIDARG;
709
710 wxAccStatus status = m_pAccessible->DoDefaultAction(varID.lVal);
711 if (status == wxACC_FAIL)
712 return E_FAIL;
713
714 if (status == wxACC_NOT_SUPPORTED)
715 return DISP_E_MEMBERNOTFOUND;
716
717 if (status == wxACC_NOT_IMPLEMENTED)
718 {
719 // Use standard interface instead.
720 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
721 if (!stdInterface)
722 return E_FAIL;
723 else
724 return stdInterface->accDoDefaultAction(varID);
725 }
726 return E_FAIL;
727 }
728
729 // Retrieves a string that describes the object's default action.
730 // Not all objects have a default action.
731
732 STDMETHODIMP wxIAccessible::get_accDefaultAction ( VARIANT varID, BSTR* pszDefaultAction)
733 {
734 wxASSERT (m_pAccessible != NULL);
735 if (!m_pAccessible)
736 return E_FAIL;
737
738 if (varID.vt != VT_I4)
739 return E_INVALIDARG;
740
741 wxString defaultAction;
742 wxAccStatus status = m_pAccessible->GetDefaultAction(varID.lVal, & defaultAction);
743 if (status == wxACC_FAIL)
744 return E_FAIL;
745
746 if (status == wxACC_NOT_SUPPORTED)
747 return DISP_E_MEMBERNOTFOUND;
748
749 if (status == wxACC_NOT_IMPLEMENTED)
750 {
751 // Use standard interface instead.
752 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
753 if (!stdInterface)
754 return E_FAIL;
755 else
756 return stdInterface->get_accDefaultAction (varID, pszDefaultAction);
757 }
758 else
759 {
760 if (defaultAction.IsEmpty())
761 {
762 * pszDefaultAction = NULL;
763 return S_FALSE;
764 }
765 else
766 {
767 wxBasicString basicString(defaultAction);
768 * pszDefaultAction = basicString.Get();
769 return S_OK;
770 }
771 }
772 return E_FAIL;
773 }
774
775 // Retrieves a string that describes the visual appearance of the specified object.
776 // Not all objects have a description.
777
778 STDMETHODIMP wxIAccessible::get_accDescription ( VARIANT varID, BSTR* pszDescription)
779 {
780 wxASSERT (m_pAccessible != NULL);
781 if (!m_pAccessible)
782 return E_FAIL;
783
784 if (varID.vt != VT_I4)
785 return E_INVALIDARG;
786
787 wxString description;
788 wxAccStatus status = m_pAccessible->GetDescription(varID.lVal, & description);
789 if (status == wxACC_FAIL)
790 return E_FAIL;
791
792 if (status == wxACC_NOT_IMPLEMENTED)
793 {
794 // Use standard interface instead.
795 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
796 if (!stdInterface)
797 return E_FAIL;
798 else
799 return stdInterface->get_accDescription (varID, pszDescription);
800 }
801 else
802 {
803 if (description.IsEmpty())
804 {
805 * pszDescription = NULL;
806 return S_FALSE;
807 }
808 else
809 {
810 wxBasicString basicString(description);
811 * pszDescription = basicString.Get();
812 return S_OK;
813 }
814 }
815 return E_FAIL;
816 }
817
818 // Retrieves an object's Help property string.
819 // Not all objects support this property.
820
821 STDMETHODIMP wxIAccessible::get_accHelp ( VARIANT varID, BSTR* pszHelp)
822 {
823 wxASSERT (m_pAccessible != NULL);
824 if (!m_pAccessible)
825 return E_FAIL;
826
827 if (varID.vt != VT_I4)
828 return E_INVALIDARG;
829
830 wxString helpString;
831 wxAccStatus status = m_pAccessible->GetHelpText(varID.lVal, & helpString);
832 if (status == wxACC_FAIL)
833 return E_FAIL;
834
835 if (status == wxACC_NOT_IMPLEMENTED)
836 {
837 // Use standard interface instead.
838 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
839 if (!stdInterface)
840 return E_FAIL;
841 else
842 return stdInterface->get_accHelp (varID, pszHelp);
843 }
844 else
845 {
846 if (helpString.IsEmpty())
847 {
848 * pszHelp = NULL;
849 return S_FALSE;
850 }
851 else
852 {
853 wxBasicString basicString(helpString);
854 * pszHelp = basicString.Get();
855 return S_OK;
856 }
857 }
858 return E_FAIL;
859 }
860
861 // Retrieves the full path of the WinHelp file associated with the specified
862 // object and the identifier of the appropriate topic within that file.
863 // Not all objects support this property.
864 // NOTE: not supported by wxWindows at this time. Use
865 // GetHelpText instead.
866
867 STDMETHODIMP wxIAccessible::get_accHelpTopic ( BSTR* pszHelpFile, VARIANT varChild, long* pidTopic)
868 {
869 wxASSERT (m_pAccessible != NULL);
870 if (!m_pAccessible)
871 return E_FAIL;
872
873 if (varChild.vt != VT_I4)
874 return E_INVALIDARG;
875
876 wxAccStatus status = wxACC_NOT_IMPLEMENTED;
877 if (status == wxACC_FAIL)
878 return E_FAIL;
879
880 if (status == wxACC_NOT_IMPLEMENTED)
881 {
882 // Use standard interface instead.
883 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
884 if (!stdInterface)
885 return E_FAIL;
886 else
887 return stdInterface->get_accHelpTopic (pszHelpFile, varChild, pidTopic);
888 }
889 return E_FAIL;
890 }
891
892 // Retrieves the specified object's shortcut key or access key, also known as
893 // the mnemonic. All objects that have a shortcut key or access key support
894 // this property.
895
896 STDMETHODIMP wxIAccessible::get_accKeyboardShortcut ( VARIANT varID, BSTR* pszKeyboardShortcut)
897 {
898 *pszKeyboardShortcut = NULL;
899
900 wxASSERT (m_pAccessible != NULL);
901 if (!m_pAccessible)
902 return E_FAIL;
903
904 if (varID.vt != VT_I4)
905 return E_INVALIDARG;
906
907 wxString keyboardShortcut;
908 wxAccStatus status = m_pAccessible->GetHelpText(varID.lVal, & keyboardShortcut);
909 if (status == wxACC_FAIL)
910 return E_FAIL;
911
912 if (status == wxACC_NOT_IMPLEMENTED)
913 {
914 // Use standard interface instead.
915 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
916 if (!stdInterface)
917 return E_FAIL;
918 else
919 return stdInterface->get_accKeyboardShortcut(varID, pszKeyboardShortcut);
920 }
921 else
922 {
923 if (keyboardShortcut.IsEmpty())
924 {
925 * pszKeyboardShortcut = NULL;
926 return S_FALSE;
927 }
928 else
929 {
930 wxBasicString basicString(keyboardShortcut);
931 * pszKeyboardShortcut = basicString.Get();
932 return S_OK;
933 }
934 }
935 return E_FAIL;
936 }
937
938 // Retrieves the name of the specified object.
939 // All objects support this property.
940
941 STDMETHODIMP wxIAccessible::get_accName ( VARIANT varID, BSTR* pszName)
942 {
943 *pszName = NULL;
944
945 wxASSERT (m_pAccessible != NULL);
946 if (!m_pAccessible)
947 return E_FAIL;
948
949 if (varID.vt != VT_I4)
950 return E_INVALIDARG;
951
952 wxString name;
953
954 wxAccStatus status = m_pAccessible->GetName(varID.lVal, & name);
955
956 if (status == wxACC_FAIL)
957 return E_FAIL;
958
959 if (status == wxACC_NOT_IMPLEMENTED)
960 {
961 // Use standard interface instead.
962 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
963 if (!stdInterface)
964 return E_FAIL;
965 else
966 return stdInterface->get_accName (varID, pszName);
967 }
968 else
969 {
970 wxBasicString basicString(name);
971 *pszName = basicString.Get();
972 return S_OK;
973 }
974 return E_FAIL;
975 }
976
977 // Retrieves information that describes the role of the specified object.
978 // All objects support this property.
979
980 STDMETHODIMP wxIAccessible::get_accRole ( VARIANT varID, VARIANT* pVarRole)
981 {
982 wxASSERT (m_pAccessible != NULL);
983 if (!m_pAccessible)
984 return E_FAIL;
985
986 if (varID.vt != VT_I4)
987 return E_INVALIDARG;
988
989 VariantInit(pVarRole);
990
991 wxAccRole role = wxROLE_NONE;
992
993 wxAccStatus status = m_pAccessible->GetRole(varID.lVal, & role);
994
995 if (status == wxACC_FAIL)
996 return E_FAIL;
997
998 if (status == wxACC_NOT_IMPLEMENTED)
999 {
1000 // Use standard interface instead.
1001 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1002 if (!stdInterface)
1003 return E_FAIL;
1004 else
1005 return stdInterface->get_accRole (varID, pVarRole);
1006 }
1007 else
1008 {
1009 if (role == wxROLE_NONE)
1010 {
1011 pVarRole->vt = VT_EMPTY;
1012 return S_OK;
1013 }
1014
1015 pVarRole->lVal = wxConvertToWindowsRole(role);
1016 pVarRole->vt = VT_I4;
1017
1018 return S_OK;
1019 }
1020 return E_FAIL;
1021 }
1022
1023 // Retrieves the current state of the specified object.
1024 // All objects support this property.
1025
1026 STDMETHODIMP wxIAccessible::get_accState ( VARIANT varID, VARIANT* pVarState)
1027 {
1028 wxASSERT (m_pAccessible != NULL);
1029 if (!m_pAccessible)
1030 return E_FAIL;
1031
1032 if (varID.vt != VT_I4)
1033 return E_INVALIDARG;
1034
1035 long wxstate = 0;
1036
1037 wxAccStatus status = m_pAccessible->GetState(varID.lVal, & wxstate);
1038 if (status == wxACC_FAIL)
1039 return E_FAIL;
1040
1041 if (status == wxACC_NOT_IMPLEMENTED)
1042 {
1043 // Use standard interface instead.
1044 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1045 if (!stdInterface)
1046 return E_FAIL;
1047 else
1048 return stdInterface->get_accState (varID, pVarState);
1049 }
1050 else
1051 {
1052 long state = wxConvertToWindowsState(wxstate);
1053 pVarState->lVal = state;
1054 pVarState->vt = VT_I4;
1055 return S_OK;
1056 }
1057 return E_FAIL;
1058 }
1059
1060 // Retrieves the value of the specified object.
1061 // Not all objects have a value.
1062
1063 STDMETHODIMP wxIAccessible::get_accValue ( VARIANT varID, BSTR* pszValue)
1064 {
1065 wxASSERT (m_pAccessible != NULL);
1066 if (!m_pAccessible)
1067 return E_FAIL;
1068
1069 if (varID.vt != VT_I4)
1070 return E_INVALIDARG;
1071
1072 wxString strValue;
1073
1074 wxAccStatus status = m_pAccessible->GetValue(varID.lVal, & strValue);
1075
1076 if (status == wxACC_FAIL)
1077 return E_FAIL;
1078
1079 if (status == wxACC_NOT_IMPLEMENTED)
1080 {
1081 // Use standard interface instead.
1082 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1083 if (!stdInterface)
1084 return E_FAIL;
1085 else
1086 return stdInterface->get_accValue (varID, pszValue);
1087 }
1088 else
1089 {
1090 wxBasicString basicString(strValue);
1091 * pszValue = basicString.Get();
1092 return S_OK;
1093 }
1094 return E_FAIL;
1095 }
1096
1097 // Modifies the selection or moves the keyboard focus of the
1098 // specified object. All objects that select or receive the
1099 // keyboard focus must support this method.
1100
1101 STDMETHODIMP wxIAccessible::accSelect ( long flagsSelect, VARIANT varID )
1102 {
1103 wxASSERT (m_pAccessible != NULL);
1104 if (!m_pAccessible)
1105 return E_FAIL;
1106
1107 if (varID.vt != VT_I4)
1108 return E_INVALIDARG;
1109
1110 wxAccSelectionFlags wxsel = wxConvertFromWindowsSelFlag(flagsSelect);
1111
1112 wxAccStatus status = m_pAccessible->Select(varID.lVal, wxsel);
1113 if (status == wxACC_FAIL)
1114 return E_FAIL;
1115
1116 if (status == wxACC_NOT_IMPLEMENTED)
1117 {
1118 // Use standard interface instead.
1119 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1120 if (!stdInterface)
1121 return E_FAIL;
1122 else
1123 return stdInterface->accSelect ( flagsSelect, varID );
1124 }
1125 else
1126 return S_OK;
1127
1128 return E_FAIL;
1129 }
1130
1131 // Retrieves the object that has the keyboard focus. All objects
1132 // that receive the keyboard focus must support this property.
1133
1134 STDMETHODIMP wxIAccessible::get_accFocus ( VARIANT* pVarID)
1135 {
1136 wxASSERT (m_pAccessible != NULL);
1137 if (!m_pAccessible)
1138 return E_FAIL;
1139
1140 wxAccessible* childObject = NULL;
1141 int childId = 0;
1142 VariantInit(pVarID);
1143
1144 wxAccStatus status = m_pAccessible->GetFocus(& childId, & childObject);
1145 if (status == wxACC_FAIL)
1146 return E_FAIL;
1147
1148 if (status == wxACC_NOT_IMPLEMENTED)
1149 {
1150 // Use standard interface instead.
1151 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1152 if (!stdInterface)
1153 return E_FAIL;
1154 else
1155 return stdInterface->get_accFocus (pVarID);
1156 }
1157 if (childObject)
1158 {
1159 if (childObject == m_pAccessible)
1160 {
1161 pVarID->vt = VT_I4;
1162 pVarID->lVal = CHILDID_SELF;
1163 return S_OK;
1164 }
1165 else
1166 {
1167 wxIAccessible* childIA = childObject->GetIAccessible();
1168 if (!childIA)
1169 return E_FAIL;
1170
1171 if (childIA->QueryInterface(IID_IDispatch, (LPVOID*) pVarID->pdispVal) != S_OK)
1172 return E_FAIL;
1173
1174 pVarID->vt = VT_DISPATCH;
1175 pVarID->pdispVal->AddRef();
1176 return S_OK;
1177 }
1178 }
1179 else if (childId > 0)
1180 {
1181 pVarID->vt = VT_I4;
1182 pVarID->lVal = childId;
1183 return S_OK;
1184 }
1185 else
1186 {
1187 pVarID->vt = VT_EMPTY;
1188 return S_FALSE;
1189 }
1190
1191 return E_FAIL;
1192 }
1193
1194 // Retrieves the selected children of this object. All objects
1195 // selected must support this property.
1196
1197 STDMETHODIMP wxIAccessible::get_accSelection ( VARIANT * pVarChildren)
1198 {
1199 wxASSERT (m_pAccessible != NULL);
1200 if (!m_pAccessible)
1201 return E_FAIL;
1202
1203 VariantInit(pVarChildren);
1204
1205 wxVariant selections;
1206 wxAccStatus status = m_pAccessible->GetSelections(& selections);
1207 if (status == wxACC_FAIL)
1208 return E_FAIL;
1209
1210 if (status == wxACC_NOT_IMPLEMENTED)
1211 {
1212 // Use standard interface instead.
1213 IAccessible* stdInterface = (IAccessible*)m_pAccessible->GetIAccessibleStd();
1214 if (!stdInterface)
1215 return E_FAIL;
1216 else
1217 return stdInterface->get_accSelection (pVarChildren);
1218 }
1219 else
1220 {
1221 if (selections.GetType() == wxT("long"))
1222 {
1223 pVarChildren->vt = VT_I4;
1224 pVarChildren->lVal = selections.GetLong();
1225
1226 return S_OK;
1227 }
1228 else if (selections.GetType() == wxT("void*"))
1229 {
1230 wxAccessible* childObject = (wxAccessible*) selections.GetVoidPtr();
1231 wxIAccessible* childIA = childObject->GetIAccessible();
1232 if (!childIA)
1233 return E_FAIL;
1234
1235 if (childIA->QueryInterface(IID_IDispatch, (LPVOID*) pVarChildren->pdispVal) != S_OK)
1236 return E_FAIL;
1237
1238 pVarChildren->vt = VT_DISPATCH;
1239 pVarChildren->pdispVal->AddRef();
1240
1241 return S_OK;
1242 }
1243 else if (selections.GetType() == wxT("list"))
1244 {
1245 // TODO: should we AddRef for every "void*" member??
1246
1247 wxIEnumVARIANT* enumVariant = new wxIEnumVARIANT(selections);
1248 enumVariant->AddRef();
1249
1250 pVarChildren->vt = VT_UNKNOWN;
1251 pVarChildren->punkVal = enumVariant;
1252
1253 return S_OK;
1254 }
1255 }
1256
1257 return E_FAIL;
1258 }
1259
1260 // Get type info
1261
1262 STDMETHODIMP wxIAccessible::GetTypeInfo(unsigned int typeInfo, LCID lcid, ITypeInfo** ppTypeInfo)
1263 {
1264 *ppTypeInfo = NULL;
1265 return E_NOTIMPL;
1266 }
1267
1268 // Get type info count
1269
1270 STDMETHODIMP wxIAccessible::GetTypeInfoCount(unsigned int* typeInfoCount)
1271 {
1272 *typeInfoCount = 0;
1273 return E_NOTIMPL;
1274 }
1275
1276 // Get ids of names
1277
1278 STDMETHODIMP wxIAccessible::GetIDsOfNames(REFIID riid, OLECHAR** names, unsigned int cNames,
1279 LCID lcid, DISPID* dispId)
1280 {
1281 return E_NOTIMPL;
1282 }
1283
1284 // Invoke
1285
1286 STDMETHODIMP wxIAccessible::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
1287 WORD wFlags, DISPPARAMS *pDispParams,
1288 VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
1289 unsigned int *puArgErr )
1290 {
1291 return E_NOTIMPL;
1292 }
1293
1294 // ----------------------------------------------------------------------------
1295 // wxAccessible implementation
1296 // ----------------------------------------------------------------------------
1297
1298 // ctors
1299
1300 // common part of all ctors
1301 void wxAccessible::Init()
1302 {
1303 m_pIAccessibleStd = NULL;
1304 m_pIAccessible = new wxIAccessible(this);
1305 m_pIAccessible->AddRef();
1306 }
1307
1308 wxAccessible::wxAccessible(wxWindow* win)
1309 : wxAccessibleBase(win)
1310 {
1311 Init();
1312 }
1313
1314 wxAccessible::~wxAccessible()
1315 {
1316 m_pIAccessible->Release();
1317 if (m_pIAccessibleStd)
1318 ((IAccessible*)m_pIAccessibleStd)->Release();
1319 }
1320
1321 // Gets or creates a standard interface for this object.
1322 void* wxAccessible::GetIAccessibleStd()
1323 {
1324 if (m_pIAccessibleStd)
1325 return m_pIAccessibleStd;
1326
1327 if (GetWindow())
1328 {
1329 #if 0
1330 HRESULT retCode = ::CreateStdAccessibleProxy((HWND) GetWindow()->GetHWND(),
1331 wxT("wxWindowClass"), OBJID_CLIENT, IID_IAccessible, (void**) & m_pIAccessibleStd);
1332 #else
1333 HRESULT retCode = ::CreateStdAccessibleObject((HWND) GetWindow()->GetHWND(),
1334 OBJID_CLIENT, IID_IAccessible, (void**) & m_pIAccessibleStd);
1335 #endif
1336 if (retCode == S_OK)
1337 return m_pIAccessibleStd;
1338 else
1339 {
1340 m_pIAccessibleStd = NULL;
1341 return NULL;
1342 }
1343 }
1344 return NULL;
1345 }
1346
1347 // Utilities
1348
1349 // Convert to Windows role
1350 int wxConvertToWindowsRole(wxAccRole wxrole)
1351 {
1352 switch (wxrole)
1353 {
1354 case wxROLE_SYSTEM_ALERT:
1355 return ROLE_SYSTEM_ALERT;
1356 case wxROLE_SYSTEM_ANIMATION:
1357 return ROLE_SYSTEM_ANIMATION;
1358 case wxROLE_SYSTEM_APPLICATION:
1359 return ROLE_SYSTEM_APPLICATION;
1360 case wxROLE_SYSTEM_BORDER:
1361 return ROLE_SYSTEM_BORDER;
1362 case wxROLE_SYSTEM_BUTTONDROPDOWN:
1363 return ROLE_SYSTEM_BUTTONDROPDOWN;
1364 case wxROLE_SYSTEM_BUTTONDROPDOWNGRID:
1365 return ROLE_SYSTEM_BUTTONDROPDOWNGRID;
1366 case wxROLE_SYSTEM_BUTTONMENU:
1367 return ROLE_SYSTEM_BUTTONMENU;
1368 case wxROLE_SYSTEM_CARET:
1369 return ROLE_SYSTEM_CARET;
1370 case wxROLE_SYSTEM_CELL:
1371 return ROLE_SYSTEM_CELL;
1372 case wxROLE_SYSTEM_CHARACTER:
1373 return ROLE_SYSTEM_CHARACTER;
1374 case wxROLE_SYSTEM_CHART:
1375 return ROLE_SYSTEM_CHART;
1376 case wxROLE_SYSTEM_CHECKBUTTON:
1377 return ROLE_SYSTEM_CHECKBUTTON;
1378 case wxROLE_SYSTEM_CLIENT:
1379 return ROLE_SYSTEM_CLIENT;
1380 case wxROLE_SYSTEM_CLOCK:
1381 return ROLE_SYSTEM_CLOCK;
1382 case wxROLE_SYSTEM_COLUMN:
1383 return ROLE_SYSTEM_COLUMN;
1384 case wxROLE_SYSTEM_COLUMNHEADER:
1385 return ROLE_SYSTEM_COLUMNHEADER;
1386 case wxROLE_SYSTEM_COMBOBOX:
1387 return ROLE_SYSTEM_COMBOBOX;
1388 case wxROLE_SYSTEM_CURSOR:
1389 return ROLE_SYSTEM_CURSOR;
1390 case wxROLE_SYSTEM_DIAGRAM:
1391 return ROLE_SYSTEM_DIAGRAM;
1392 case wxROLE_SYSTEM_DIAL:
1393 return ROLE_SYSTEM_DIAL;
1394 case wxROLE_SYSTEM_DIALOG:
1395 return ROLE_SYSTEM_DIALOG;
1396 case wxROLE_SYSTEM_DOCUMENT:
1397 return ROLE_SYSTEM_DOCUMENT;
1398 case wxROLE_SYSTEM_DROPLIST:
1399 return ROLE_SYSTEM_DROPLIST;
1400 case wxROLE_SYSTEM_EQUATION:
1401 return ROLE_SYSTEM_EQUATION;
1402 case wxROLE_SYSTEM_GRAPHIC:
1403 return ROLE_SYSTEM_GRAPHIC;
1404 case wxROLE_SYSTEM_GRIP:
1405 return ROLE_SYSTEM_GRIP;
1406 case wxROLE_SYSTEM_GROUPING:
1407 return ROLE_SYSTEM_GROUPING;
1408 case wxROLE_SYSTEM_HELPBALLOON:
1409 return ROLE_SYSTEM_HELPBALLOON;
1410 case wxROLE_SYSTEM_HOTKEYFIELD:
1411 return ROLE_SYSTEM_HOTKEYFIELD;
1412 case wxROLE_SYSTEM_INDICATOR:
1413 return ROLE_SYSTEM_INDICATOR;
1414 case wxROLE_SYSTEM_LINK:
1415 return ROLE_SYSTEM_LINK;
1416 case wxROLE_SYSTEM_LIST:
1417 return ROLE_SYSTEM_LIST;
1418 case wxROLE_SYSTEM_LISTITEM:
1419 return ROLE_SYSTEM_LISTITEM;
1420 case wxROLE_SYSTEM_MENUBAR:
1421 return ROLE_SYSTEM_MENUBAR;
1422 case wxROLE_SYSTEM_MENUITEM:
1423 return ROLE_SYSTEM_MENUITEM;
1424 case wxROLE_SYSTEM_MENUPOPUP:
1425 return ROLE_SYSTEM_MENUPOPUP;
1426 case wxROLE_SYSTEM_OUTLINE:
1427 return ROLE_SYSTEM_OUTLINE;
1428 case wxROLE_SYSTEM_OUTLINEITEM:
1429 return ROLE_SYSTEM_OUTLINEITEM;
1430 case wxROLE_SYSTEM_PAGETAB:
1431 return ROLE_SYSTEM_PAGETAB;
1432 case wxROLE_SYSTEM_PAGETABLIST:
1433 return ROLE_SYSTEM_PAGETABLIST;
1434 case wxROLE_SYSTEM_PANE:
1435 return ROLE_SYSTEM_PANE;
1436 case wxROLE_SYSTEM_PROGRESSBAR:
1437 return ROLE_SYSTEM_PROGRESSBAR;
1438 case wxROLE_SYSTEM_PROPERTYPAGE:
1439 return ROLE_SYSTEM_PROPERTYPAGE;
1440 case wxROLE_SYSTEM_PUSHBUTTON:
1441 return ROLE_SYSTEM_PUSHBUTTON;
1442 case wxROLE_SYSTEM_RADIOBUTTON:
1443 return ROLE_SYSTEM_RADIOBUTTON;
1444 case wxROLE_SYSTEM_ROW:
1445 return ROLE_SYSTEM_ROW;
1446 case wxROLE_SYSTEM_ROWHEADER:
1447 return ROLE_SYSTEM_ROWHEADER;
1448 case wxROLE_SYSTEM_SCROLLBAR:
1449 return ROLE_SYSTEM_SCROLLBAR;
1450 case wxROLE_SYSTEM_SEPARATOR:
1451 return ROLE_SYSTEM_SEPARATOR;
1452 case wxROLE_SYSTEM_SLIDER:
1453 return ROLE_SYSTEM_SLIDER;
1454 case wxROLE_SYSTEM_SOUND:
1455 return ROLE_SYSTEM_SOUND;
1456 case wxROLE_SYSTEM_SPINBUTTON:
1457 return ROLE_SYSTEM_SPINBUTTON;
1458 case wxROLE_SYSTEM_STATICTEXT:
1459 return ROLE_SYSTEM_STATICTEXT;
1460 case wxROLE_SYSTEM_STATUSBAR:
1461 return ROLE_SYSTEM_STATUSBAR;
1462 case wxROLE_SYSTEM_TABLE:
1463 return ROLE_SYSTEM_TABLE;
1464 case wxROLE_SYSTEM_TEXT:
1465 return ROLE_SYSTEM_TEXT;
1466 case wxROLE_SYSTEM_TITLEBAR:
1467 return ROLE_SYSTEM_TITLEBAR;
1468 case wxROLE_SYSTEM_TOOLBAR:
1469 return ROLE_SYSTEM_TOOLBAR;
1470 case wxROLE_SYSTEM_TOOLTIP:
1471 return ROLE_SYSTEM_TOOLTIP;
1472 case wxROLE_SYSTEM_WHITESPACE:
1473 return ROLE_SYSTEM_WHITESPACE;
1474 case wxROLE_SYSTEM_WINDOW:
1475 return ROLE_SYSTEM_WINDOW;
1476 }
1477 return 0;
1478 }
1479
1480 // Convert to Windows state
1481 long wxConvertToWindowsState(long wxstate)
1482 {
1483 long state = 0;
1484 if (wxstate & wxACC_STATE_SYSTEM_ALERT_HIGH)
1485 state |= STATE_SYSTEM_ALERT_HIGH;
1486
1487 if (wxstate & wxACC_STATE_SYSTEM_ALERT_MEDIUM)
1488 state |= STATE_SYSTEM_ALERT_MEDIUM;
1489
1490 if (wxstate & wxACC_STATE_SYSTEM_ALERT_LOW)
1491 state |= STATE_SYSTEM_ALERT_LOW;
1492
1493 if (wxstate & wxACC_STATE_SYSTEM_ANIMATED)
1494 state |= STATE_SYSTEM_ANIMATED;
1495
1496 if (wxstate & wxACC_STATE_SYSTEM_BUSY)
1497 state |= STATE_SYSTEM_BUSY;
1498
1499 if (wxstate & wxACC_STATE_SYSTEM_CHECKED)
1500 state |= STATE_SYSTEM_CHECKED;
1501
1502 if (wxstate & wxACC_STATE_SYSTEM_COLLAPSED)
1503 state |= STATE_SYSTEM_COLLAPSED;
1504
1505 if (wxstate & wxACC_STATE_SYSTEM_DEFAULT)
1506 state |= STATE_SYSTEM_DEFAULT;
1507
1508 if (wxstate & wxACC_STATE_SYSTEM_EXPANDED)
1509 state |= STATE_SYSTEM_EXPANDED;
1510
1511 if (wxstate & wxACC_STATE_SYSTEM_EXTSELECTABLE)
1512 state |= STATE_SYSTEM_EXTSELECTABLE;
1513
1514 if (wxstate & wxACC_STATE_SYSTEM_FLOATING)
1515 state |= STATE_SYSTEM_FLOATING;
1516
1517 if (wxstate & wxACC_STATE_SYSTEM_FOCUSABLE)
1518 state |= STATE_SYSTEM_FOCUSABLE;
1519
1520 if (wxstate & wxACC_STATE_SYSTEM_FOCUSED)
1521 state |= STATE_SYSTEM_FOCUSED;
1522
1523 if (wxstate & wxACC_STATE_SYSTEM_HOTTRACKED)
1524 state |= STATE_SYSTEM_HOTTRACKED;
1525
1526 if (wxstate & wxACC_STATE_SYSTEM_INVISIBLE)
1527 state |= STATE_SYSTEM_INVISIBLE;
1528
1529 if (wxstate & wxACC_STATE_SYSTEM_INVISIBLE)
1530 state |= STATE_SYSTEM_INVISIBLE;
1531
1532 if (wxstate & wxACC_STATE_SYSTEM_MIXED)
1533 state |= STATE_SYSTEM_MIXED;
1534
1535 if (wxstate & wxACC_STATE_SYSTEM_MULTISELECTABLE)
1536 state |= STATE_SYSTEM_MULTISELECTABLE;
1537
1538 if (wxstate & wxACC_STATE_SYSTEM_OFFSCREEN)
1539 state |= STATE_SYSTEM_OFFSCREEN;
1540
1541 if (wxstate & wxACC_STATE_SYSTEM_PRESSED)
1542 state |= STATE_SYSTEM_PRESSED;
1543
1544 // if (wxstate & wxACC_STATE_SYSTEM_PROTECTED)
1545 // state |= STATE_SYSTEM_PROTECTED;
1546
1547 if (wxstate & wxACC_STATE_SYSTEM_READONLY)
1548 state |= STATE_SYSTEM_READONLY;
1549
1550 if (wxstate & wxACC_STATE_SYSTEM_SELECTABLE)
1551 state |= STATE_SYSTEM_SELECTABLE;
1552
1553 if (wxstate & wxACC_STATE_SYSTEM_SELECTED)
1554 state |= STATE_SYSTEM_SELECTED;
1555
1556 if (wxstate & wxACC_STATE_SYSTEM_SELFVOICING)
1557 state |= STATE_SYSTEM_SELFVOICING;
1558
1559 if (wxstate & wxACC_STATE_SYSTEM_UNAVAILABLE)
1560 state |= STATE_SYSTEM_UNAVAILABLE;
1561
1562 return state;
1563 }
1564
1565 // Convert to Windows selection flag
1566 int wxConvertToWindowsSelFlag(wxAccSelectionFlags wxsel)
1567 {
1568 int sel = 0;
1569
1570 if (sel & wxACC_SEL_TAKEFOCUS)
1571 sel |= SELFLAG_TAKEFOCUS;
1572 if (sel & wxACC_SEL_TAKESELECTION)
1573 sel |= SELFLAG_TAKESELECTION;
1574 if (sel & wxACC_SEL_EXTENDSELECTION)
1575 sel |= SELFLAG_EXTENDSELECTION;
1576 if (sel & wxACC_SEL_ADDSELECTION)
1577 sel |= SELFLAG_ADDSELECTION;
1578 if (sel & wxACC_SEL_REMOVESELECTION)
1579 sel |= SELFLAG_REMOVESELECTION;
1580 return sel;
1581 }
1582
1583 // Convert from Windows selection flag
1584 wxAccSelectionFlags wxConvertFromWindowsSelFlag(int sel)
1585 {
1586 int wxsel = 0;
1587
1588 if (sel & SELFLAG_TAKEFOCUS)
1589 wxsel |= wxACC_SEL_TAKEFOCUS;
1590 if (sel & SELFLAG_TAKESELECTION)
1591 wxsel |= wxACC_SEL_TAKESELECTION;
1592 if (sel & SELFLAG_EXTENDSELECTION)
1593 wxsel |= wxACC_SEL_EXTENDSELECTION;
1594 if (sel & SELFLAG_ADDSELECTION)
1595 wxsel |= wxACC_SEL_ADDSELECTION;
1596 if (sel & SELFLAG_REMOVESELECTION)
1597 wxsel |= wxACC_SEL_REMOVESELECTION;
1598 return (wxAccSelectionFlags) wxsel;
1599 }
1600
1601
1602 #endif //USE_ACCESSIBILITY