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.

154 lines
5.2 KiB

  1. //
  2. // correctionimx.h
  3. //
  4. #pragma once
  5. #include "timsink.h"
  6. #include "mscandui.h"
  7. #include "globals.h"
  8. #define ESCB_RESETTARGETPOS 1
  9. #define ESCB_RECONVERTMYSELF 3
  10. #define ESCB_INJECTALTERNATETEXT 4
  11. enum WINDOWSTATE
  12. {
  13. WINDOW_HIDE = 0,
  14. // Hides the correction widget window.
  15. WINDOW_SMALL = 1,
  16. // Resizes the correction widget window to small.
  17. WINDOW_SMALLSHOW = 2,
  18. // Shows the correction widget window in its initial small state.
  19. WINDOW_LARGE = 3,
  20. // Resizes the correction widget window to its large size.
  21. WINDOW_REFRESH = 4,
  22. // Moves the correction widget to a new location but does not change its size.
  23. WINDOW_LARGECLOSE = 5
  24. // Resizes the correction widget window to its large size and displays close icon.
  25. };
  26. #ifdef SUPPORT_INTERNAL_WIDGET
  27. class CCorrectionIMX :
  28. public ITfTextInputProcessor,
  29. public ITfTextEditSink,
  30. public ITfTextLayoutSink,
  31. public ITfThreadFocusSink,
  32. public ITfKeyTraceEventSink,
  33. public CComObjectRoot,
  34. public CComCoClass<CCorrectionIMX, &CLSID_CorrectionIMX>
  35. {
  36. public:
  37. CCorrectionIMX();
  38. ~CCorrectionIMX();
  39. STDMETHODIMP FinalConstruct(void);
  40. BEGIN_COM_MAP(CCorrectionIMX)
  41. COM_INTERFACE_ENTRY(ITfTextInputProcessor)
  42. COM_INTERFACE_ENTRY(ITfTextEditSink)
  43. COM_INTERFACE_ENTRY(ITfTextLayoutSink)
  44. COM_INTERFACE_ENTRY(ITfThreadFocusSink)
  45. COM_INTERFACE_ENTRY(ITfKeyTraceEventSink)
  46. END_COM_MAP()
  47. DECLARE_NOT_AGGREGATABLE(CCorrectionIMX)
  48. DECLARE_REGISTRY_RESOURCE(IDR_CORRECTIONIMX)
  49. static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj);
  50. //
  51. // ITfTextInputProcessor
  52. //
  53. STDMETHODIMP Activate(ITfThreadMgr *ptim, TfClientId tid);
  54. STDMETHODIMP Deactivate();
  55. // ITfTextEditSink
  56. STDMETHODIMP OnEndEdit(ITfContext *pic, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord);
  57. // ITfTextLayoutSink
  58. STDMETHODIMP OnLayoutChange( ITfContext *pic, TfLayoutCode lcode, ITfContextView *pView );
  59. // ITfThreadFocusSink
  60. STDMETHODIMP OnSetThreadFocus(void);
  61. STDMETHODIMP OnKillThreadFocus(void);
  62. // ITfKeyTraceEventSink
  63. STDMETHODIMP OnKeyTraceDown(WPARAM wParam,LPARAM lParam);
  64. STDMETHODIMP OnKeyTraceUp(WPARAM wParam,LPARAM lParam);
  65. TfClientId GetId(void) { return m_tid; }
  66. ITfContext *GetIC(void) { return m_cpic; }
  67. CComPtr<ITfThreadMgr> m_cptim;
  68. private:
  69. // Internal functions
  70. HRESULT InitICPriv(TfClientId tid, CICPriv *priv, ITfContext *pic);
  71. HRESULT DeleteICPriv(CICPriv *picp, ITfContext *pic);
  72. HRESULT GetReconversion(TfEditCookie ec, ITfCandidateList** ppCandList);
  73. static HRESULT SetResult(ITfContext *pic, ITfRange *pRange, CCandidateString *pCand, TfCandidateResult imcr);
  74. static HRESULT SetOptionResult(ITfContext *pic, ITfRange *pRange, CCandidateString *pCand, TfCandidateResult imcr);
  75. HRESULT ShowCandidateList(TfEditCookie ec, ITfContext *pic, ITfRange *pRange, ITfCandidateList *pCandList);
  76. HRESULT IsWordInDictionary(WCHAR *pwzWord);
  77. HRESULT AddWordToDictionary(WCHAR *pwzWord);
  78. HRESULT RemoveWordFromDictionary(WCHAR *pwzWord);
  79. HRESULT IsCandidateObjectOpen(ITfContext *pic, BOOL *fOpen);
  80. HRESULT CompareRange(TfEditCookie ecReadOnly, ITfRange *pRange1, ITfRange *pRange2, BOOL *fIdentical);
  81. HRESULT FindWordRange(TfEditCookie ecReadOnly, ITfRange *pRangeIP, ITfRange **pRangeWord);
  82. HRESULT DoesUserSelectionMatchReconversion(TfEditCookie ecReadOnly, ITfRange *pRangeUser, ITfRange *pRangeReconv, BOOL *fMatch);
  83. HRESULT UpdateWidgetLocation(TfEditCookie ec);
  84. HRESULT Show(WINDOWSTATE eWindowState);
  85. HRESULT DrawWidget(BYTE uAlpha);
  86. HRESULT LazyInitializeWindow(void);
  87. static HRESULT ICCallback(UINT uCode, ITfContext *pic, void *pv);
  88. static HRESULT DIMCallback(UINT uCode, ITfDocumentMgr *pdim, ITfDocumentMgr *pdimPrevFocus, void *pv);
  89. static HRESULT EditSessionCallback(TfEditCookie ec, CEditSession *pes);
  90. static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  91. CComPtr<ITfRange> m_cpRangeReconv;
  92. CComPtr<ITfRange> m_cpRangeUser;
  93. CComPtr<ITfRange> m_cpRangeWord;
  94. CComPtr<ITfCandidateUI> m_cpCandUIEx;
  95. CComPtr<ITfFnReconversion> m_cpSysReconv;
  96. CComPtr<ITfContext> m_cpic;
  97. TfClientId m_tid;
  98. CThreadMgrEventSink *m_ptimEventSink;
  99. WCHAR m_wszDelete[MAX_PATH];
  100. WCHAR m_wszAddPrefix[MAX_PATH];
  101. WCHAR m_wszAddPostfix[MAX_PATH];
  102. DWORD m_dwLayoutCookie;
  103. DWORD m_dwEditCookie;
  104. DWORD m_dwThreadFocusCookie;
  105. DWORD m_dwKeyTraceCookie;
  106. BOOL m_fExpanded;
  107. RECT m_rcSelection;
  108. BOOL m_fDisplayAlternatesMyself;
  109. HWND m_hWnd;
  110. HICON m_hIconInvoke;
  111. HICON m_hIconInvokeLarge;
  112. HICON m_hIconInvokeClose;
  113. WINDOWSTATE m_eWindowState;
  114. UINT m_uAlpha;
  115. CComPtr<ISpLexicon> m_cpLexicon;
  116. BOOL m_fCandidateOpen;
  117. BOOL m_fKeyDown;
  118. ATOM m_hAtom;
  119. };
  120. #endif // SUPPORT_INTERNAL_WIDGET