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.

189 lines
5.0 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 "private.h"
  8. #include "globals.h"
  9. #include "common.h"
  10. #include "korimx.h"
  11. #include "cmode.h"
  12. #include "userex.h"
  13. #include "resource.h"
  14. // {951549C6-9752-4b7d-9B0E-35AEBFF9E446}
  15. const GUID GUID_LBI_KORIMX_CMODE =
  16. {
  17. 0x951549c6,
  18. 0x9752,
  19. 0x4b7d,
  20. { 0x9b, 0xe, 0x35, 0xae, 0xbf, 0xf9, 0xe4, 0x46 }
  21. };
  22. /*---------------------------------------------------------------------------
  23. CMode::CMode
  24. ---------------------------------------------------------------------------*/
  25. CMode::CMode(CToolBar *ptb)
  26. {
  27. WCHAR szText[256];
  28. m_pTb = ptb;
  29. // Set Add/Remove and tootip text
  30. LoadStringExW(g_hInst, IDS_TT_HAN_ENG, szText, sizeof(szText)/sizeof(WCHAR));
  31. InitInfo(CLSID_KorIMX,
  32. GUID_LBI_KORIMX_CMODE,
  33. TF_LBI_STYLE_BTN_BUTTON | TF_LBI_STYLE_SHOWNINTRAY | TF_LBI_STYLE_TEXTCOLORICON,
  34. 100,
  35. szText);
  36. SetToolTip(szText);
  37. // Set button text
  38. LoadStringExW(g_hInst, IDS_BUTTON_HAN_ENG, szText, sizeof(szText)/sizeof(WCHAR));
  39. SetText(szText);
  40. }
  41. /*---------------------------------------------------------------------------
  42. CMode::Release
  43. ---------------------------------------------------------------------------*/
  44. STDAPI_(ULONG) CMode::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. CMode::GetIcon
  57. Get Button face Icon
  58. ---------------------------------------------------------------------------*/
  59. STDAPI CMode::GetIcon(HICON *phIcon)
  60. {
  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() & TIP_HANGUL_MODE))
  68. uiIcon = 1;
  69. if (IsHighContrastBlack())
  70. uiIcon = uidIcons[uiIcon][1];
  71. else
  72. uiIcon = uidIcons[uiIcon][0];
  73. *phIcon = (HICON)LoadImage(g_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. DWORD dwConvMode;
  100. dwConvMode = m_pTb->GetConversionMode();
  101. // Toggle Hangul mode
  102. dwConvMode ^= TIP_HANGUL_MODE;
  103. SetCMode(dwConvMode);
  104. return S_OK;
  105. }
  106. #if 0
  107. //+---------------------------------------------------------------------------
  108. //
  109. // OnRButtonUp
  110. //
  111. //----------------------------------------------------------------------------
  112. HRESULT CMode::OnRButtonUp(const POINT pt, const RECT* prcArea)
  113. {
  114. HMENU hMenu;
  115. DWORD dwConvMode;
  116. CHAR szText[256];
  117. UINT uiId;
  118. int nRet;
  119. hMenu = CreatePopupMenu();
  120. dwConvMode = GetCMode();
  121. if (dwConvMode & TIP_HANGUL_MODE)
  122. uiId = IDS_ENGLISH_MODE;
  123. else
  124. uiId = IDS_HANGUL_MODE;
  125. // Add Hangul/English mode menu
  126. LoadStringExA(g_hInst, uiId, szText, sizeof(szText)/sizeof(CHAR));
  127. InsertMenu(hMenu, -1, MF_BYPOSITION | MF_STRING, 1, szText);
  128. // Add Cancel menu
  129. LoadStringExA(g_hInst, IDS_CANCEL, szText, sizeof(szText)/sizeof(CHAR));
  130. InsertMenu(hMenu, -1, MF_BYPOSITION | MF_STRING, 0, szText);
  131. nRet = TrackPopupMenuEx(hMenu,
  132. TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD,
  133. pt.x, pt.y, m_pTb->GetOwnerWnd(), NULL);
  134. switch (nRet)
  135. {
  136. case 1:
  137. dwConvMode = GetCMode();
  138. // Toggle Hangul mode
  139. if (dwConvMode & TIP_HANGUL_MODE)
  140. dwConvMode &= ~TIP_HANGUL_MODE;
  141. else
  142. dwConvMode |= TIP_HANGUL_MODE;
  143. SetCMode(dwConvMode);
  144. break;
  145. }
  146. DestroyMenu(hMenu);
  147. return S_OK;
  148. }
  149. #endif