Path: blob/master/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java
41154 views
/*1* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.apple.laf;2627import java.awt.*;28import java.awt.image.BufferedImage;2930import javax.swing.plaf.UIResource;3132import com.apple.laf.AquaUtils.RecyclableSingleton;3334@SuppressWarnings("removal")35public class AquaNativeResources {36static {37java.security.AccessController.doPrivileged(38new java.security.PrivilegedAction<Void>() {39public Void run() {40System.loadLibrary("osxui");41return null;42}43});44}4546// TODO: removing CColorPaint for now47@SuppressWarnings("serial") // JDK implementation class48static class CColorPaintUIResource extends Color/*CColorPaint*/ implements UIResource {49// The color passed to this MUST be a retained NSColor, and the CColorPaintUIResource50// takes ownership of that retain.51public CColorPaintUIResource(long color, int r, int g, int b, int a) {52super(r, g, b, a);53//super(color, r, g, b, a);54}55}5657private static final RecyclableSingleton<Color> sBackgroundColor = new RecyclableSingleton<Color>() {58@Override59protected Color getInstance() {60final long backgroundID = getWindowBackgroundColor();61return new CColorPaintUIResource(backgroundID, 0xEE, 0xEE, 0xEE, 0xFF);62}63};64private static native long getWindowBackgroundColor();65public static Color getWindowBackgroundColorUIResource() {66return sBackgroundColor.get();67}6869static BufferedImage getRadioButtonSizerImage() {70final BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB_PRE);7172Graphics g = img.getGraphics();73g.setColor(Color.pink);74g.fillRect(0, 0, 20, 20);75g.dispose();7677return img;78}79}808182