< prev index next >

src/windows/native/sun/windows/awt_Component.cpp

Print this page




3822 }
3823 
3824 // support IME Composition messages
3825 void AwtComponent::SetCompositionWindow(RECT& r)
3826 {
3827     HWND hwnd = ImmGetHWnd();
3828     HIMC hIMC = ImmGetContext(hwnd);
3829     if (hIMC == NULL) {
3830         return;
3831     }
3832     COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}};
3833     ImmSetCompositionWindow(hIMC, &cf);
3834     ImmReleaseContext(hwnd, hIMC);
3835 }
3836 
3837 void AwtComponent::OpenCandidateWindow(int x, int y)
3838 {
3839     UINT bits = 1;
3840     POINT p = {0, 0}; // upper left corner of the client area
3841     HWND hWnd = GetHWnd();



3842     HWND hTop = GetTopLevelParentForWindow(hWnd);
3843     ::ClientToScreen(hTop, &p);
3844     if (!m_bitsCandType) {
3845         SetCandidateWindow(m_bitsCandType, x - p.x, y - p.y);
3846         return;
3847     }
3848     for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
3849         if ( m_bitsCandType & bits )
3850             SetCandidateWindow(iCandType, x - p.x, y - p.y);
3851     }
3852 }
3853 
3854 void AwtComponent::SetCandidateWindow(int iCandType, int x, int y)
3855 {
3856     HWND hwnd = ImmGetHWnd();
3857     HIMC hIMC = ImmGetContext(hwnd);
3858     if (hIMC) {
3859         CANDIDATEFORM cf;
3860         cf.dwStyle = CFS_POINT;
3861         ImmGetCandidateWindow(hIMC, 0, &cf);


4104         DASSERT(sendIMEventMid);
4105         CHECK_NULL(sendIMEventMid);
4106     }
4107 
4108     // call m_InputMethod.sendInputMethod()
4109     env->CallVoidMethod(m_InputMethod, sendIMEventMid, id, TimeHelper::getMessageTimeUTC(),
4110                         text, clauseBoundary, clauseReading, attrBoundary,
4111                         attrValue, commitedTextLength, caretPos, visiblePos);
4112     if (safe_ExceptionOccurred(env))   env->ExceptionDescribe();
4113     DASSERT(!safe_ExceptionOccurred(env));
4114 
4115 }
4116 
4117 
4118 
4119 //
4120 // Inquires candidate position according to the composed text
4121 //
4122 void AwtComponent::InquireCandidatePosition()
4123 {



4124     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
4125 
4126     // get global reference of WInputMethod class (run only once)
4127     static jclass wInputMethodCls = NULL;
4128     if (wInputMethodCls == NULL) {
4129         jclass wInputMethodClsLocal = env->FindClass("sun/awt/windows/WInputMethod");
4130         DASSERT(wInputMethodClsLocal);
4131         CHECK_NULL(wInputMethodClsLocal);
4132         wInputMethodCls = (jclass)env->NewGlobalRef(wInputMethodClsLocal);
4133         env->DeleteLocalRef(wInputMethodClsLocal);
4134     }
4135 
4136     // get method ID of sendInputMethodEvent() (run only once)
4137     static jmethodID inqCandPosMid = 0;
4138     if (inqCandPosMid == 0) {
4139         inqCandPosMid =  env->GetMethodID(wInputMethodCls, "inquireCandidatePosition", "()V");
4140         DASSERT(!safe_ExceptionOccurred(env));
4141         DASSERT(inqCandPosMid);
4142         CHECK_NULL(inqCandPosMid);
4143     }




3822 }
3823 
3824 // support IME Composition messages
3825 void AwtComponent::SetCompositionWindow(RECT& r)
3826 {
3827     HWND hwnd = ImmGetHWnd();
3828     HIMC hIMC = ImmGetContext(hwnd);
3829     if (hIMC == NULL) {
3830         return;
3831     }
3832     COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}};
3833     ImmSetCompositionWindow(hIMC, &cf);
3834     ImmReleaseContext(hwnd, hIMC);
3835 }
3836 
3837 void AwtComponent::OpenCandidateWindow(int x, int y)
3838 {
3839     UINT bits = 1;
3840     POINT p = {0, 0}; // upper left corner of the client area
3841     HWND hWnd = GetHWnd();
3842     if (!::IsWindowVisible(hWnd)) {
3843         return;
3844     }
3845     HWND hTop = GetTopLevelParentForWindow(hWnd);
3846     ::ClientToScreen(hTop, &p);
3847     if (!m_bitsCandType) {
3848         SetCandidateWindow(m_bitsCandType, x - p.x, y - p.y);
3849         return;
3850     }
3851     for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
3852         if ( m_bitsCandType & bits )
3853             SetCandidateWindow(iCandType, x - p.x, y - p.y);
3854     }
3855 }
3856 
3857 void AwtComponent::SetCandidateWindow(int iCandType, int x, int y)
3858 {
3859     HWND hwnd = ImmGetHWnd();
3860     HIMC hIMC = ImmGetContext(hwnd);
3861     if (hIMC) {
3862         CANDIDATEFORM cf;
3863         cf.dwStyle = CFS_POINT;
3864         ImmGetCandidateWindow(hIMC, 0, &cf);


4107         DASSERT(sendIMEventMid);
4108         CHECK_NULL(sendIMEventMid);
4109     }
4110 
4111     // call m_InputMethod.sendInputMethod()
4112     env->CallVoidMethod(m_InputMethod, sendIMEventMid, id, TimeHelper::getMessageTimeUTC(),
4113                         text, clauseBoundary, clauseReading, attrBoundary,
4114                         attrValue, commitedTextLength, caretPos, visiblePos);
4115     if (safe_ExceptionOccurred(env))   env->ExceptionDescribe();
4116     DASSERT(!safe_ExceptionOccurred(env));
4117 
4118 }
4119 
4120 
4121 
4122 //
4123 // Inquires candidate position according to the composed text
4124 //
4125 void AwtComponent::InquireCandidatePosition()
4126 {
4127     if (!::IsWindowVisible(GetHWnd())) {
4128         return;
4129     }
4130     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
4131 
4132     // get global reference of WInputMethod class (run only once)
4133     static jclass wInputMethodCls = NULL;
4134     if (wInputMethodCls == NULL) {
4135         jclass wInputMethodClsLocal = env->FindClass("sun/awt/windows/WInputMethod");
4136         DASSERT(wInputMethodClsLocal);
4137         CHECK_NULL(wInputMethodClsLocal);
4138         wInputMethodCls = (jclass)env->NewGlobalRef(wInputMethodClsLocal);
4139         env->DeleteLocalRef(wInputMethodClsLocal);
4140     }
4141 
4142     // get method ID of sendInputMethodEvent() (run only once)
4143     static jmethodID inqCandPosMid = 0;
4144     if (inqCandPosMid == 0) {
4145         inqCandPosMid =  env->GetMethodID(wInputMethodCls, "inquireCandidatePosition", "()V");
4146         DASSERT(!safe_ExceptionOccurred(env));
4147         DASSERT(inqCandPosMid);
4148         CHECK_NULL(inqCandPosMid);
4149     }


< prev index next >