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.

293 lines
6.2 KiB

  1. //
  2. // candmgr.h - Candidate List Manager
  3. //
  4. #ifndef CANDMGR_H
  5. #define CANDMGR_H
  6. #include "private.h"
  7. #include "mscandui.h"
  8. class CCandidateUI;
  9. class CCandListMgr;
  10. class CCandListEventSink;
  11. #define CANDLISTSINK_MAX 5
  12. #define ICANDITEM_NULL (-1)
  13. #define ICANDITEM_EXTRA (-2)
  14. //
  15. // CCandidateItem
  16. // = candidate item object =
  17. //
  18. class CCandidateItem
  19. {
  20. public:
  21. CCandidateItem( int iCandItem, ITfCandidateString *pCandStr );
  22. virtual ~CCandidateItem( void );
  23. int GetICandItemOrg( void );
  24. // ITfCandidateString
  25. ULONG GetIndex( void );
  26. LPCWSTR GetString( void );
  27. // ITfCandidateStringInlineComment
  28. LPCWSTR GetInlineComment( void );
  29. // ITfCandidateStringPopupComment
  30. LPCWSTR GetPopupComment( void );
  31. DWORD GetPopupCommentGroupID( void );
  32. // ITfCandidateStringColor
  33. BOOL GetColor( COLORREF *pcr );
  34. // ITfCandidateStringFixture
  35. LPCWSTR GetPrefixString( void );
  36. LPCWSTR GetSuffixString( void );
  37. // ITfCandidateStringIcon
  38. HICON GetIcon( void );
  39. //
  40. // internal property
  41. //
  42. void SetVisibleState( BOOL fVisible );
  43. BOOL IsVisible( void );
  44. void SetPopupCommentState( BOOL fVisible );
  45. BOOL IsPopupCommentVisible( void );
  46. protected:
  47. ITfCandidateString *m_pCandStr;
  48. int m_iCandItemOrg;
  49. // ITfCandidateString
  50. ULONG m_nIndex;
  51. BSTR m_bstr;
  52. // ITfCandidateStringInlineComment
  53. BSTR m_bstrInlineComment;
  54. // ITfCandidateStringPopupComment
  55. BSTR m_bstrPopupComment;
  56. DWORD m_dwPopupCommentGroupID;
  57. // ITfCandidateStringColor
  58. BOOL m_fHasColor;
  59. COLORREF m_cr;
  60. // ITfCandidateStringFixture
  61. BSTR m_bstrPrefix;
  62. BSTR m_bstrSuffix;
  63. // ITfCandidateStringIcon
  64. HICON m_hIcon;
  65. // internal property
  66. BOOL m_fVisible;
  67. BOOL m_fPopupCommentVisible;
  68. };
  69. //
  70. // CCandidateList
  71. // = candidate list property =
  72. //
  73. class CCandidateList
  74. {
  75. public:
  76. CCandidateList( CCandListMgr *pCandListMgr, ITfCandidateList *pCandList );
  77. CCandidateList( CCandListMgr *pCandListMgr, ITfOptionsCandidateList *pCandList );
  78. virtual ~CCandidateList( void );
  79. HRESULT Initialize( void );
  80. HRESULT Uninitialize( void );
  81. //
  82. // candidate item
  83. //
  84. int GetItemCount( void );
  85. CCandidateItem *GetCandidateItem( int iItem );
  86. void SwapCandidateItem( int iItem1, int iItem2 );
  87. //
  88. // extra candidate item
  89. //
  90. CCandidateItem *GetExtraCandItem( void );
  91. ULONG GetExtraCandIndex( void );
  92. //
  93. // candidate list tip
  94. //
  95. LPCWSTR GetTipString( void );
  96. //
  97. // rawdata
  98. //
  99. BOOL FHasRawData( void );
  100. CANDUIRAWDATATYPE GetRawDataType( void );
  101. LPCWSTR GetRawDataString( void );
  102. HBITMAP GetRawDataBitmap( void );
  103. HENHMETAFILE GetRawDataMetafile( void );
  104. ULONG GetRawDataIndex( void );
  105. BOOL FRawDataSelectable( void );
  106. //
  107. // internal property
  108. //
  109. void SetSelection( int iItem );
  110. int GetSelection( void );
  111. //
  112. //
  113. //
  114. HRESULT MapIItemToIndex( int iItem, ULONG *pnIndex );
  115. HRESULT MapIndexToIItem( ULONG nIndex, int *piItem );
  116. //
  117. //
  118. //
  119. __inline ITfOptionsCandidateList *GetOptionsCandidateList( void )
  120. {
  121. return m_pOptionsList;
  122. }
  123. __inline ITfCandidateList *GetCandidateList( void )
  124. {
  125. return m_pCandList;
  126. }
  127. protected:
  128. CCandListMgr *m_pCandListMgr;
  129. ITfOptionsCandidateList *m_pOptionsList;
  130. ITfCandidateList *m_pCandList;
  131. // candidate item
  132. CCandidateItem **m_rgCandItem;
  133. int m_nCandItem;
  134. // extra candidate item
  135. CCandidateItem *m_pExtraCandItem;
  136. // candidate list tip
  137. BSTR m_bstrTip;
  138. // rawdata
  139. BOOL m_fRawData;
  140. CANDUIRAWDATATYPE m_kRawData;
  141. BSTR m_bstrRawData;
  142. HBITMAP m_hbmpRawData;
  143. HENHMETAFILE m_hemfRawData;
  144. ULONG m_nIndexRawData;
  145. BOOL m_fIndexRawData;
  146. // internal property
  147. int m_iItemSel;
  148. void BuildCandItem( void );
  149. void ClearCandItem( void );
  150. __inline CCandListMgr *GetCandListMgr( void )
  151. {
  152. return m_pCandListMgr;
  153. }
  154. };
  155. //
  156. // CCandListMgr
  157. // = candidate list manager =
  158. //
  159. class CCandListMgr
  160. {
  161. public:
  162. CCandListMgr( void );
  163. ~CCandListMgr( void );
  164. HRESULT Initialize( CCandidateUI *pCandUI );
  165. HRESULT Uninitialize( void );
  166. //
  167. // event sink functions
  168. //
  169. HRESULT AdviseEventSink( CCandListEventSink *pSink );
  170. HRESULT UnadviseEventSink( CCandListEventSink *pSink );
  171. void NotifySetCandList( void );
  172. void NotifyClearCandList( void );
  173. void NotifyCandItemUpdate( CCandListEventSink *pSink );
  174. void NotifySelectionChanged( CCandListEventSink *pSink );
  175. //
  176. // CandidateList handling functions
  177. //
  178. HRESULT SetCandidateList( ITfCandidateList *pCandList );
  179. HRESULT GetOptionsCandidateList( ITfOptionsCandidateList **ppCandList );
  180. HRESULT GetCandidateList( ITfCandidateList **ppCandList );
  181. HRESULT ClearCandiateList( void );
  182. HRESULT SetOptionSelection( int iItem, CCandListEventSink *pSink );
  183. HRESULT SetSelection( int iItem, CCandListEventSink *pSink );
  184. //
  185. //
  186. //
  187. __inline CCandidateUI *GetCandidateUI( void )
  188. {
  189. return m_pCandUI;
  190. }
  191. __inline CCandidateList *GetCandList( void )
  192. {
  193. return m_pCandListObj;
  194. }
  195. __inline CCandidateList *GetOptionsList( void )
  196. {
  197. return m_pOptionsListObj;
  198. }
  199. protected:
  200. CCandidateUI *m_pCandUI;
  201. CCandidateList *m_pOptionsListObj;
  202. CCandidateList *m_pCandListObj;
  203. CCandListEventSink *m_rgCandListSink[ CANDLISTSINK_MAX ];
  204. };
  205. //
  206. // CCandListEventSink
  207. // = candidate list event sink =
  208. //
  209. class CCandListEventSink
  210. {
  211. public:
  212. CCandListEventSink( void );
  213. virtual ~CCandListEventSink( void );
  214. HRESULT InitEventSink( CCandListMgr *pCandListMgr );
  215. HRESULT DoneEventSink( void );
  216. //
  217. // callback functions
  218. //
  219. virtual void OnSetCandidateList( void ) = 0; /* PURE */
  220. virtual void OnClearCandidateList( void ) = 0; /* PURE */
  221. virtual void OnCandItemUpdate( void ) = 0; /* PURE */
  222. virtual void OnSelectionChanged( void ) = 0; /* PURE */
  223. protected:
  224. CCandListMgr *m_pCandListMgr;
  225. __inline CCandListMgr *GetCandListMgr( void )
  226. {
  227. return m_pCandListMgr;
  228. }
  229. };
  230. #endif // CANDMGR_H