ReactOS 0.4.15-dev-7961-gdcf9eb0
cicimc.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Cicero
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Locking and Unlocking IMC and IMCC handles
5 * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#pragma once
9
10// struct CTFIMECONTEXT;
11// class CIC_IMCC_LOCK<T_DATA>;
12// class CicIMCCLock<T_DATA>;
13// class CIC_IMC_LOCK;
14// class CicIMCLock;
15
16class CicInputContext;
17
18typedef struct tagCTFIMECONTEXT
19{
23
24template <typename T_DATA>
26{
27protected:
28 T_DATA *m_pIMCC;
29
30public:
33
35 {
36 m_pIMCC = NULL;
37 m_hr = S_OK;
38 m_hIMCC = hIMCC;
39 }
40};
41
42template <typename T_DATA>
43class CicIMCCLock : public CIC_IMCC_LOCK<T_DATA>
44{
45public:
46 CicIMCCLock(HIMCC hIMCC) : CIC_IMCC_LOCK<T_DATA>(hIMCC)
47 {
48 this->m_hr = _LockIMCC(this->m_hIMCC, &this->m_pIMCC);
49 }
51 {
52 unlock();
53 }
54
55 void unlock()
56 {
57 if (this->m_pIMCC)
58 {
59 _UnlockIMCC(this->m_hIMCC);
60 this->m_pIMCC = NULL;
61 }
62 }
63
64 operator T_DATA*() const
65 {
66 return this->m_pIMCC;
67 }
68 T_DATA& get() const
69 {
70 return *this->m_pIMCC;
71 }
72
73protected:
74 HRESULT _LockIMCC(HIMCC hIMCC, T_DATA **pptr)
75 {
76 if (!hIMCC)
77 return E_INVALIDARG;
78 *pptr = (T_DATA*)::ImmLockIMCC(hIMCC);
79 return (*pptr ? S_OK : E_FAIL);
80 }
82 {
83 if (!::ImmUnlockIMCC(hIMCC))
84 return (::GetLastError() ? E_FAIL : S_OK);
85 return S_OK;
86 }
87};
88
90{
91protected:
93
94public:
98
100 {
101 m_pIC = NULL;
102 m_hIMC = hIMC;
103 m_hr = S_OK;
104 m_dw3 = 0;
105 }
106
107 BOOL Invalid() const
108 {
109 return (!m_pIC || m_hr != S_OK);
110 }
111};
112
114{
115public:
117 {
118 m_hr = _LockIMC(hIMC, &m_pIC);
119 }
121 {
122 unlock();
123 }
124
125 void unlock()
126 {
127 if (m_pIC)
128 {
130 m_pIC = NULL;
131 }
132 }
133
135 {
136 if (!(m_pIC->fdwInit & INIT_COMPFORM))
137 m_pIC->cfCompForm.dwStyle = 0;
138 for (UINT i = 0; i < 4; ++i)
139 m_pIC->cfCandForm[i].dwStyle = 0;
140 }
141
143 {
144 if (ImmGetIMCCSize(m_pIC->hCompStr) < sizeof(COMPOSITIONSTRING))
145 return FALSE;
146
147 CicIMCCLock<COMPOSITIONSTRING> imccLock(m_pIC->hCompStr);
148 if (!imccLock)
149 return FALSE;
150
151 return imccLock.get().dwCompStrLen > 0;
152 }
153
154 BOOL ClearCand();
155
157 {
158 return m_pIC->cfCompForm.dwStyle && ((m_pIC->lfFont.A.lfEscapement / 900) % 4 == 3);
159 }
160
161 operator INPUTCONTEXTDX*() const
162 {
163 return m_pIC;
164 }
166 {
167 return *m_pIC;
168 }
169
170protected:
172 {
173 if (!hIMC)
174 return E_INVALIDARG;
175
177 *ppIC = pIC;
178 return (pIC ? S_OK : E_FAIL);
179 }
181 {
182 return ::ImmUnlockIMC(hIMC) ? S_OK : E_FAIL;
183 }
184};
struct tagCTFIMECONTEXT * PCTFIMECONTEXT
struct tagCTFIMECONTEXT CTFIMECONTEXT
CIC_IMCC_LOCK(HIMCC hIMCC)
Definition: cicimc.h:34
T_DATA * m_pIMCC
Definition: cicimc.h:28
HIMCC m_hIMCC
Definition: cicimc.h:31
HRESULT m_hr
Definition: cicimc.h:32
HIMC m_hIMC
Definition: cicimc.h:95
CIC_IMC_LOCK(HIMC hIMC)
Definition: cicimc.h:99
HRESULT m_hr
Definition: cicimc.h:96
LPINPUTCONTEXTDX m_pIC
Definition: cicimc.h:92
BOOL Invalid() const
Definition: cicimc.h:107
DWORD m_dw3
Definition: cicimc.h:97
void unlock()
Definition: cicimc.h:55
HRESULT _UnlockIMCC(HIMCC hIMCC)
Definition: cicimc.h:81
T_DATA & get() const
Definition: cicimc.h:68
CicIMCCLock(HIMCC hIMCC)
Definition: cicimc.h:46
HRESULT _LockIMCC(HIMCC hIMCC, T_DATA **pptr)
Definition: cicimc.h:74
~CicIMCCLock()
Definition: cicimc.h:50
BOOL UseVerticalCompWindow() const
Definition: cicimc.h:156
HRESULT _UnlockIMC(HIMC hIMC)
Definition: cicimc.h:180
void unlock()
Definition: cicimc.h:125
void InitContext()
Definition: cicimc.h:134
HRESULT _LockIMC(HIMC hIMC, LPINPUTCONTEXTDX *ppIC)
Definition: cicimc.h:171
INPUTCONTEXTDX & get() const
Definition: cicimc.h:165
~CicIMCLock()
Definition: cicimc.h:120
CicIMCLock(HIMC hIMC)
Definition: cicimc.h:116
BOOL ClearCand()
Definition: cicimc.cpp:16
BOOL ValidCompositionString()
Definition: cicimc.h:142
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
DWORD HIMCC
Definition: dimm.idl:76
DWORD HIMC
Definition: dimm.idl:75
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1057
BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
Definition: utils.c:1208
DWORD WINAPI ImmGetIMCCSize(HIMCC imcc)
Definition: utils.c:1236
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
Definition: utils.c:1198
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
#define INIT_COMPFORM
Definition: immdev.h:177
#define S_OK
Definition: intsafe.h:52
unsigned int UINT
Definition: ndis.h:50
CicInputContext * m_pCicIC
Definition: cicimc.h:20
DWORD m_dwCicFlags
Definition: cicimc.h:21
DWORD WINAPI GetLastError(void)
Definition: except.c:1042