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