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.

335 lines
9.7 KiB

  1. //
  2. // canduies.cpp
  3. //
  4. #include "private.h"
  5. #include "canduies.h"
  6. /*============================================================================*/
  7. /* */
  8. /* C C A N D U I E X T B U T T O N E V E N T S I N K */
  9. /* */
  10. /*============================================================================*
  11. /
  12. /* C C A N D U I E X T B U T T O N E V E N T S I N K */
  13. /*------------------------------------------------------------------------------
  14. Constructor of CCandUIExtButtonEventSink
  15. ------------------------------------------------------------------------------*/
  16. CCandUIExtButtonEventSink::CCandUIExtButtonEventSink(PFNONBUTTONPRESSED pfnOnButtonPressed, ITfContext *pic, void *pVoid)
  17. {
  18. m_cRef = 1;
  19. m_pic = pic;
  20. m_pic->AddRef();
  21. m_pv = pVoid;
  22. m_pfnOnButtonPressed = pfnOnButtonPressed;
  23. }
  24. /* ~ C C A N D U I E X T B U T T O N E V E N T S I N K */
  25. /*------------------------------------------------------------------------------
  26. Destructor of CCandUIExtButtonEventSink
  27. ------------------------------------------------------------------------------*/
  28. CCandUIExtButtonEventSink::~CCandUIExtButtonEventSink()
  29. {
  30. m_pic->Release();
  31. }
  32. /* Q U E R Y I N T E R F A C E */
  33. /*------------------------------------------------------------------------------
  34. QueryInterface
  35. (IUknown method)
  36. ------------------------------------------------------------------------------*/
  37. STDAPI CCandUIExtButtonEventSink::QueryInterface( REFIID riid, void **ppvObj)
  38. {
  39. *ppvObj = NULL;
  40. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfCandUIExtButtonEventSink))
  41. *ppvObj = SAFECAST(this, ITfCandUIExtButtonEventSink*);
  42. if (*ppvObj)
  43. {
  44. AddRef();
  45. return S_OK;
  46. }
  47. return E_NOINTERFACE;
  48. }
  49. /* A D D R E F */
  50. /*------------------------------------------------------------------------------
  51. Increment reference count
  52. (IUknown method)
  53. ------------------------------------------------------------------------------*/
  54. STDAPI_(ULONG) CCandUIExtButtonEventSink::AddRef()
  55. {
  56. ++m_cRef;
  57. return m_cRef;
  58. }
  59. /* R E L E A S E */
  60. /*------------------------------------------------------------------------------
  61. Decrement reference count and release
  62. (IUknown method)
  63. ------------------------------------------------------------------------------*/
  64. STDAPI_(ULONG) CCandUIExtButtonEventSink::Release()
  65. {
  66. --m_cRef;
  67. if (0 < m_cRef)
  68. return m_cRef;
  69. delete this;
  70. return 0;
  71. }
  72. /* O N B U T T O N P R E S S E D */
  73. /*------------------------------------------------------------------------------
  74. Callback function of CandUI button event
  75. (ITfCandUIExtButtonEventSink method)
  76. ------------------------------------------------------------------------------*/
  77. STDAPI CCandUIExtButtonEventSink::OnButtonPressed(LONG id)
  78. {
  79. return (*m_pfnOnButtonPressed)(id, m_pic, m_pv);
  80. }
  81. /*============================================================================*/
  82. /* */
  83. /* C C A N D U I A U T O F I L T E R E V E N T S I N K */
  84. /* */
  85. /*============================================================================*/
  86. /* C C A N D U I A U T O F I L T E R E V E N T S I N K */
  87. /*------------------------------------------------------------------------------
  88. Constructor of CCandUIFilterEventSink
  89. ------------------------------------------------------------------------------*/
  90. CCandUIAutoFilterEventSink::CCandUIAutoFilterEventSink(PFNONFILTEREVENT pfnOnFilterEvent, ITfContext *pic, void *pVoid)
  91. {
  92. m_cRef = 1;
  93. m_pic = pic;
  94. m_pic->AddRef();
  95. m_pv = pVoid;
  96. m_pfnOnFilterEvent = pfnOnFilterEvent;
  97. }
  98. /* ~ C C A N D U I A U T O F I L T E R E V E N T S I N K */
  99. /*------------------------------------------------------------------------------
  100. Destructor of CCandUIFilterEventSink
  101. ------------------------------------------------------------------------------*/
  102. CCandUIAutoFilterEventSink::~CCandUIAutoFilterEventSink()
  103. {
  104. m_pic->Release();
  105. }
  106. /* Q U E R Y I N T E R F A C E */
  107. /*------------------------------------------------------------------------------
  108. QueryInterface
  109. (IUknown method)
  110. ------------------------------------------------------------------------------*/
  111. STDAPI CCandUIAutoFilterEventSink::QueryInterface(REFIID riid, void **ppvObj)
  112. {
  113. *ppvObj = NULL;
  114. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfCandUIAutoFilterEventSink))
  115. *ppvObj = SAFECAST(this, ITfCandUIAutoFilterEventSink*);
  116. if (*ppvObj)
  117. {
  118. AddRef();
  119. return S_OK;
  120. }
  121. return E_NOINTERFACE;
  122. }
  123. /* A D D R E F */
  124. /*------------------------------------------------------------------------------
  125. Increment reference count
  126. (IUknown method)
  127. ------------------------------------------------------------------------------*/
  128. STDAPI_(ULONG) CCandUIAutoFilterEventSink::AddRef()
  129. {
  130. ++m_cRef;
  131. return m_cRef;
  132. }
  133. /* R E L E A S E */
  134. /*------------------------------------------------------------------------------
  135. Decrement reference count and release
  136. (IUknown method)
  137. ------------------------------------------------------------------------------*/
  138. STDAPI_(ULONG) CCandUIAutoFilterEventSink::Release()
  139. {
  140. --m_cRef;
  141. if (0 < m_cRef)
  142. return m_cRef;
  143. delete this;
  144. return 0;
  145. }
  146. /* O N F I L T E R E V E N T */
  147. /*------------------------------------------------------------------------------
  148. Callback function of CandUI filtering event
  149. (ITfCandUIAutoFilterEventSink method)
  150. ------------------------------------------------------------------------------*/
  151. STDAPI CCandUIAutoFilterEventSink::OnFilterEvent(CANDUIFILTEREVENT ev)
  152. {
  153. return (*m_pfnOnFilterEvent)(ev, m_pic, m_pv);
  154. }
  155. /*============================================================================*/
  156. /* */
  157. /* C C A N D U I M E N U E V E N T S I N K */
  158. /* */
  159. /*============================================================================*/
  160. /* C C A N D U I M E N U E V E N T S I N K */
  161. /*------------------------------------------------------------------------------
  162. Constructor of CCandUIMenuEventSink
  163. ------------------------------------------------------------------------------*/
  164. CCandUIMenuEventSink::CCandUIMenuEventSink(PFNINITMENU pfnInitMenu, PFNONCANDUIMENUCOMMAND pfnOnCandUIMenuCommand, ITfContext *pic, void *pVoid)
  165. {
  166. m_cRef = 1;
  167. m_pic = pic;
  168. m_pic->AddRef();
  169. m_pv = pVoid;
  170. m_pfnInitMenu = pfnInitMenu;
  171. m_pfnOnCandUIMenuCommand = pfnOnCandUIMenuCommand;
  172. }
  173. /* ~ C C A N D U I M E N U E V E N T S I N K */
  174. /*------------------------------------------------------------------------------
  175. Destructor of CCandUIMenuEventSink
  176. ------------------------------------------------------------------------------*/
  177. CCandUIMenuEventSink::~CCandUIMenuEventSink( void )
  178. {
  179. m_pic->Release();
  180. }
  181. /* Q U E R Y I N T E R F A C E */
  182. /*------------------------------------------------------------------------------
  183. QueryInterface
  184. (IUknown method)
  185. ------------------------------------------------------------------------------*/
  186. STDAPI CCandUIMenuEventSink::QueryInterface(REFIID riid, void **ppvObj)
  187. {
  188. *ppvObj = NULL;
  189. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfCandUIMenuEventSink))
  190. *ppvObj = SAFECAST(this, CCandUIMenuEventSink*);
  191. if (*ppvObj)
  192. {
  193. AddRef();
  194. return S_OK;
  195. }
  196. return E_NOINTERFACE;
  197. }
  198. /* A D D R E F */
  199. /*------------------------------------------------------------------------------
  200. Increment reference count
  201. (IUknown method)
  202. ------------------------------------------------------------------------------*/
  203. STDAPI_(ULONG) CCandUIMenuEventSink::AddRef()
  204. {
  205. ++m_cRef;
  206. return m_cRef;
  207. }
  208. /* R E L E A S E */
  209. /*------------------------------------------------------------------------------
  210. Decrement reference count and release
  211. (IUknown method)
  212. ------------------------------------------------------------------------------*/
  213. STDAPI_(ULONG) CCandUIMenuEventSink::Release()
  214. {
  215. --m_cRef;
  216. if (0 < m_cRef)
  217. return m_cRef;
  218. delete this;
  219. return 0;
  220. }
  221. /* I N I T C A N D I D A T E M E N U */
  222. /*------------------------------------------------------------------------------
  223. Callback function to initialize candidate menu
  224. (ITfCandUIMenuEventSink method)
  225. ------------------------------------------------------------------------------*/
  226. STDAPI CCandUIMenuEventSink::InitMenu(ITfMenu *pMenu)
  227. {
  228. return (*m_pfnInitMenu)(pMenu, m_pic, m_pv);
  229. }
  230. /* O N C A N D U I M E N U C O M M A N D */
  231. /*------------------------------------------------------------------------------
  232. Callback function of candidate menu event
  233. (ITfCandUIMenuEventSink method)
  234. ------------------------------------------------------------------------------*/
  235. STDAPI CCandUIMenuEventSink::OnMenuCommand(UINT uiCmd)
  236. {
  237. return (*m_pfnOnCandUIMenuCommand)(uiCmd, m_pic, m_pv);
  238. }