void AwtCheckbox::_SetLabel(void *param) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); SetLabelStruct *sls = (SetLabelStruct *)param; jobject checkbox = sls->checkbox; jstring label = sls->label; int badAlloc = 0; AwtCheckbox *c = NULL; PDATA pData; JNI_CHECK_PEER_GOTO(checkbox, done); c = (AwtCheckbox *)pData; if (::IsWindow(c->GetHWnd())) { LPCTSTR labelStr = NULL; // By convension null label means empty string if (label == NULL) { labelStr = TEXT(""); } else { labelStr = JNU_GetStringPlatformChars(env, label, JNI_FALSE); } if (labelStr == NULL) { badAlloc = 1; } else { c->SetText(labelStr); c->VerifyState(); if (label != NULL) { JNU_ReleaseStringPlatformChars(env, label, labelStr); } } } done: env->DeleteGlobalRef(checkbox); if (label != NULL) { env->DeleteGlobalRef(label); } delete sls; if (badAlloc) { throw std::bad_alloc(); } }
void AwtCheckbox::_SetState(void *param) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); SetStateStruct *sss = (SetStateStruct *)param; jobject checkbox = sss->checkbox; jboolean state = sss->state; AwtCheckbox *c = NULL; PDATA pData; JNI_CHECK_PEER_GOTO(checkbox, done); c = (AwtCheckbox *)pData; if (::IsWindow(c->GetHWnd())) { /* * when multifont and group checkbox receive setState native * method, it must be redraw to display correct check mark */ jobject target = env->GetObjectField(checkbox, AwtObject::targetID); jobject group = env->GetObjectField(target, AwtCheckbox::groupID); HWND hWnd = c->GetHWnd(); if (group != NULL) { RECT rect; VERIFY(::GetWindowRect(hWnd, &rect)); VERIFY(::ScreenToClient(hWnd, (LPPOINT)&rect)); VERIFY(::ScreenToClient(hWnd, ((LPPOINT)&rect) + 1)); VERIFY(::InvalidateRect(hWnd, &rect,TRUE)); VERIFY(::UpdateWindow(hWnd)); } else { c->SendMessage(BM_SETCHECK, (WPARAM)(state ? BST_CHECKED : BST_UNCHECKED)); VERIFY(::InvalidateRect(hWnd, NULL, FALSE)); } c->VerifyState(); env->DeleteLocalRef(target); env->DeleteLocalRef(group); } done: env->DeleteGlobalRef(checkbox); delete sss; }
void AwtCheckbox::_SetCheckboxGroup(void *param) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); jobject *jos = (jobject *)param; jobject checkbox = jos[0]; jobject group = jos[1]; AwtCheckbox *c = NULL; PDATA pData; JNI_CHECK_PEER_GOTO(checkbox, done); c = (AwtCheckbox *)pData; if (::IsWindow(c->GetHWnd())) { /* #ifdef DEBUG if (group != NULL) { DASSERT(IsInstanceOf((HObject*)group, "java/awt/CheckboxGroup")); } #endif */ long style = c->GetStyle(); if (group == NULL) { style = style & ~BS_AUTORADIOBUTTON; style = style | BS_AUTOCHECKBOX; } else { style = style & ~BS_AUTOCHECKBOX; style = style | BS_AUTORADIOBUTTON; } c->SetStyle(style); c->SendMessage(BM_SETSTYLE, (WPARAM)BS_OWNERDRAW, (LPARAM)TRUE); c->VerifyState(); } done: env->DeleteGlobalRef(checkbox); if (group != NULL) { env->DeleteGlobalRef(group); } delete[] jos; }