< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 1996, 2019, 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


  52 };
  53 // struct for _SetEnable() method
  54 struct SetEnableStruct {
  55     jobject menuitem;
  56     jboolean isEnabled;
  57 };
  58 // struct for _setState() method
  59 struct SetStateStruct {
  60     jobject menuitem;
  61     jboolean isChecked;
  62 };
  63 /************************************************************************
  64  * AwtMenuItem fields
  65  */
  66 
  67 HBITMAP AwtMenuItem::bmpCheck;
  68 jobject AwtMenuItem::systemFont;
  69 
  70 jfieldID AwtMenuItem::labelID;
  71 jfieldID AwtMenuItem::enabledID;


  72 jfieldID AwtMenuItem::shortcutLabelID;
  73 jfieldID AwtMenuItem::isCheckboxID;
  74 jfieldID AwtMenuItem::stateID;
  75 
  76 jmethodID AwtMenuItem::getDefaultFontMID;
  77 
  78 // Added by waleed to initialize the RTL Flags
  79 LANGID AwtMenuItem::m_idLang = LOWORD(GetKeyboardLayout(0));
  80 UINT AwtMenuItem::m_CodePage =
  81     AwtMenuItem::LangToCodePage(AwtMenuItem::m_idLang);
  82 BOOL AwtMenuItem::sm_rtl = PRIMARYLANGID(GetInputLanguage()) == LANG_ARABIC ||
  83                            PRIMARYLANGID(GetInputLanguage()) == LANG_HEBREW;
  84 BOOL AwtMenuItem::sm_rtlReadingOrder =
  85     PRIMARYLANGID(GetInputLanguage()) == LANG_ARABIC;
  86 
  87 /*
  88  * This constant holds width of the default menu
  89  * check-mark bitmap for default settings on XP/Vista,
  90  * in pixels
  91  */


 939     }
 940     LPCWSTR labelW = JNU_GetStringPlatformChars(env, label, NULL);
 941     BOOL isSeparator = (labelW && (wcscmp(labelW, L"-") == 0));
 942     JNU_ReleaseStringPlatformChars(env, label, labelW);
 943 
 944     env->DeleteLocalRef(label);
 945     env->DeleteLocalRef(jitem);
 946 
 947     return isSeparator;
 948 }
 949 
 950 /************************************************************************
 951  * MenuComponent native methods
 952  */
 953 
 954 extern "C" {
 955 
 956 JNIEXPORT void JNICALL
 957 Java_java_awt_MenuComponent_initIDs(JNIEnv *env, jclass cls)
 958 {







 959 }
 960 
 961 } /* extern "C" */
 962 
 963 
 964 /************************************************************************
 965  * MenuItem native methods
 966  */
 967 
 968 extern "C" {
 969 
 970 JNIEXPORT void JNICALL
 971 Java_java_awt_MenuItem_initIDs(JNIEnv *env, jclass cls)
 972 {
 973     TRY;
 974 
 975     AwtMenuItem::labelID = env->GetFieldID(cls, "label", "Ljava/lang/String;");
 976     CHECK_NULL(AwtMenuItem::labelID);
 977     AwtMenuItem::enabledID = env->GetFieldID(cls, "enabled", "Z");
 978 


   1 /*
   2  * Copyright (c) 1996, 2017, 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


  52 };
  53 // struct for _SetEnable() method
  54 struct SetEnableStruct {
  55     jobject menuitem;
  56     jboolean isEnabled;
  57 };
  58 // struct for _setState() method
  59 struct SetStateStruct {
  60     jobject menuitem;
  61     jboolean isChecked;
  62 };
  63 /************************************************************************
  64  * AwtMenuItem fields
  65  */
  66 
  67 HBITMAP AwtMenuItem::bmpCheck;
  68 jobject AwtMenuItem::systemFont;
  69 
  70 jfieldID AwtMenuItem::labelID;
  71 jfieldID AwtMenuItem::enabledID;
  72 jfieldID AwtMenuItem::fontID;
  73 jfieldID AwtMenuItem::appContextID;
  74 jfieldID AwtMenuItem::shortcutLabelID;
  75 jfieldID AwtMenuItem::isCheckboxID;
  76 jfieldID AwtMenuItem::stateID;
  77 
  78 jmethodID AwtMenuItem::getDefaultFontMID;
  79 
  80 // Added by waleed to initialize the RTL Flags
  81 LANGID AwtMenuItem::m_idLang = LOWORD(GetKeyboardLayout(0));
  82 UINT AwtMenuItem::m_CodePage =
  83     AwtMenuItem::LangToCodePage(AwtMenuItem::m_idLang);
  84 BOOL AwtMenuItem::sm_rtl = PRIMARYLANGID(GetInputLanguage()) == LANG_ARABIC ||
  85                            PRIMARYLANGID(GetInputLanguage()) == LANG_HEBREW;
  86 BOOL AwtMenuItem::sm_rtlReadingOrder =
  87     PRIMARYLANGID(GetInputLanguage()) == LANG_ARABIC;
  88 
  89 /*
  90  * This constant holds width of the default menu
  91  * check-mark bitmap for default settings on XP/Vista,
  92  * in pixels
  93  */


 941     }
 942     LPCWSTR labelW = JNU_GetStringPlatformChars(env, label, NULL);
 943     BOOL isSeparator = (labelW && (wcscmp(labelW, L"-") == 0));
 944     JNU_ReleaseStringPlatformChars(env, label, labelW);
 945 
 946     env->DeleteLocalRef(label);
 947     env->DeleteLocalRef(jitem);
 948 
 949     return isSeparator;
 950 }
 951 
 952 /************************************************************************
 953  * MenuComponent native methods
 954  */
 955 
 956 extern "C" {
 957 
 958 JNIEXPORT void JNICALL
 959 Java_java_awt_MenuComponent_initIDs(JNIEnv *env, jclass cls)
 960 {
 961     TRY;
 962 
 963     AwtMenuItem::fontID = env->GetFieldID(cls, "font", "Ljava/awt/Font;");
 964     CHECK_NULL(AwtMenuItem::fontID);
 965     AwtMenuItem::appContextID = env->GetFieldID(cls, "appContext", "Lsun/awt/AppContext;");
 966 
 967     CATCH_BAD_ALLOC;
 968 }
 969 
 970 } /* extern "C" */
 971 
 972 
 973 /************************************************************************
 974  * MenuItem native methods
 975  */
 976 
 977 extern "C" {
 978 
 979 JNIEXPORT void JNICALL
 980 Java_java_awt_MenuItem_initIDs(JNIEnv *env, jclass cls)
 981 {
 982     TRY;
 983 
 984     AwtMenuItem::labelID = env->GetFieldID(cls, "label", "Ljava/lang/String;");
 985     CHECK_NULL(AwtMenuItem::labelID);
 986     AwtMenuItem::enabledID = env->GetFieldID(cls, "enabled", "Z");
 987 


< prev index next >