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.

203 lines
5.5 KiB

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