< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_Component.cpp

Print this page


   1 /*
   2  * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


4305     if ((int) (drawInfo.itemID) >= 0) {
4306             jobject font = GET_FONT(target, peer);
4307             jstring text = GetItemString(env, target, drawInfo.itemID);
4308             if (env->ExceptionCheck()) {
4309                 env->DeleteLocalRef(font);
4310                 env->DeleteLocalRef(target);
4311                 return;
4312             }
4313             SIZE size = AwtFont::getMFStringSize(hDC, font, text);
4314             AwtFont::drawMFString(hDC, font, text,
4315                                   (GetRTL()) ? rect.right - size.cx - 1
4316                                              : rect.left + 1,
4317                                   (rect.top + rect.bottom - size.cy) / 2,
4318                                   GetCodePage());
4319             env->DeleteLocalRef(font);
4320             env->DeleteLocalRef(text);
4321     }
4322     if ((drawInfo.itemState & ODS_FOCUS)  &&
4323         (drawInfo.itemAction & (ODA_FOCUS | ODA_DRAWENTIRE))) {
4324       if (!unfocusableChoice){
4325           VERIFY(::DrawFocusRect(hDC, &rect));

4326       }
4327     }
4328     env->DeleteLocalRef(target);
4329 }
4330 
4331 /* for MeasureListItem method and WmDrawItem method of Checkbox */
4332 jint AwtComponent::GetFontHeight(JNIEnv *env)
4333 {
4334     if (env->EnsureLocalCapacity(4) < 0) {
4335         return NULL;
4336     }
4337     jobject self = GetPeer(env);
4338     jobject target = env->GetObjectField(self, AwtObject::targetID);
4339 
4340     jobject font = GET_FONT(target, self);
4341     jobject toolkit = env->CallObjectMethod(target,
4342                                             AwtComponent::getToolkitMID);
4343 
4344     DASSERT(!safe_ExceptionOccurred(env));
4345 


   1 /*
   2  * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


4305     if ((int) (drawInfo.itemID) >= 0) {
4306             jobject font = GET_FONT(target, peer);
4307             jstring text = GetItemString(env, target, drawInfo.itemID);
4308             if (env->ExceptionCheck()) {
4309                 env->DeleteLocalRef(font);
4310                 env->DeleteLocalRef(target);
4311                 return;
4312             }
4313             SIZE size = AwtFont::getMFStringSize(hDC, font, text);
4314             AwtFont::drawMFString(hDC, font, text,
4315                                   (GetRTL()) ? rect.right - size.cx - 1
4316                                              : rect.left + 1,
4317                                   (rect.top + rect.bottom - size.cy) / 2,
4318                                   GetCodePage());
4319             env->DeleteLocalRef(font);
4320             env->DeleteLocalRef(text);
4321     }
4322     if ((drawInfo.itemState & ODS_FOCUS)  &&
4323         (drawInfo.itemAction & (ODA_FOCUS | ODA_DRAWENTIRE))) {
4324       if (!unfocusableChoice){
4325           if(::DrawFocusRect(hDC, &rect) == 0)
4326               VERIFY(::GetLastError() == 0);
4327       }
4328     }
4329     env->DeleteLocalRef(target);
4330 }
4331 
4332 /* for MeasureListItem method and WmDrawItem method of Checkbox */
4333 jint AwtComponent::GetFontHeight(JNIEnv *env)
4334 {
4335     if (env->EnsureLocalCapacity(4) < 0) {
4336         return NULL;
4337     }
4338     jobject self = GetPeer(env);
4339     jobject target = env->GetObjectField(self, AwtObject::targetID);
4340 
4341     jobject font = GET_FONT(target, self);
4342     jobject toolkit = env->CallObjectMethod(target,
4343                                             AwtComponent::getToolkitMID);
4344 
4345     DASSERT(!safe_ExceptionOccurred(env));
4346 


< prev index next >