Bug 589145 - dexpcom accessible event classes, r=davidb, sr=neil, a=davidb
[mozilla-central.git] / accessible / src / msaa / nsAccessibleWrap.h
blob3b437b3e64e5013f5b1ff374793daf69bc28539e
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2003
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Original Author: Aaron Leventhal (aaronl@netscape.com)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 /* For documentation of the accessibility architecture,
40 * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
43 #ifndef _nsAccessibleWrap_H_
44 #define _nsAccessibleWrap_H_
46 #include "nsCOMPtr.h"
47 #include "nsAccessible.h"
48 #include "Accessible2.h"
49 #include "CAccessibleComponent.h"
50 #include "CAccessibleHyperlink.h"
51 #include "CAccessibleValue.h"
53 #define DECL_IUNKNOWN_INHERITED \
54 public: \
55 STDMETHODIMP QueryInterface(REFIID, void**); \
57 #define IMPL_IUNKNOWN_QUERY_HEAD(Class) \
58 STDMETHODIMP \
59 Class::QueryInterface(REFIID iid, void** ppv) \
60 { \
61 HRESULT hr = E_NOINTERFACE; \
62 *ppv = NULL; \
64 #define IMPL_IUNKNOWN_QUERY_TAIL \
65 return hr; \
66 } \
68 #define IMPL_IUNKNOWN_QUERY_ENTRY(Class) \
69 hr = Class::QueryInterface(iid, ppv); \
70 if (SUCCEEDED(hr)) \
71 return hr; \
73 #define IMPL_IUNKNOWN_QUERY_ENTRY_COND(Class, Cond) \
74 if (Cond) { \
75 hr = Class::QueryInterface(iid, ppv); \
76 if (SUCCEEDED(hr)) \
77 return hr; \
78 } \
80 #define IMPL_IUNKNOWN_INHERITED0(Class, Super) \
81 IMPL_IUNKNOWN_QUERY_HEAD(Class) \
82 IMPL_IUNKNOWN_QUERY_ENTRY(Super) \
83 IMPL_IUNKNOWN_QUERY_TAIL \
85 #define IMPL_IUNKNOWN_INHERITED1(Class, Super, I1) \
86 IMPL_IUNKNOWN_QUERY_HEAD(Class) \
87 IMPL_IUNKNOWN_QUERY_ENTRY(I1); \
88 IMPL_IUNKNOWN_QUERY_ENTRY(Super) \
89 IMPL_IUNKNOWN_QUERY_TAIL \
91 #define IMPL_IUNKNOWN_INHERITED2(Class, Super, I1, I2) \
92 IMPL_IUNKNOWN_QUERY_HEAD(Class) \
93 IMPL_IUNKNOWN_QUERY_ENTRY(I1); \
94 IMPL_IUNKNOWN_QUERY_ENTRY(I2); \
95 IMPL_IUNKNOWN_QUERY_ENTRY(Super) \
96 IMPL_IUNKNOWN_QUERY_TAIL \
99 class nsAccessibleWrap : public nsAccessible,
100 public CAccessibleComponent,
101 public CAccessibleHyperlink,
102 public CAccessibleValue,
103 public IAccessible2,
104 public IEnumVARIANT
106 public: // construction, destruction
107 nsAccessibleWrap(nsIContent *aContent, nsIWeakReference *aShell);
108 virtual ~nsAccessibleWrap();
110 // nsISupports
111 NS_DECL_ISUPPORTS_INHERITED
113 public: // IUnknown methods - see iunknown.h for documentation
114 STDMETHODIMP QueryInterface(REFIID, void**);
116 // Return the registered OLE class ID of this object's CfDataObj.
117 CLSID GetClassID() const;
119 public: // COM interface IAccessible
120 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accParent(
121 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdispParent);
123 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accChildCount(
124 /* [retval][out] */ long __RPC_FAR *pcountChildren);
126 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accChild(
127 /* [in] */ VARIANT varChild,
128 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdispChild);
130 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accName(
131 /* [optional][in] */ VARIANT varChild,
132 /* [retval][out] */ BSTR __RPC_FAR *pszName);
134 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accValue(
135 /* [optional][in] */ VARIANT varChild,
136 /* [retval][out] */ BSTR __RPC_FAR *pszValue);
138 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accDescription(
139 /* [optional][in] */ VARIANT varChild,
140 /* [retval][out] */ BSTR __RPC_FAR *pszDescription);
142 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accRole(
143 /* [optional][in] */ VARIANT varChild,
144 /* [retval][out] */ VARIANT __RPC_FAR *pvarRole);
146 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accState(
147 /* [optional][in] */ VARIANT varChild,
148 /* [retval][out] */ VARIANT __RPC_FAR *pvarState);
150 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accHelp(
151 /* [optional][in] */ VARIANT varChild,
152 /* [retval][out] */ BSTR __RPC_FAR *pszHelp);
154 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accHelpTopic(
155 /* [out] */ BSTR __RPC_FAR *pszHelpFile,
156 /* [optional][in] */ VARIANT varChild,
157 /* [retval][out] */ long __RPC_FAR *pidTopic);
159 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accKeyboardShortcut(
160 /* [optional][in] */ VARIANT varChild,
161 /* [retval][out] */ BSTR __RPC_FAR *pszKeyboardShortcut);
163 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accFocus(
164 /* [retval][out] */ VARIANT __RPC_FAR *pvarChild);
166 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accSelection(
167 /* [retval][out] */ VARIANT __RPC_FAR *pvarChildren);
169 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accDefaultAction(
170 /* [optional][in] */ VARIANT varChild,
171 /* [retval][out] */ BSTR __RPC_FAR *pszDefaultAction);
173 virtual /* [id] */ HRESULT STDMETHODCALLTYPE accSelect(
174 /* [in] */ long flagsSelect,
175 /* [optional][in] */ VARIANT varChild);
177 virtual /* [id] */ HRESULT STDMETHODCALLTYPE accLocation(
178 /* [out] */ long __RPC_FAR *pxLeft,
179 /* [out] */ long __RPC_FAR *pyTop,
180 /* [out] */ long __RPC_FAR *pcxWidth,
181 /* [out] */ long __RPC_FAR *pcyHeight,
182 /* [optional][in] */ VARIANT varChild);
184 virtual /* [id] */ HRESULT STDMETHODCALLTYPE accNavigate(
185 /* [in] */ long navDir,
186 /* [optional][in] */ VARIANT varStart,
187 /* [retval][out] */ VARIANT __RPC_FAR *pvarEndUpAt);
189 virtual /* [id] */ HRESULT STDMETHODCALLTYPE accHitTest(
190 /* [in] */ long xLeft,
191 /* [in] */ long yTop,
192 /* [retval][out] */ VARIANT __RPC_FAR *pvarChild);
194 virtual /* [id] */ HRESULT STDMETHODCALLTYPE accDoDefaultAction(
195 /* [optional][in] */ VARIANT varChild);
197 virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_accName(
198 /* [optional][in] */ VARIANT varChild,
199 /* [in] */ BSTR szName);
201 virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_accValue(
202 /* [optional][in] */ VARIANT varChild,
203 /* [in] */ BSTR szValue);
205 public: // IAccessible2
206 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nRelations(
207 /* [retval][out] */ long *nRelations);
209 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_relation(
210 /* [in] */ long relationIndex,
211 /* [retval][out] */ IAccessibleRelation **relation);
213 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_relations(
214 /* [in] */ long maxRelations,
215 /* [length_is][size_is][out] */ IAccessibleRelation **relation,
216 /* [retval][out] */ long *nRelations);
218 virtual HRESULT STDMETHODCALLTYPE role(
219 /* [retval][out] */ long *role);
221 virtual HRESULT STDMETHODCALLTYPE scrollTo(
222 /* [in] */ enum IA2ScrollType scrollType);
224 virtual HRESULT STDMETHODCALLTYPE scrollToPoint(
225 /* [in] */ enum IA2CoordinateType coordinateType,
226 /* [in] */ long x,
227 /* [in] */ long y);
229 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_groupPosition(
230 /* [out] */ long *groupLevel,
231 /* [out] */ long *similarItemsInGroup,
232 /* [retval][out] */ long *positionInGroup);
234 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_states(
235 /* [retval][out] */ AccessibleStates *states);
237 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_extendedRole(
238 /* [retval][out] */ BSTR *extendedRole);
240 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_localizedExtendedRole(
241 /* [retval][out] */ BSTR *localizedExtendedRole);
243 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nExtendedStates(
244 /* [retval][out] */ long *nExtendedStates);
246 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_extendedStates(
247 /* [in] */ long maxExtendedStates,
248 /* [length_is][length_is][size_is][size_is][out] */ BSTR **extendedStates,
249 /* [retval][out] */ long *nExtendedStates);
251 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_localizedExtendedStates(
252 /* [in] */ long maxLocalizedExtendedStates,
253 /* [length_is][length_is][size_is][size_is][out] */ BSTR **localizedExtendedStates,
254 /* [retval][out] */ long *nLocalizedExtendedStates);
256 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_uniqueID(
257 /* [retval][out] */ long *uniqueID);
259 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_windowHandle(
260 /* [retval][out] */ HWND *windowHandle);
262 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_indexInParent(
263 /* [retval][out] */ long *indexInParent);
265 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_locale(
266 /* [retval][out] */ IA2Locale *locale);
268 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_attributes(
269 /* [retval][out] */ BSTR *attributes);
271 public: // IEnumVariant
272 // If there are two clients using this at the same time, and they are
273 // each using a different mEnumVariant position it would be bad, because
274 // we have only 1 object and can only keep of mEnumVARIANT position once.
276 virtual /* [local] */ HRESULT STDMETHODCALLTYPE Next(
277 /* [in] */ ULONG celt,
278 /* [length_is][size_is][out] */ VARIANT __RPC_FAR *rgVar,
279 /* [out] */ ULONG __RPC_FAR *pCeltFetched);
281 virtual HRESULT STDMETHODCALLTYPE Skip(
282 /* [in] */ ULONG celt);
284 virtual HRESULT STDMETHODCALLTYPE Reset( void);
286 virtual HRESULT STDMETHODCALLTYPE Clone(
287 /* [out] */ IEnumVARIANT __RPC_FAR *__RPC_FAR *ppEnum);
290 // IDispatch (support of scripting languages like VB)
291 virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *pctinfo);
293 virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid,
294 ITypeInfo **ppTInfo);
296 virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid,
297 LPOLESTR *rgszNames,
298 UINT cNames,
299 LCID lcid,
300 DISPID *rgDispId);
302 virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid,
303 LCID lcid, WORD wFlags,
304 DISPPARAMS *pDispParams,
305 VARIANT *pVarResult,
306 EXCEPINFO *pExcepInfo,
307 UINT *puArgErr);
309 // nsAccessible
310 virtual nsresult HandleAccEvent(AccEvent* aEvent);
312 // Helper methods
313 static PRInt32 GetChildIDFor(nsIAccessible* aAccessible);
314 static HWND GetHWNDFor(nsAccessible *aAccessible);
315 static HRESULT ConvertToIA2Attributes(nsIPersistentProperties *aAttributes,
316 BSTR *aIA2Attributes);
319 * System caret support: update the Windows caret position.
320 * The system caret works more universally than the MSAA caret
321 * For example, Window-Eyes, JAWS, ZoomText and Windows Tablet Edition use it
322 * We will use an invisible system caret.
323 * Gecko is still responsible for drawing its own caret
325 void UpdateSystemCaret();
328 * Find an accessible by the given child ID in cached documents.
330 virtual nsAccessible *GetXPAccessibleFor(const VARIANT& aVarChild);
332 NS_IMETHOD GetNativeInterface(void **aOutAccessible);
334 // NT4 does not have the oleacc that defines these methods. So we define copies here that automatically
335 // load the library only if needed.
336 static STDMETHODIMP AccessibleObjectFromWindow(HWND hwnd,DWORD dwObjectID,REFIID riid,void **ppvObject);
337 static STDMETHODIMP NotifyWinEvent(DWORD event,HWND hwnd,LONG idObjectType,LONG idObject);
339 static IDispatch *NativeAccessible(nsIAccessible *aXPAccessible);
342 * Drops the IEnumVariant current position so that navigation methods
343 * Next() and Skip() doesn't work until Reset() method is called. The method
344 * is used when children of the accessible are changed.
346 void UnattachIEnumVariant();
348 protected:
349 virtual nsresult FirePlatformEvent(AccEvent* aEvent);
351 // mEnumVARIANTPosition not the current accessible's position, but a "cursor" of
352 // where we are in the current list of children, with respect to
353 // nsIEnumVariant::Reset(), Skip() and Next().
354 PRInt32 mEnumVARIANTPosition;
357 * Creates ITypeInfo for LIBID_Accessibility if it's needed and returns it.
359 ITypeInfo *GetTI(LCID lcid);
361 ITypeInfo *mTypeInfo;
364 enum navRelations {
365 NAVRELATION_CONTROLLED_BY = 0x1000,
366 NAVRELATION_CONTROLLER_FOR = 0x1001,
367 NAVRELATION_LABEL_FOR = 0x1002,
368 NAVRELATION_LABELLED_BY = 0x1003,
369 NAVRELATION_MEMBER_OF = 0x1004,
370 NAVRELATION_NODE_CHILD_OF = 0x1005,
371 NAVRELATION_FLOWS_TO = 0x1006,
372 NAVRELATION_FLOWS_FROM = 0x1007,
373 NAVRELATION_SUBWINDOW_OF = 0x1008,
374 NAVRELATION_EMBEDS = 0x1009,
375 NAVRELATION_EMBEDDED_BY = 0x100a,
376 NAVRELATION_POPUP_FOR = 0x100b,
377 NAVRELATION_PARENT_WINDOW_OF = 0x100c,
378 NAVRELATION_DEFAULT_BUTTON = 0x100d,
379 NAVRELATION_DESCRIBED_BY = 0x100e,
380 NAVRELATION_DESCRIPTION_FOR = 0x100f
384 // Define unsupported wrap classes here
385 typedef class nsHTMLTextFieldAccessible nsHTMLTextFieldAccessibleWrap;
386 typedef class nsXULTextFieldAccessible nsXULTextFieldAccessibleWrap;
388 #endif