4632N/A/*
4632N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4632N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4632N/A *
4632N/A * This code is free software; you can redistribute it and/or modify it
4632N/A * under the terms of the GNU General Public License version 2 only, as
4632N/A * published by the Free Software Foundation. Oracle designates this
4632N/A * particular file as subject to the "Classpath" exception as provided
4632N/A * by Oracle in the LICENSE file that accompanied this code.
4632N/A *
4632N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4632N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4632N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4632N/A * version 2 for more details (a copy is included in the LICENSE file that
4632N/A * accompanied this code).
4632N/A *
4632N/A * You should have received a copy of the GNU General Public License version
4632N/A * 2 along with this work; if not, write to the Free Software Foundation,
4632N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4632N/A *
4632N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4632N/A * or visit www.oracle.com if you need additional information or have any
4632N/A * questions.
4632N/A */
4632N/A
4632N/Apackage apple.laf;
4632N/A
4632N/Aimport com.apple.laf.AquaImageFactory.NineSliceMetrics;
4632N/A
4632N/Aimport apple.laf.JRSUIConstants.*;
4632N/A
4632N/Apublic class JRSUIUtils {
4632N/A static boolean isLeopard = isMacOSXLeopard();
4632N/A static boolean isSnowLeopardOrBelow = isMacOSXSnowLeopardOrBelow();
4632N/A
4632N/A static boolean isMacOSXLeopard() {
4632N/A return isCurrentMacOSXVersion(5);
4632N/A }
4632N/A
4632N/A static boolean isMacOSXSnowLeopardOrBelow() {
4632N/A return currentMacOSXVersionMatchesGivenVersionRange(6, true, true, false);
4632N/A }
4632N/A
4632N/A static boolean isCurrentMacOSXVersion(final int version) {
4632N/A return currentMacOSXVersionMatchesGivenVersionRange(version, true, false, false);
4632N/A }
4632N/A
4632N/A static boolean currentMacOSXVersionMatchesGivenVersionRange(final int version, final boolean inclusive, final boolean matchBelow, final boolean matchAbove) {
4632N/A // split the "10.x.y" version number
4632N/A String osVersion = System.getProperty("os.version");
4632N/A String[] fragments = osVersion.split("\\.");
4632N/A
4632N/A // sanity check the "10." part of the version
4632N/A if (!fragments[0].equals("10")) return false;
4632N/A if (fragments.length < 2) return false;
4632N/A
4632N/A // check if os.version matches the given version using the given match method
4632N/A try {
4632N/A int minorVers = Integer.parseInt(fragments[1]);
4632N/A
4632N/A if (inclusive && minorVers == version) return true;
4632N/A if (matchBelow && minorVers < version) return true;
4632N/A if (matchAbove && minorVers > version) return true;
4632N/A
4632N/A } catch (NumberFormatException e) {
4632N/A // was not an integer
4632N/A }
4632N/A return false;
4632N/A }
4632N/A
4632N/A public static class TabbedPane {
4632N/A public static boolean useLegacyTabs() {
4632N/A return isLeopard;
4632N/A }
4632N/A public static boolean shouldUseTabbedPaneContrastUI() {
4632N/A return !isSnowLeopardOrBelow;
4632N/A }
4632N/A }
4632N/A
4632N/A public static class InternalFrame {
4632N/A public static boolean shouldUseLegacyBorderMetrics() {
4632N/A return isSnowLeopardOrBelow;
4632N/A }
4632N/A }
4632N/A
4632N/A public static class Tree {
4632N/A public static boolean useLegacyTreeKnobs() {
4632N/A return isLeopard;
4632N/A }
4632N/A }
4632N/A
4632N/A public static class ScrollBar {
4632N/A private static native boolean shouldUseScrollToClick();
4632N/A
4632N/A public static boolean useScrollToClick() {
4632N/A return shouldUseScrollToClick();
4632N/A }
4632N/A
4632N/A public static void getPartBounds(final double[] rect, final JRSUIControl control, final double x, final double y, final double w, final double h, final ScrollBarPart part) {
4632N/A control.getPartBounds(rect, x, y, w, h, part.ordinal);
4632N/A }
4632N/A
4632N/A public static double getNativeOffsetChange(final JRSUIControl control, final double x, final double y, final double w, final double h, final int offset, final int visibleAmount, final int extent) {
4632N/A return control.getScrollBarOffsetChange(x, y, w, h, offset, visibleAmount, extent);
4632N/A }
4632N/A }
4632N/A
4632N/A public static class Images {
4632N/A public static boolean shouldUseLegacySecurityUIPath() {
4632N/A return isSnowLeopardOrBelow;
4632N/A }
4632N/A }
4632N/A
4632N/A public static class HitDetection {
4632N/A public static Hit getHitForPoint(final JRSUIControl control, final double x, final double y, final double w, final double h, final double hitX, final double hitY) {
4632N/A return control.getHitForPoint(x, y, w, h, hitX, hitY);
4632N/A }
4632N/A }
4632N/A
4632N/A public interface NineSliceMetricsProvider {
4632N/A public NineSliceMetrics getNineSliceMetricsForState(JRSUIState state);
4632N/A }
4632N/A}