// Create a new AwtTextField object and window. AwtTextField* AwtTextField::Create(jobject peer, jobject hParent) { JNIEnv *env; if (JVM->AttachCurrentThread((void **) &env, 0) != 0) { return NULL; } CHECK_NULL_RETURN(hParent, "null hParent"); AwtCanvas* parent = (AwtCanvas*) env->GetIntField(hParent, WCachedIDs.PPCObjectPeer_pDataFID); CHECK_NULL_RETURN(parent, "null parent"); jobject target = env->GetObjectField(peer, WCachedIDs.PPCObjectPeer_targetFID); CHECK_NULL_RETURN(target, "null target"); AwtTextField* c = new AwtTextField(); CHECK_NULL_RETURN(c, "AwtTextField() failed"); DWORD style = WS_CHILD | WS_CLIPSIBLINGS | ES_LEFT | ES_AUTOHSCROLL | ES_NOHIDESEL | (IS_WIN4X ? 0 : WS_BORDER); DWORD exStyle = IS_WIN4X ? WS_EX_CLIENTEDGE : 0; c->CreateHWnd(TEXT(""), style, exStyle, (int)env->CallIntMethod(target, WCachedIDs.java_awt_Component_getXMID), (int)env->CallIntMethod(target, WCachedIDs.java_awt_Component_getYMID), (int)env->CallIntMethod(target,WCachedIDs.java_awt_Component_getWidthMID), (int)env->CallIntMethod(target,WCachedIDs.java_awt_Component_getHeightMID), parent->GetHWnd(), (HMENU)parent->CreateControlID(), ::GetSysColor(COLOR_WINDOWTEXT), ::GetSysColor(COLOR_WINDOW), peer ); c->m_backgroundColorSet = TRUE; // suppress inheriting parent's color. return c; }
/* Create a new AwtTextField object and window. */ AwtTextField* AwtTextField::Create(jobject peer, jobject parent) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); jobject target = NULL; AwtTextField* c = NULL; try { PDATA pData; AwtCanvas* awtParent; JNI_CHECK_PEER_GOTO(parent, done); awtParent = (AwtCanvas*)pData; JNI_CHECK_NULL_GOTO(awtParent, "null awtParent", done); target = env->GetObjectField(peer, AwtObject::targetID); JNI_CHECK_NULL_GOTO(target, "null target", done); c = new AwtTextField(); { DWORD style = WS_CHILD | WS_CLIPSIBLINGS | ES_LEFT | ES_AUTOHSCROLL | (IS_WIN4X ? 0 : WS_BORDER); DWORD exStyle = IS_WIN4X ? WS_EX_CLIENTEDGE : 0; if (GetRTL()) { exStyle |= WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR; if (GetRTLReadingOrder()) exStyle |= WS_EX_RTLREADING; } jint x = env->GetIntField(target, AwtComponent::xID); jint y = env->GetIntField(target, AwtComponent::yID); jint width = env->GetIntField(target, AwtComponent::widthID); jint height = env->GetIntField(target, AwtComponent::heightID); c->CreateHWnd(env, L"", style, exStyle, x, y, width, height, awtParent->GetHWnd(), reinterpret_cast<HMENU>(static_cast<INT_PTR>( awtParent->CreateControlID())), ::GetSysColor(COLOR_WINDOWTEXT), ::GetSysColor(COLOR_WINDOW), peer); c->m_backgroundColorSet = TRUE; /* suppress inheriting parent's color. */ c->UpdateBackground(env, target); c->SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(1, 1)); /* * Fix for BugTraq Id 4260109. * Set the text limit to the maximum. */ c->SendMessage(EM_SETLIMITTEXT); } } catch (...) { env->DeleteLocalRef(target); throw; } done: env->DeleteLocalRef(target); return c; }