< prev index next >

jdk/src/java.desktop/windows/native/libawt/windows/awt_TextComponent.cpp

Print this page




 494         return;
 495     }
 496 
 497     if (GetTextLength() == 0) {
 498         m_EOLchecked = FALSE;
 499     }
 500 
 501     // check to see if there are any LF's
 502     if (m_EOLchecked == TRUE || wcschr(pStr, L'\n') == NULL) {
 503         return;
 504     }
 505 
 506     for (int i=0; pStr[i] != 0; i++) {
 507         if (pStr[i] == L'\n') {
 508             if (i > 0 && pStr[i-1] == L'\r') {
 509                 m_isLFonly = FALSE;
 510             } else {
 511                 m_isLFonly = TRUE;
 512             }
 513             m_EOLchecked = TRUE;
 514             return;
 515         }
 516     }
 517 }
 518 
 519 void AwtTextComponent::SetSelRange(LONG start, LONG end)
 520 {
 521     SendMessage(EM_SETSEL,
 522                 getWin32SelPos(start),
 523                 getWin32SelPos(end));
 524     // it isn't necessary to wrap this in EM_HIDESELECTION or setting/clearing
 525     // ES_NOHIDESEL, as regular edit control honors EM_SCROLLCARET even when not in focus
 526 }
 527 
 528 jstring AwtTextComponent::_GetText(void *param)
 529 {
 530     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 531 
 532     jobject self = (jobject)param;
 533 
 534     AwtTextComponent *c = NULL;


 573 {
 574     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 575 
 576     SetTextStruct *sts = (SetTextStruct *)param;
 577     jobject self = sts->textcomponent;
 578     jstring text = sts->text;
 579 
 580     AwtTextComponent *c = NULL;
 581 
 582     PDATA pData;
 583     JNI_CHECK_PEER_GOTO(self, ret);
 584     c = (AwtTextComponent *)pData;
 585     if (::IsWindow(c->GetHWnd()))
 586     {
 587         int length = env->GetStringLength(text);
 588         WCHAR* buffer = new WCHAR[length + 1];
 589         env->GetStringRegion(text, 0, length, reinterpret_cast<jchar*>(buffer));
 590         buffer[length] = 0;
 591         c->CheckLineSeparator(buffer);
 592         c->RemoveCR(buffer);

 593         c->SetText(buffer);
 594         delete[] buffer;
 595     }
 596 ret:
 597     env->DeleteGlobalRef(self);
 598     env->DeleteGlobalRef(text);
 599 
 600     delete sts;
 601 }
 602 
 603 jint AwtTextComponent::_GetSelectionStart(void *param)
 604 {
 605     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 606 
 607     jobject self = (jobject)param;
 608 
 609     jint result = 0;
 610     AwtTextComponent *c = NULL;
 611 
 612     PDATA pData;




 494         return;
 495     }
 496 
 497     if (GetTextLength() == 0) {
 498         m_EOLchecked = FALSE;
 499     }
 500 
 501     // check to see if there are any LF's
 502     if (m_EOLchecked == TRUE || wcschr(pStr, L'\n') == NULL) {
 503         return;
 504     }
 505 
 506     for (int i=0; pStr[i] != 0; i++) {
 507         if (pStr[i] == L'\n') {
 508             if (i > 0 && pStr[i-1] == L'\r') {
 509                 m_isLFonly = FALSE;
 510             } else {
 511                 m_isLFonly = TRUE;
 512             }
 513             m_EOLchecked = TRUE;

 514         }
 515     }
 516 }
 517 
 518 void AwtTextComponent::SetSelRange(LONG start, LONG end)
 519 {
 520     SendMessage(EM_SETSEL,
 521                 getWin32SelPos(start),
 522                 getWin32SelPos(end));
 523     // it isn't necessary to wrap this in EM_HIDESELECTION or setting/clearing
 524     // ES_NOHIDESEL, as regular edit control honors EM_SCROLLCARET even when not in focus
 525 }
 526 
 527 jstring AwtTextComponent::_GetText(void *param)
 528 {
 529     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 530 
 531     jobject self = (jobject)param;
 532 
 533     AwtTextComponent *c = NULL;


 572 {
 573     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 574 
 575     SetTextStruct *sts = (SetTextStruct *)param;
 576     jobject self = sts->textcomponent;
 577     jstring text = sts->text;
 578 
 579     AwtTextComponent *c = NULL;
 580 
 581     PDATA pData;
 582     JNI_CHECK_PEER_GOTO(self, ret);
 583     c = (AwtTextComponent *)pData;
 584     if (::IsWindow(c->GetHWnd()))
 585     {
 586         int length = env->GetStringLength(text);
 587         WCHAR* buffer = new WCHAR[length + 1];
 588         env->GetStringRegion(text, 0, length, reinterpret_cast<jchar*>(buffer));
 589         buffer[length] = 0;
 590         c->CheckLineSeparator(buffer);
 591         c->RemoveCR(buffer);
 592         c->RemoveEOL(buffer);
 593         c->SetText(buffer);
 594         delete[] buffer;
 595     }
 596 ret:
 597     env->DeleteGlobalRef(self);
 598     env->DeleteGlobalRef(text);
 599 
 600     delete sts;
 601 }
 602 
 603 jint AwtTextComponent::_GetSelectionStart(void *param)
 604 {
 605     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 606 
 607     jobject self = (jobject)param;
 608 
 609     jint result = 0;
 610     AwtTextComponent *c = NULL;
 611 
 612     PDATA pData;


< prev index next >