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.

194 lines
5.0 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 "private.h"
  8. #include "globals.h"
  9. #include "common.h"
  10. #include "korimx.h"
  11. #include "fmode.h"
  12. #include "userex.h"
  13. #include "resource.h"
  14. // {D96498AF-0E46-446e-8F00-E113236FD22D}
  15. const GUID GUID_LBI_KORIMX_FMODE =
  16. {
  17. 0xd96498af,
  18. 0x0e46,
  19. 0x446e,
  20. { 0x8f, 0x0, 0xe1, 0x13, 0x23, 0x6f, 0xd2, 0x2d }
  21. };
  22. /*---------------------------------------------------------------------------
  23. FMode::FMode
  24. ---------------------------------------------------------------------------*/
  25. FMode::FMode(CToolBar *ptb)
  26. {
  27. WCHAR szText[256];
  28. m_pTb = ptb;
  29. // Set Add/Remove and tootip text
  30. LoadStringExW(g_hInst, IDS_TT_JUN_BAN, szText, sizeof(szText)/sizeof(WCHAR));
  31. InitInfo(CLSID_KorIMX,
  32. GUID_LBI_KORIMX_FMODE,
  33. TF_LBI_STYLE_BTN_BUTTON | TF_LBI_STYLE_HIDDENBYDEFAULT | TF_LBI_STYLE_TEXTCOLORICON,
  34. 110,
  35. szText);
  36. SetToolTip(szText);
  37. // Set button text
  38. LoadStringExW(g_hInst, IDS_BUTTON_JUN_BAN, szText, sizeof(szText)/sizeof(WCHAR));
  39. SetText(szText);
  40. }
  41. /*---------------------------------------------------------------------------
  42. FMode::Release
  43. ---------------------------------------------------------------------------*/
  44. STDAPI_(ULONG) FMode::Release()
  45. {
  46. long cr;
  47. cr = --m_cRef;
  48. Assert(cr >= 0);
  49. if (cr == 0)
  50. {
  51. delete this;
  52. }
  53. return cr;
  54. }
  55. /*---------------------------------------------------------------------------
  56. FMode::GetIcon
  57. Get Button face Icon
  58. ---------------------------------------------------------------------------*/
  59. STDAPI FMode::GetIcon(HICON *phIcon)
  60. {
  61. DWORD dwCM = GetCMode();
  62. UINT uiIcon = 0;
  63. static const UINT uidIcons[2][2] =
  64. {
  65. { IDI_CMODE_BANJA, IDI_CMODE_BANJAW },
  66. { IDI_CMODE_JUNJA, IDI_CMODE_JUNJAW }
  67. };
  68. if (m_pTb->IsOn() && (m_pTb->GetConversionMode() & TIP_JUNJA_MODE))
  69. uiIcon = 1;
  70. if (IsHighContrastBlack())
  71. uiIcon = uidIcons[uiIcon][1];
  72. else
  73. uiIcon = uidIcons[uiIcon][0];
  74. *phIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(uiIcon), IMAGE_ICON, 16, 16, LR_LOADMAP3DCOLORS);
  75. return S_OK;
  76. }
  77. /*---------------------------------------------------------------------------
  78. FMode::InitMenu
  79. No need, this is just toggle button
  80. ---------------------------------------------------------------------------*/
  81. STDAPI FMode::InitMenu(ITfMenu *pMenu)
  82. {
  83. return E_NOTIMPL;
  84. }
  85. /*---------------------------------------------------------------------------
  86. FMode::OnMenuSelect
  87. No need, this is just toggle button
  88. ---------------------------------------------------------------------------*/
  89. STDAPI FMode::OnMenuSelect(UINT wID)
  90. {
  91. return E_NOTIMPL;
  92. }
  93. //+---------------------------------------------------------------------------
  94. //
  95. // OnLButtonUp
  96. //
  97. //----------------------------------------------------------------------------
  98. HRESULT FMode::OnLButtonUp(const POINT pt, const RECT* prcArea)
  99. {
  100. DWORD dwConvMode;
  101. dwConvMode = GetCMode();
  102. // Toggle Full/Half mode
  103. if (dwConvMode & TIP_JUNJA_MODE)
  104. dwConvMode &= ~TIP_JUNJA_MODE;
  105. else
  106. dwConvMode |= TIP_JUNJA_MODE;
  107. SetCMode(dwConvMode);
  108. return S_OK;
  109. }
  110. #if 0
  111. //+---------------------------------------------------------------------------
  112. //
  113. // OnRButtonUp
  114. //
  115. //----------------------------------------------------------------------------
  116. HRESULT FMode::OnRButtonUp(const POINT pt, const RECT* prcArea)
  117. {
  118. HMENU hMenu;
  119. DWORD dwConvMode;
  120. CHAR szText[256];
  121. UINT uiId;
  122. int nRet;
  123. hMenu = CreatePopupMenu();
  124. dwConvMode = GetCMode();
  125. if (dwConvMode & TIP_JUNJA_MODE)
  126. uiId = IDS_BANJA_MODE;
  127. else
  128. uiId = IDS_JUNJA_MODE;
  129. // Add Hangul/English mode menu
  130. LoadStringExA(g_hInst, uiId, szText, sizeof(szText)/sizeof(CHAR));
  131. InsertMenu(hMenu, -1, MF_BYPOSITION | MF_STRING, 1, szText);
  132. // Add Cancel menu
  133. LoadStringExA(g_hInst, IDS_CANCEL, szText, sizeof(szText)/sizeof(CHAR));
  134. InsertMenu(hMenu, -1, MF_BYPOSITION | MF_STRING, 0, szText);
  135. nRet = TrackPopupMenuEx(hMenu,
  136. TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD,
  137. pt.x, pt.y, m_pTb->GetOwnerWnd(), NULL);
  138. switch (nRet)
  139. {
  140. case 1:
  141. dwConvMode = GetCMode();
  142. // Toggle Full/Half mode
  143. if (dwConvMode & TIP_JUNJA_MODE)
  144. dwConvMode &= ~TIP_JUNJA_MODE;
  145. else
  146. dwConvMode |= TIP_JUNJA_MODE;
  147. SetCMode(dwConvMode);
  148. break;
  149. }
  150. DestroyMenu(hMenu);
  151. return S_OK;
  152. }
  153. #endif