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.

269 lines
6.9 KiB

  1. //
  2. // nuihkl.h
  3. //
  4. #ifndef NUIHKL_H
  5. #define NUIHKL_H
  6. #include "private.h"
  7. #include "strary.h"
  8. #include "commctrl.h"
  9. #include "internat.h"
  10. #include "nuibase.h"
  11. #include "sink.h"
  12. #include "assembly.h"
  13. #include "lbmenu.h"
  14. #include "systhrd.h"
  15. ULONG GetIconIndexFromhKL(HKL hKL);
  16. ULONG GetIconIndex(LANGID langid, ASSEMBLYITEM *pItem);
  17. HRESULT AsyncReconversion();
  18. extern const TCHAR c_szNuiWin32IMEWndClass[];
  19. class CCompartmentEventSink;
  20. typedef struct tag_TIPMENUITEMMAP {
  21. ITfSystemLangBarItemSink *plbSink;
  22. UINT nOrgID;
  23. UINT nTmpID;
  24. } TIPMENUITEMMAP;
  25. typedef struct tag_GUIDATOMHKL {
  26. TfGuidAtom guidatom;
  27. HKL hkl;
  28. ULONG uIconIndex;
  29. ASSEMBLYITEM *pItem;
  30. } GUIDATOMHKL;
  31. //////////////////////////////////////////////////////////////////////////////
  32. //
  33. // CLBarItemWin32IME
  34. //
  35. //////////////////////////////////////////////////////////////////////////////
  36. class CLBarItemWin32IME : public CLBarItemButtonBase
  37. {
  38. public:
  39. CLBarItemWin32IME();
  40. ~CLBarItemWin32IME() {}
  41. STDMETHODIMP GetIcon(HICON *phIcon);
  42. HRESULT OnLButtonUp(const POINT pt, const RECT *prcArea);
  43. HRESULT OnRButtonUp(const POINT pt, const RECT *prcArea);
  44. void UpdateIMEIcon();
  45. private:
  46. void ShowIMELeftMenu(HWND hWnd, LONG xPos, LONG yPos);
  47. void ShowIMERightMenu(HWND hWnd, LONG xPos, LONG yPos);
  48. static LRESULT CALLBACK _WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  49. HWND CreateMyWnd()
  50. {
  51. return CreateWindow(c_szNuiWin32IMEWndClass,
  52. "",
  53. WS_POPUP | WS_DISABLED,
  54. 0,0,0,0,
  55. NULL, 0, g_hInst, this);
  56. }
  57. static void SetThis(HWND hWnd, LPARAM lParam)
  58. {
  59. SetWindowLongPtr(hWnd, GWLP_USERDATA,
  60. (LONG_PTR)((CREATESTRUCT *)lParam)->lpCreateParams);
  61. }
  62. static CLBarItemWin32IME *GetThis(HWND hWnd)
  63. {
  64. CLBarItemWin32IME *p = (CLBarItemWin32IME *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
  65. Assert(p != NULL);
  66. return p;
  67. }
  68. int _nIconId;
  69. DBG_ID_DECLARE;
  70. };
  71. //////////////////////////////////////////////////////////////////////////////
  72. //
  73. // CLBarItemReconv
  74. //
  75. //////////////////////////////////////////////////////////////////////////////
  76. class CLBarItemReconv : public CLBarItemButtonBase,
  77. public CSysThreadRef
  78. {
  79. public:
  80. CLBarItemReconv(SYSTHREAD *psfn);
  81. STDMETHODIMP GetIcon(HICON *phIcon);
  82. void ShowOrHide(BOOL fNotify);
  83. private:
  84. HRESULT OnLButtonUp(const POINT pt, const RECT *prcArea);
  85. BOOL _fAddedBefore;
  86. DBG_ID_DECLARE;
  87. };
  88. //////////////////////////////////////////////////////////////////////////////
  89. //
  90. // CLBarItemDeviceType
  91. //
  92. //////////////////////////////////////////////////////////////////////////////
  93. class __declspec(novtable) CLBarItemSystemButtonBase : public CLBarItemButtonBase,
  94. public ITfSystemLangBarItem,
  95. public ITfSystemDeviceTypeLangBarItem,
  96. public CSysThreadRef
  97. {
  98. public:
  99. CLBarItemSystemButtonBase(SYSTHREAD *psfn);
  100. ~CLBarItemSystemButtonBase();
  101. //
  102. // IUnknown methods
  103. //
  104. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  105. STDMETHODIMP_(ULONG) AddRef(void);
  106. STDMETHODIMP_(ULONG) Release(void);
  107. //
  108. // ITfSource
  109. //
  110. STDMETHODIMP AdviseSink(REFIID riid, IUnknown *punk, DWORD *pdwCookie);
  111. STDMETHODIMP UnadviseSink(DWORD dwCookie);
  112. //
  113. // ITfLangBarItem
  114. //
  115. STDMETHODIMP GetInfo(TF_LANGBARITEMINFO *pInfo);
  116. STDMETHODIMP Show(BOOL fShow);
  117. //
  118. // ITfSystemLangBarItem
  119. //
  120. STDMETHODIMP SetIcon(HICON hIcon);
  121. STDMETHODIMP SetTooltipString(WCHAR *pchToolTip, ULONG cch);
  122. //
  123. // ITfSystemDeviceTypeLangBarItem,
  124. //
  125. STDMETHODIMP SetIconMode(DWORD dwFlags);
  126. STDMETHODIMP GetIconMode(DWORD *pdwFlags);
  127. protected:
  128. BOOL _InsertCustomMenus(ITfMenu *pMenu, UINT *pnTipCurMenuID);
  129. UINT _MergeMenu(ITfMenu *pMenu, CCicLibMenu *pMenuTip, ITfSystemLangBarItemSink *plbSink, CStructArray<TIPMENUITEMMAP> *pMenuMap, UINT &nCurID);
  130. CStructArray<TIPMENUITEMMAP> *_pMenuMap;
  131. void ClearMenuMap()
  132. {
  133. if (_pMenuMap)
  134. _pMenuMap->Clear();
  135. }
  136. virtual void SetBrandingIcon(HKL hKL, BOOL fNotify) {return;}
  137. virtual void SetDefaultIcon(BOOL fNotify) {return;}
  138. CStructArray<GENERICSINK> _rgEventSinks; // ITfSystemLangBarItemSink
  139. DWORD _dwIconMode;
  140. };
  141. //////////////////////////////////////////////////////////////////////////////
  142. //
  143. // CLBarItemDeviceType
  144. //
  145. //////////////////////////////////////////////////////////////////////////////
  146. #define ID_TYPE_KEYBOARD 0
  147. #define ID_TYPE_HANDWRITING 1
  148. #define ID_TYPE_SPEECH 2
  149. class CLBarItemDeviceType : public CLBarItemSystemButtonBase
  150. {
  151. public:
  152. CLBarItemDeviceType(SYSTHREAD *psfn, REFGUID rguid);
  153. ~CLBarItemDeviceType();
  154. //
  155. // IUnknown methods
  156. //
  157. // STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  158. // STDMETHODIMP_(ULONG) AddRef(void);
  159. // STDMETHODIMP_(ULONG) Release(void);
  160. //
  161. // ITfSource
  162. //
  163. // STDMETHODIMP AdviseSink(REFIID riid, IUnknown *punk, DWORD *pdwCookie);
  164. // STDMETHODIMP UnadviseSink(DWORD dwCookie);
  165. //
  166. // ITfLangBarItem
  167. //
  168. // STDMETHODIMP GetInfo(TF_LANGBARITEMINFO *pInfo);
  169. STDMETHODIMP Show(BOOL fShow);
  170. STDMETHODIMP GetIcon(HICON *phIcon);
  171. //
  172. // ITfSystemLangBarItem
  173. //
  174. STDMETHODIMP SetIcon(HICON hIcon);
  175. STDMETHODIMP SetTooltipString(WCHAR *pchToolTip, ULONG cch);
  176. void Init();
  177. void Uninit();
  178. void ShowOrHide(BOOL fNotify);
  179. void InitTipArray(BOOL fInitIconIndex);
  180. BOOL IsKeyboardType() {return (_nType == ID_TYPE_KEYBOARD) ? TRUE : FALSE;}
  181. HICON GetIcon()
  182. {
  183. return CLBarItemSystemButtonBase::GetIcon();
  184. }
  185. void SetBrandingIcon(HKL hKL, BOOL fNotify);
  186. void SetDefaultIcon(BOOL fNotify);
  187. GUID *GetDeviceTypeGUID() {return &_guid;}
  188. private:
  189. BOOL _StringFromMenuId(int nMenuId, BSTR *pbstr);
  190. STDMETHODIMP InitMenu(ITfMenu *pMenu);
  191. STDMETHODIMP OnMenuSelect(UINT wID);
  192. GUID _guid;
  193. int _nType;
  194. CStructArray<GUIDATOMHKL> _rgGuidatomHkl;
  195. CCompartmentEventSink *_pces;
  196. static HRESULT CompEventSinkCallback(void *pv, REFGUID rguid);
  197. HRESULT SetSpeechButtonState(CThreadInputMgr *ptim);
  198. typedef struct tag_ICONFILE {
  199. int uIconIndex;
  200. WCHAR szFile[MAX_PATH];
  201. } ICONFILE;
  202. ICONFILE *_pif;
  203. //
  204. // When someone else calls Show(FALSE), we hide the button forcefully.
  205. // If this is TRUE, we never clear TF_LBI_STATUS_HIDDEN flag.
  206. //
  207. BOOL _fHideOrder;
  208. DBG_ID_DECLARE;
  209. };
  210. #endif // NUIHKL_H