< prev index next >

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

Print this page


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


  40 
  41 extern "C" {
  42 
  43 /*
  44  * Class:     java_awt_Color
  45  * Method:    initIDs
  46  * Signature: ()V;
  47  */
  48 JNIEXPORT void JNICALL
  49 Java_java_awt_Color_initIDs(JNIEnv *env, jclass cls)
  50 {
  51     TRY;
  52 
  53     AwtColor::getRGBMID = env->GetMethodID(cls, "getRGB", "()I");
  54     DASSERT(AwtColor::getRGBMID != NULL);
  55 
  56     CATCH_BAD_ALLOC;
  57 }
  58 
  59 } /* extern "C" */
  60 
  61 /************************************************************************
  62  * WColor native methods
  63  */
  64 
  65 extern "C" {
  66 
  67 /*
  68  * Class:     sun_awt_windows_WColor
  69  * Method:    getDefaultColor
  70  * Signature: (I)Ljava/awt/Color;
  71  */
  72 JNIEXPORT jobject JNICALL
  73 Java_sun_awt_windows_WColor_getDefaultColor(JNIEnv *env, jclass cls,
  74                                             jint index)
  75 {
  76     TRY;
  77 
  78     int iColor = 0;
  79     switch(index) {
  80 
  81     case sun_awt_windows_WColor_WINDOW_BKGND:
  82         iColor = COLOR_WINDOW;
  83         break;
  84     case sun_awt_windows_WColor_WINDOW_TEXT:
  85         iColor = COLOR_WINDOWTEXT;
  86         break;
  87     case sun_awt_windows_WColor_FRAME:
  88         iColor = COLOR_WINDOWFRAME;
  89         break;
  90     case sun_awt_windows_WColor_SCROLLBAR:
  91         iColor = COLOR_SCROLLBAR;
  92         break;
  93     case sun_awt_windows_WColor_MENU_BKGND:
  94         iColor = COLOR_MENU;
  95         break;
  96     case sun_awt_windows_WColor_MENU_TEXT:
  97         iColor = COLOR_MENUTEXT;
  98         break;
  99     case sun_awt_windows_WColor_BUTTON_BKGND:
 100         iColor = COLOR_BTNFACE;
 101         break;
 102     case sun_awt_windows_WColor_BUTTON_TEXT:
 103         iColor = COLOR_BTNTEXT;
 104         break;
 105     case sun_awt_windows_WColor_HIGHLIGHT:
 106         iColor = COLOR_HIGHLIGHT;
 107         break;
 108 
 109     default:
 110         return NULL;
 111     }
 112     DWORD c = ::GetSysColor(iColor);
 113 
 114     jobject wColor = JNU_NewObjectByName(env, "java/awt/Color", "(III)V",
 115                                          GetRValue(c), GetGValue(c),
 116                                          GetBValue(c));
 117 
 118     DASSERT(!safe_ExceptionOccurred(env));
 119     return wColor;
 120 
 121     CATCH_BAD_ALLOC_RET(NULL);
 122 }
 123 
 124 } /* extern "C" */
   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


  40 
  41 extern "C" {
  42 
  43 /*
  44  * Class:     java_awt_Color
  45  * Method:    initIDs
  46  * Signature: ()V;
  47  */
  48 JNIEXPORT void JNICALL
  49 Java_java_awt_Color_initIDs(JNIEnv *env, jclass cls)
  50 {
  51     TRY;
  52 
  53     AwtColor::getRGBMID = env->GetMethodID(cls, "getRGB", "()I");
  54     DASSERT(AwtColor::getRGBMID != NULL);
  55 
  56     CATCH_BAD_ALLOC;
  57 }
  58 
  59 } /* extern "C" */

































































< prev index next >