https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7dd33088282e7029f3a81…
commit 7dd33088282e7029f3a81f939dbd24835954f953
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Feb 7 16:47:10 2024 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Feb 7 16:47:10 2024 +0900
[MSUTB][SDK] Add CUTBContextMenu (#6452)
Supporting Language Bar...
JIRA issue: CORE-19363
- Add some resource strings.
- Half-implement CUTBContextMenu
class.
---
dll/win32/msutb/lang/en-US.rc | 10 +-
dll/win32/msutb/msutb.cpp | 326 +++++++++++++++++++++++++++++++++++++++++-
dll/win32/msutb/resource.h | 21 +++
sdk/include/psdk/msctf.idl | 13 +-
4 files changed, 360 insertions(+), 10 deletions(-)
diff --git a/dll/win32/msutb/lang/en-US.rc b/dll/win32/msutb/lang/en-US.rc
index 8b09fb014c3..97a03d501df 100644
--- a/dll/win32/msutb/lang/en-US.rc
+++ b/dll/win32/msutb/lang/en-US.rc
@@ -17,11 +17,19 @@ BEGIN
IDS_YES "&Yes"
IDS_NO "&No"
+ IDS_SETTINGS "S&ettings..."
IDS_RESTORELANGBAR "Restore Language Bar"
IDS_LANGUAGE "Language"
- IDS_RESTORELANGBAR2 "&Restore Language Bar"
IDS_LANGUAGEBUTTON "Language Button"
+ IDS_TRANSPARENCY "&Transparency"
+ IDS_TEXTLABELS "Tex&t Labels"
+ IDS_MINIMIZE "&Minimize"
+ IDS_CLOSELANGBAR "&Close Language Bar"
+ IDS_EXTRAICONS "&Additional icons in taskbar"
+ IDS_RESTORELANGBAR2 "&Restore Language Bar"
IDS_MENUWND "Menu Window"
+ IDS_VERTICAL "&Vertical"
+ IDS_ADJUSTLANGBAND "&Adjust Language Band position"
IDS_LEFTCLICK "Left Click"
END
diff --git a/dll/win32/msutb/msutb.cpp b/dll/win32/msutb/msutb.cpp
index ba2b71e43ca..899d51d5442 100644
--- a/dll/win32/msutb/msutb.cpp
+++ b/dll/win32/msutb/msutb.cpp
@@ -15,6 +15,7 @@ UINT g_uACP = CP_ACP;
DWORD g_dwOSInfo = 0;
CRITICAL_SECTION g_cs;
LONG g_DllRefCount = 0;
+BOOL g_bWinLogon = FALSE;
BOOL g_bShowTipbar = TRUE;
BOOL g_bShowDebugMenu = FALSE;
@@ -307,6 +308,60 @@ HRESULT LangBarInsertSeparator(_In_ ITfMenu *pMenu)
return pMenu->AddMenuItem(-1, TF_LBMENUF_SEPARATOR, NULL, NULL, NULL, 0, NULL);
}
+// Is it a Far-East language ID?
+BOOL IsFELangId(LANGID LangID)
+{
+ switch (LangID)
+ {
+ case MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED): // Chinese
(Simplified)
+ case MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL): // Chinese
(Traditional)
+ case MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT): // Japanese
+ case MAKELANGID(LANG_KOREAN, SUBLANG_DEFAULT): // Korean
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+BOOL CheckCloseMenuAvailable(void)
+{
+ BOOL ret = FALSE;
+ ITfInputProcessorProfiles *pProfiles = NULL;
+ LANGID *pLangIds = NULL;
+ ULONG iItem, cItems;
+
+ if (g_fPolicyDisableCloseButton)
+ return FALSE;
+
+ if (g_bShowCloseMenu)
+ return TRUE;
+
+ if (SUCCEEDED(TF_CreateInputProcessorProfiles(&pProfiles)) &&
+ SUCCEEDED(pProfiles->GetLanguageList(&pLangIds, &cItems)))
+ {
+ for (iItem = 0; iItem < cItems; ++iItem)
+ {
+ if (IsFELangId(pLangIds[iItem]))
+ break;
+ }
+
+ ret = (iItem == cItems);
+ }
+
+ if (pLangIds)
+ CoTaskMemFree(pLangIds);
+ if (pProfiles)
+ pProfiles->Release();
+
+ return ret;
+}
+
+/// @unimplemented
+BOOL IsTransparecyAvailable(void)
+{
+ return FALSE;
+}
+
BOOL InitFromReg(void)
{
DWORD dwValue;
@@ -814,13 +869,38 @@ public:
CModalMenu() { }
virtual ~CModalMenu() { }
- CUTBMenuItem *InsertItem(CUTBMenuWnd *pMenuUI, SIZE_T uBytes, INT nStringID);
+ CUTBMenuItem *InsertItem(CUTBMenuWnd *pMenuUI, INT nCommandId, INT nStringID);
void PostKey(BOOL bUp, WPARAM wParam, LPARAM lParam);
void CancelMenu();
};
/***********************************************************************/
+class CTipbarThread;
+
+class CUTBContextMenu : public CModalMenu
+{
+public:
+ CTipbarWnd *m_pTipbarWnd;
+ CTipbarThread *m_pTipbarThread;
+
+public:
+ CUTBContextMenu(CTipbarWnd *pTipbarWnd);
+
+ BOOL Init();
+ CUTBMenuWnd *CreateMenuUI(BOOL bFlag);
+
+ UINT ShowPopup(
+ CUIFWindow *pWindow,
+ POINT pt,
+ LPCRECT prc,
+ BOOL bFlag);
+
+ BOOL SelectMenuItem(UINT nCommandId);
+};
+
+/***********************************************************************/
+
class CUTBLBarMenuItem;
class CUTBLBarMenu : public CCicLibMenu
@@ -2173,7 +2253,7 @@ STDMETHODIMP_(INT) CUTBMenuItem::GetAccRole()
*/
CUTBMenuItem *
-CModalMenu::InsertItem(CUTBMenuWnd *pMenuUI, SIZE_T uBytes, INT nStringID)
+CModalMenu::InsertItem(CUTBMenuWnd *pMenuUI, INT nCommandId, INT nStringID)
{
CUTBMenuItem *pMenuItem = new(cicNoThrow) CUTBMenuItem(pMenuUI);
if (!pMenuItem)
@@ -2183,7 +2263,7 @@ CModalMenu::InsertItem(CUTBMenuWnd *pMenuUI, SIZE_T uBytes, INT
nStringID)
::LoadStringW(g_hInst, nStringID, szText, _countof(szText));
if (pMenuItem->Initialize() &&
- pMenuItem->Init(uBytes, szText) &&
+ pMenuItem->Init(nCommandId, szText) &&
pMenuUI->InsertItem(pMenuItem))
{
return pMenuItem;
@@ -2204,6 +2284,246 @@ void CModalMenu::CancelMenu()
m_pMenuUI->CancelMenu();
}
+/***********************************************************************
+ * CUTBContextMenu
+ */
+
+CUTBContextMenu::CUTBContextMenu(CTipbarWnd *pTipbarWnd)
+{
+ m_pTipbarWnd = pTipbarWnd;
+}
+
+/// @unimplemented
+BOOL CUTBContextMenu::Init()
+{
+#if 0 // FIXME: m_pTipbarWnd
+ m_pTipbarThread = m_pTipbarWnd->m_pFocusThread;
+ return !!m_pTipbarThread;
+#else
+ return TRUE;
+#endif
+}
+
+/// @unimplemented
+CUTBMenuWnd *CUTBContextMenu::CreateMenuUI(BOOL bFlag)
+{
+ DWORD dwStatus = 0;
+
+#if 0 // FIXME: m_pTipbarWnd
+ if (FAILED(m_pTipbarWnd->m_pLangBarMgr->GetShowFloatingStatus(&dwStatus)))
+ return NULL;
+#endif
+
+ CUTBMenuWnd *pMenuUI = new (cicNoThrow) CUTBMenuWnd(g_hInst, g_dwMenuStyle, 0);
+ if (!pMenuUI)
+ return NULL;
+
+ pMenuUI->Initialize();
+
+ if (dwStatus & (TF_SFT_DESKBAND | TF_SFT_MINIMIZED))
+ {
+ CUTBMenuItem *pRestoreLangBar = InsertItem(pMenuUI, ID_RESTORELANGBAR,
IDS_RESTORELANGBAR2);
+#if 0 // FIXME: m_pTipbarWnd
+ if (pRestoreLangBar && !m_pTipbarWnd->m_dwUnknown20)
+ pRestoreLangBar->Gray(TRUE);
+#endif
+ pRestoreLangBar = pRestoreLangBar;
+ }
+ else
+ {
+ InsertItem(pMenuUI, ID_DESKBAND, IDS_MINIMIZE);
+
+ if (bFlag)
+ {
+ if (IsTransparecyAvailable())
+ {
+ if (dwStatus & TF_LBI_BALLOON)
+ {
+ InsertItem(pMenuUI, ID_TRANS, IDS_TRANSPARENCY);
+ }
+ else
+ {
+ CUTBMenuItem *pTransparency = InsertItem(pMenuUI, ID_NOTRANS,
IDS_TRANSPARENCY);
+ if (pTransparency)
+ pTransparency->Check(TRUE);
+ }
+ }
+
+ if (!(dwStatus & TF_SFT_LABELS))
+ {
+ InsertItem(pMenuUI, ID_LABELS, IDS_TEXTLABELS);
+ }
+ else
+ {
+ CUTBMenuItem *pTextLabels = InsertItem(pMenuUI, ID_NOLABELS,
IDS_TEXTLABELS);
+ if (pTextLabels)
+ pTextLabels->Check(TRUE);
+ }
+
+ CUTBMenuItem *pVertical = InsertItem(pMenuUI, ID_VERTICAL, IDS_VERTICAL);
+#if 0 // FIXME: m_pTipbarWnd
+ if (pVertical)
+ pVertical->Check(!!(m_pTipbarWnd->m_dwTipbarWndFlags &
0x800000));
+#endif
+ pVertical = pVertical;
+ }
+ }
+
+ if (bFlag)
+ {
+ CUTBMenuItem *pExtraIcons = NULL;
+
+ if (dwStatus & TF_SFT_EXTRAICONSONMINIMIZED)
+ {
+ pExtraIcons = InsertItem(pMenuUI, ID_NOEXTRAICONS, IDS_EXTRAICONS);
+ if (pExtraIcons)
+ pExtraIcons->Check(TRUE);
+ }
+ else
+ {
+ pExtraIcons = CModalMenu::InsertItem(pMenuUI, ID_EXTRAICONS,
IDS_EXTRAICONS);
+ }
+
+ if (pExtraIcons)
+ {
+ if (::GetKeyboardLayoutList(0, NULL) == 1)
+ {
+ pExtraIcons->Check(TRUE);
+ pExtraIcons->Gray(TRUE);
+ }
+ else
+ {
+ pExtraIcons->Gray(FALSE);
+ }
+ }
+
+ if (dwStatus & TF_SFT_DESKBAND)
+ InsertItem(pMenuUI, ID_ADJUSTDESKBAND, IDS_ADJUSTLANGBAND);
+
+ InsertItem(pMenuUI, ID_SETTINGS, IDS_SETTINGS);
+
+ if (CheckCloseMenuAvailable())
+ InsertItem(pMenuUI, ID_CLOSELANGBAR, IDS_CLOSELANGBAR);
+ }
+
+ return pMenuUI;
+}
+
+UINT
+CUTBContextMenu::ShowPopup(
+ CUIFWindow *pWindow,
+ POINT pt,
+ LPCRECT prc,
+ BOOL bFlag)
+{
+ if (g_bWinLogon)
+ return 0;
+
+ if (m_pMenuUI)
+ return -1;
+
+ m_pMenuUI = CreateMenuUI(bFlag);
+ if (!m_pMenuUI)
+ return 0;
+
+ UINT nCommandId = m_pMenuUI->ShowModalPopup(pWindow, prc, TRUE);
+
+ if (m_pMenuUI)
+ {
+ delete m_pMenuUI;
+ m_pMenuUI = NULL;
+ }
+
+ return nCommandId;
+}
+
+/// @unimplemented
+BOOL CUTBContextMenu::SelectMenuItem(UINT nCommandId)
+{
+ switch (nCommandId)
+ {
+#if 0 // FIXME: g_pTipbarWnd
+ case ID_TRANS:
+ m_pTipbarWnd->m_pLangBarMgr->ShowFloating(TF_SFT_LOWTRANSPARENCY);
+ break;
+
+ case ID_NOTRANS:
+ m_pTipbarWnd->m_pLangBarMgr->ShowFloating(TF_SFT_NOTRANSPARENCY);
+ break;
+
+ case ID_LABELS:
+ m_pTipbarWnd->m_pLangBarMgr->ShowFloating(TF_SFT_LABELS);
+ break;
+
+ case ID_NOLABELS:
+ m_pTipbarWnd->m_pLangBarMgr->ShowFloating(TF_SFT_NOLABELS);
+ break;
+
+ case ID_DESKBAND:
+ {
+ m_pTipbarWnd->m_pLangBarMgr->GetShowFloatingStatus(&dwStatus);
+
+ if (dwStatus & TF_SFT_DESKBAND)
+ break;
+
+ m_pTipbarWnd->m_pLangBarMgr->ShowFloating(TF_SFT_DESKBAND);
+
+ CUTBMinimizeLangBarDlg *pDialog = new(cicNoThrow) CUTBMinimizeLangBarDlg();
+ if (pDialog)
+ {
+ pDialog->DoModal(m_pTipbarWnd->m_Window);
+ pDialog->_Release();
+ }
+ break;
+ }
+
+ case ID_CLOSELANGBAR:
+ {
+ CUTBCloseLangBarDlg *pDialog = new(cicNoThrow) CUTBCloseLangBarDlg();
+ if (pDialog)
+ {
+ BOOL bOK = pDialog->DoModal(m_pTipbarWnd->m_Window);
+ pDialog->_Release();
+ if (!bOK)
+ DoCloseLangbar();
+ }
+ break;
+ }
+
+ case ID_EXTRAICONS:
+ m_pTipbarWnd->m_dwTipbarWndFlags &= ~0x4000;
+
m_pTipbarWnd->m_pLangBarMgr->ShowFloating(TF_SFT_EXTRAICONSONMINIMIZED);
+ break;
+
+ case ID_NOEXTRAICONS:
+ m_pTipbarWnd->m_dwTipbarWndFlags &= ~0x4000;
+
m_pTipbarWnd->m_pLangBarMgr->ShowFloating(TF_SFT_NOEXTRAICONSONMINIMIZED);
+ break;
+
+ case ID_RESTORELANGBAR:
+ m_pTipbarWnd->m_pLangBarMgr->ShowFloating(TF_LBI_ICON);
+ break;
+
+ case ID_VERTICAL:
+ m_pTipbarWnd->SetVertical((m_pTipbarWnd->m_dwTipbarWndFlags & 0x4)
? TRUE : FALSE);
+ break;
+
+ case ID_ADJUSTDESKBAND:
+ m_pTipbarWnd->AdjustDeskBandSize(TRUE);
+ break;
+#endif
+
+ case ID_SETTINGS:
+ TF_RunInputCPL();
+ break;
+
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
/***********************************************************************
* CTrayIconItem
*/
diff --git a/dll/win32/msutb/resource.h b/dll/win32/msutb/resource.h
index ee02ba159b2..4a911d35967 100644
--- a/dll/win32/msutb/resource.h
+++ b/dll/win32/msutb/resource.h
@@ -10,13 +10,34 @@
#define IDI_MAINICON 100
+#define IDS_SETTINGS 300
#define IDS_RESTORELANGBAR 308
#define IDS_LANGUAGE 309
#define IDS_LANGUAGEBUTTON 310
+#define IDS_TRANSPARENCY 312
+#define IDS_TEXTLABELS 313
+#define IDS_MINIMIZE 314
+#define IDS_CLOSELANGBAR 315
+#define IDS_EXTRAICONS 318
#define IDS_RESTORELANGBAR2 321
#define IDS_MENUWND 322
+#define IDS_VERTICAL 324
+#define IDS_ADJUSTLANGBAND 326
#define IDS_LEFTCLICK 323
+#define ID_TRANS 208
+#define ID_NOTRANS 209
+#define ID_LABELS 210
+#define ID_NOLABELS 211
+#define ID_DESKBAND 212
+#define ID_CLOSELANGBAR 213
+#define ID_EXTRAICONS 214
+#define ID_NOEXTRAICONS 215
+#define ID_RESTORELANGBAR 216
+#define ID_VERTICAL 217
+#define ID_ADJUSTDESKBAND 219
+#define ID_SETTINGS 2000
+
#define IDD_CLOSELANGBAR 1001
#define IDD_MINIMIZELANGBAR 1004
diff --git a/sdk/include/psdk/msctf.idl b/sdk/include/psdk/msctf.idl
index f9f6e6fe17d..5ff4b4b090c 100644
--- a/sdk/include/psdk/msctf.idl
+++ b/sdk/include/psdk/msctf.idl
@@ -59,14 +59,15 @@ cpp_quote("EXTERN_C HANDLE WINAPI TF_CreateCicLoadMutex(_Out_
LPBOOL pfWinLogon
cpp_quote("EXTERN_C HRESULT WINAPI TF_InvalidAssemblyListCache(VOID);")
cpp_quote("EXTERN_C HRESULT WINAPI TF_InvalidAssemblyListCacheIfExist(VOID);")
cpp_quote("EXTERN_C HRESULT WINAPI TF_DllDetachInOther(VOID);")
-cpp_quote("EXTERN_C HRESULT WINAPI TF_CreateCategoryMgr(ITfCategoryMgr
**ppcat);")
-cpp_quote("EXTERN_C HRESULT WINAPI
TF_CreateDisplayAttributeMgr(ITfDisplayAttributeMgr **ppdam);")
-cpp_quote("EXTERN_C HICON WINAPI TF_GetLangIcon(LANGID LangID, LPWSTR pszText, INT
cchText);")
+cpp_quote("EXTERN_C HRESULT WINAPI TF_CreateCategoryMgr(_Out_ ITfCategoryMgr
**ppcat);")
+cpp_quote("EXTERN_C HRESULT WINAPI TF_CreateDisplayAttributeMgr(_Out_
ITfDisplayAttributeMgr **ppdam);")
+cpp_quote("EXTERN_C HICON WINAPI TF_GetLangIcon(_In_ LANGID LangID, _Out_ LPWSTR
pszText, _In_ INT cchText);")
cpp_quote("EXTERN_C HRESULT WINAPI TF_InitMlngInfo(VOID);")
cpp_quote("EXTERN_C INT WINAPI TF_MlngInfoCount(VOID);")
-cpp_quote("EXTERN_C BOOL WINAPI TF_GetMlngHKL(INT iKL, HKL *phKL, LPWSTR pszText,
INT cchText);")
-cpp_quote("EXTERN_C INT WINAPI TF_GetMlngIconIndex(INT iKL);")
-cpp_quote("EXTERN_C HICON WINAPI TF_InatExtractIcon(INT iKL);")
+cpp_quote("EXTERN_C BOOL WINAPI TF_GetMlngHKL(_In_ INT iKL, _Out_ HKL *phKL, _Out_
LPWSTR pszText, _In_ INT cchText);")
+cpp_quote("EXTERN_C INT WINAPI TF_GetMlngIconIndex(_In_ INT iKL);")
+cpp_quote("EXTERN_C HICON WINAPI TF_InatExtractIcon(_In_ INT iKL);")
+cpp_quote("EXTERN_C HRESULT WINAPI TF_RunInputCPL(VOID);")
cpp_quote("EXTERN_C const GUID GUID_PROP_TEXTOWNER;")
cpp_quote("EXTERN_C const GUID GUID_PROP_ATTRIBUTE;")