Bug 453883, ensure true/false marcos are available, r=joshmoz, sr=jst
[wine-gecko.git] / accessible / src / msaa / nsAccessibleWrap.h
blobf587434afbb95f80c1fdbaefa9e00c4eacea774d
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_INHERITED0(Class, Super) \
74 IMPL_IUNKNOWN_QUERY_HEAD(Class) \
75 IMPL_IUNKNOWN_QUERY_ENTRY(Super) \
76 IMPL_IUNKNOWN_QUERY_TAIL \
78 #define IMPL_IUNKNOWN_INHERITED1(Class, Super, I1) \
79 IMPL_IUNKNOWN_QUERY_HEAD(Class) \
80 IMPL_IUNKNOWN_QUERY_ENTRY(I1); \
81 IMPL_IUNKNOWN_QUERY_ENTRY(Super) \
82 IMPL_IUNKNOWN_QUERY_TAIL \
84 #define IMPL_IUNKNOWN_INHERITED2(Class, Super, I1, I2) \
85 IMPL_IUNKNOWN_QUERY_HEAD(Class) \
86 IMPL_IUNKNOWN_QUERY_ENTRY(I1); \
87 IMPL_IUNKNOWN_QUERY_ENTRY(I2); \
88 IMPL_IUNKNOWN_QUERY_ENTRY(Super) \
89 IMPL_IUNKNOWN_QUERY_TAIL \
92 class nsAccessibleWrap : public nsAccessible,
93 public CAccessibleComponent,
94 public CAccessibleHyperlink,
95 public CAccessibleValue,
96 public IAccessible2,
97 public IEnumVARIANT
99 public: // construction, destruction
100 nsAccessibleWrap(nsIDOMNode*, nsIWeakReference *aShell);
101 virtual ~nsAccessibleWrap();
103 // nsISupports
104 NS_DECL_ISUPPORTS_INHERITED
106 public: // IUnknown methods - see iunknown.h for documentation
107 STDMETHODIMP QueryInterface(REFIID, void**);
109 // Return the registered OLE class ID of this object's CfDataObj.
110 CLSID GetClassID() const;
112 public: // COM interface IAccessible
113 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accParent(
114 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdispParent);
116 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accChildCount(
117 /* [retval][out] */ long __RPC_FAR *pcountChildren);
119 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accChild(
120 /* [in] */ VARIANT varChild,
121 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdispChild);
123 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accName(
124 /* [optional][in] */ VARIANT varChild,
125 /* [retval][out] */ BSTR __RPC_FAR *pszName);
127 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accValue(
128 /* [optional][in] */ VARIANT varChild,
129 /* [retval][out] */ BSTR __RPC_FAR *pszValue);
131 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accDescription(
132 /* [optional][in] */ VARIANT varChild,
133 /* [retval][out] */ BSTR __RPC_FAR *pszDescription);
135 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accRole(
136 /* [optional][in] */ VARIANT varChild,
137 /* [retval][out] */ VARIANT __RPC_FAR *pvarRole);
139 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accState(
140 /* [optional][in] */ VARIANT varChild,
141 /* [retval][out] */ VARIANT __RPC_FAR *pvarState);
143 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accHelp(
144 /* [optional][in] */ VARIANT varChild,
145 /* [retval][out] */ BSTR __RPC_FAR *pszHelp);
147 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accHelpTopic(
148 /* [out] */ BSTR __RPC_FAR *pszHelpFile,
149 /* [optional][in] */ VARIANT varChild,
150 /* [retval][out] */ long __RPC_FAR *pidTopic);
152 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accKeyboardShortcut(
153 /* [optional][in] */ VARIANT varChild,
154 /* [retval][out] */ BSTR __RPC_FAR *pszKeyboardShortcut);
156 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accFocus(
157 /* [retval][out] */ VARIANT __RPC_FAR *pvarChild);
159 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accSelection(
160 /* [retval][out] */ VARIANT __RPC_FAR *pvarChildren);
162 virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_accDefaultAction(
163 /* [optional][in] */ VARIANT varChild,
164 /* [retval][out] */ BSTR __RPC_FAR *pszDefaultAction);
166 virtual /* [id] */ HRESULT STDMETHODCALLTYPE accSelect(
167 /* [in] */ long flagsSelect,
168 /* [optional][in] */ VARIANT varChild);
170 virtual /* [id] */ HRESULT STDMETHODCALLTYPE accLocation(
171 /* [out] */ long __RPC_FAR *pxLeft,
172 /* [out] */ long __RPC_FAR *pyTop,
173 /* [out] */ long __RPC_FAR *pcxWidth,
174 /* [out] */ long __RPC_FAR *pcyHeight,
175 /* [optional][in] */ VARIANT varChild);
177 virtual /* [id] */ HRESULT STDMETHODCALLTYPE accNavigate(
178 /* [in] */ long navDir,
179 /* [optional][in] */ VARIANT varStart,
180 /* [retval][out] */ VARIANT __RPC_FAR *pvarEndUpAt);
182 virtual /* [id] */ HRESULT STDMETHODCALLTYPE accHitTest(
183 /* [in] */ long xLeft,
184 /* [in] */ long yTop,
185 /* [retval][out] */ VARIANT __RPC_FAR *pvarChild);
187 virtual /* [id] */ HRESULT STDMETHODCALLTYPE accDoDefaultAction(
188 /* [optional][in] */ VARIANT varChild);
190 virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_accName(
191 /* [optional][in] */ VARIANT varChild,
192 /* [in] */ BSTR szName);
194 virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_accValue(
195 /* [optional][in] */ VARIANT varChild,
196 /* [in] */ BSTR szValue);
198 public: // IAccessible2
199 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nRelations(
200 /* [retval][out] */ long *nRelations);
202 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_relation(
203 /* [in] */ long relationIndex,
204 /* [retval][out] */ IAccessibleRelation **relation);
206 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_relations(
207 /* [in] */ long maxRelations,
208 /* [length_is][size_is][out] */ IAccessibleRelation **relation,
209 /* [retval][out] */ long *nRelations);
211 virtual HRESULT STDMETHODCALLTYPE role(
212 /* [retval][out] */ long *role);
214 virtual HRESULT STDMETHODCALLTYPE scrollTo(
215 /* [in] */ enum IA2ScrollType scrollType);
217 virtual HRESULT STDMETHODCALLTYPE scrollToPoint(
218 /* [in] */ enum IA2CoordinateType coordinateType,
219 /* [in] */ long x,
220 /* [in] */ long y);
222 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_groupPosition(
223 /* [out] */ long *groupLevel,
224 /* [out] */ long *similarItemsInGroup,
225 /* [retval][out] */ long *positionInGroup);
227 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_states(
228 /* [retval][out] */ AccessibleStates *states);
230 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_extendedRole(
231 /* [retval][out] */ BSTR *extendedRole);
233 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_localizedExtendedRole(
234 /* [retval][out] */ BSTR *localizedExtendedRole);
236 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nExtendedStates(
237 /* [retval][out] */ long *nExtendedStates);
239 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_extendedStates(
240 /* [in] */ long maxExtendedStates,
241 /* [length_is][length_is][size_is][size_is][out] */ BSTR **extendedStates,
242 /* [retval][out] */ long *nExtendedStates);
244 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_localizedExtendedStates(
245 /* [in] */ long maxLocalizedExtendedStates,
246 /* [length_is][length_is][size_is][size_is][out] */ BSTR **localizedExtendedStates,
247 /* [retval][out] */ long *nLocalizedExtendedStates);
249 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_uniqueID(
250 /* [retval][out] */ long *uniqueID);
252 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_windowHandle(
253 /* [retval][out] */ HWND *windowHandle);
255 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_indexInParent(
256 /* [retval][out] */ long *indexInParent);
258 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_locale(
259 /* [retval][out] */ IA2Locale *locale);
261 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_attributes(
262 /* [retval][out] */ BSTR *attributes);
264 public: // IEnumVariant
265 // If there are two clients using this at the same time, and they are
266 // each using a different mEnumVariant position it would be bad, because
267 // we have only 1 object and can only keep of mEnumVARIANT position once.
269 virtual /* [local] */ HRESULT STDMETHODCALLTYPE Next(
270 /* [in] */ ULONG celt,
271 /* [length_is][size_is][out] */ VARIANT __RPC_FAR *rgVar,
272 /* [out] */ ULONG __RPC_FAR *pCeltFetched);
274 virtual HRESULT STDMETHODCALLTYPE Skip(
275 /* [in] */ ULONG celt);
277 virtual HRESULT STDMETHODCALLTYPE Reset( void);
279 virtual HRESULT STDMETHODCALLTYPE Clone(
280 /* [out] */ IEnumVARIANT __RPC_FAR *__RPC_FAR *ppEnum);
283 // ====== Methods for IDispatch - for VisualBasic bindings (not implemented) ======
285 STDMETHODIMP GetTypeInfoCount(UINT *p);
286 STDMETHODIMP GetTypeInfo(UINT i, LCID lcid, ITypeInfo **ppti);
287 STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames,
288 UINT cNames, LCID lcid, DISPID *rgDispId);
289 STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid,
290 LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
291 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
293 // nsPIAccessible
294 NS_IMETHOD FireAccessibleEvent(nsIAccessibleEvent *aEvent);
296 // Helper methods
297 static PRInt32 GetChildIDFor(nsIAccessible* aAccessible);
298 static HWND GetHWNDFor(nsIAccessible *aAccessible);
299 static HRESULT ConvertToIA2Attributes(nsIPersistentProperties *aAttributes,
300 BSTR *aIA2Attributes);
303 * System caret support: update the Windows caret position.
304 * The system caret works more universally than the MSAA caret
305 * For example, Window-Eyes, JAWS, ZoomText and Windows Tablet Edition use it
306 * We will use an invisible system caret.
307 * Gecko is still responsible for drawing its own caret
309 void UpdateSystemCaret();
311 virtual void GetXPAccessibleFor(const VARIANT& aVarChild, nsIAccessible **aXPAccessible);
312 NS_IMETHOD GetNativeInterface(void **aOutAccessible);
314 // NT4 does not have the oleacc that defines these methods. So we define copies here that automatically
315 // load the library only if needed.
316 static STDMETHODIMP AccessibleObjectFromWindow(HWND hwnd,DWORD dwObjectID,REFIID riid,void **ppvObject);
317 static STDMETHODIMP NotifyWinEvent(DWORD event,HWND hwnd,LONG idObjectType,LONG idObject);
319 static IDispatch *NativeAccessible(nsIAccessible *aXPAccessible);
322 * Drops the IEnumVariant current position so that navigation methods
323 * Next() and Skip() doesn't work until Reset() method is called. The method
324 * is used when children of the accessible are changed.
326 void UnattachIEnumVariant();
328 protected:
329 virtual nsresult FirePlatformEvent(nsIAccessibleEvent *aEvent);
331 // mEnumVARIANTPosition not the current accessible's position, but a "cursor" of
332 // where we are in the current list of children, with respect to
333 // nsIEnumVariant::Reset(), Skip() and Next().
334 PRInt32 mEnumVARIANTPosition;
336 enum navRelations {
337 NAVRELATION_CONTROLLED_BY = 0x1000,
338 NAVRELATION_CONTROLLER_FOR = 0x1001,
339 NAVRELATION_LABEL_FOR = 0x1002,
340 NAVRELATION_LABELLED_BY = 0x1003,
341 NAVRELATION_MEMBER_OF = 0x1004,
342 NAVRELATION_NODE_CHILD_OF = 0x1005,
343 NAVRELATION_FLOWS_TO = 0x1006,
344 NAVRELATION_FLOWS_FROM = 0x1007,
345 NAVRELATION_SUBWINDOW_OF = 0x1008,
346 NAVRELATION_EMBEDS = 0x1009,
347 NAVRELATION_EMBEDDED_BY = 0x100a,
348 NAVRELATION_POPUP_FOR = 0x100b,
349 NAVRELATION_PARENT_WINDOW_OF = 0x100c,
350 NAVRELATION_DEFAULT_BUTTON = 0x100d,
351 NAVRELATION_DESCRIBED_BY = 0x100e,
352 NAVRELATION_DESCRIPTION_FOR = 0x100f
356 // Define unsupported wrap classes here
357 typedef class nsHTMLTextFieldAccessible nsHTMLTextFieldAccessibleWrap;
358 typedef class nsXULTextFieldAccessible nsXULTextFieldAccessibleWrap;
360 #endif