328 ::GetClientRect(GetHWnd(), &rc);
329 env->SetIntField(target, AwtComponent::widthID, ScaleDownX(rc.right));
330 env->SetIntField(target, AwtComponent::heightID, ScaleDownY(rc.bottom));
331
332 env->DeleteLocalRef(target);
333 env->DeleteLocalRef(parent);
334 }
335
336 jobject AwtChoice::PreferredItemSize(JNIEnv *env)
337 {
338 jobject dimension = JNU_CallMethodByName(env, NULL, GetPeer(env),
339 "preferredSize",
340 "()Ljava/awt/Dimension;").l;
341 DASSERT(!safe_ExceptionOccurred(env));
342 CHECK_NULL_RETURN(dimension, NULL);
343
344 /* This size is window size of choice and it's too big for each
345 * drop down item height.
346 */
347 env->SetIntField(dimension, AwtDimension::heightID,
348 GetFontHeight(env));
349 return dimension;
350 }
351
352 void AwtChoice::SetFont(AwtFont* font)
353 {
354 AwtComponent::SetFont(font);
355
356 //Get the text metrics and change the height of each item.
357 HDC hDC = ::GetDC(GetHWnd());
358 DASSERT(hDC != NULL);
359 TEXTMETRIC tm;
360
361 HANDLE hFont = font->GetHFont();
362 VERIFY(::SelectObject(hDC, hFont) != NULL);
363 VERIFY(::GetTextMetrics(hDC, &tm));
364 long h = tm.tmHeight + tm.tmExternalLeading;
365 VERIFY(::ReleaseDC(GetHWnd(), hDC) != 0);
366
367 int nCount = (int)::SendMessage(GetHWnd(), CB_GETCOUNT, 0, 0);
368 for(int i = 0; i < nCount; ++i) {
|
328 ::GetClientRect(GetHWnd(), &rc);
329 env->SetIntField(target, AwtComponent::widthID, ScaleDownX(rc.right));
330 env->SetIntField(target, AwtComponent::heightID, ScaleDownY(rc.bottom));
331
332 env->DeleteLocalRef(target);
333 env->DeleteLocalRef(parent);
334 }
335
336 jobject AwtChoice::PreferredItemSize(JNIEnv *env)
337 {
338 jobject dimension = JNU_CallMethodByName(env, NULL, GetPeer(env),
339 "preferredSize",
340 "()Ljava/awt/Dimension;").l;
341 DASSERT(!safe_ExceptionOccurred(env));
342 CHECK_NULL_RETURN(dimension, NULL);
343
344 /* This size is window size of choice and it's too big for each
345 * drop down item height.
346 */
347 env->SetIntField(dimension, AwtDimension::heightID,
348 ScaleUpY(GetFontHeight(env)));
349 return dimension;
350 }
351
352 void AwtChoice::SetFont(AwtFont* font)
353 {
354 AwtComponent::SetFont(font);
355
356 //Get the text metrics and change the height of each item.
357 HDC hDC = ::GetDC(GetHWnd());
358 DASSERT(hDC != NULL);
359 TEXTMETRIC tm;
360
361 HANDLE hFont = font->GetHFont();
362 VERIFY(::SelectObject(hDC, hFont) != NULL);
363 VERIFY(::GetTextMetrics(hDC, &tm));
364 long h = tm.tmHeight + tm.tmExternalLeading;
365 VERIFY(::ReleaseDC(GetHWnd(), hDC) != 0);
366
367 int nCount = (int)::SendMessage(GetHWnd(), CB_GETCOUNT, 0, 0);
368 for(int i = 0; i < nCount; ++i) {
|