Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
6.8 KiB

  1. /*
  2. * Accessibility support
  3. */
  4. #ifndef DUI_CORE_ACCESSIBILITY_H_INCLUDED
  5. #define DUI_CORE_ACCESSIBILITY_H_INCLUDED
  6. #pragma once
  7. #include <oleauto.h>
  8. #include <oleacc.h>
  9. #if !defined(SUPPRESS)
  10. #define SUPPRESS(ClassName) \
  11. private: \
  12. ClassName(const ClassName & copy); \
  13. ClassName & operator=(const ClassName & rhs); \
  14. public:
  15. #endif
  16. namespace DirectUI
  17. {
  18. class Element;
  19. class HWNDElement;
  20. class HWNDHost;
  21. void NotifyAccessibilityEvent(IN DWORD dwEvent, Element * pe);
  22. class DuiAccessible : public IAccessible, public IEnumVARIANT, public IOleWindow
  23. {
  24. public:
  25. static HRESULT Create(Element * pe, DuiAccessible ** ppDA);
  26. SUPPRESS(DuiAccessible);
  27. //
  28. // Our IAccessible implementations can be disconnected from the actual
  29. // element at any time.
  30. //
  31. virtual HRESULT Disconnect();
  32. DuiAccessible() { }
  33. void Initialize(Element * pe) { _pe = pe; _cRefs = 1; }
  34. virtual ~DuiAccessible();
  35. public:
  36. //
  37. // IUnknown methods
  38. //
  39. STDMETHOD_(ULONG,AddRef)();
  40. STDMETHOD_(ULONG,Release)();
  41. STDMETHOD(QueryInterface)(REFIID riid, LPVOID *ppvObj);
  42. //
  43. // IDispatch methods
  44. //
  45. STDMETHOD(GetIDsOfNames)(REFIID riid, OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID *rgdispid);
  46. STDMETHOD(GetTypeInfoCount)(UINT *pctinfo);
  47. STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo **pptinfo);
  48. STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdispparams, VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr);
  49. //
  50. // IAccessible methods
  51. //
  52. STDMETHOD(accSelect)(long flagsSelect, VARIANT varChild);
  53. STDMETHOD(accLocation)(long *pxLeft, long *pyTop, long *pcxWidth, long *pcyHeight, VARIANT varChild);
  54. STDMETHOD(accNavigate)(long navDir, VARIANT varStart, VARIANT *pvarEndUpAt);
  55. STDMETHOD(accHitTest)(long xLeft, long yTop, VARIANT *pvarChildAtPoint);
  56. STDMETHOD(accDoDefaultAction)(VARIANT varChild);
  57. STDMETHOD(get_accChild)(VARIANT varChildIndex, IDispatch **ppdispChild);
  58. STDMETHOD(get_accParent)(IDispatch **ppdispParent);
  59. STDMETHOD(get_accChildCount)(long *pChildCount);
  60. STDMETHOD(get_accName)(VARIANT varChild, BSTR *pszName);
  61. STDMETHOD(put_accName)(VARIANT varChild, BSTR szName);
  62. STDMETHOD(get_accValue)(VARIANT varChild, BSTR *pszValue);
  63. STDMETHOD(put_accValue)(VARIANT varChild, BSTR pszValue);
  64. STDMETHOD(get_accDescription)(VARIANT varChild, BSTR *pszDescription);
  65. STDMETHOD(get_accKeyboardShortcut)(VARIANT varChild, BSTR *pszKeyboardShortcut);
  66. STDMETHOD(get_accRole)(VARIANT varChild, VARIANT *pvarRole);
  67. STDMETHOD(get_accState)(VARIANT varChild, VARIANT *pvarState);
  68. STDMETHOD(get_accHelp)(VARIANT varChild, BSTR *pszHelp);
  69. STDMETHOD(get_accHelpTopic)(BSTR *pszHelpFile, VARIANT varChild, long *pidTopic);
  70. STDMETHOD(get_accFocus)(VARIANT *pvarFocusChild);
  71. STDMETHOD(get_accSelection)(VARIANT *pvarSelectedChildren);
  72. STDMETHOD(get_accDefaultAction)(VARIANT varChild, BSTR *pszDefaultAction);
  73. //
  74. // IEnumVARIANT methods
  75. //
  76. STDMETHOD(Next)(unsigned long celt, VARIANT * rgvar, unsigned long * pceltFetched);
  77. STDMETHOD(Skip)(unsigned long celt);
  78. STDMETHOD(Reset)();
  79. STDMETHOD(Clone)(IEnumVARIANT ** ppenum);
  80. //
  81. // IOleWindow methods
  82. //
  83. STDMETHOD(GetWindow)(HWND * phwnd);
  84. STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode);
  85. protected:
  86. Element * GetAccessibleParent(Element * pe);
  87. HRESULT GetDispatchFromElement(Element * pe, IDispatch ** ppDispatch);
  88. protected:
  89. Element * _pe;
  90. private:
  91. LONG _cRefs;
  92. };
  93. class HWNDElementAccessible : public DuiAccessible
  94. {
  95. public:
  96. static HRESULT Create(HWNDElement * pe, DuiAccessible ** ppDA);
  97. SUPPRESS(HWNDElementAccessible);
  98. //
  99. // Our IAccessible implementations can be disconnected from the actual
  100. // element at any time.
  101. //
  102. virtual HRESULT Disconnect();
  103. HWNDElementAccessible() { }
  104. HRESULT Initialize(HWNDElement * pe);
  105. virtual ~HWNDElementAccessible();
  106. public:
  107. //
  108. // IAccessible methods
  109. //
  110. STDMETHOD(get_accParent)(IDispatch **ppdispParent);
  111. private:
  112. IAccessible * _pParent;
  113. };
  114. class HWNDHostAccessible : public DuiAccessible
  115. {
  116. public:
  117. static HRESULT Create(HWNDHost * pe, DuiAccessible ** ppDA);
  118. SUPPRESS(HWNDHostAccessible);
  119. //
  120. // Our IAccessible implementations can be disconnected from the actual
  121. // element at any time.
  122. //
  123. virtual HRESULT Disconnect();
  124. HWNDHostAccessible() { }
  125. HRESULT Initialize(HWNDHost * pe);
  126. virtual ~HWNDHostAccessible();
  127. public:
  128. //
  129. // IUnknown methods
  130. //
  131. STDMETHOD(QueryInterface)(REFIID riid, LPVOID *ppvObj);
  132. //
  133. // IAccessible methods
  134. //
  135. STDMETHOD(accSelect)(long flagsSelect, VARIANT varChild);
  136. STDMETHOD(accLocation)(long *pxLeft, long *pyTop, long *pcxWidth, long *pcyHeight, VARIANT varChild);
  137. STDMETHOD(accNavigate)(long navDir, VARIANT varStart, VARIANT *pvarEndUpAt);
  138. STDMETHOD(accHitTest)(long xLeft, long yTop, VARIANT *pvarChildAtPoint);
  139. STDMETHOD(accDoDefaultAction)(VARIANT varChild);
  140. STDMETHOD(get_accChild)(VARIANT varChildIndex, IDispatch **ppdispChild);
  141. STDMETHOD(get_accParent)(IDispatch **ppdispParent);
  142. STDMETHOD(get_accChildCount)(long *pChildCount);
  143. STDMETHOD(get_accName)(VARIANT varChild, BSTR *pszName);
  144. STDMETHOD(put_accName)(VARIANT varChild, BSTR szName);
  145. STDMETHOD(get_accValue)(VARIANT varChild, BSTR *pszValue);
  146. STDMETHOD(put_accValue)(VARIANT varChild, BSTR pszValue);
  147. STDMETHOD(get_accDescription)(VARIANT varChild, BSTR *pszDescription);
  148. STDMETHOD(get_accKeyboardShortcut)(VARIANT varChild, BSTR *pszKeyboardShortcut);
  149. STDMETHOD(get_accRole)(VARIANT varChild, VARIANT *pvarRole);
  150. STDMETHOD(get_accState)(VARIANT varChild, VARIANT *pvarState);
  151. STDMETHOD(get_accHelp)(VARIANT varChild, BSTR *pszHelp);
  152. STDMETHOD(get_accHelpTopic)(BSTR *pszHelpFile, VARIANT varChild, long *pidTopic);
  153. STDMETHOD(get_accFocus)(VARIANT *pvarFocusChild);
  154. STDMETHOD(get_accSelection)(VARIANT *pvarSelectedChildren);
  155. STDMETHOD(get_accDefaultAction)(VARIANT varChild, BSTR *pszDefaultAction);
  156. //
  157. // IEnumVARIANT methods
  158. //
  159. STDMETHOD(Next)(unsigned long celt, VARIANT * rgvar, unsigned long * pceltFetched);
  160. STDMETHOD(Skip)(unsigned long celt);
  161. STDMETHOD(Reset)();
  162. STDMETHOD(Clone)(IEnumVARIANT ** ppenum);
  163. //
  164. // IOleWindow methods
  165. //
  166. STDMETHOD(GetWindow)(HWND * phwnd);
  167. STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode);
  168. private:
  169. IAccessible * _pCtrl;
  170. IEnumVARIANT * _pEnum;
  171. IOleWindow * _pOleWindow;
  172. };
  173. } // namespace DirectUI
  174. #endif // DUI_CORE_ACCESSIBILITY_H_INCLUDED