3807 } 3808 3809 void AwtComponent::OpenCandidateWindow(int x, int y) 3810 { 3811 UINT bits = 1; 3812 POINT p = {0, 0}; // upper left corner of the client area 3813 HWND hWnd = GetHWnd(); 3814 if (!::IsWindowVisible(hWnd)) { 3815 return; 3816 } 3817 HWND hTop = GetTopLevelParentForWindow(hWnd); 3818 ::ClientToScreen(hTop, &p); 3819 if (!m_bitsCandType) { 3820 SetCandidateWindow(m_bitsCandType, x - p.x, y - p.y); 3821 return; 3822 } 3823 for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) { 3824 if ( m_bitsCandType & bits ) 3825 SetCandidateWindow(iCandType, x - p.x, y - p.y); 3826 } 3827 if (m_bitsCandType != 0) { 3828 // REMIND: is there any chance GetProxyFocusOwner() returns NULL here? 3829 ::DefWindowProc(ImmGetHWnd(), 3830 WM_IME_NOTIFY, IMN_OPENCANDIDATE, m_bitsCandType); 3831 } 3832 } 3833 3834 void AwtComponent::SetCandidateWindow(int iCandType, int x, int y) 3835 { 3836 HWND hwnd = ImmGetHWnd(); 3837 HIMC hIMC = ImmGetContext(hwnd); 3838 CANDIDATEFORM cf; 3839 cf.dwIndex = iCandType; 3840 cf.dwStyle = CFS_POINT; 3841 cf.ptCurrentPos.x = x; 3842 cf.ptCurrentPos.y = y; 3843 3844 ImmSetCandidateWindow(hIMC, &cf); 3845 ImmReleaseContext(hwnd, hIMC); 3846 } 3847 3848 MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam) 3849 { 3850 // If the Windows input context is disabled, do not let Windows 3851 // display any UIs. 3852 HWND hwnd = ImmGetHWnd(); 3853 HIMC hIMC = ImmGetContext(hwnd); 3854 if (hIMC == NULL) { 3855 *lplParam = 0; 3856 return mrDoDefault; 3857 } 3858 ImmReleaseContext(hwnd, hIMC); 3859 3860 if (fSet) { 3861 LPARAM lParam = *lplParam; 3862 if (!m_useNativeCompWindow) { 3863 // stop to draw native composing window. 3864 *lplParam &= ~ISC_SHOWUICOMPOSITIONWINDOW; 3865 } 3866 } 3867 return mrDoDefault; 3868 } 3869 3870 MsgRouting AwtComponent::WmImeNotify(WPARAM subMsg, LPARAM bitsCandType) 3871 { 3872 if (!m_useNativeCompWindow) { 3873 if (subMsg == IMN_OPENCANDIDATE) { 3874 m_bitsCandType = bitsCandType; 3875 InquireCandidatePosition(); 3876 } else if (subMsg == IMN_OPENSTATUSWINDOW || 3877 subMsg == WM_IME_STARTCOMPOSITION) { 3878 m_bitsCandType = 0; 3879 InquireCandidatePosition(); 3880 } else if (subMsg == IMN_SETCANDIDATEPOS) { 3881 InquireCandidatePosition(); 3882 } 3883 return mrConsume; 3884 } 3885 return mrDoDefault; 3886 } 3887 3888 MsgRouting AwtComponent::WmImeStartComposition() 3889 { 3890 if (m_useNativeCompWindow) { 3891 RECT rc; 3892 ::GetClientRect(GetHWnd(), &rc); 3893 SetCompositionWindow(rc); 3894 return mrDoDefault; 3895 } else 3896 return mrConsume; 3897 } 3898 3899 MsgRouting AwtComponent::WmImeEndComposition() 3900 { | 3807 } 3808 3809 void AwtComponent::OpenCandidateWindow(int x, int y) 3810 { 3811 UINT bits = 1; 3812 POINT p = {0, 0}; // upper left corner of the client area 3813 HWND hWnd = GetHWnd(); 3814 if (!::IsWindowVisible(hWnd)) { 3815 return; 3816 } 3817 HWND hTop = GetTopLevelParentForWindow(hWnd); 3818 ::ClientToScreen(hTop, &p); 3819 if (!m_bitsCandType) { 3820 SetCandidateWindow(m_bitsCandType, x - p.x, y - p.y); 3821 return; 3822 } 3823 for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) { 3824 if ( m_bitsCandType & bits ) 3825 SetCandidateWindow(iCandType, x - p.x, y - p.y); 3826 } 3827 } 3828 3829 void AwtComponent::SetCandidateWindow(int iCandType, int x, int y) 3830 { 3831 HWND hwnd = ImmGetHWnd(); 3832 HIMC hIMC = ImmGetContext(hwnd); 3833 if (hIMC) { 3834 CANDIDATEFORM cf; 3835 cf.dwStyle = CFS_POINT; 3836 ImmGetCandidateWindow(hIMC, 0, &cf); 3837 if (x != cf.ptCurrentPos.x || y != cf.ptCurrentPos.y) { 3838 cf.dwIndex = iCandType; 3839 cf.dwStyle = CFS_POINT; 3840 cf.ptCurrentPos = {x, y}; 3841 cf.rcArea = {0, 0, 0, 0}; 3842 ImmSetCandidateWindow(hIMC, &cf); 3843 } 3844 COMPOSITIONFORM cfr; 3845 cfr.dwStyle = CFS_POINT; 3846 ImmGetCompositionWindow(hIMC, &cfr); 3847 if (x != cfr.ptCurrentPos.x || y != cfr.ptCurrentPos.y) { 3848 cfr.dwStyle = CFS_POINT; 3849 cfr.ptCurrentPos = {x, y}; 3850 cfr.rcArea = {0, 0, 0, 0}; 3851 ImmSetCompositionWindow(hIMC, &cfr); 3852 } 3853 ImmReleaseContext(hwnd, hIMC); 3854 } 3855 } 3856 3857 MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam) 3858 { 3859 // If the Windows input context is disabled, do not let Windows 3860 // display any UIs. 3861 HWND hwnd = ImmGetHWnd(); 3862 HIMC hIMC = ImmGetContext(hwnd); 3863 if (hIMC == NULL) { 3864 *lplParam = 0; 3865 return mrDoDefault; 3866 } 3867 ImmReleaseContext(hwnd, hIMC); 3868 3869 if (fSet) { 3870 LPARAM lParam = *lplParam; 3871 if (!m_useNativeCompWindow) { 3872 // stop to draw native composing window. 3873 *lplParam &= ~ISC_SHOWUICOMPOSITIONWINDOW; 3874 } 3875 } 3876 return mrDoDefault; 3877 } 3878 3879 MsgRouting AwtComponent::WmImeNotify(WPARAM subMsg, LPARAM bitsCandType) 3880 { 3881 if (!m_useNativeCompWindow) { 3882 if (subMsg == IMN_OPENCANDIDATE || subMsg == IMN_CHANGECANDIDATE) { 3883 m_bitsCandType = bitsCandType; 3884 InquireCandidatePosition(); 3885 } else if (subMsg == IMN_OPENSTATUSWINDOW || 3886 subMsg == WM_IME_STARTCOMPOSITION || 3887 subMsg == IMN_SETCANDIDATEPOS) { 3888 InquireCandidatePosition(); 3889 } 3890 return mrConsume; 3891 } 3892 return mrDoDefault; 3893 } 3894 3895 MsgRouting AwtComponent::WmImeStartComposition() 3896 { 3897 if (m_useNativeCompWindow) { 3898 RECT rc; 3899 ::GetClientRect(GetHWnd(), &rc); 3900 SetCompositionWindow(rc); 3901 return mrDoDefault; 3902 } else 3903 return mrConsume; 3904 } 3905 3906 MsgRouting AwtComponent::WmImeEndComposition() 3907 { |