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
7.8 KiB

  1. //
  2. // candui.h
  3. //
  4. #ifndef CANDUI_H
  5. #define CANDUI_H
  6. #include "private.h"
  7. #include "mscandui.h"
  8. #include "globals.h"
  9. #include "ico.h"
  10. #include "tes.h"
  11. #include "editcb.h"
  12. #include "cuilib.h"
  13. #include "candmgr.h"
  14. #include "candprop.h"
  15. #include "candext.h"
  16. #include "candkey.h"
  17. #include "candobj.h"
  18. #include "candfunc.h"
  19. #include "wcand.h"
  20. #include "sptask.h"
  21. #include "candcomp.h"
  22. //
  23. //
  24. //
  25. #define ESCB_RESETTARGETPOS 0
  26. #define ESCB_COMPARERANGEANDCLOSECANDIDATE 1
  27. #define ESCB_TEXTEVENT 2
  28. class CSpTask;
  29. //
  30. // CCandidateUI
  31. //
  32. class CCandidateUI : public ITfCandidateUI,
  33. public ITfContextOwner,
  34. public ITfContextKeyEventSink,
  35. public ITfTextEditSink,
  36. public ITfTextLayoutSink,
  37. public ITfEditTransactionSink,
  38. public CComObjectRoot_CreateInstance<CCandidateUI>,
  39. public CCandListMgr,
  40. public CCandUIObjectMgr,
  41. public CCandUIPropertyMgr,
  42. public CCandUICompartmentMgr,
  43. public CCandUIFunctionMgr,
  44. public CCandUIExtensionMgr
  45. {
  46. public:
  47. CCandidateUI( void );
  48. virtual ~CCandidateUI( void );
  49. BEGIN_COM_MAP_IMMX( CCandidateUI )
  50. COM_INTERFACE_ENTRY( ITfCandidateUI )
  51. COM_INTERFACE_ENTRY( ITfContextOwner )
  52. COM_INTERFACE_ENTRY( ITfContextKeyEventSink )
  53. COM_INTERFACE_ENTRY( ITfTextEditSink )
  54. COM_INTERFACE_ENTRY( ITfTextLayoutSink )
  55. COM_INTERFACE_ENTRY( ITfEditTransactionSink )
  56. END_COM_MAP_IMMX()
  57. ITfThreadMgr *_ptim;
  58. //
  59. // ITfCandidateUIEx methods
  60. //
  61. STDMETHODIMP SetClientId( TfClientId tid );
  62. STDMETHODIMP OpenCandidateUI( HWND hWnd, ITfDocumentMgr *pdim, TfEditCookie ec, ITfRange *pRange );
  63. STDMETHODIMP CloseCandidateUI( void );
  64. STDMETHODIMP SetCandidateList( ITfCandidateList *pCandList );
  65. STDMETHODIMP SetSelection( ULONG nIndex );
  66. STDMETHODIMP GetSelection( ULONG *pnIndex );
  67. STDMETHODIMP SetTargetRange( ITfRange *pRange );
  68. STDMETHODIMP GetTargetRange( ITfRange **ppRange );
  69. STDMETHODIMP GetUIObject( REFIID riid, IUnknown **ppunk );
  70. STDMETHODIMP GetFunction( REFIID riid, IUnknown **ppunk );
  71. STDMETHODIMP ProcessCommand( CANDUICOMMAND cmd, INT iParam );
  72. // key config function methods
  73. HRESULT SetKeyTable( ITfContext *pic, ITfCandUIKeyTable *pCandUIKeyTable );
  74. HRESULT GetKeyTable( ITfContext *pic, ITfCandUIKeyTable **ppCandUIKeyTable );
  75. HRESULT ResetKeyTable( ITfContext *pic );
  76. // UI config function methods
  77. HRESULT SetUIStyle( ITfContext *pic, CANDUISTYLE style );
  78. HRESULT GetUIStyle( ITfContext *pic, CANDUISTYLE *pstyle );
  79. HRESULT SetUIOption( ITfContext *pic, DWORD dwOption );
  80. HRESULT GetUIOption( ITfContext *pic, DWORD *pdwOption );
  81. //
  82. // input context eventsink
  83. //
  84. HRESULT InitContextEventSinks( ITfContext *pic );
  85. HRESULT DoneContextEventSinks( ITfContext *pic );
  86. STDMETHODIMP GetACPFromPoint( const POINT *pt, DWORD dwFlags, LONG *pacp );
  87. STDMETHODIMP GetScreenExt( RECT *prc );
  88. STDMETHODIMP GetTextExt( LONG acpStart, LONG acpEnd, RECT *prc, BOOL *pfClipped );
  89. STDMETHODIMP GetStatus( TF_STATUS *pdcs );
  90. STDMETHODIMP GetWnd( HWND *phwnd );
  91. STDMETHODIMP GetAttribute( REFGUID rguidAttribute, VARIANT *pvarValue );
  92. STDMETHODIMP OnKeyDown( WPARAM wParam, LPARAM lParam, BOOL *pfEaten );
  93. STDMETHODIMP OnKeyUp( WPARAM wParam, LPARAM lParam, BOOL *pfEaten );
  94. STDMETHODIMP OnTestKeyDown( WPARAM wParam, LPARAM lParam, BOOL *pfEaten );
  95. STDMETHODIMP OnTestKeyUp( WPARAM wParam, LPARAM lParam, BOOL *pfEaten );
  96. static HRESULT TextEventCallback( UINT uCode, VOID *pv, VOID *pvData );
  97. //
  98. // text eventsink
  99. //
  100. HRESULT InitTextEventSinks( ITfContext *pic );
  101. HRESULT DoneTextEventSinks( ITfContext *pic );
  102. STDMETHODIMP OnEndEdit( ITfContext *pic, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord );
  103. STDMETHODIMP OnLayoutChange( ITfContext *pic, TfLayoutCode lcode, ITfContextView *pView );
  104. STDMETHODIMP OnStartEditTransaction( ITfContext *pic );
  105. STDMETHODIMP OnEndEditTransaction( ITfContext *pic );
  106. //
  107. // edit session callback
  108. //
  109. static HRESULT EditSessionCallback( TfEditCookie ec, CEditSession *pes );
  110. void ClearWndCand( void )
  111. {
  112. if (m_pCandWnd) {
  113. m_pCandWnd->Release();
  114. m_pCandWnd = NULL;
  115. }
  116. }
  117. // accessed from CCandWnd
  118. HRESULT NotifyCancelCand( void );
  119. HRESULT NotifySelectCand( int iCandItem );
  120. HRESULT NotifyCompleteOption( int iCandItem );
  121. HRESULT NotifyCompleteCand( int iCandItem );
  122. HRESULT NotifyExtensionEvent( int iExtension, DWORD dwCommand, LPARAM lParam );
  123. HRESULT NotifyFilteringEvent( CANDUIFILTEREVENT ev );
  124. HRESULT NotifySortEvent( CANDUISORTEVENT sort );
  125. HRESULT NotifyCompleteRawData( void );
  126. HRESULT NotifyCompleteExtraCand( void );
  127. void EndCandidateList();
  128. HRESULT NotifySpeechCmd(SPPHRASE *pPhrase, const WCHAR *pszRuleName, ULONG ulRuleId);
  129. HRESULT FHandleSpellingChar( WCHAR ch );
  130. void EnsureSpeech(void);
  131. HRESULT CreateCandWindowObject( ITfContext *pic, CCandWindowBase** ppCandWnd );
  132. HRESULT InitCandWindow( void );
  133. __inline CCandListMgr *GetCandListMgr( void )
  134. {
  135. return this;
  136. }
  137. __inline CCandUIObjectMgr *GetUIObjectMgr( void )
  138. {
  139. return this;
  140. }
  141. __inline CCandUIPropertyMgr *GetPropertyMgr( void )
  142. {
  143. return this;
  144. }
  145. __inline CCandUICompartmentMgr *GetCompartmentMgr( void )
  146. {
  147. return this;
  148. }
  149. __inline CCandUIFunctionMgr *GetFunctionMgr( void )
  150. {
  151. return this;
  152. }
  153. __inline CCandUIExtensionMgr *GetExtensionMgr( void )
  154. {
  155. return this;
  156. }
  157. void PostCommand( CANDUICOMMAND cmd, INT iParam );
  158. __inline CCandWindowBase *GetCandWindow( void )
  159. {
  160. return m_pCandWnd;
  161. }
  162. protected:
  163. // internal use
  164. HRESULT CloseCandidateUIProc( void );
  165. HRESULT CallSetOptionResult( int nIndex, TfCandidateResult imcr );
  166. HRESULT CallSetResult( int nIndex, TfCandidateResult imcr );
  167. HRESULT OnKeyEvent( UINT uCode, WPARAM wParam, LPARAM lParam, BOOL *pfEaten );
  168. BOOL FHandleKeyEvent( UINT uCode, UINT uVKey, BYTE *pbKeyState, BOOL *pfEatKey );
  169. BOOL HandleTextDeltas( TfEditCookie ec, ITfContext *pic, IEnumTfRanges *pEnumText );
  170. //
  171. void SetSelectionCur( ITfRange *pRange );
  172. void ClearSelectionCur( void );
  173. ITfRange *GetSelectionCur( void );
  174. // transaction functions
  175. void SetSelectionStart( ITfRange *pRange );
  176. void ClearSelectionStart( void );
  177. ITfRange *GetSelectionStart( void );
  178. void EnterEditTransaction( ITfRange *pSelection );
  179. void LeaveEditTransaction( void );
  180. __inline BOOL IsInEditTransaction( void )
  181. {
  182. return m_fInTransaction;
  183. }
  184. // filtering functions
  185. BOOL FHandleFilteringKey( UINT uCode, UINT uVKey, BYTE *pbKeyState, BOOL *pfEatKey );
  186. HRESULT AddFilteringChar( WCHAR wch, BOOL *pfUpdateList );
  187. HRESULT DelFilteringChar( BOOL *pfUpdateList );
  188. HRESULT FilterCandidateList( void );
  189. //
  190. WCHAR CharFromKey( UINT uVKey, BYTE *pbKeyState );
  191. CCandUIKeyTable *GetKeyTableProc( ITfContext *pic );
  192. void CommandFromKey( UINT uVkey, BYTE *pbKeyState, CANDUICOMMAND *pcmd, UINT *pParam );
  193. void CommandFromRule( LPCWSTR szRule, CANDUICOMMAND *pcmd, UINT *pParam );
  194. // members
  195. CCandUIKeyTable *m_pCandUIKeyTable;
  196. TfClientId m_tidClient;
  197. ITfContext *m_pic;
  198. ITfDocumentMgr *m_pdim;
  199. HWND m_hWndParent;
  200. CCandWindowBase *m_pCandWnd;
  201. ITfContext *m_picParent;
  202. ITfRange *m_pTargetRange;
  203. UINT m_codepage;
  204. //
  205. BOOL m_fContextEventSinkAdvised;
  206. DWORD m_dwCookieContextOwnerSink;
  207. DWORD m_dwCookieContextKeySink;
  208. //
  209. BOOL m_fTextEventSinkAdvised;
  210. DWORD m_dwCookieTextEditSink;
  211. DWORD m_dwCookieTextLayoutSink;
  212. DWORD m_dwCookieTransactionSink;
  213. //
  214. CTextEventSink *m_pTextEventSink;
  215. //
  216. ITfRange *m_pSelectionCur;
  217. //
  218. BOOL m_fInTransaction;
  219. ITfRange *m_pSelectionStart;
  220. //
  221. BOOL m_fInCallback;
  222. CSpTask *m_pSpTask;
  223. };
  224. #endif // CANDUI_H