|
9 | 9 |
|
10 | 10 | WINE_DEFAULT_DEBUG_CHANNEL(msctfime);
|
11 | 11 |
|
| 12 | +/***********************************************************************/ |
| 13 | + |
12 | 14 | UINT WM_MSIME_SERVICE = 0;
|
13 | 15 | UINT WM_MSIME_UIREADY = 0;
|
14 | 16 | UINT WM_MSIME_RECONVERTREQUEST = 0;
|
@@ -61,6 +63,326 @@ BOOL RegisterMSIMEMessage(VOID)
|
61 | 63 | WM_MSIME_KEYMAP);
|
62 | 64 | }
|
63 | 65 |
|
| 66 | +/***********************************************************************/ |
| 67 | + |
| 68 | +/// @implemented |
| 69 | +CDefCompFrameGripper::CDefCompFrameGripper( |
| 70 | + CDefCompFrameWindow *pDefCompFrameWindow, |
| 71 | + LPCRECT prc, |
| 72 | + DWORD style) : CUIFGripper(pDefCompFrameWindow, prc, style) |
| 73 | +{ |
| 74 | + m_pDefCompFrameWindow = pDefCompFrameWindow; |
| 75 | +} |
| 76 | + |
| 77 | +/***********************************************************************/ |
| 78 | + |
| 79 | +/// @implemented |
| 80 | +CCompFinalizeButton::CCompFinalizeButton( |
| 81 | + CCompFrameWindow *pParent, |
| 82 | + DWORD nObjectID, |
| 83 | + LPCRECT prc, |
| 84 | + DWORD style, |
| 85 | + DWORD dwButtonFlags, |
| 86 | + LPCWSTR pszText) |
| 87 | + : CUIFToolbarButton(pParent, nObjectID, prc, style, dwButtonFlags, pszText) |
| 88 | +{ |
| 89 | + m_pCompFrameWindow = pParent; |
| 90 | +} |
| 91 | + |
| 92 | +/// @implemented |
| 93 | +CCompFinalizeButton::~CCompFinalizeButton() |
| 94 | +{ |
| 95 | + HICON hIcon = CUIFToolbarButton::GetIcon(); |
| 96 | + if (hIcon) |
| 97 | + { |
| 98 | + ::DestroyIcon(hIcon); |
| 99 | + CUIFToolbarButton::SetIcon(NULL); |
| 100 | + } |
| 101 | +} |
| 102 | + |
| 103 | +/// @implemented |
| 104 | +void CCompFinalizeButton::OnLeftClick() |
| 105 | +{ |
| 106 | + HIMC hIMC = m_pCompFrameWindow->m_hIMC; |
| 107 | + if (hIMC) |
| 108 | + ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0); |
| 109 | +} |
| 110 | + |
| 111 | +/***********************************************************************/ |
| 112 | + |
| 113 | +/// @implemented |
| 114 | +CCompFrameWindow::CCompFrameWindow(HIMC hIMC, DWORD style) |
| 115 | + : CUIFWindow(g_hInst, style) |
| 116 | +{ |
| 117 | + m_hIMC = hIMC; |
| 118 | +} |
| 119 | + |
| 120 | +/***********************************************************************/ |
| 121 | + |
| 122 | +/// @implemented |
| 123 | +CCompButtonFrameWindow::CCompButtonFrameWindow(HIMC hIMC, DWORD style) |
| 124 | + : CCompFrameWindow(hIMC, style) |
| 125 | +{ |
| 126 | +} |
| 127 | + |
| 128 | +/// @implemented |
| 129 | +void CCompButtonFrameWindow::Init() |
| 130 | +{ |
| 131 | + if (m_pFinalizeButton) |
| 132 | + return; |
| 133 | + |
| 134 | + RECT rc = { 0, 0, 0, 0 }; |
| 135 | + m_pFinalizeButton = new(cicNoThrow) CCompFinalizeButton(this, 0, &rc, 0, 0x10000, NULL); |
| 136 | + |
| 137 | + m_pFinalizeButton->Initialize(); |
| 138 | + m_pFinalizeButton->Init(); |
| 139 | + |
| 140 | + HICON hIcon = (HICON)::LoadImageW(g_hInst, MAKEINTRESOURCEW(IDI_DOWN), IMAGE_ICON, 16, 16, 0); |
| 141 | + m_pFinalizeButton->SetIcon(hIcon); |
| 142 | + |
| 143 | + WCHAR szText[256]; |
| 144 | + LoadStringW(g_hInst, IDS_FINALIZE_STRING, szText, _countof(szText)); |
| 145 | + m_pFinalizeButton->SetToolTip(szText); |
| 146 | + |
| 147 | + AddUIObj(m_pFinalizeButton); |
| 148 | +} |
| 149 | + |
| 150 | +/// @implemented |
| 151 | +void CCompButtonFrameWindow::MoveShow(LONG x, LONG y, BOOL bShow) |
| 152 | +{ |
| 153 | + INT nWidth = m_Margins.cxRightWidth + m_Margins.cxLeftWidth + 18; |
| 154 | + INT nHeight = m_Margins.cyBottomHeight + m_Margins.cyTopHeight + 18; |
| 155 | + Move(x, y, nWidth + 4, nHeight + 4); |
| 156 | + |
| 157 | + if (m_pFinalizeButton) |
| 158 | + { |
| 159 | + RECT rc = { 1, 1, nWidth + 1, nHeight + 1 }; |
| 160 | + m_pFinalizeButton->SetRect(&rc); |
| 161 | + } |
| 162 | + |
| 163 | + Show(bShow); |
| 164 | +} |
| 165 | + |
| 166 | +/// @implemented |
| 167 | +STDMETHODIMP_(void) CCompButtonFrameWindow::OnCreate(HWND hWnd) |
| 168 | +{ |
| 169 | + ::SetWindowTheme(hWnd, L"TOOLBAR", NULL); |
| 170 | + |
| 171 | + ZeroMemory(&m_Margins, sizeof(m_Margins)); |
| 172 | + |
| 173 | + CUIFTheme theme; |
| 174 | + theme.m_hTheme = NULL; |
| 175 | + theme.m_iPartId = 1; |
| 176 | + theme.m_iStateId = 0; |
| 177 | + theme.m_pszClassList = L"TOOLBAR"; |
| 178 | + if (SUCCEEDED(theme.InternalOpenThemeData(hWnd))) |
| 179 | + theme.GetThemeMargins(NULL, 1, 3602, NULL, &m_Margins); |
| 180 | +} |
| 181 | + |
| 182 | +/***********************************************************************/ |
| 183 | + |
| 184 | +/// @implemented |
| 185 | +CDefCompFrameWindow::CDefCompFrameWindow(HIMC hIMC, DWORD style) |
| 186 | + : CCompFrameWindow(hIMC, style) |
| 187 | +{ |
| 188 | + LoadPosition(); |
| 189 | + m_iPartId = 1; |
| 190 | + m_iStateId = 1; |
| 191 | + m_pszClassList = L"TASKBAR"; |
| 192 | +} |
| 193 | + |
| 194 | +/// @implemented |
| 195 | +CDefCompFrameWindow::~CDefCompFrameWindow() |
| 196 | +{ |
| 197 | + SavePosition(); |
| 198 | +} |
| 199 | + |
| 200 | +/// @implemented |
| 201 | +void CDefCompFrameWindow::Init() |
| 202 | +{ |
| 203 | + RECT rc; |
| 204 | + |
| 205 | + if (!m_pGripper) |
| 206 | + { |
| 207 | + ZeroMemory(&rc, sizeof(rc)); |
| 208 | + m_pGripper = new(cicNoThrow) CDefCompFrameGripper(this, &rc, 0); |
| 209 | + m_pGripper->Initialize(); |
| 210 | + AddUIObj(m_pGripper); |
| 211 | + } |
| 212 | + |
| 213 | + if (!m_pFinalizeButton) |
| 214 | + { |
| 215 | + ZeroMemory(&rc, sizeof(rc)); |
| 216 | + m_pFinalizeButton = new(cicNoThrow) CCompFinalizeButton(this, 0, &rc, 0, 0x10000, NULL); |
| 217 | + m_pFinalizeButton->Initialize(); |
| 218 | + m_pFinalizeButton->Init(); |
| 219 | + |
| 220 | + HICON hIcon = (HICON)LoadImageW(g_hInst, MAKEINTRESOURCEW(IDI_DOWN), IMAGE_ICON, 16, 16, 0); |
| 221 | + m_pFinalizeButton->SetIcon(hIcon); |
| 222 | + |
| 223 | + WCHAR szText[256]; |
| 224 | + ::LoadStringW(g_hInst, IDS_FINALIZE_STRING, szText, _countof(szText)); |
| 225 | + SetToolTip(szText); |
| 226 | + |
| 227 | + AddUIObj(m_pFinalizeButton); |
| 228 | + } |
| 229 | +} |
| 230 | + |
| 231 | +/// @implemented |
| 232 | +INT CDefCompFrameWindow::GetGripperWidth() |
| 233 | +{ |
| 234 | + if (!m_pGripper || FAILED(m_pGripper->EnsureThemeData(m_hWnd))) |
| 235 | + return 5; |
| 236 | + |
| 237 | + INT ret = -1; |
| 238 | + HDC hDC = ::GetDC(m_hWnd); |
| 239 | + SIZE partSize; |
| 240 | + if (SUCCEEDED(m_pGripper->GetThemePartSize(hDC, 1, 0, TS_TRUE, &partSize))) |
| 241 | + ret = partSize.cx + 4; |
| 242 | + |
| 243 | + ::ReleaseDC(m_hWnd, hDC); |
| 244 | + |
| 245 | + return ((ret < 0) ? 5 : ret); |
| 246 | +} |
| 247 | + |
| 248 | +/// @implemented |
| 249 | +void CDefCompFrameWindow::MyScreenToClient(LPPOINT ppt, LPRECT prc) |
| 250 | +{ |
| 251 | + if (ppt) |
| 252 | + ::ScreenToClient(m_hWnd, ppt); |
| 253 | + |
| 254 | + if (prc) |
| 255 | + { |
| 256 | + ::ScreenToClient(m_hWnd, (LPPOINT)prc); |
| 257 | + ::ScreenToClient(m_hWnd, (LPPOINT)&prc->right); |
| 258 | + } |
| 259 | +} |
| 260 | + |
| 261 | +/// @implemented |
| 262 | +void CDefCompFrameWindow::SetCompStrRect(INT nWidth, INT nHeight, BOOL bShow) |
| 263 | +{ |
| 264 | + INT GripperWidth = GetGripperWidth(); |
| 265 | + |
| 266 | + RECT rc; |
| 267 | + ::GetWindowRect(m_hWnd, &rc); |
| 268 | + |
| 269 | + Move(rc.left, rc.top, GripperWidth + nWidth + 24, nHeight + 10); |
| 270 | + |
| 271 | + if (m_pGripper) |
| 272 | + { |
| 273 | + rc = { 2, 3, GripperWidth + 2, nHeight + 7 }; |
| 274 | + m_pGripper->SetRect(&rc); |
| 275 | + } |
| 276 | + |
| 277 | + if (m_pFinalizeButton) |
| 278 | + { |
| 279 | + rc = { |
| 280 | + GripperWidth + nWidth + 4, |
| 281 | + 3, |
| 282 | + m_Margins.cxLeftWidth + m_Margins.cxRightWidth + GripperWidth + nWidth + 22, |
| 283 | + m_Margins.cyBottomHeight + m_Margins.cyTopHeight + 21 |
| 284 | + }; |
| 285 | + m_pFinalizeButton->SetRect(&rc); |
| 286 | + } |
| 287 | + |
| 288 | + Show(bShow); |
| 289 | + |
| 290 | + ::MoveWindow(m_hwndDefCompFrame, GripperWidth + 2, 7, nWidth, nHeight, TRUE); |
| 291 | + ::ShowWindow(m_hwndDefCompFrame, (bShow ? SW_SHOWNOACTIVATE : SW_HIDE)); |
| 292 | +} |
| 293 | + |
| 294 | +/// @implemented |
| 295 | +void CDefCompFrameWindow::LoadPosition() |
| 296 | +{ |
| 297 | + DWORD x = 0, y = 0; |
| 298 | + |
| 299 | + LSTATUS error; |
| 300 | + CicRegKey regKey; |
| 301 | + error = regKey.Open(HKEY_CURRENT_USER, |
| 302 | + TEXT("SOFTWARE\\Microsoft\\CTF\\CUAS\\DefaultCompositionWindow")); |
| 303 | + if (error == ERROR_SUCCESS) |
| 304 | + { |
| 305 | + regKey.QueryDword(TEXT("Left"), &x); |
| 306 | + regKey.QueryDword(TEXT("Top"), &y); |
| 307 | + } |
| 308 | + |
| 309 | + Move(x, y, 0, 0); |
| 310 | +} |
| 311 | + |
| 312 | +/// @implemented |
| 313 | +void CDefCompFrameWindow::SavePosition() |
| 314 | +{ |
| 315 | + LSTATUS error; |
| 316 | + CicRegKey regKey; |
| 317 | + error = regKey.Create(HKEY_CURRENT_USER, |
| 318 | + TEXT("SOFTWARE\\Microsoft\\CTF\\CUAS\\DefaultCompositionWindow")); |
| 319 | + if (error == ERROR_SUCCESS) |
| 320 | + { |
| 321 | + regKey.SetDword(TEXT("Left"), m_nLeft); |
| 322 | + regKey.SetDword(TEXT("Top"), m_nTop); |
| 323 | + } |
| 324 | +} |
| 325 | + |
| 326 | +/// @implemented |
| 327 | +STDMETHODIMP_(void) CDefCompFrameWindow::OnCreate(HWND hWnd) |
| 328 | +{ |
| 329 | + ::SetWindowTheme(hWnd, L"TASKBAR", NULL); |
| 330 | + |
| 331 | + ZeroMemory(&m_Margins, sizeof(m_Margins)); |
| 332 | + |
| 333 | + CUIFTheme theme; |
| 334 | + theme.m_hTheme = NULL; |
| 335 | + theme.m_iPartId = 1; |
| 336 | + theme.m_iStateId = 0; |
| 337 | + theme.m_pszClassList = L"TOOLBAR"; |
| 338 | + if (SUCCEEDED(theme.InternalOpenThemeData(hWnd))) |
| 339 | + GetThemeMargins(NULL, 1, 3602, NULL, &m_Margins); |
| 340 | +} |
| 341 | + |
| 342 | +/// @implemented |
| 343 | +STDMETHODIMP_(BOOL) CDefCompFrameWindow::OnSetCursor(UINT uMsg, LONG x, LONG y) |
| 344 | +{ |
| 345 | + if (!::IsWindow(m_hwndDefCompFrame)) |
| 346 | + return FALSE; |
| 347 | + |
| 348 | + RECT rc; |
| 349 | + ::GetWindowRect(m_hwndDefCompFrame, &rc); |
| 350 | + MyScreenToClient(NULL, &rc); |
| 351 | + POINT pt = { x, y }; |
| 352 | + return ::PtInRect(&rc, pt); |
| 353 | +} |
| 354 | + |
| 355 | +/// @implemented |
| 356 | +STDMETHODIMP_(LRESULT) |
| 357 | +CDefCompFrameWindow::OnWindowPosChanged(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 358 | +{ |
| 359 | + CicIMCLock imcLock(m_hIMC); |
| 360 | + if (!imcLock) |
| 361 | + imcLock.m_hr = E_FAIL; |
| 362 | + if (SUCCEEDED(imcLock.m_hr)) |
| 363 | + ::SendMessage(imcLock.get().hWnd, WM_IME_NOTIFY, 0xF, (LPARAM)m_hIMC); |
| 364 | + return ::DefWindowProc(hWnd, uMsg, wParam, lParam); |
| 365 | +} |
| 366 | + |
| 367 | +/// @implemented |
| 368 | +STDMETHODIMP_(void) CDefCompFrameWindow::HandleMouseMsg(UINT uMsg, LONG x, LONG y) |
| 369 | +{ |
| 370 | + if (::IsWindow(m_hwndDefCompFrame)) |
| 371 | + { |
| 372 | + RECT rc; |
| 373 | + ::GetWindowRect(m_hwndDefCompFrame, &rc); |
| 374 | + MyScreenToClient(NULL, &rc); |
| 375 | + |
| 376 | + POINT pt = { x, y }; |
| 377 | + if (::PtInRect(&rc, pt)) |
| 378 | + ::SendMessage(m_hwndDefCompFrame, 0x7E8, 0, 0); |
| 379 | + } |
| 380 | + |
| 381 | + CUIFWindow::HandleMouseMsg(uMsg, x, y); |
| 382 | +} |
| 383 | + |
| 384 | +/***********************************************************************/ |
| 385 | + |
64 | 386 | // For GetWindowLongPtr/SetWindowLongPtr
|
65 | 387 | #define UIGWLP_HIMC 0
|
66 | 388 | #define UIGWLP_UI sizeof(HIMC)
|
|
0 commit comments