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.

202 lines
5.5 KiB

  1. /****************************************************************************
  2. CMODE.CPP : CMode class implementation which manage conversion mode button
  3. on the Cicero Toolbar
  4. History:
  5. 10-JAN-2000 CSLim Created
  6. ****************************************************************************/
  7. #include "precomp.h"
  8. #include "cmode.h"
  9. #include "gdata.h"
  10. #include "ui.h"
  11. #include "winex.h"
  12. #include "resource.h"
  13. // {3CB8145F-8A84-4d53-8899-5783B942FBDE}
  14. const GUID GUID_LBI_KORIME_CMODE =
  15. {
  16. 0x3cb8145f, 0x8a84, 0x4d53,
  17. { 0x88, 0x99, 0x57, 0x83, 0xb9, 0x42, 0xfb, 0xde }
  18. };
  19. /*---------------------------------------------------------------------------
  20. CMode::CMode
  21. ---------------------------------------------------------------------------*/
  22. CMode::CMode(CToolBar *ptb)
  23. {
  24. WCHAR szText[256];
  25. m_pTb = ptb;
  26. szText[0] = L'\0';
  27. // Set Add/Remove text and tootip text
  28. OurLoadStringW(vpInstData->hInst, IDS_STATUS_TT_HAN_ENG, szText, sizeof(szText)/sizeof(WCHAR));
  29. InitInfo(CLSID_SYSTEMLANGBARITEM_KEYBOARD,
  30. GUID_LBI_KORIME_CMODE,
  31. TF_LBI_STYLE_BTN_BUTTON | TF_LBI_STYLE_SHOWNINTRAY | TF_LBI_STYLE_TEXTCOLORICON,
  32. 200,
  33. szText);
  34. SetToolTip(szText);
  35. // Set button text
  36. szText[0] = L'\0';
  37. OurLoadStringW(vpInstData->hInst, IDS_STATUS_BUTTON_HAN_ENG, szText, sizeof(szText)/sizeof(WCHAR));
  38. SetText(szText);
  39. }
  40. /*---------------------------------------------------------------------------
  41. CMode::Release
  42. ---------------------------------------------------------------------------*/
  43. STDAPI_(ULONG) CMode::Release()
  44. {
  45. long cr;
  46. cr = --m_cRef;
  47. DbgAssert(cr >= 0);
  48. if (cr == 0)
  49. {
  50. delete this;
  51. }
  52. return cr;
  53. }
  54. /*---------------------------------------------------------------------------
  55. CMode::GetIcon
  56. Get Button face Icon
  57. ---------------------------------------------------------------------------*/
  58. STDAPI CMode::GetIcon(HICON *phIcon)
  59. {
  60. DWORD dwCM = GetCMode();
  61. UINT uiIcon = 0;
  62. static const UINT uidIcons[2][2] =
  63. {
  64. { IDI_CMODE_ENGLISH, IDI_CMODE_ENGLISHW },
  65. { IDI_CMODE_HANGUL, IDI_CMODE_HANGULW }
  66. };
  67. if (m_pTb->IsOn() && (m_pTb->GetConversionMode() & IME_CMODE_HANGUL))
  68. uiIcon = 1;
  69. if (IsHighContrastBlack())
  70. uiIcon = uidIcons[uiIcon][1];
  71. else
  72. uiIcon = uidIcons[uiIcon][0];
  73. *phIcon = (HICON)LoadImage(vpInstData->hInst, MAKEINTRESOURCE(uiIcon), IMAGE_ICON, 16, 16, LR_LOADMAP3DCOLORS);
  74. return S_OK;
  75. }
  76. /*---------------------------------------------------------------------------
  77. CMode::InitMenu
  78. No need, this is just toggle button
  79. ---------------------------------------------------------------------------*/
  80. STDAPI CMode::InitMenu(ITfMenu *pMenu)
  81. {
  82. return E_NOTIMPL;
  83. }
  84. /*---------------------------------------------------------------------------
  85. CMode::OnMenuSelect
  86. No need, this is just toggle button
  87. ---------------------------------------------------------------------------*/
  88. STDAPI CMode::OnMenuSelect(UINT wID)
  89. {
  90. return E_NOTIMPL;
  91. }
  92. //+---------------------------------------------------------------------------
  93. //
  94. // OnLButtonUp
  95. //
  96. //----------------------------------------------------------------------------
  97. HRESULT CMode::OnLButtonUp(const POINT pt, const RECT* prcArea)
  98. {
  99. #if 0
  100. DWORD dwConvMode;
  101. dwConvMode = m_pTb->GetConversionMode();
  102. // Toggle Hangul mode
  103. if (dwConvMode & IME_CMODE_HANGUL)
  104. dwConvMode &= ~TIP_HANGUL_MODE;
  105. else
  106. dwConvMode |= TIP_HANGUL_MODE;
  107. SetCMode(dwConvMode);
  108. #endif
  109. keybd_event(VK_HANGUL, 0, 0, 0);
  110. keybd_event(VK_HANGUL, 0, KEYEVENTF_KEYUP, 0);
  111. return S_OK;
  112. }
  113. #if 0
  114. //+---------------------------------------------------------------------------
  115. //
  116. // OnRButtonUp
  117. //
  118. //----------------------------------------------------------------------------
  119. HRESULT CMode::OnRButtonUp(const POINT pt, const RECT* prcArea)
  120. {
  121. HMENU hMenu;
  122. DWORD dwConvMode;
  123. PCIMECtx pImeCtx;
  124. CHAR szText[256];
  125. UINT uiId;
  126. int nRet;
  127. hMenu = CreatePopupMenu();
  128. dwConvMode = GetCMode();
  129. if (dwConvMode & IME_CMODE_HANGUL)
  130. uiId = IDS_CIC_ENGLISH_MODE;
  131. else
  132. uiId = IDS_CIC_HANGUL_MODE;
  133. // Add Hangul/English mode menu
  134. OurLoadStringA(vpInstData->hInst, uiId, szText, sizeof(szText)/sizeof(CHAR));
  135. InsertMenu(hMenu, -1, MF_BYPOSITION | MF_STRING, 1, szText);
  136. // Add Cancel menu
  137. OurLoadStringA(vpInstData->hInst, IDS_CIC_CANCEL, szText, sizeof(szText)/sizeof(CHAR));
  138. InsertMenu(hMenu, -1, MF_BYPOSITION | MF_STRING, 0, szText);
  139. nRet = TrackPopupMenuEx(hMenu,
  140. TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD,
  141. pt.x, pt.y, GetActiveUIWnd(), NULL);
  142. switch (nRet)
  143. {
  144. case 1:
  145. dwConvMode = GetCMode();
  146. // Toggle Hangul mode
  147. if (dwConvMode & IME_CMODE_HANGUL)
  148. dwConvMode &= ~IME_CMODE_HANGUL;
  149. else
  150. dwConvMode |= IME_CMODE_HANGUL;
  151. pImeCtx = m_pTb->GetImeCtx();
  152. if (pImeCtx)
  153. OurImmSetConversionStatus(pImeCtx->GetHIMC(),
  154. dwConvMode, pImeCtx->GetSentenceMode());
  155. break;
  156. }
  157. DestroyMenu(hMenu);
  158. return S_OK;
  159. }
  160. #endif