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.

171 lines
4.0 KiB

  1. //
  2. // ico.h
  3. //
  4. // Generic ITfContextOwner object
  5. //
  6. #ifndef ICO_H
  7. #define ICO_H
  8. #include "private.h"
  9. #define ICO_INVALID_COOKIE ((DWORD)(-1))
  10. #define ICO_POINT_TO_ACP 1
  11. #define ICO_SCREENEXT 2
  12. #define ICO_TEXTEXT 3
  13. #define ICO_KEYDOWN 4
  14. #define ICO_KEYUP 5
  15. #define ICO_STATUS 6
  16. #define ICO_WND 7
  17. #define ICO_ATTR 8
  18. #define ICO_ADVISEMOUSE 9
  19. #define ICO_UNADVISEMOUSE 10
  20. #define ICO_TESTKEYDOWN 11
  21. #define ICO_TESTKEYUP 12
  22. typedef struct
  23. {
  24. union
  25. {
  26. // ICO_POINT_TO_ACP
  27. struct
  28. {
  29. const POINT *pt;
  30. DWORD dwFlags;
  31. LONG *pacp;
  32. } pta;
  33. // ICO_SCREENEXT
  34. struct
  35. {
  36. RECT *prc;
  37. } scr_ext;
  38. // ICO_TEXTEXT
  39. struct
  40. {
  41. LONG acpStart;
  42. LONG acpEnd;
  43. RECT *prc;
  44. BOOL *pfClipped;
  45. } text_ext;
  46. // ICO_KEYDOWN, ICO_KEYUP
  47. struct
  48. {
  49. WPARAM wParam;
  50. LPARAM lParam;
  51. ITfContext *pic;
  52. BOOL *pfEaten;
  53. } key;
  54. // ICO_STATUS
  55. struct
  56. {
  57. TF_STATUS *pdcs;
  58. } status;
  59. // ICO_HWND
  60. struct
  61. {
  62. HWND *phwnd;
  63. } hwnd;
  64. // ICO_ATTR
  65. struct
  66. {
  67. const GUID *pguid;
  68. VARIANT *pvar;
  69. } sys_attr;
  70. // ICO_ADVISEMOUSE
  71. struct
  72. {
  73. ITfRangeACP *rangeACP;
  74. ITfMouseSink *pSink;
  75. DWORD *pdwCookie;
  76. } advise_mouse;
  77. // ICO_UNADVISEMOUSE
  78. struct
  79. {
  80. DWORD dwCookie;
  81. } unadvise_mouse;
  82. };
  83. } ICOARGS;
  84. typedef HRESULT (*ICOCALLBACK)(UINT uCode, ICOARGS *pargs, void *pv);
  85. class CInputContextOwner : public ITfContextOwner,
  86. public ITfMouseTrackerACP
  87. {
  88. public:
  89. CInputContextOwner(ICOCALLBACK pfnCallback, void *pv);
  90. virtual ~CInputContextOwner() {};
  91. //
  92. // IUnknown methods
  93. //
  94. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  95. STDMETHODIMP_(ULONG) AddRef(void);
  96. STDMETHODIMP_(ULONG) Release(void);
  97. //
  98. // ITfContextOwner
  99. //
  100. STDMETHODIMP GetACPFromPoint(const POINT *pt, DWORD dwFlags, LONG *pacp);
  101. STDMETHODIMP GetScreenExt(RECT *prc);
  102. STDMETHODIMP GetTextExt(LONG acpStart, LONG acpEnd, RECT *prc, BOOL *pfClipped);
  103. STDMETHODIMP GetStatus(TF_STATUS *pdcs);
  104. STDMETHODIMP GetWnd(HWND *phwnd);
  105. STDMETHODIMP GetAttribute(REFGUID rguidAttribute, VARIANT *pvarValue);
  106. // ITfMouseTrackerACP
  107. STDMETHODIMP AdviseMouseSink(ITfRangeACP *range, ITfMouseSink *pSink, DWORD *pdwCookie);
  108. STDMETHODIMP UnadviseMouseSink(DWORD dwCookie);
  109. HRESULT _Advise(ITfContext *pic);
  110. HRESULT _Unadvise();
  111. protected:
  112. void SetCallbackPV(void* pv)
  113. {
  114. if (_pv == NULL)
  115. _pv = pv;
  116. };
  117. private:
  118. long _cRef;
  119. ITfContext *_pic;
  120. DWORD _dwCookie;
  121. ICOCALLBACK _pfnCallback;
  122. void *_pv;
  123. };
  124. class CInputContextKeyEventSink : public ITfContextKeyEventSink
  125. {
  126. public:
  127. CInputContextKeyEventSink(ICOCALLBACK pfnCallback, void *pv);
  128. //
  129. // IUnknown methods
  130. //
  131. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  132. STDMETHODIMP_(ULONG) AddRef(void);
  133. STDMETHODIMP_(ULONG) Release(void);
  134. //
  135. // ITfContextKeyEventSink
  136. //
  137. STDMETHODIMP OnKeyDown(WPARAM wParam, LPARAM lParam, BOOL *pfEaten);
  138. STDMETHODIMP OnKeyUp(WPARAM wParam, LPARAM lParam, BOOL *pfEaten);
  139. STDMETHODIMP OnTestKeyDown(WPARAM wParam, LPARAM lParam, BOOL *pfEaten);
  140. STDMETHODIMP OnTestKeyUp(WPARAM wParam, LPARAM lParam, BOOL *pfEaten);
  141. HRESULT _Advise(ITfContext *pic);
  142. HRESULT _Unadvise();
  143. private:
  144. long _cRef;
  145. ITfContext *_pic;
  146. DWORD _dwCookie;
  147. ICOCALLBACK _pfnCallback;
  148. void *_pv;
  149. };
  150. #endif // ICO_H