src/windows/native/sun/windows/awt_TextComponent.cpp

Print this page




 172     if (m_synthetic) {
 173         JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 174         if (env->EnsureLocalCapacity(1) < 0) {
 175             return mrConsume;
 176         }
 177         jobject target = GetTarget(env);
 178         jboolean canAccessClipboard =
 179             env->GetBooleanField(target,
 180                                  AwtTextComponent::canAccessClipboardID);
 181         env->DeleteLocalRef(target);
 182         return (canAccessClipboard) ? mrDoDefault : mrConsume;
 183     }
 184     else {
 185         return mrDoDefault;
 186     }
 187 }
 188 
 189 //im --- override to over the spot composition
 190 void AwtTextComponent::SetCompositionWindow(RECT& rc)
 191 {
 192     HIMC hIMC = ImmGetContext();

 193     // rc is not used for text component.
 194     COMPOSITIONFORM cf = { CFS_FORCE_POSITION, {0,0}, {0,0,0,0} };
 195     GetCaretPos(&(cf.ptCurrentPos));
 196     // the proxy is the native focus owner and it contains the composition window
 197     // let's convert the position to a coordinate space relative to proxy
 198     ::MapWindowPoints(GetHWnd(), GetProxyFocusOwner(), (LPPOINT)&cf.ptCurrentPos, 1);
 199     ImmSetCompositionWindow(hIMC, &cf);
 200 
 201     LOGFONT lf;
 202     GetObject(m_hFont, sizeof(LOGFONT), &lf);
 203     ImmSetCompositionFont(hIMC, &lf);

 204 }
 205 //im --- end
 206 
 207 LONG AwtTextComponent::getJavaSelPos(LONG orgPos)
 208 {
 209     long wlen;
 210     long pos = 0;
 211     long cur = 0;
 212     LPTSTR wbuf;
 213 
 214     if ((wlen = GetTextLength()) == 0)
 215         return 0;
 216     wbuf = new TCHAR[wlen + 1];
 217     GetText(wbuf, wlen + 1);
 218     if (m_isLFonly == TRUE) {
 219         wlen = RemoveCR(wbuf);
 220     }
 221 
 222     while (cur < orgPos && pos++ < wlen) {
 223         if (wbuf[cur] == _T('\r') && wbuf[cur + 1] == _T('\n')) {




 172     if (m_synthetic) {
 173         JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 174         if (env->EnsureLocalCapacity(1) < 0) {
 175             return mrConsume;
 176         }
 177         jobject target = GetTarget(env);
 178         jboolean canAccessClipboard =
 179             env->GetBooleanField(target,
 180                                  AwtTextComponent::canAccessClipboardID);
 181         env->DeleteLocalRef(target);
 182         return (canAccessClipboard) ? mrDoDefault : mrConsume;
 183     }
 184     else {
 185         return mrDoDefault;
 186     }
 187 }
 188 
 189 //im --- override to over the spot composition
 190 void AwtTextComponent::SetCompositionWindow(RECT& rc)
 191 {
 192     HWND hwnd = ImmGetHWnd();
 193     HIMC hIMC = ImmGetContext(hwnd);
 194     // rc is not used for text component.
 195     COMPOSITIONFORM cf = { CFS_FORCE_POSITION, {0,0}, {0,0,0,0} };
 196     GetCaretPos(&(cf.ptCurrentPos));
 197     // the proxy is the native focus owner and it contains the composition window
 198     // let's convert the position to a coordinate space relative to proxy
 199     ::MapWindowPoints(GetHWnd(), GetProxyFocusOwner(), (LPPOINT)&cf.ptCurrentPos, 1);
 200     ImmSetCompositionWindow(hIMC, &cf);
 201 
 202     LOGFONT lf;
 203     GetObject(m_hFont, sizeof(LOGFONT), &lf);
 204     ImmSetCompositionFont(hIMC, &lf);
 205     ImmReleaseContext(hwnd, hIMC);
 206 }
 207 //im --- end
 208 
 209 LONG AwtTextComponent::getJavaSelPos(LONG orgPos)
 210 {
 211     long wlen;
 212     long pos = 0;
 213     long cur = 0;
 214     LPTSTR wbuf;
 215 
 216     if ((wlen = GetTextLength()) == 0)
 217         return 0;
 218     wbuf = new TCHAR[wlen + 1];
 219     GetText(wbuf, wlen + 1);
 220     if (m_isLFonly == TRUE) {
 221         wlen = RemoveCR(wbuf);
 222     }
 223 
 224     while (cur < orgPos && pos++ < wlen) {
 225         if (wbuf[cur] == _T('\r') && wbuf[cur + 1] == _T('\n')) {