https://git.reactos.org/?p=reactos.git;a=commitdiff;h=34705d1a5de6be58132c3…
commit 34705d1a5de6be58132c38e73d2b7ba3a3154b13
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Feb 6 12:21:46 2024 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Feb 6 12:21:46 2024 +0900
[MSUTB][SDK] Add CLBarItemBase (#6444)
Supporting Language Bar...
JIRA issue: CORE-19363
- Implement CLBarItemBase class.
- Add TF_E_... flags to "msctf.idl".
---
dll/win32/msutb/msutb.cpp | 138 +++++++++++++++++++++++++++++++++++++++++++++
sdk/include/psdk/msctf.idl | 26 +++++++--
2 files changed, 160 insertions(+), 4 deletions(-)
diff --git a/dll/win32/msutb/msutb.cpp b/dll/win32/msutb/msutb.cpp
index 1a8ee45cc03..4585ed7e6ca 100644
--- a/dll/win32/msutb/msutb.cpp
+++ b/dll/win32/msutb/msutb.cpp
@@ -830,6 +830,40 @@ public:
STDMETHOD_(BOOL, OnDelayMsg)(UINT uMsg) override;
};
+/***********************************************************************/
+
+class CLBarItemBase : public ITfLangBarItem
+{
+protected:
+ DWORD m_dwItemStatus;
+ TF_LANGBARITEMINFO m_NewUIInfo;
+ WCHAR m_szToolTipText[256];
+ LONG m_cRefs;
+ ITfLangBarItemSink *m_pLangBarItemSink;
+
+public:
+ CLBarItemBase();
+ virtual ~CLBarItemBase();
+
+ HRESULT ShowInternal(BOOL bShow, BOOL bUpdate);
+
+ void InitNuiInfo(
+ REFIID clsidService,
+ REFGUID guidItem,
+ DWORD dwStyle,
+ DWORD ulSort,
+ LPCWSTR Source);
+
+ HRESULT AdviseSink(REFIID riid, IUnknown *punk, DWORD *pdwCookie);
+ HRESULT UnadviseSink(DWORD dwCookie);
+
+ // ITfLangBarItem methods
+ STDMETHOD(GetInfo)(TF_LANGBARITEMINFO *pInfo) override;
+ STDMETHOD(GetStatus)(DWORD *pdwStatus) override;
+ STDMETHOD(Show)(BOOL fShow) override;
+ STDMETHOD(GetTooltipString)(BSTR *pbstrToolTip) override;
+};
+
/***********************************************************************
* CUTBLangBarDlg
*/
@@ -2362,6 +2396,110 @@ CTrayIconWnd::_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
return 0;
}
+/***********************************************************************
+ * CLBarItemBase
+ */
+
+CLBarItemBase::CLBarItemBase()
+{
+ m_dwItemStatus = 0;
+ m_szToolTipText[0] = 0;
+ m_cRefs = 1;
+ m_pLangBarItemSink = NULL;
+}
+
+CLBarItemBase::~CLBarItemBase()
+{
+ if (m_pLangBarItemSink)
+ m_pLangBarItemSink->Release();
+}
+
+HRESULT
+CLBarItemBase::AdviseSink(
+ REFIID riid,
+ IUnknown *punk,
+ DWORD *pdwCookie)
+{
+ if (IsEqualIID(riid, IID_ITfLangBarItemSink) || m_pLangBarItemSink)
+ return TF_E_NOOBJECT;
+
+ HRESULT hr = punk->QueryInterface(IID_ITfLangBarItemSink, (void
**)&m_pLangBarItemSink);
+ if (SUCCEEDED(hr))
+ *pdwCookie = 0x80000001;
+ return hr;
+}
+
+HRESULT CLBarItemBase::UnadviseSink(DWORD dwCookie)
+{
+ if (dwCookie != 0x80000001)
+ return E_FAIL;
+
+ if (!m_pLangBarItemSink)
+ return E_UNEXPECTED;
+
+ m_pLangBarItemSink->Release();
+ m_pLangBarItemSink = NULL;
+ return S_OK;
+}
+
+void
+CLBarItemBase::InitNuiInfo(
+ REFIID clsidService,
+ REFGUID guidItem,
+ DWORD dwStyle,
+ DWORD ulSort,
+ LPCWSTR Source)
+{
+ m_NewUIInfo.clsidService = clsidService;
+ m_NewUIInfo.guidItem = guidItem;
+ m_NewUIInfo.dwStyle = dwStyle;
+ m_NewUIInfo.ulSort = ulSort;
+ StringCchCopyW(m_NewUIInfo.szDescription, _countof(m_NewUIInfo.szDescription),
Source);
+}
+
+HRESULT
+CLBarItemBase::ShowInternal(BOOL bShow, BOOL bUpdate)
+{
+ DWORD dwOldStatus = m_dwItemStatus;
+ if (bShow)
+ m_dwItemStatus &= ~0x1;
+ else
+ m_dwItemStatus |= 0x1;
+ if (bUpdate && (dwOldStatus != m_dwItemStatus))
+ {
+ if (m_pLangBarItemSink)
+ m_pLangBarItemSink->OnUpdate(TF_LBI_STATUS);
+ }
+
+ return S_OK;
+}
+
+STDMETHODIMP CLBarItemBase::GetInfo(TF_LANGBARITEMINFO *pInfo)
+{
+ CopyMemory(pInfo, &m_NewUIInfo, sizeof(*pInfo));
+ return S_OK;
+}
+
+STDMETHODIMP CLBarItemBase::GetStatus(DWORD *pdwStatus)
+{
+ *pdwStatus = m_dwItemStatus;
+ return S_OK;
+}
+
+STDMETHODIMP CLBarItemBase::Show(BOOL fShow)
+{
+ return ShowInternal(fShow, TRUE);
+}
+
+STDMETHODIMP CLBarItemBase::GetTooltipString(BSTR *pbstrToolTip)
+{
+ if (!pbstrToolTip)
+ return E_INVALIDARG;
+ BSTR bstr = ::SysAllocString(m_szToolTipText);
+ *pbstrToolTip = bstr;
+ return bstr ? S_OK : E_OUTOFMEMORY;
+}
+
/***********************************************************************
* GetLibTls (MSUTB.@)
*
diff --git a/sdk/include/psdk/msctf.idl b/sdk/include/psdk/msctf.idl
index c9cc9908474..748787fb795 100644
--- a/sdk/include/psdk/msctf.idl
+++ b/sdk/include/psdk/msctf.idl
@@ -23,10 +23,28 @@ import "textstor.idl";
import "ctfutb.idl";
#endif
-cpp_quote("#define TF_E_STACKFULL MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF,
0x0501)")
-cpp_quote("#define TF_E_DISCONNECTED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF,
0x0504)")
-cpp_quote("#define TF_E_ALREADY_EXISTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF,
0x0506)")
-cpp_quote("#define TF_E_NOLOCK MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF,
0x0201)")
+cpp_quote("#define TF_E_ALREADY_EXISTS MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0506)")
+cpp_quote("#define TF_E_COMPOSITION_REJECTED MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0508)")
+cpp_quote("#define TF_E_DISCONNECTED MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0504)")
+cpp_quote("#define TF_E_EMPTYCONTEXT MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0509)")
+cpp_quote("#define TF_E_FORMAT MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x020A)")
+cpp_quote("#define TF_E_INVALIDPOINT MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0207)")
+cpp_quote("#define TF_E_INVALIDPOS MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0200)")
+cpp_quote("#define TF_E_INVALIDVIEW MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0505)")
+cpp_quote("#define TF_E_LOCKED MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0500)")
+cpp_quote("#define TF_E_NOINTERFACE MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0204)")
+cpp_quote("#define TF_E_NOLAYOUT MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0206)")
+cpp_quote("#define TF_E_NOLOCK MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0201)")
+cpp_quote("#define TF_E_NOOBJECT MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0202)")
+cpp_quote("#define TF_E_NOPROVIDER MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0503)")
+cpp_quote("#define TF_E_NOSELECTION MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0205)")
+cpp_quote("#define TF_E_NOSERVICE MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0203)")
+cpp_quote("#define TF_E_NOTOWNEDRANGE MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0502)")
+cpp_quote("#define TF_E_RANGE_NOT_COVERED MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0507)")
+cpp_quote("#define TF_E_READONLY MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0209)")
+cpp_quote("#define TF_E_STACKFULL MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0501)")
+cpp_quote("#define TF_E_SYNCHRONOUS MAKE_HRESULT(SEVERITY_ERROR,
FACILITY_ITF, 0x0208)")
+cpp_quote("#define TF_S_ASYNC MAKE_HRESULT(SEVERITY_SUCCESS,
FACILITY_ITF, 0x0300)")
cpp_quote("EXTERN_C HRESULT WINAPI TF_InitSystem(VOID);")
cpp_quote("EXTERN_C HRESULT WINAPI TF_UninitSystem(VOID);")