feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
@jdk.Exported(false)
|
||||
abstract class AccessBridgeLoader {
|
||||
|
||||
/**
|
||||
* Load JavaAccessBridge.DLL (our native half)
|
||||
*/
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
System.loadLibrary("JavaAccessBridge-32");
|
||||
return null;
|
||||
}
|
||||
}, null, new java.lang.RuntimePermission("loadLibrary.JavaAccessBridge-32")
|
||||
);
|
||||
}
|
||||
|
||||
boolean useJAWT_DLL = false;
|
||||
|
||||
/**
|
||||
* AccessBridgeLoader constructor
|
||||
*/
|
||||
AccessBridgeLoader() {
|
||||
// load JAWTAccessBridge.DLL on JDK 1.4.1 or later
|
||||
// determine which version of the JDK is running
|
||||
String version = System.getProperty("java.version");
|
||||
if (version != null)
|
||||
useJAWT_DLL = (version.compareTo("1.4.1") >= 0);
|
||||
|
||||
if (useJAWT_DLL) {
|
||||
// Note that we have to explicitly load JAWT.DLL
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
System.loadLibrary("JAWT");
|
||||
System.loadLibrary("JAWTAccessBridge-32");
|
||||
return null;
|
||||
}
|
||||
}, null, new RuntimePermission("loadLibrary.JAWT"),
|
||||
new RuntimePermission("loadLibrary.JAWTAccessBridge-32")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
@jdk.Exported(false)
|
||||
abstract class AccessBridgeLoader {
|
||||
|
||||
/**
|
||||
* Load JavaAccessBridge.DLL (our native half)
|
||||
*/
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
System.loadLibrary("JavaAccessBridge-64");
|
||||
return null;
|
||||
}
|
||||
}, null, new RuntimePermission("loadLibrary.JavaAccessBridge-64")
|
||||
);
|
||||
}
|
||||
|
||||
boolean useJAWT_DLL = false;
|
||||
|
||||
/**
|
||||
* AccessBridgLoader constructor
|
||||
*/
|
||||
AccessBridgeLoader() {
|
||||
// load JAWTAccessBridge.DLL on JDK 1.4.1 or later
|
||||
String version = System.getProperty("java.version");
|
||||
if (version != null)
|
||||
useJAWT_DLL = (version.compareTo("1.4.1") >= 0);
|
||||
|
||||
if (useJAWT_DLL) {
|
||||
// Note that we have to explicitly load JAWT.DLL
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
System.loadLibrary("JAWT");
|
||||
System.loadLibrary("JAWTAccessBridge-64");
|
||||
return null;
|
||||
}
|
||||
}, null, new RuntimePermission("loadLibrary.JAWT"),
|
||||
new RuntimePermission("loadLibrary.JAWTAccessBridge-64")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
7443
jdkSrc/jdk8/com/sun/java/accessibility/AccessBridge.java
Normal file
7443
jdkSrc/jdk8/com/sun/java/accessibility/AccessBridge.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.java.accessibility.legacy;
|
||||
|
||||
@jdk.Exported(false)
|
||||
abstract class AccessBridgeLoader {
|
||||
|
||||
/**
|
||||
* Load JavaAccessBridge.DLL (our native half)
|
||||
*/
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
System.loadLibrary("JavaAccessBridge");
|
||||
return null;
|
||||
}
|
||||
}, null, new RuntimePermission("loadLibrary.JavaAccessBridge")
|
||||
);
|
||||
}
|
||||
|
||||
boolean useJAWT_DLL = false;
|
||||
|
||||
/**
|
||||
* AccessBridgeLoader constructor
|
||||
*/
|
||||
AccessBridgeLoader() {
|
||||
String version = System.getProperty("java.version");
|
||||
if (version != null)
|
||||
useJAWT_DLL = (version.compareTo("1.4.1") >= 0);
|
||||
|
||||
// load JAWTAccessBridge.DLL on JDK 1.4.1 or later
|
||||
if (useJAWT_DLL) {
|
||||
// Note that we have to explicitly load JAWT.DLL
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
System.loadLibrary("JAWT");
|
||||
System.loadLibrary("JAWTAccessBridge");
|
||||
return null;
|
||||
}
|
||||
}, null, new RuntimePermission("loadLibrary.JAWT"),
|
||||
new RuntimePermission("loadLibrary.JAWTAccessBridge")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
1495
jdkSrc/jdk8/com/sun/java/accessibility/util/AWTEventMonitor.java
Normal file
1495
jdkSrc/jdk8/com/sun/java/accessibility/util/AWTEventMonitor.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,376 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util;
|
||||
|
||||
import java.util.*;
|
||||
import java.beans.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.accessibility.*;
|
||||
|
||||
/**
|
||||
* <P>{@code AccessibilityEventMonitor} implements a PropertyChange listener
|
||||
* on every UI object that implements interface {@code Accessible} in the Java
|
||||
* Virtual Machine. The events captured by these listeners are made available
|
||||
* through listeners supported by {@code AccessibilityEventMonitor}.
|
||||
* With this, all the individual events on each of the UI object
|
||||
* instances are funneled into one set of PropertyChange listeners.
|
||||
* <p>This class depends upon {@link EventQueueMonitor}, which provides the base
|
||||
* level support for capturing the top-level containers as they are created.
|
||||
*
|
||||
*/
|
||||
|
||||
@jdk.Exported
|
||||
public class AccessibilityEventMonitor {
|
||||
|
||||
// listeners
|
||||
/**
|
||||
* The current list of registered {@link java.beans.PropertyChangeListener
|
||||
* PropertyChangeListener} classes.
|
||||
*
|
||||
* @see #addPropertyChangeListener
|
||||
* @see #removePropertyChangeListener
|
||||
*/
|
||||
static protected final AccessibilityListenerList listenerList =
|
||||
new AccessibilityListenerList();
|
||||
|
||||
|
||||
/**
|
||||
* The actual listener that is installed on the component instances.
|
||||
* This listener calls the other registered listeners when an event
|
||||
* occurs. By doing things this way, the actual number of listeners
|
||||
* installed on a component instance is drastically reduced.
|
||||
*/
|
||||
static protected final AccessibilityEventListener accessibilityListener =
|
||||
new AccessibilityEventListener();
|
||||
|
||||
/**
|
||||
* Adds the specified listener to receive all PropertyChange events on
|
||||
* each UI object instance in the Java Virtual Machine as they occur.
|
||||
* <P>Note: This listener is automatically added to all component
|
||||
* instances created after this method is called. In addition, it
|
||||
* is only added to UI object instances that support this listener type.
|
||||
*
|
||||
* @param l the listener to add
|
||||
*
|
||||
* @see #removePropertyChangeListener
|
||||
*/
|
||||
static public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) {
|
||||
accessibilityListener.installListeners();
|
||||
}
|
||||
listenerList.add(PropertyChangeListener.class, l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified listener so it no longer receives PropertyChange
|
||||
* events when they occur.
|
||||
* @see #addPropertyChangeListener
|
||||
* @param l the listener to remove
|
||||
*/
|
||||
static public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
listenerList.remove(PropertyChangeListener.class, l);
|
||||
if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) {
|
||||
accessibilityListener.removeListeners();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AccessibilityEventListener is the class that does all the work for
|
||||
* AccessibilityEventMonitor. It is not intended for use by any other
|
||||
* class except AccessibilityEventMonitor.
|
||||
*
|
||||
*/
|
||||
|
||||
static class AccessibilityEventListener implements TopLevelWindowListener,
|
||||
PropertyChangeListener {
|
||||
|
||||
/**
|
||||
* Create a new instance of this class and install it on each component
|
||||
* instance in the virtual machine that supports any of the currently
|
||||
* registered listeners in AccessibilityEventMonitor. Also registers
|
||||
* itself as a TopLevelWindowListener with EventQueueMonitor so it can
|
||||
* automatically add new listeners to new components.
|
||||
* @see EventQueueMonitor
|
||||
* @see AccessibilityEventMonitor
|
||||
*/
|
||||
public AccessibilityEventListener() {
|
||||
EventQueueMonitor.addTopLevelWindowListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs PropertyChange listeners on all Accessible objects based
|
||||
* upon the current topLevelWindows cached by EventQueueMonitor.
|
||||
* @see EventQueueMonitor
|
||||
* @see AWTEventMonitor
|
||||
*/
|
||||
protected void installListeners() {
|
||||
Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows();
|
||||
if (topLevelWindows != null) {
|
||||
for (int i = 0; i < topLevelWindows.length; i++) {
|
||||
if (topLevelWindows[i] instanceof Accessible) {
|
||||
installListeners((Accessible) topLevelWindows[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs PropertyChange listeners to the Accessible object, and it's
|
||||
* children (so long as the object isn't of TRANSIENT state).
|
||||
* @param a the Accessible object to add listeners to
|
||||
*/
|
||||
protected void installListeners(Accessible a) {
|
||||
installListeners(a.getAccessibleContext());
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs PropertyChange listeners to the AccessibleContext object,
|
||||
* and it's * children (so long as the object isn't of TRANSIENT state).
|
||||
* @param a the Accessible object to add listeners to
|
||||
*/
|
||||
private void installListeners(AccessibleContext ac) {
|
||||
|
||||
if (ac != null) {
|
||||
AccessibleStateSet states = ac.getAccessibleStateSet();
|
||||
if (!states.contains(AccessibleState.TRANSIENT)) {
|
||||
ac.addPropertyChangeListener(this);
|
||||
/*
|
||||
* Don't add listeners to transient children. Components
|
||||
* with transient children should return an AccessibleStateSet
|
||||
* containing AccessibleState.MANAGES_DESCENDANTS. Components
|
||||
* may not explicitly return the MANAGES_DESCENDANTS state.
|
||||
* In this case, don't add listeners to the children of
|
||||
* lists, tables and trees.
|
||||
*/
|
||||
AccessibleStateSet set = ac.getAccessibleStateSet();
|
||||
if (set.contains(_AccessibleState.MANAGES_DESCENDANTS)) {
|
||||
return;
|
||||
}
|
||||
AccessibleRole role = ac.getAccessibleRole();
|
||||
if (role == AccessibleRole.LIST ||
|
||||
role == AccessibleRole.TREE) {
|
||||
return;
|
||||
}
|
||||
if (role == AccessibleRole.TABLE) {
|
||||
// handle Oracle tables containing tables
|
||||
Accessible child = ac.getAccessibleChild(0);
|
||||
if (child != null) {
|
||||
AccessibleContext ac2 = child.getAccessibleContext();
|
||||
if (ac2 != null) {
|
||||
role = ac2.getAccessibleRole();
|
||||
if (role != null && role != AccessibleRole.TABLE) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int count = ac.getAccessibleChildrenCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
Accessible child = ac.getAccessibleChild(i);
|
||||
if (child != null) {
|
||||
installListeners(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes PropertyChange listeners on all Accessible objects based
|
||||
* upon the topLevelWindows cached by EventQueueMonitor.
|
||||
* @param eventID the event ID
|
||||
* @see EventID
|
||||
*/
|
||||
protected void removeListeners() {
|
||||
Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows();
|
||||
if (topLevelWindows != null) {
|
||||
for (int i = 0; i < topLevelWindows.length; i++) {
|
||||
if (topLevelWindows[i] instanceof Accessible) {
|
||||
removeListeners((Accessible) topLevelWindows[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes PropertyChange listeners for the given Accessible object,
|
||||
* it's children (so long as the object isn't of TRANSIENT state).
|
||||
* @param a the Accessible object to remove listeners from
|
||||
*/
|
||||
protected void removeListeners(Accessible a) {
|
||||
removeListeners(a.getAccessibleContext());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes PropertyChange listeners for the given AccessibleContext
|
||||
* object, it's children (so long as the object isn't of TRANSIENT
|
||||
* state).
|
||||
* @param a the Accessible object to remove listeners from
|
||||
*/
|
||||
private void removeListeners(AccessibleContext ac) {
|
||||
|
||||
|
||||
if (ac != null) {
|
||||
// Listeners are not added to transient components.
|
||||
AccessibleStateSet states = ac.getAccessibleStateSet();
|
||||
if (!states.contains(AccessibleState.TRANSIENT)) {
|
||||
ac.removePropertyChangeListener(this);
|
||||
/*
|
||||
* Listeners are not added to transient children. Components
|
||||
* with transient children should return an AccessibleStateSet
|
||||
* containing AccessibleState.MANAGES_DESCENDANTS. Components
|
||||
* may not explicitly return the MANAGES_DESCENDANTS state.
|
||||
* In this case, don't remove listeners from the children of
|
||||
* lists, tables and trees.
|
||||
*/
|
||||
if (states.contains(_AccessibleState.MANAGES_DESCENDANTS)) {
|
||||
return;
|
||||
}
|
||||
AccessibleRole role = ac.getAccessibleRole();
|
||||
if (role == AccessibleRole.LIST ||
|
||||
role == AccessibleRole.TABLE ||
|
||||
role == AccessibleRole.TREE) {
|
||||
return;
|
||||
}
|
||||
int count = ac.getAccessibleChildrenCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
Accessible child = ac.getAccessibleChild(i);
|
||||
if (child != null) {
|
||||
removeListeners(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Listener Interface Methods */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
|
||||
/* TopLevelWindow Methods ***************************************/
|
||||
|
||||
/**
|
||||
* Called when top level window is created.
|
||||
* @see EventQueueMonitor
|
||||
* @see EventQueueMonitor#addTopLevelWindowListener
|
||||
*/
|
||||
public void topLevelWindowCreated(Window w) {
|
||||
if (w instanceof Accessible) {
|
||||
installListeners((Accessible) w);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when top level window is destroyed.
|
||||
* @see EventQueueMonitor
|
||||
* @see EventQueueMonitor#addTopLevelWindowListener
|
||||
*/
|
||||
public void topLevelWindowDestroyed(Window w) {
|
||||
if (w instanceof Accessible) {
|
||||
removeListeners((Accessible) w);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* PropertyChangeListener Methods **************************************/
|
||||
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
// propogate the event
|
||||
Object[] listeners =
|
||||
AccessibilityEventMonitor.listenerList.getListenerList();
|
||||
for (int i = listeners.length-2; i>=0; i-=2) {
|
||||
if (listeners[i]==PropertyChangeListener.class) {
|
||||
((PropertyChangeListener)listeners[i+1]).propertyChange(e);
|
||||
}
|
||||
}
|
||||
|
||||
// handle childbirth/death
|
||||
String name = e.getPropertyName();
|
||||
if (name.compareTo(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY) == 0) {
|
||||
Object oldValue = e.getOldValue();
|
||||
Object newValue = e.getNewValue();
|
||||
|
||||
if ((oldValue == null) ^ (newValue == null)) { // one null, not both
|
||||
if (oldValue != null) {
|
||||
// this Accessible is a child that's going away
|
||||
if (oldValue instanceof Accessible) {
|
||||
Accessible a = (Accessible) oldValue;
|
||||
removeListeners(a.getAccessibleContext());
|
||||
} else if (oldValue instanceof AccessibleContext) {
|
||||
removeListeners((AccessibleContext) oldValue);
|
||||
}
|
||||
} else if (newValue != null) {
|
||||
// this Accessible is a child was just born
|
||||
if (newValue instanceof Accessible) {
|
||||
Accessible a = (Accessible) newValue;
|
||||
installListeners(a.getAccessibleContext());
|
||||
} else if (newValue instanceof AccessibleContext) {
|
||||
installListeners((AccessibleContext) newValue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("ERROR in usage of PropertyChangeEvents for: " + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* workaround for no public AccessibleState constructor
|
||||
*/
|
||||
class _AccessibleState extends AccessibleState {
|
||||
/**
|
||||
* Indicates this object is responsible for managing its
|
||||
* subcomponents. This is typically used for trees and tables
|
||||
* that have a large number of subcomponents and where the
|
||||
* objects are created only when needed and otherwise remain virtual.
|
||||
* The application should not manage the subcomponents directly.
|
||||
*/
|
||||
public static final _AccessibleState MANAGES_DESCENDANTS
|
||||
= new _AccessibleState ("managesDescendants");
|
||||
|
||||
/**
|
||||
* Creates a new AccessibleState using the given locale independent key.
|
||||
* This should not be a public method. Instead, it is used to create
|
||||
* the constants in this file to make it a strongly typed enumeration.
|
||||
* Subclasses of this class should enforce similar policy.
|
||||
* <p>
|
||||
* The key String should be a locale independent key for the state.
|
||||
* It is not intended to be used as the actual String to display
|
||||
* to the user. To get the localized string, use toDisplayString.
|
||||
*
|
||||
* @param key the locale independent name of the state.
|
||||
* @see AccessibleBundle#toDisplayString
|
||||
*/
|
||||
protected _AccessibleState(String key) {
|
||||
super(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util;
|
||||
|
||||
import java.util.*;
|
||||
import java.beans.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.accessibility.*;
|
||||
|
||||
/**
|
||||
* <P>The {@code AccessibilityListenerList} is a copy of the Swing
|
||||
* {@link javax.swing.event.EventListenerList EventListerList} class.
|
||||
*
|
||||
*/
|
||||
|
||||
@jdk.Exported
|
||||
public class AccessibilityListenerList {
|
||||
/* A null array to be shared by all empty listener lists */
|
||||
private final static Object[] NULL_ARRAY = new Object[0];
|
||||
|
||||
/**
|
||||
* The list of listener type, listener pairs
|
||||
*/
|
||||
protected transient Object[] listenerList = NULL_ARRAY;
|
||||
|
||||
/**
|
||||
* Passes back the event listener list as an array of listener type, listener pairs.
|
||||
* Note that for performance reasons, this implementation passes back the actual
|
||||
* data structure in which the listener data is stored internally. This method
|
||||
* is guaranteed to pass back a non-null array, so that no null-checking
|
||||
* is required in fire methods. A zero-length array of Object is returned if
|
||||
* there are currently no listeners.
|
||||
* <p>
|
||||
* Absolutely no modification of the data contained in this array should be
|
||||
* made. If any such manipulation is necessary, it should be done on a copy
|
||||
* of the array returned rather than the array itself.
|
||||
*
|
||||
* @return an array of listener type, listener pairs.
|
||||
*/
|
||||
public Object[] getListenerList() {
|
||||
return listenerList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of listeners for this listener list.
|
||||
*
|
||||
* @return the total number of listeners for this listener list.
|
||||
*/
|
||||
public int getListenerCount() {
|
||||
return listenerList.length/2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total number of listeners of the supplied type
|
||||
* for this listener list.
|
||||
*
|
||||
* @param t the type of the listener to be counted
|
||||
* @return the number of listeners found
|
||||
*/
|
||||
public int getListenerCount(Class t) {
|
||||
int count = 0;
|
||||
Object[] lList = listenerList;
|
||||
for (int i = 0; i < lList.length; i+=2) {
|
||||
if (t == (Class)lList[i])
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the listener as a listener of the specified type.
|
||||
*
|
||||
* @param t the type of the listener to be added
|
||||
* @param l the listener to be added
|
||||
*/
|
||||
public synchronized void add(Class t, EventListener l) {
|
||||
if (!t.isInstance(l)) {
|
||||
throw new IllegalArgumentException("Listener " + l +
|
||||
" is not of type " + t);
|
||||
}
|
||||
if (l ==null) {
|
||||
throw new IllegalArgumentException("Listener " + l +
|
||||
" is null");
|
||||
}
|
||||
if (listenerList == NULL_ARRAY) {
|
||||
// if this is the first listener added,
|
||||
// initialize the lists
|
||||
listenerList = new Object[] { t, l };
|
||||
} else {
|
||||
// Otherwise copy the array and add the new listener
|
||||
int i = listenerList.length;
|
||||
Object[] tmp = new Object[i+2];
|
||||
System.arraycopy(listenerList, 0, tmp, 0, i);
|
||||
|
||||
tmp[i] = t;
|
||||
tmp[i+1] = l;
|
||||
|
||||
listenerList = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the listener as a listener of the specified type.
|
||||
*
|
||||
* @param t the type of the listener to be removed
|
||||
* @param l the listener to be removed
|
||||
*/
|
||||
public synchronized void remove(Class t, EventListener l) {
|
||||
if (!t.isInstance(l)) {
|
||||
throw new IllegalArgumentException("Listener " + l +
|
||||
" is not of type " + t);
|
||||
}
|
||||
if (l ==null) {
|
||||
throw new IllegalArgumentException("Listener " + l +
|
||||
" is null");
|
||||
}
|
||||
|
||||
// Is l on the list?
|
||||
int index = -1;
|
||||
for (int i = listenerList.length-2; i>=0; i-=2) {
|
||||
if ((listenerList[i]==t) && (listenerList[i+1] == l)) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If so, remove it
|
||||
if (index != -1) {
|
||||
Object[] tmp = new Object[listenerList.length-2];
|
||||
// Copy the list up to index
|
||||
System.arraycopy(listenerList, 0, tmp, 0, index);
|
||||
// Copy from two past the index, up to
|
||||
// the end of tmp (which is two elements
|
||||
// shorter than the old list)
|
||||
if (index < tmp.length)
|
||||
System.arraycopy(listenerList, index+2, tmp, index,
|
||||
tmp.length - index);
|
||||
// set the listener array to the new array or null
|
||||
listenerList = (tmp.length == 0) ? NULL_ARRAY : tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string representation of the {@code AccessibilityListenerList}.
|
||||
*
|
||||
* @return a string representation of the {@code AccessibilityListenerList}.
|
||||
*/
|
||||
public String toString() {
|
||||
Object[] lList = listenerList;
|
||||
String s = "EventListenerList: ";
|
||||
s += lList.length/2 + " listeners: ";
|
||||
for (int i = 0 ; i <= lList.length-2 ; i+=2) {
|
||||
s += " type " + ((Class)lList[i]).getName();
|
||||
s += " listener " + lList[i+1];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
206
jdkSrc/jdk8/com/sun/java/accessibility/util/EventID.java
Normal file
206
jdkSrc/jdk8/com/sun/java/accessibility/util/EventID.java
Normal file
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util;
|
||||
|
||||
/**
|
||||
* EventID contains integer constants that map to event support in
|
||||
* AWT and Swing. They are used by primarily by AWTEventMonitor,
|
||||
* AWTEventsListener, SwingEventMonitor, and SwingEventListener, but
|
||||
* can be freely used by any other class.
|
||||
*
|
||||
* @see AWTEventMonitor
|
||||
* @see SwingEventMonitor
|
||||
*
|
||||
*/
|
||||
@jdk.Exported
|
||||
public class EventID {
|
||||
|
||||
/**
|
||||
* Maps to AWT Action support (i.e., ActionListener and ActionEvent)
|
||||
*/
|
||||
static public final int ACTION = 0;
|
||||
|
||||
/**
|
||||
* Maps to AWT Adjustment support (i.e., AdjustmentListener
|
||||
* and AdjustmentEvent)
|
||||
*/
|
||||
static public final int ADJUSTMENT = 1;
|
||||
|
||||
/**
|
||||
* Maps to AWT Component support (i.e., ComponentListener
|
||||
* and ComponentEvent)
|
||||
*/
|
||||
static public final int COMPONENT = 2;
|
||||
|
||||
/**
|
||||
* Maps to AWT Container support (i.e., ContainerListener
|
||||
* and ContainerEvent)
|
||||
*/
|
||||
static public final int CONTAINER = 3;
|
||||
|
||||
/**
|
||||
* Maps to AWT Focus support (i.e., FocusListener and FocusEvent)
|
||||
*/
|
||||
static public final int FOCUS = 4;
|
||||
|
||||
/**
|
||||
* Maps to AWT Item support (i.e., ItemListener and ItemEvent)
|
||||
*/
|
||||
static public final int ITEM = 5;
|
||||
|
||||
/**
|
||||
* Maps to AWT Key support (i.e., KeyListener and KeyEvent)
|
||||
*/
|
||||
static public final int KEY = 6;
|
||||
|
||||
/**
|
||||
* Maps to AWT Mouse support (i.e., MouseListener and MouseEvent)
|
||||
*/
|
||||
static public final int MOUSE = 7;
|
||||
|
||||
/**
|
||||
* Maps to AWT MouseMotion support (i.e., MouseMotionListener
|
||||
* and MouseMotionEvent)
|
||||
*/
|
||||
static public final int MOTION = 8;
|
||||
|
||||
/**
|
||||
* Maps to AWT Text support (i.e., TextListener and TextEvent)
|
||||
*/
|
||||
static public final int TEXT = 10;
|
||||
|
||||
/**
|
||||
* Maps to AWT Window support (i.e., WindowListener and WindowEvent)
|
||||
*/
|
||||
static public final int WINDOW = 11;
|
||||
|
||||
/**
|
||||
* Maps to Swing Ancestor support (i.e., AncestorListener and
|
||||
* AncestorEvent)
|
||||
*/
|
||||
static public final int ANCESTOR = 12;
|
||||
|
||||
/**
|
||||
* Maps to Swing Text Caret support (i.e., CaretListener and
|
||||
* CaretEvent)
|
||||
*/
|
||||
static public final int CARET = 13;
|
||||
|
||||
/**
|
||||
* Maps to Swing CellEditor support (i.e., CellEditorListener and
|
||||
* CellEditorEvent)
|
||||
*/
|
||||
static public final int CELLEDITOR = 14;
|
||||
|
||||
/**
|
||||
* Maps to Swing Change support (i.e., ChangeListener and
|
||||
* ChangeEvent)
|
||||
*/
|
||||
static public final int CHANGE = 15;
|
||||
|
||||
/**
|
||||
* Maps to Swing TableColumnModel support (i.e.,
|
||||
* TableColumnModelListener and TableColumnModelEvent)
|
||||
*/
|
||||
static public final int COLUMNMODEL = 16;
|
||||
|
||||
/**
|
||||
* Maps to Swing Document support (i.e., DocumentListener and
|
||||
* DocumentEvent)
|
||||
*/
|
||||
static public final int DOCUMENT = 17;
|
||||
|
||||
/**
|
||||
* Maps to Swing ListData support (i.e., ListDataListener and
|
||||
* ListDataEvent)
|
||||
*/
|
||||
static public final int LISTDATA = 18;
|
||||
|
||||
/**
|
||||
* Maps to Swing ListSelection support (i.e., ListSelectionListener and
|
||||
* ListSelectionEvent)
|
||||
*/
|
||||
static public final int LISTSELECTION = 19;
|
||||
|
||||
/**
|
||||
* Maps to Swing Menu support (i.e., MenuListener and
|
||||
* MenuEvent)
|
||||
*/
|
||||
static public final int MENU = 20;
|
||||
|
||||
/**
|
||||
* Maps to Swing PopupMenu support (i.e., PopupMenuListener and
|
||||
* PopupMenuEvent)
|
||||
*/
|
||||
static public final int POPUPMENU = 21;
|
||||
|
||||
/**
|
||||
* Maps to Swing TableModel support (i.e., TableModelListener and
|
||||
* TableModelEvent)
|
||||
*/
|
||||
static public final int TABLEMODEL = 22;
|
||||
|
||||
/**
|
||||
* Maps to Swing TreeExpansion support (i.e., TreeExpansionListener and
|
||||
* TreeExpansionEvent)
|
||||
*/
|
||||
static public final int TREEEXPANSION = 23;
|
||||
|
||||
/**
|
||||
* Maps to Swing TreeModel support (i.e., TreeModelListener and
|
||||
* TreeModelEvent)
|
||||
*/
|
||||
static public final int TREEMODEL = 24;
|
||||
|
||||
/**
|
||||
* Maps to Swing TreeSelection support (i.e., TreeSelectionListener and
|
||||
* TreeSelectionEvent)
|
||||
*/
|
||||
static public final int TREESELECTION = 25;
|
||||
|
||||
/**
|
||||
* Maps to Swing UndoableEdit support (i.e., UndoableEditListener and
|
||||
* UndoableEditEvent)
|
||||
*/
|
||||
static public final int UNDOABLEEDIT = 26;
|
||||
|
||||
/**
|
||||
* Maps to Beans PropertyChange support (i.e., PropertyChangeListener
|
||||
* and PropertyChangeEvent)
|
||||
*/
|
||||
static public final int PROPERTYCHANGE = 27;
|
||||
|
||||
/**
|
||||
* Maps to Beans VetoableChange support (i.e., VetoableChangeListener
|
||||
* and VetoableChangeEvent)
|
||||
*/
|
||||
static public final int VETOABLECHANGE = 28;
|
||||
|
||||
/**
|
||||
* Maps to Swing InternalFrame support (i.e., InternalFrameListener)
|
||||
*/
|
||||
static public final int INTERNALFRAME = 29;
|
||||
}
|
||||
@@ -0,0 +1,619 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util;
|
||||
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.accessibility.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
/**
|
||||
* The {@code EventQueueMonitor} class provides key core functionality for Assistive
|
||||
* Technologies (and other system-level technologies that need some of the same
|
||||
* things that Assistive Technology needs).
|
||||
*
|
||||
* @see AWTEventMonitor
|
||||
* @see SwingEventMonitor
|
||||
*/
|
||||
@jdk.Exported
|
||||
public class EventQueueMonitor
|
||||
implements AWTEventListener {
|
||||
|
||||
// NOTE: All of the following properties are static. The reason
|
||||
// for this is that there may be multiple EventQueue instances
|
||||
// in use in the same VM. By making these properties static,
|
||||
// we can guarantee we get the information from all of the
|
||||
// EventQueue instances.
|
||||
|
||||
// The stuff that is cached.
|
||||
//
|
||||
static Vector topLevelWindows = new Vector();
|
||||
static Window topLevelWindowWithFocus = null;
|
||||
static Point currentMousePosition = null;
|
||||
static Component currentMouseComponent = null;
|
||||
|
||||
// Low-level listener interfaces
|
||||
//
|
||||
static GUIInitializedListener guiInitializedListener = null;
|
||||
static TopLevelWindowListener topLevelWindowListener = null;
|
||||
static MouseMotionListener mouseMotionListener = null;
|
||||
|
||||
/**
|
||||
* Class variable stating whether the assistive technologies have
|
||||
* been loaded yet or not. The assistive technologies won't be
|
||||
* loaded until the first event is posted to the EventQueue. This
|
||||
* gives the toolkit a chance to do all the necessary initialization
|
||||
* it needs to do.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class variable stating whether the GUI subsystem has been initialized
|
||||
* or not.
|
||||
*
|
||||
* @see #isGUIInitialized
|
||||
*/
|
||||
static boolean guiInitialized = false;
|
||||
|
||||
/**
|
||||
* Queue that holds events for later processing.
|
||||
*/
|
||||
static EventQueueMonitorItem componentEventQueue = null;
|
||||
|
||||
/**
|
||||
* Class that tells us what the component event dispatch thread is.
|
||||
*/
|
||||
static private ComponentEvtDispatchThread cedt = null;
|
||||
|
||||
/**
|
||||
* Handle the synchronization between the thing that populates the
|
||||
* component event dispatch thread ({@link #queueComponentEvent})
|
||||
* and the thing that processes the events ({@link ComponentEvtDispatchThread}).
|
||||
*/
|
||||
static Object componentEventQueueLock = new Object();
|
||||
|
||||
/**
|
||||
* Create a new {@code EventQueueMonitor} instance. Normally, this will
|
||||
* be called only by the AWT Toolkit during initialization time.
|
||||
* Assistive technologies should not create instances of
|
||||
* EventQueueMonitor by themselves. Instead, they should either
|
||||
* refer to it directly via the static methods in this class, e.g.,
|
||||
* {@link #getCurrentMousePosition} or obtain the instance by asking the
|
||||
* Toolkit, e.g., {@link java.awt.Toolkit#getSystemEventQueue}.
|
||||
*/
|
||||
public EventQueueMonitor() {
|
||||
if (cedt == null) {
|
||||
cedt = new ComponentEvtDispatchThread("EventQueueMonitor-ComponentEvtDispatch");
|
||||
|
||||
cedt.setDaemon(true);
|
||||
cedt.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue up a {@link java.awt.event.ComponentEvent ComponentEvent} for later
|
||||
* processing by the {@link ComponentEvtDispatch} thread.
|
||||
*
|
||||
* @param e a {@code ComponentEvent}
|
||||
*/
|
||||
static void queueComponentEvent(ComponentEvent e) {
|
||||
synchronized(componentEventQueueLock) {
|
||||
EventQueueMonitorItem eqi = new EventQueueMonitorItem(e);
|
||||
if (componentEventQueue == null) {
|
||||
componentEventQueue = eqi;
|
||||
} else {
|
||||
EventQueueMonitorItem q = componentEventQueue;
|
||||
while (true) {
|
||||
if (q.next != null) {
|
||||
q = q.next;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
q.next = eqi;
|
||||
}
|
||||
componentEventQueueLock.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell the {@code EventQueueMonitor} to start listening for events.
|
||||
*/
|
||||
public static void maybeInitialize() {
|
||||
if (cedt == null) {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction() {
|
||||
public Object run() {
|
||||
try {
|
||||
long eventMask = AWTEvent.WINDOW_EVENT_MASK |
|
||||
AWTEvent.FOCUS_EVENT_MASK |
|
||||
AWTEvent.MOUSE_MOTION_EVENT_MASK;
|
||||
|
||||
Toolkit.getDefaultToolkit().addAWTEventListener(new EventQueueMonitor(), eventMask);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle events as a result of registering a listener
|
||||
* on the {@link java.awt.EventQueue EventQueue} in {@link #maybeInitialize}.
|
||||
*/
|
||||
public void eventDispatched(AWTEvent theEvent) {
|
||||
processEvent(theEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assisitive technologies that have
|
||||
* registered a {@link GUIInitializedListener} will be notified.
|
||||
*
|
||||
* @see #addGUIInitializedListener
|
||||
*/
|
||||
static void maybeNotifyAssistiveTechnologies() {
|
||||
|
||||
if (!guiInitialized) {
|
||||
guiInitialized = true;
|
||||
if (guiInitializedListener != null) {
|
||||
guiInitializedListener.guiInitialized();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Package Private Methods */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
|
||||
/**
|
||||
* Add a Container to the list of top-level containers
|
||||
* in the cache. This follows the object's hierarchy up the
|
||||
* tree until it finds the top most parent. If the parent is
|
||||
* not already in the list of Containers, it adds it to the list.
|
||||
*
|
||||
* @param c the Container
|
||||
*/
|
||||
static void addTopLevelWindow(Component c) {
|
||||
Container parent;
|
||||
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(c instanceof Window)) {
|
||||
addTopLevelWindow(c.getParent());
|
||||
return;
|
||||
}
|
||||
|
||||
if ((c instanceof Dialog) || (c instanceof Window)) {
|
||||
parent = (Container) c;
|
||||
} else {
|
||||
parent = c.getParent();
|
||||
if (parent != null) {
|
||||
addTopLevelWindow(parent);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (parent == null) {
|
||||
parent = (Container) c;
|
||||
}
|
||||
|
||||
// Because this method is static, do not make it synchronized because
|
||||
// it can lock the whole class. Instead, just lock what needs to be
|
||||
// locked.
|
||||
//
|
||||
synchronized (topLevelWindows) {
|
||||
if ((parent != null) && !topLevelWindows.contains(parent)) {
|
||||
topLevelWindows.addElement(parent);
|
||||
if (topLevelWindowListener != null) {
|
||||
topLevelWindowListener.topLevelWindowCreated((Window) parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a container from the list of top level containers in the cache.
|
||||
*
|
||||
* @param c the top level container to remove
|
||||
*/
|
||||
static void removeTopLevelWindow(Window w) {
|
||||
|
||||
// Because this method is static, do not make it synchronized because
|
||||
// it can lock the whole class. Instead, just lock what needs to be
|
||||
// locked.
|
||||
//
|
||||
synchronized (topLevelWindows) {
|
||||
if (topLevelWindows.contains(w)) {
|
||||
topLevelWindows.removeElement(w);
|
||||
if (topLevelWindowListener != null) {
|
||||
topLevelWindowListener.topLevelWindowDestroyed(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update current mouse position.
|
||||
*
|
||||
* @param mouseEvent the MouseEvent that holds the new mouse position.
|
||||
*/
|
||||
static void updateCurrentMousePosition(MouseEvent mouseEvent) {
|
||||
Point oldMousePos = currentMousePosition;
|
||||
// Be careful here. The component in the event might be
|
||||
// hidden by the time we process the event.
|
||||
try {
|
||||
Point eventPoint = mouseEvent.getPoint();
|
||||
currentMouseComponent = (Component) (mouseEvent.getSource());
|
||||
currentMousePosition = currentMouseComponent.getLocationOnScreen();
|
||||
currentMousePosition.translate(eventPoint.x,eventPoint.y);
|
||||
} catch (Exception e) {
|
||||
currentMousePosition = oldMousePos;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the event. This maintains the event cache in addition
|
||||
* to calling all the registered listeners. NOTE: The events that
|
||||
* come through here are from peered Components.
|
||||
*
|
||||
* @param theEvent the AWTEvent
|
||||
*/
|
||||
static void processEvent(AWTEvent theEvent) {
|
||||
switch (theEvent.getID()) {
|
||||
case MouseEvent.MOUSE_MOVED:
|
||||
case MouseEvent.MOUSE_DRAGGED:
|
||||
case FocusEvent.FOCUS_GAINED:
|
||||
case WindowEvent.WINDOW_DEACTIVATED:
|
||||
queueComponentEvent((ComponentEvent) theEvent);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_ACTIVATED:
|
||||
// Dialogs fire WINDOW_ACTIVATED and FOCUS_GAINED events
|
||||
// before WINDOW_OPENED so we need to add topLevelListeners
|
||||
// for the dialog when it is first activated to get a
|
||||
// focus gained event for the focus component in the dialog.
|
||||
if (theEvent instanceof ComponentEvent) {
|
||||
ComponentEvent ce = (ComponentEvent)theEvent;
|
||||
if (ce.getComponent() instanceof Window) {
|
||||
EventQueueMonitor.addTopLevelWindow(ce.getComponent());
|
||||
EventQueueMonitor.maybeNotifyAssistiveTechnologies();
|
||||
} else {
|
||||
EventQueueMonitor.maybeNotifyAssistiveTechnologies();
|
||||
EventQueueMonitor.addTopLevelWindow(ce.getComponent());
|
||||
}
|
||||
}
|
||||
queueComponentEvent((ComponentEvent) theEvent);
|
||||
break;
|
||||
|
||||
// handle WINDOW_OPENED and WINDOW_CLOSED events synchronously
|
||||
case WindowEvent.WINDOW_OPENED:
|
||||
if (theEvent instanceof ComponentEvent) {
|
||||
ComponentEvent ce = (ComponentEvent)theEvent;
|
||||
if (ce.getComponent() instanceof Window) {
|
||||
EventQueueMonitor.addTopLevelWindow(ce.getComponent());
|
||||
EventQueueMonitor.maybeNotifyAssistiveTechnologies();
|
||||
} else {
|
||||
EventQueueMonitor.maybeNotifyAssistiveTechnologies();
|
||||
EventQueueMonitor.addTopLevelWindow(ce.getComponent());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WindowEvent.WINDOW_CLOSED:
|
||||
if (theEvent instanceof ComponentEvent) {
|
||||
ComponentEvent ce = (ComponentEvent)theEvent;
|
||||
EventQueueMonitor.removeTopLevelWindow((Window) (ce.getComponent()));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal test
|
||||
*/
|
||||
static synchronized Component getShowingComponentAt(Container c, int x, int y) {
|
||||
if (!c.contains(x, y)) {
|
||||
return null;
|
||||
}
|
||||
int ncomponents = c.getComponentCount();
|
||||
for (int i = 0 ; i < ncomponents ; i++) {
|
||||
Component comp = c.getComponent(i);
|
||||
if (comp != null && comp.isShowing()) {
|
||||
Point location = comp.getLocation();
|
||||
if (comp.contains(x - location.x, y - location.y)) {
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Component at the given Point on the screen in the
|
||||
* given Container.
|
||||
*
|
||||
* @param c the Container to search
|
||||
* @param p the Point in screen coordinates
|
||||
* @return the Component at the given Point on the screen in the
|
||||
* given Container -- can be null if no Component is at that Point
|
||||
*/
|
||||
static synchronized Component getComponentAt(Container c, Point p) {
|
||||
if (!c.isShowing()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Component comp;
|
||||
Point containerLoc = c.getLocationOnScreen();
|
||||
Point containerPoint = new Point(p.x - containerLoc.x,
|
||||
p.y - containerLoc.y);
|
||||
|
||||
comp = getShowingComponentAt(c, containerPoint.x, containerPoint.y);
|
||||
|
||||
if ((comp != c) && (comp instanceof Container)) {
|
||||
return getComponentAt((Container)comp,p);
|
||||
} else {
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the {@link javax.accessibility.Accessible Accessible} object at the given point on the Screen.
|
||||
* The return value may be null if an {@code Accessible} object cannot be
|
||||
* found at the particular point.
|
||||
*
|
||||
* @param p the point to be accessed
|
||||
* @return the {@code Accessible} at the specified point
|
||||
*/
|
||||
static public Accessible getAccessibleAt(Point p) {
|
||||
Window w = getTopLevelWindowWithFocus();
|
||||
Window[] wins = getTopLevelWindows();
|
||||
Component c = null;
|
||||
|
||||
// See if the point we're being asked about is the
|
||||
// currentMousePosition. If so, start with the component
|
||||
// that we know the currentMousePostion is over
|
||||
//
|
||||
if (currentMousePosition == null) {
|
||||
return null;
|
||||
}
|
||||
if (currentMousePosition.equals(p)) {
|
||||
if (currentMouseComponent instanceof Container) {
|
||||
c = getComponentAt((Container) currentMouseComponent, p);
|
||||
}
|
||||
}
|
||||
|
||||
// Try the window with focus next
|
||||
//
|
||||
if (c == null && w != null) {
|
||||
c = getComponentAt(w,p);
|
||||
}
|
||||
|
||||
// Try the other windows next. [[[WDW: Stacking order???]]]
|
||||
if (c == null) {
|
||||
for (int i = 0; i < wins.length; i++) {
|
||||
c = getComponentAt(wins[i],p);
|
||||
if (c != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (c instanceof Accessible) {
|
||||
AccessibleContext ac = ((Accessible) c).getAccessibleContext();
|
||||
if (ac != null) {
|
||||
AccessibleComponent acmp = ac.getAccessibleComponent();
|
||||
if ((acmp != null) && (ac.getAccessibleChildrenCount() != 0)) {
|
||||
Point location = acmp.getLocationOnScreen();
|
||||
location.move(p.x - location.x, p.y - location.y);
|
||||
return acmp.getAccessibleAt(location);
|
||||
}
|
||||
}
|
||||
return (Accessible) c;
|
||||
} else {
|
||||
return Translator.getAccessible(c);
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Public Methods */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
|
||||
/**
|
||||
* Says whether the GUI subsystem has been initialized or not.
|
||||
* If this returns true, the assistive technology can freely
|
||||
* create GUI component instances. If the return value is false,
|
||||
* the assistive technology should register a {@link GUIInitializedListener}
|
||||
* and wait to create GUI component instances until the listener is
|
||||
* called.
|
||||
*
|
||||
* @return true if the GUI subsystem has been initialized
|
||||
* @see #addGUIInitializedListener
|
||||
*/
|
||||
static public boolean isGUIInitialized() {
|
||||
maybeInitialize();
|
||||
return guiInitialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified listener to be notified when the GUI subsystem
|
||||
* is initialized. Assistive technologies should get the results of
|
||||
* {@link #isGUIInitialized} before calling this method.
|
||||
*
|
||||
* @param l the listener to add
|
||||
* @see #isGUIInitialized
|
||||
* @see #removeTopLevelWindowListener
|
||||
*/
|
||||
static public void addGUIInitializedListener(GUIInitializedListener l) {
|
||||
maybeInitialize();
|
||||
guiInitializedListener =
|
||||
GUIInitializedMulticaster.add(guiInitializedListener,l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified listener to be notified when the GUI subsystem
|
||||
* is initialized.
|
||||
*
|
||||
* @param l the listener to remove
|
||||
* @see #addGUIInitializedListener
|
||||
*/
|
||||
static public void removeGUIInitializedListener(GUIInitializedListener l) {
|
||||
guiInitializedListener =
|
||||
GUIInitializedMulticaster.remove(guiInitializedListener,l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified listener to be notified when a top level window
|
||||
* is created or destroyed.
|
||||
*
|
||||
* @param l the listener to add
|
||||
* @see #removeTopLevelWindowListener
|
||||
*/
|
||||
static public void addTopLevelWindowListener(TopLevelWindowListener l) {
|
||||
topLevelWindowListener =
|
||||
TopLevelWindowMulticaster.add(topLevelWindowListener,l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified listener to be notified when a top level window
|
||||
* is created or destroyed.
|
||||
*
|
||||
* @param l the listener to remove
|
||||
* @see #addTopLevelWindowListener
|
||||
*/
|
||||
static public void removeTopLevelWindowListener(TopLevelWindowListener l) {
|
||||
topLevelWindowListener =
|
||||
TopLevelWindowMulticaster.remove(topLevelWindowListener,l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the last recorded position of the mouse in screen coordinates.
|
||||
*
|
||||
* @return the last recorded position of the mouse in screen coordinates
|
||||
*/
|
||||
static public Point getCurrentMousePosition() {
|
||||
return currentMousePosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of top level Windows in use in the Java Virtual Machine.
|
||||
*
|
||||
* @return an array of top level {@code Window}s in use in the Java Virtual Machine
|
||||
*/
|
||||
static public Window[] getTopLevelWindows() {
|
||||
|
||||
// Because this method is static, do not make it synchronized because
|
||||
// it can lock the whole class. Instead, just lock what needs to be
|
||||
// locked.
|
||||
//
|
||||
synchronized (topLevelWindows) {
|
||||
int count = topLevelWindows.size();
|
||||
if (count > 0) {
|
||||
Window[] w = new Window[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
w[i] = (Window)topLevelWindows.elementAt(i);
|
||||
}
|
||||
return w;
|
||||
} else {
|
||||
return new Window[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the top level {@code Window} that currently has keyboard focus.
|
||||
*
|
||||
* @return the top level {@code Window} that currently has keyboard focus
|
||||
*/
|
||||
static public Window getTopLevelWindowWithFocus() {
|
||||
return topLevelWindowWithFocus;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle all Component events in a separate thread. The reason for this is
|
||||
* that WindowEvents tend to be used to do lots of processing on the Window
|
||||
* hierarchy. As a result, it can frequently result in deadlock situations.
|
||||
*/
|
||||
class ComponentEvtDispatchThread extends Thread {
|
||||
public ComponentEvtDispatchThread(String name) {
|
||||
super(name);
|
||||
}
|
||||
public void run() {
|
||||
ComponentEvent ce = null;
|
||||
while (true) {
|
||||
synchronized(EventQueueMonitor.componentEventQueueLock) {
|
||||
while (EventQueueMonitor.componentEventQueue == null) {
|
||||
try {
|
||||
EventQueueMonitor.componentEventQueueLock.wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
ce = (ComponentEvent)EventQueueMonitor.componentEventQueue.event;
|
||||
EventQueueMonitor.componentEventQueue =
|
||||
EventQueueMonitor.componentEventQueue.next;
|
||||
}
|
||||
switch (ce.getID()) {
|
||||
case MouseEvent.MOUSE_MOVED:
|
||||
case MouseEvent.MOUSE_DRAGGED:
|
||||
EventQueueMonitor.updateCurrentMousePosition((MouseEvent) ce);
|
||||
break;
|
||||
case WindowEvent.WINDOW_ACTIVATED:
|
||||
EventQueueMonitor.maybeNotifyAssistiveTechnologies();
|
||||
EventQueueMonitor.topLevelWindowWithFocus = ((WindowEvent) ce).getWindow();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* EventQueueMonitorItem is the basic type that handles the
|
||||
* queue for queueComponentEvent and the ComponentEvtDispatchThread.
|
||||
*/
|
||||
class EventQueueMonitorItem {
|
||||
AWTEvent event;
|
||||
EventQueueMonitorItem next;
|
||||
|
||||
EventQueueMonitorItem(AWTEvent evt) {
|
||||
event = evt;
|
||||
next = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import javax.accessibility.*;
|
||||
|
||||
/**
|
||||
* The {@code GUIInitializedListener} interface is used by the {@link EventQueueMonitor}
|
||||
* class to notify an interested party when the GUI subsystem has been
|
||||
* initialized. This is necessary because assistive technologies can
|
||||
* be loaded before the GUI subsystem is initialized. As a result,
|
||||
* assistive technologies should check the
|
||||
* {@link EventQueueMonitor#isGUIInitialized isGUIInitialized} method
|
||||
* of {@code EventQueueMonitor} before creating any GUI components. If the
|
||||
* return value is true, assistive technologies can create GUI components
|
||||
* following the same thread restrictions as any other application. If
|
||||
* the return value is false, the assistive technology should register
|
||||
* a {@code GUIInitializedListener} with the {@code EventQueueMonitor} to be notified
|
||||
* when the GUI subsystem is initialized.
|
||||
*
|
||||
* @see EventQueueMonitor
|
||||
* @see EventQueueMonitor#isGUIInitialized
|
||||
* @see EventQueueMonitor#addGUIInitializedListener
|
||||
* @see EventQueueMonitor#removeGUIInitializedListener
|
||||
*
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface GUIInitializedListener extends EventListener {
|
||||
|
||||
/**
|
||||
* Invoked when the GUI subsystem is initialized and it's OK for
|
||||
* the assisitive technology to create instances of GUI objects.
|
||||
*/
|
||||
public void guiInitialized();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.EventListener;
|
||||
import javax.accessibility.*;
|
||||
|
||||
|
||||
/**
|
||||
* The GUIInitializedMulticaster class is used to maintain a list of
|
||||
* GUIInitializedListener classes. It is intended to be used primarily
|
||||
* for internal support in the EventQueueMonitor class, and is not intended
|
||||
* to be used by classes outside the Java Accessibility Utility package.
|
||||
*
|
||||
* @see EventQueueMonitor
|
||||
* @see EventQueueMonitor#addGUIInitializedListener
|
||||
* @see EventQueueMonitor#removeGUIInitializedListener
|
||||
*
|
||||
*/
|
||||
@jdk.Exported(false)
|
||||
public class GUIInitializedMulticaster
|
||||
extends AWTEventMulticaster implements GUIInitializedListener
|
||||
{
|
||||
protected GUIInitializedMulticaster(EventListener a, EventListener b) {
|
||||
super(a, b);
|
||||
}
|
||||
|
||||
public void guiInitialized() {
|
||||
((GUIInitializedListener)a).guiInitialized();
|
||||
((GUIInitializedListener)b).guiInitialized();
|
||||
}
|
||||
|
||||
public static GUIInitializedListener add(GUIInitializedListener a, GUIInitializedListener b) {
|
||||
return (GUIInitializedListener)addInternal(a, b);
|
||||
}
|
||||
|
||||
public static GUIInitializedListener remove(GUIInitializedListener l, GUIInitializedListener oldl) {
|
||||
return (GUIInitializedListener)removeInternal(l, oldl);
|
||||
}
|
||||
|
||||
protected static EventListener addInternal(EventListener a, EventListener b) {
|
||||
if (a == null) return b;
|
||||
if (b == null) return a;
|
||||
return new GUIInitializedMulticaster(a, b);
|
||||
}
|
||||
|
||||
protected static EventListener removeInternal(EventListener l, EventListener oldl) {
|
||||
if (l == oldl || l == null) {
|
||||
return null;
|
||||
} else if (l instanceof GUIInitializedMulticaster) {
|
||||
return ((GUIInitializedMulticaster)l).remove(oldl);
|
||||
} else {
|
||||
return l; // it's not here
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
2542
jdkSrc/jdk8/com/sun/java/accessibility/util/SwingEventMonitor.java
Normal file
2542
jdkSrc/jdk8/com/sun/java/accessibility/util/SwingEventMonitor.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import javax.accessibility.*;
|
||||
|
||||
/**
|
||||
* The {@code TopLevelWindowListener} interface is used by the {@link EventQueueMonitor}
|
||||
* class to notify an interested party when a top level window is created
|
||||
* or destroyed in the Java Virtual Machine. Classes wishing to express
|
||||
* an interest in top level window events should implement this interface
|
||||
* and register themselves with the {@code EventQueueMonitor} by calling the
|
||||
* {@link EventQueueMonitor#addTopLevelWindowListener EventQueueMonitor.addTopLevelWindowListener}
|
||||
* class method.
|
||||
*
|
||||
* @see EventQueueMonitor
|
||||
* @see EventQueueMonitor#addTopLevelWindowListener
|
||||
* @see EventQueueMonitor#removeTopLevelWindowListener
|
||||
*
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface TopLevelWindowListener extends EventListener {
|
||||
|
||||
/**
|
||||
* Invoked when a new top level window has been created.
|
||||
*
|
||||
* @param w the Window that was created
|
||||
*/
|
||||
public void topLevelWindowCreated(Window w);
|
||||
|
||||
/**
|
||||
* Invoked when a top level window has been destroyed.
|
||||
*
|
||||
* @param w the Window that was destroyed
|
||||
*/
|
||||
public void topLevelWindowDestroyed(Window w);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.EventListener;
|
||||
import javax.accessibility.*;
|
||||
|
||||
|
||||
/**
|
||||
* The TopLevelWindowMulticaster class is used to maintain a list of
|
||||
* TopLevelWindowListener classes. It is intended to be used primarily
|
||||
* for internal support in the EventQueueMonitor class, and is not intended
|
||||
* to be used by classes outside the Java Accessibility Utility package.
|
||||
*
|
||||
* @see EventQueueMonitor
|
||||
* @see EventQueueMonitor#addTopLevelWindowListener
|
||||
* @see EventQueueMonitor#removeTopLevelWindowListener
|
||||
*
|
||||
*/
|
||||
@jdk.Exported(false)
|
||||
public class TopLevelWindowMulticaster
|
||||
extends AWTEventMulticaster implements TopLevelWindowListener
|
||||
{
|
||||
protected TopLevelWindowMulticaster(EventListener a, EventListener b) {
|
||||
super(a, b);
|
||||
}
|
||||
|
||||
public void topLevelWindowCreated(Window w) {
|
||||
((TopLevelWindowListener)a).topLevelWindowCreated(w);
|
||||
((TopLevelWindowListener)b).topLevelWindowCreated(w);
|
||||
}
|
||||
|
||||
public void topLevelWindowDestroyed(Window w) {
|
||||
((TopLevelWindowListener)a).topLevelWindowDestroyed(w);
|
||||
((TopLevelWindowListener)b).topLevelWindowDestroyed(w);
|
||||
}
|
||||
|
||||
public static TopLevelWindowListener add(TopLevelWindowListener a, TopLevelWindowListener b) {
|
||||
return (TopLevelWindowListener)addInternal(a, b);
|
||||
}
|
||||
|
||||
public static TopLevelWindowListener remove(TopLevelWindowListener l, TopLevelWindowListener oldl) {
|
||||
return (TopLevelWindowListener)removeInternal(l, oldl);
|
||||
}
|
||||
|
||||
protected static EventListener addInternal(EventListener a, EventListener b) {
|
||||
if (a == null) return b;
|
||||
if (b == null) return a;
|
||||
return new TopLevelWindowMulticaster(a, b);
|
||||
}
|
||||
|
||||
protected static EventListener removeInternal(EventListener l, EventListener oldl) {
|
||||
if (l == oldl || l == null) {
|
||||
return null;
|
||||
} else if (l instanceof TopLevelWindowMulticaster) {
|
||||
return ((TopLevelWindowMulticaster)l).remove(oldl);
|
||||
} else {
|
||||
return l; // it's not here
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
730
jdkSrc/jdk8/com/sun/java/accessibility/util/Translator.java
Normal file
730
jdkSrc/jdk8/com/sun/java/accessibility/util/Translator.java
Normal file
@@ -0,0 +1,730 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.java.accessibility.util;
|
||||
|
||||
import java.lang.*;
|
||||
import java.beans.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
// Do not import Swing classes. This module is intended to work
|
||||
// with both Swing and AWT.
|
||||
// import javax.swing.*;
|
||||
import javax.accessibility.*;
|
||||
|
||||
/**
|
||||
* <p>The {@code Translator} class provides a translation to interface
|
||||
* {@link javax.accessibility.Accessible Accessible}
|
||||
* for objects that do not implement interface {@code Accessible}. Assistive
|
||||
* technologies can use the {@link #getAccessible getAccessible} class method of
|
||||
* {@code Translator} to obtain an object that implements interface {@code Accessible}.
|
||||
* If the object passed in already implements interface {@code Accessible},
|
||||
* {@code getAccessible} merely returns the object.
|
||||
*
|
||||
* <p>An example of how an assistive technology might use the {@code Translator}
|
||||
* class is as follows:
|
||||
*
|
||||
* <PRE>
|
||||
* Accessible accessible = Translator.getAccessible(someObj);
|
||||
* // obtain information from the 'accessible' object.
|
||||
* </PRE>
|
||||
*
|
||||
* <P>Note: This implementation is missing many things and is not a recommended way
|
||||
* to implement accessibility features for a toolkit. Instead of relying upon this
|
||||
* code, a toolkit's components should implement interface {@code Accessible} directly.
|
||||
*/
|
||||
@jdk.Exported
|
||||
public class Translator extends AccessibleContext
|
||||
implements Accessible, AccessibleComponent {
|
||||
|
||||
/** The source object needing translating. */
|
||||
protected Object source;
|
||||
|
||||
/**
|
||||
* Find a translator for this class. If one doesn't exist for this
|
||||
* class explicitly, try its superclass and so on.
|
||||
*
|
||||
* @param c a Class
|
||||
* @return the {@code Translator} Class for the Class passed in
|
||||
*/
|
||||
protected static Class getTranslatorClass(Class c) {
|
||||
Class t = null;
|
||||
if (c == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
t = Class.forName("com.sun.java.accessibility.util."
|
||||
+ c.getName()
|
||||
+ "Translator");
|
||||
return t;
|
||||
} catch (Exception e) {
|
||||
return getTranslatorClass(c.getSuperclass());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain an object that implements interface {@code Accessible}. If the object
|
||||
* passed in already implements interface {@code Accessible}, {@code getAccessible}
|
||||
* merely returns the object.
|
||||
*
|
||||
* @param o an Object; if a null is passed in a null is returned
|
||||
* @return an {@code Object}, possibly the {@code Object} passed in, that
|
||||
* implements the {@code Accessible} interface for the {@code Object}
|
||||
* which was passed in
|
||||
*/
|
||||
public static Accessible getAccessible(Object o) {
|
||||
Accessible a = null;
|
||||
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
if (o instanceof Accessible) {
|
||||
a = (Accessible)o;
|
||||
} else {
|
||||
Class translatorClass = getTranslatorClass(o.getClass());
|
||||
if (translatorClass != null) {
|
||||
try {
|
||||
Translator t = (Translator)translatorClass.newInstance();
|
||||
t.setSource(o);
|
||||
a = t;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a == null) {
|
||||
a = new Translator(o);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code Translator}. You must call the {@link #setSource setSource}
|
||||
* method to set the object to be translated after calling this constructor.
|
||||
*/
|
||||
public Translator() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code Translator} with the source object o.
|
||||
*
|
||||
* @param o the Component that does not implement interface
|
||||
* {@link javax.accessibility.Accessible Accessible}
|
||||
*/
|
||||
public Translator(Object o) {
|
||||
source = o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source {@code Object} of the {@code Translator}.
|
||||
*
|
||||
* @return the source {@code Object} of the {@code Translator}
|
||||
*/
|
||||
public Object getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source object of the {@code Translator}.
|
||||
*
|
||||
* @param o the Component that does not implement interface Accessible
|
||||
*/
|
||||
public void setSource(Object o) {
|
||||
source = o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this object is the same as the one passed in.
|
||||
*
|
||||
* @param o the {@code Object} to check against
|
||||
* @return true if this is the same object
|
||||
*/
|
||||
public boolean equals(Object o) {
|
||||
return source.equals(o);
|
||||
}
|
||||
|
||||
|
||||
// Accessible methods
|
||||
|
||||
/**
|
||||
* Returns this object.
|
||||
*/
|
||||
public AccessibleContext getAccessibleContext() {
|
||||
return this;
|
||||
}
|
||||
|
||||
// AccessibleContext methods
|
||||
|
||||
/**
|
||||
* Get the accessible name of this object.
|
||||
*
|
||||
* @return the localized name of the object; can be null if this object
|
||||
* does not have a name
|
||||
*/
|
||||
public String getAccessibleName() {
|
||||
if (source instanceof MenuItem) {
|
||||
return ((MenuItem) source).getLabel();
|
||||
} else if (source instanceof Component) {
|
||||
return ((Component) source).getName();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of this object.
|
||||
*/
|
||||
public void setAccessibleName(String s) {
|
||||
if (source instanceof MenuItem) {
|
||||
((MenuItem) source).setLabel(s);
|
||||
} else if (source instanceof Component) {
|
||||
((Component) source).setName(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the accessible description of this object.
|
||||
*
|
||||
* @return the description of the object; can be null if this object does
|
||||
* not have a description
|
||||
*/
|
||||
public String getAccessibleDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the accessible description of this object.
|
||||
*
|
||||
* @param s the new localized description of the object
|
||||
*/
|
||||
public void setAccessibleDescription(String s) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the role of this object.
|
||||
*
|
||||
* @return an instance of AccessibleRole describing the role of the object
|
||||
*/
|
||||
public AccessibleRole getAccessibleRole() {
|
||||
return AccessibleRole.UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the state of this object, given an already populated state.
|
||||
* This method is intended for use by subclasses so they don't have
|
||||
* to check for everything.
|
||||
*
|
||||
* @return an instance of {@code AccessibleStateSet}
|
||||
* containing the current state of the object
|
||||
*/
|
||||
public AccessibleStateSet getAccessibleStateSet() {
|
||||
AccessibleStateSet states = new AccessibleStateSet();
|
||||
if (source instanceof Component) {
|
||||
Component c = (Component) source;
|
||||
for (Container p = c.getParent(); p != null; p = p.getParent()) {
|
||||
if (p instanceof Window) {
|
||||
if (((Window)p).getFocusOwner() == c) {
|
||||
states.add(AccessibleState.FOCUSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isEnabled()) {
|
||||
states.add(AccessibleState.ENABLED);
|
||||
}
|
||||
if (isFocusTraversable()) {
|
||||
states.add(AccessibleState.FOCUSABLE);
|
||||
}
|
||||
if (source instanceof MenuItem) {
|
||||
states.add(AccessibleState.FOCUSABLE);
|
||||
}
|
||||
return states;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the accessible parent of this object.
|
||||
*
|
||||
* @return the accessible parent of this object; can be null if this
|
||||
* object does not have an accessible parent
|
||||
*/
|
||||
public Accessible getAccessibleParent() {
|
||||
if (accessibleParent != null) {
|
||||
return accessibleParent;
|
||||
} else if (source instanceof Component) {
|
||||
return getAccessible(((Component) source).getParent());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index of this object in its accessible parent.
|
||||
*
|
||||
* @return -1 of this object does not have an accessible parent; otherwise,
|
||||
* the index of the child in its accessible parent
|
||||
*/
|
||||
public int getAccessibleIndexInParent() {
|
||||
if (source instanceof Component) {
|
||||
Container parent = ((Component) source).getParent();
|
||||
if (parent != null) {
|
||||
Component ca[] = parent.getComponents();
|
||||
for (int i = 0; i < ca.length; i++) {
|
||||
if (source.equals(ca[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of accessible children in the object.
|
||||
*
|
||||
* @return the number of accessible children in the object
|
||||
*/
|
||||
public int getAccessibleChildrenCount() {
|
||||
if (source instanceof Container) {
|
||||
Component[] children = ((Container) source).getComponents();
|
||||
int count = 0;
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
Accessible a = getAccessible(children[i]);
|
||||
if (a != null) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the nth accessible child of the object.
|
||||
*
|
||||
* @param i zero-based index of child
|
||||
* @return the nth accessible child of the object
|
||||
*/
|
||||
public Accessible getAccessibleChild(int i) {
|
||||
if (source instanceof Container) {
|
||||
Component[] children = ((Container) source).getComponents();
|
||||
int count = 0;
|
||||
|
||||
for (int j = 0; j < children.length; j++) {
|
||||
Accessible a = getAccessible(children[j]);
|
||||
if (a != null) {
|
||||
if (count == i) {
|
||||
AccessibleContext ac = a.getAccessibleContext();
|
||||
if (ac != null) {
|
||||
ac.setAccessibleParent(this);
|
||||
}
|
||||
return a;
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@code Locale} of the component. If the component does not have a
|
||||
* locale, the locale of its parent is returned.
|
||||
*
|
||||
* @return the {@code Locale} of the object
|
||||
*/
|
||||
public Locale getLocale() throws IllegalComponentStateException {
|
||||
if (source instanceof Component) {
|
||||
return ((Component) source).getLocale();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a {@code PropertyChangeListener} to the listener list. The listener
|
||||
* is registered for all properties.
|
||||
*/
|
||||
public void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the {@code PropertyChangeListener} from the listener list.
|
||||
*/
|
||||
public void removePropertyChangeListener(PropertyChangeListener l) {
|
||||
}
|
||||
|
||||
// AccessibleComponent methods
|
||||
|
||||
/**
|
||||
* Get the background {@code Color} of this object.
|
||||
*
|
||||
* @return if supported, the background {@code Color} of the object;
|
||||
* otherwise, null
|
||||
*
|
||||
*/
|
||||
public Color getBackground() {
|
||||
if (source instanceof Component) { // MenuComponent doesn't do background
|
||||
return ((Component) source).getBackground();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the background {@code Color} of this object.
|
||||
*
|
||||
* @param c the new {@code Color} for the background
|
||||
*/
|
||||
public void setBackground(Color c) {
|
||||
if (source instanceof Component) { // MenuComponent doesn't do background
|
||||
((Component) source).setBackground(c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the foreground {@code Color} of this object.
|
||||
*
|
||||
* @return if supported, the foreground {@code Color} of the object; otherwise, null
|
||||
*/
|
||||
public Color getForeground() {
|
||||
if (source instanceof Component) { // MenuComponent doesn't do foreground
|
||||
return ((Component) source).getForeground();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the foreground {@code Color} of this object.
|
||||
*
|
||||
* @param c the new {@code Color} for the foreground
|
||||
*/
|
||||
public void setForeground(Color c) {
|
||||
if (source instanceof Component) { // MenuComponent doesn't do foreground
|
||||
((Component) source).setForeground(c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@code Cursor} of this object.
|
||||
*
|
||||
* @return if supported, the Cursor of the object; otherwise, null
|
||||
*/
|
||||
public Cursor getCursor() {
|
||||
if (source instanceof Component) { // MenuComponent doesn't do cursor
|
||||
return ((Component) source).getCursor();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@code Cursor} of this object.
|
||||
* @param c the new {@code Cursor} for the object
|
||||
*/
|
||||
public void setCursor(Cursor c) {
|
||||
if (source instanceof Component) { // MenuComponent doesn't do cursor
|
||||
((Component) source).setCursor(c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@code Font} of this object.
|
||||
*
|
||||
* @return if supported, the {@code Font} for the object; otherwise, null
|
||||
*/
|
||||
public Font getFont() {
|
||||
if (source instanceof Component) {
|
||||
return ((Component) source).getFont();
|
||||
} else if (source instanceof MenuComponent) {
|
||||
return ((MenuComponent) source).getFont();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@code Font} of this object.
|
||||
*
|
||||
* @param f the new {@code Font} for the object
|
||||
*/
|
||||
public void setFont(Font f) {
|
||||
if (source instanceof Component) {
|
||||
((Component) source).setFont(f);
|
||||
} else if (source instanceof MenuComponent) {
|
||||
((MenuComponent) source).setFont(f);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@code FontMetrics} of this object.
|
||||
*
|
||||
* @param f the {@code Font}
|
||||
* @return if supported, the {@code FontMetrics} the object; otherwise, null
|
||||
* @see #getFont
|
||||
*/
|
||||
public FontMetrics getFontMetrics(Font f) {
|
||||
if (source instanceof Component) {
|
||||
return ((Component) source).getFontMetrics(f);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the object is enabled.
|
||||
*
|
||||
* @return true if object is enabled; otherwise, false
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
if (source instanceof Component) {
|
||||
return ((Component) source).isEnabled();
|
||||
} else if (source instanceof MenuItem) {
|
||||
return ((MenuItem) source).isEnabled();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the enabled state of the object.
|
||||
*
|
||||
* @param b if true, enables this object; otherwise, disables it
|
||||
*/
|
||||
public void setEnabled(boolean b) {
|
||||
if (source instanceof Component) {
|
||||
((Component) source).setEnabled(b);
|
||||
} else if (source instanceof MenuItem) {
|
||||
((MenuItem) source).setEnabled(b);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the object is visible.
|
||||
*
|
||||
* @return true if object is visible; otherwise, false
|
||||
*/
|
||||
public boolean isVisible() {
|
||||
if (source instanceof Component) {
|
||||
return ((Component) source).isVisible();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the visible state of the object.
|
||||
*
|
||||
* @param b if true, shows this object; otherwise, hides it
|
||||
*/
|
||||
public void setVisible(boolean b) {
|
||||
if (source instanceof Component) {
|
||||
((Component) source).setVisible(b);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the object is showing. This is determined by checking
|
||||
* the visibility of the object and ancestors of the object.
|
||||
*
|
||||
* @return true if object is showing; otherwise, false
|
||||
*/
|
||||
public boolean isShowing() {
|
||||
if (source instanceof Component) {
|
||||
return ((Component) source).isShowing();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the specified {@code Point} is within this
|
||||
* object's bounds, where the {@code Point} is relative to the coordinate
|
||||
* system of the object.
|
||||
*
|
||||
* @param p the {@code Point} relative to the coordinate system of the object
|
||||
* @return true if object contains {@code Point}; otherwise false
|
||||
*/
|
||||
public boolean contains(Point p) {
|
||||
if (source instanceof Component) {
|
||||
return ((Component) source).contains(p);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location of the object on the screen.
|
||||
*
|
||||
* @return location of object on screen; can be null if this object
|
||||
* is not on the screen
|
||||
*/
|
||||
public Point getLocationOnScreen() {
|
||||
if (source instanceof Component) {
|
||||
return ((Component) source).getLocationOnScreen();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location of the object relative to parent.
|
||||
*
|
||||
* @return location of object relative to parent; can be null if
|
||||
* this object or its parent are not on the screen
|
||||
*/
|
||||
public Point getLocation() {
|
||||
if (source instanceof Component) {
|
||||
return ((Component) source).getLocation();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location of the object relative to parent.
|
||||
*/
|
||||
public void setLocation(Point p) {
|
||||
if (source instanceof Component) {
|
||||
((Component) source).setLocation(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current bounds of this object.
|
||||
*
|
||||
* @return current bounds of object; can be null if this object
|
||||
* is not on the screen
|
||||
*/
|
||||
public Rectangle getBounds() {
|
||||
if (source instanceof Component) {
|
||||
return ((Component) source).getBounds();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current bounds of this object.
|
||||
*/
|
||||
public void setBounds(Rectangle r) {
|
||||
if (source instanceof Component) {
|
||||
((Component) source).setBounds(r);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current size of this object.
|
||||
*
|
||||
* @return current size of object; can be null if this object is
|
||||
* not on the screen
|
||||
*/
|
||||
public Dimension getSize() {
|
||||
if (source instanceof Component) {
|
||||
return ((Component) source).getSize();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current size of this object.
|
||||
*/
|
||||
public void setSize(Dimension d) {
|
||||
if (source instanceof Component) {
|
||||
((Component) source).setSize(d);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the accessible child contained at the local coordinate
|
||||
* Point, if one exists.
|
||||
*
|
||||
* @return the Accessible at the specified location, if it exists
|
||||
*/
|
||||
public Accessible getAccessibleAt(Point p) {
|
||||
if (source instanceof Component) {
|
||||
Component c = ((Component) source).getComponentAt(p);
|
||||
if (c != null) {
|
||||
return (getAccessible(c));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this object can accept focus or not.
|
||||
*
|
||||
* @return true if object can accept focus; otherwise false
|
||||
*/
|
||||
public boolean isFocusTraversable() {
|
||||
if (source instanceof Component) {
|
||||
return ((Component) source).isFocusTraversable();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests focus for this object.
|
||||
*/
|
||||
public void requestFocus() {
|
||||
if (source instanceof Component) {
|
||||
((Component) source).requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified {@code FocusListener} to receive focus events from
|
||||
* this component.
|
||||
*
|
||||
* @param l the focus listener
|
||||
*/
|
||||
public synchronized void addFocusListener(FocusListener l) {
|
||||
if (source instanceof Component) {
|
||||
((Component) source).addFocusListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified focus listener so it no longer receives focus
|
||||
* events from this component.
|
||||
*
|
||||
* @param l the focus listener; this method performs no function, nor does it
|
||||
* throw an exception if the listener specified was not previously added
|
||||
* to this component; if listener is null, no exception is thrown and no
|
||||
* action is performed.
|
||||
*/
|
||||
public synchronized void removeFocusListener(FocusListener l) {
|
||||
if (source instanceof Component) {
|
||||
((Component) source).removeFocusListener(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util.java.awt;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import javax.accessibility.*;
|
||||
import com.sun.java.accessibility.util.*;
|
||||
|
||||
/**
|
||||
* <p>The Translator class provides a translation to interface Accessible
|
||||
* for objects that do not implement interface Accessible. Assistive
|
||||
* technologies can use the 'getAccessible' class method of Translator to
|
||||
* obtain an object that implements interface Accessible. If the object
|
||||
* passed in already implements interface Accessible, getAccessible merely
|
||||
* returns the object.
|
||||
*
|
||||
* <p>An example of how an assistive technology might use the Translator
|
||||
* class is as follows:
|
||||
*
|
||||
* <PRE>
|
||||
* Accessible accessible = Translator.getAccessible(someObj);
|
||||
* // obtain information from the 'accessible' object.
|
||||
* </PRE>
|
||||
*
|
||||
* <P>This class extends the Translator class to provide specific support
|
||||
* for the Button class. Translator.getAccessible() will automatically
|
||||
* load this class when an assistive technology asks for an accessible
|
||||
* translator for Button.
|
||||
*
|
||||
*/
|
||||
public class ButtonTranslator extends Translator {
|
||||
|
||||
/**
|
||||
* Get the name of this object.
|
||||
* @return the name of the object -- can be null if this object does
|
||||
* not have a name
|
||||
*/
|
||||
public String getAccessibleName() {
|
||||
return ((Button) source).getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of this object.
|
||||
*/
|
||||
public void setAccessibleName(String s) {
|
||||
((Button) source).setLabel(s);
|
||||
}
|
||||
|
||||
public AccessibleRole getAccessibleRole() {
|
||||
return AccessibleRole.PUSH_BUTTON;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util.java.awt;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import javax.accessibility.*;
|
||||
import com.sun.java.accessibility.util.*;
|
||||
|
||||
/**
|
||||
* <p>The Translator class provides a translation to interface Accessible
|
||||
* for objects that do not implement interface Accessible. Assistive
|
||||
* technologies can use the 'getAccessible' class method of Translator to
|
||||
* obtain an object that implements interface Accessible. If the object
|
||||
* passed in already implements interface Accessible, getAccessible merely
|
||||
* returns the object.
|
||||
*
|
||||
* <p>An example of how an assistive technology might use the Translator
|
||||
* class is as follows:
|
||||
*
|
||||
* <PRE>
|
||||
* Accessible accessible = Translator.getAccessible(someObj);
|
||||
* // obtain information from the 'accessible' object.
|
||||
* </PRE>
|
||||
*
|
||||
* <P>This class extends the Translator class to provide specific support
|
||||
* for the Checkbox class. Translator.getAccessible() will automatically
|
||||
* load this class when an assistive technology asks for an accessible
|
||||
* translator for Checkbox.
|
||||
*
|
||||
*/
|
||||
public class CheckboxTranslator extends Translator {
|
||||
|
||||
/**
|
||||
* Get the state of this object.
|
||||
* @return an instance of AccessibleState containing the current state of the object
|
||||
* @see AccessibleState
|
||||
*/
|
||||
public AccessibleStateSet getAccessibleStateSet() {
|
||||
AccessibleStateSet states = super.getAccessibleStateSet();
|
||||
if (((Checkbox) source).getState()) {
|
||||
states.add(AccessibleState.CHECKED);
|
||||
}
|
||||
return states;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this object.
|
||||
* @return the name of the object -- can be null if this object does
|
||||
* not have a name
|
||||
*/
|
||||
public String getAccessibleName() {
|
||||
return ((Checkbox) source).getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of this object.
|
||||
*/
|
||||
public void setAccessibleName(String s) {
|
||||
((Checkbox) source).setLabel(s);
|
||||
}
|
||||
|
||||
public AccessibleRole getAccessibleRole() {
|
||||
return AccessibleRole.CHECK_BOX;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util.java.awt;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import javax.accessibility.*;
|
||||
import com.sun.java.accessibility.util.*;
|
||||
|
||||
/**
|
||||
* <p>The Translator class provides a translation to interface Accessible
|
||||
* for objects that do not implement interface Accessible. Assistive
|
||||
* technologies can use the 'getAccessible' class method of Translator to
|
||||
* obtain an object that implements interface Accessible. If the object
|
||||
* passed in already implements interface Accessible, getAccessible merely
|
||||
* returns the object.
|
||||
*
|
||||
* <p>An example of how an assistive technology might use the Translator
|
||||
* class is as follows:
|
||||
*
|
||||
* <PRE>
|
||||
* Accessible accessible = Translator.getAccessible(someObj);
|
||||
* // obtain information from the 'accessible' object.
|
||||
* </PRE>
|
||||
*
|
||||
* <P>This class extends the Translator class to provide specific support
|
||||
* for the Label class. Translator.getAccessible() will automatically
|
||||
* load this class when an assistive technology asks for an accessible
|
||||
* translator for Label.
|
||||
*
|
||||
*/
|
||||
public class LabelTranslator extends Translator {
|
||||
|
||||
public String getAccessibleName() {
|
||||
return ((Label) source).getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of this object.
|
||||
*/
|
||||
public void setAccessibleName(String s) {
|
||||
((Label) source).setText(s);
|
||||
}
|
||||
|
||||
public AccessibleRole getAccessibleRole() {
|
||||
return AccessibleRole.LABEL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util.java.awt;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import javax.accessibility.*;
|
||||
import com.sun.java.accessibility.util.*;
|
||||
|
||||
/**
|
||||
* <p>The Translator class provides a translation to interface Accessible
|
||||
* for objects that do not implement interface Accessible. Assistive
|
||||
* technologies can use the 'getAccessible' class method of Translator to
|
||||
* obtain an object that implements interface Accessible. If the object
|
||||
* passed in already implements interface Accessible, getAccessible merely
|
||||
* returns the object.
|
||||
*
|
||||
* <p>An example of how an assistive technology might use the Translator
|
||||
* class is as follows:
|
||||
*
|
||||
* <PRE>
|
||||
* Accessible accessible = Translator.getAccessible(someObj);
|
||||
* // obtain information from the 'accessible' object.
|
||||
* </PRE>
|
||||
*
|
||||
* <P>This class extends the Translator class to provide specific support
|
||||
* for the List class. Translator.getAccessible() will automatically
|
||||
* load this class when an assistive technology asks for an accessible
|
||||
* translator for List.
|
||||
*
|
||||
*/
|
||||
public class ListTranslator extends Translator {
|
||||
|
||||
/**
|
||||
* Get the state of this object.
|
||||
* @return an instance of AccessibleState containing the current state of the object
|
||||
* @see AccessibleState
|
||||
*/
|
||||
public AccessibleStateSet getAccessibleStateSet() {
|
||||
AccessibleStateSet states = super.getAccessibleStateSet();
|
||||
if (((java.awt.List) source).isMultipleMode()) {
|
||||
states.add(AccessibleState.MULTISELECTABLE);
|
||||
}
|
||||
if (((java.awt.List) source).getSelectedItems().length > 0) {
|
||||
states.add(AccessibleState.SELECTED);
|
||||
}
|
||||
return states;
|
||||
}
|
||||
|
||||
public AccessibleRole getAccessibleRole() {
|
||||
return AccessibleRole.LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.accessibility.util.java.awt;
|
||||
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import javax.accessibility.*;
|
||||
import com.sun.java.accessibility.util.*;
|
||||
|
||||
/**
|
||||
* <p>The Translator class provides a translation to interface Accessible
|
||||
* for objects that do not implement interface Accessible. Assistive
|
||||
* technologies can use the 'getAccessible' class method of Translator to
|
||||
* obtain an object that implements interface Accessible. If the object
|
||||
* passed in already implements interface Accessible, getAccessible merely
|
||||
* returns the object.
|
||||
*
|
||||
* <p>An example of how an assistive technology might use the Translator
|
||||
* class is as follows:
|
||||
*
|
||||
* <PRE>
|
||||
* Accessible accessible = Translator.getAccessible(someObj);
|
||||
* // obtain information from the 'accessible' object.
|
||||
* </PRE>
|
||||
*
|
||||
* <P>This class extends the Translator class to provide specific support
|
||||
* for the TextComponent class. Translator.getAccessible() will automatically
|
||||
* load this class when an assistive technology asks for an accessible
|
||||
* translator for TextComponent.
|
||||
*
|
||||
*/
|
||||
public class TextComponentTranslator extends Translator {
|
||||
|
||||
public AccessibleRole getAccessibleRole() {
|
||||
return AccessibleRole.TEXT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides a collection of interfaces and classes that compose the Java Accessibility
|
||||
* Utilities. The classes are used by Assistive Technologies, such as the screen
|
||||
* readers which are used by those who are blind, and help provide access to GUI
|
||||
* toolkits that implement the Java Accessibility API. An overview of the important
|
||||
* classes follows.
|
||||
*
|
||||
* <p>The class {@code AccessibilityEventMonitor} implements a PropertyChange
|
||||
* listener on every UI object that implements interface {@code Accessible} in the Java
|
||||
* Virtual Machine.
|
||||
*
|
||||
* <p> The class {@code AWTEventMonitor} implements a suite of listeners that are
|
||||
* conditionally installed on every AWT component instance in the Java Virtual Machine.
|
||||
*
|
||||
* <p>The class {@code EventQueueMonitor} provides key core functionality for
|
||||
* Assistive Technologies (and other system-level technologies that need some of
|
||||
* the same things that Assistive Technology needs).
|
||||
*
|
||||
* <p>The class {@code GUIInitializedMulticaster} is used to maintain a list of
|
||||
* {@code GUIInitializedListener} classes which are used by the {@code EventQueueMonitor}
|
||||
* class to notify an interested party when the GUI subsystem has been initialized.
|
||||
* Note that this class is intended to be used primarily for internal support in
|
||||
* the {@code EventQueueMonitor} class, and is not intended to be used by classes
|
||||
* outside the Java Accessibility Utility package.
|
||||
*
|
||||
* <p>The class {@code SwingEventMonitor} extends {@code AWTEventMonitor} by adding
|
||||
* a suite of listeners conditionally installed on every Swing component instance
|
||||
* in the Java Virtual Machine.
|
||||
*
|
||||
* <p>The class {@code TopLevelWindowMulticaster} is used to maintain a list of
|
||||
* {@code TopLevelWindowListener} classes which are used by the {@code EventQueueMonitor}
|
||||
* class to notify an interested party when a top level window is created or destroyed
|
||||
* in the Java Virtual Machine Note that this class is intended to be used primarily
|
||||
* for internal support in the {@code EventQueueMonitor} class, and is not intended
|
||||
* to be used by classes outside the Java Accessibility Utility package.
|
||||
*
|
||||
* <p>The class {@code Translator} provides a translation to interface {@code Accessible}
|
||||
* for objects that do not implement interface {@code Accessible}.
|
||||
*
|
||||
* @since JDK1.7
|
||||
*/
|
||||
|
||||
@jdk.Exported
|
||||
package com.sun.java.accessibility.util;
|
||||
89
jdkSrc/jdk8/com/sun/java/browser/dom/DOMAccessException.java
Normal file
89
jdkSrc/jdk8/com/sun/java/browser/dom/DOMAccessException.java
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.browser.dom;
|
||||
|
||||
public class DOMAccessException extends Exception
|
||||
{
|
||||
/**
|
||||
* Constructs a new DOMAccessException with no detail message.
|
||||
*/
|
||||
public DOMAccessException()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new DOMAccessException with the given detail message.
|
||||
*
|
||||
* @param msg Detail message.
|
||||
*/
|
||||
public DOMAccessException(String msg)
|
||||
{
|
||||
this(null, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new DOMAccessException with the given exception as a root clause.
|
||||
*
|
||||
* @param e Exception.
|
||||
*/
|
||||
public DOMAccessException(Exception e)
|
||||
{
|
||||
this(e, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new DOMAccessException with the given exception as a root clause and the given detail message.
|
||||
*
|
||||
* @param e Exception.
|
||||
* @param msg Detail message.
|
||||
*/
|
||||
public DOMAccessException(Exception e, String msg)
|
||||
{
|
||||
this.ex = e;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the detail message of the error or null if there is no detail message.
|
||||
*/
|
||||
public String getMessage()
|
||||
{
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the root cause of the error or null if there is none.
|
||||
*/
|
||||
public Throwable getCause()
|
||||
{
|
||||
return ex;
|
||||
}
|
||||
|
||||
private Throwable ex;
|
||||
private String msg;
|
||||
}
|
||||
40
jdkSrc/jdk8/com/sun/java/browser/dom/DOMAccessor.java
Normal file
40
jdkSrc/jdk8/com/sun/java/browser/dom/DOMAccessor.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.browser.dom;
|
||||
|
||||
|
||||
public interface DOMAccessor
|
||||
{
|
||||
/**
|
||||
* Returns the Document object of the DOM.
|
||||
*/
|
||||
public org.w3c.dom.Document getDocument(Object obj) throws org.w3c.dom.DOMException;
|
||||
|
||||
/**
|
||||
* Returns a DOMImplementation object.
|
||||
*/
|
||||
public org.w3c.dom.DOMImplementation getDOMImplementation();
|
||||
}
|
||||
42
jdkSrc/jdk8/com/sun/java/browser/dom/DOMAction.java
Normal file
42
jdkSrc/jdk8/com/sun/java/browser/dom/DOMAction.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.browser.dom;
|
||||
|
||||
|
||||
public interface DOMAction
|
||||
{
|
||||
/**
|
||||
* When an object implementing interface DOMAction is passed
|
||||
* to DOMService.invokeAndWait() or DOMService.invokeLater(),
|
||||
* run method is called in the DOM access dispatch thread.
|
||||
*
|
||||
* accessor is used for the DOMAction to access the entry point of
|
||||
* the browser's DOM, if necessary.
|
||||
*
|
||||
* @param accessor DOMAccessor
|
||||
*/
|
||||
public Object run(DOMAccessor accessor);
|
||||
}
|
||||
103
jdkSrc/jdk8/com/sun/java/browser/dom/DOMService.java
Normal file
103
jdkSrc/jdk8/com/sun/java/browser/dom/DOMService.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.browser.dom;
|
||||
|
||||
public abstract class DOMService
|
||||
{
|
||||
/**
|
||||
* Returns new instance of a DOMService. The implementation
|
||||
* of the DOMService returns depends on the setting of the
|
||||
* com.sun.java.browser.dom.DOMServiceProvider property or,
|
||||
* if the property is not set, a platform specific default.
|
||||
*
|
||||
* Throws DOMUnsupportedException if the DOMService is not
|
||||
* available to the obj.
|
||||
*
|
||||
* @param obj Object to leverage the DOMService
|
||||
*/
|
||||
public static DOMService getService(Object obj)
|
||||
throws DOMUnsupportedException
|
||||
{
|
||||
try
|
||||
{
|
||||
String provider = (String) java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction("com.sun.java.browser.dom.DOMServiceProvider"));
|
||||
|
||||
Class clazz = DOMService.class.forName("sun.plugin.dom.DOMService");
|
||||
|
||||
return (DOMService) clazz.newInstance();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
throw new DOMUnsupportedException(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An empty constructor is provided. Implementations of this
|
||||
* abstract class must provide a public no-argument constructor
|
||||
* in order for the static getService() method to work correctly.
|
||||
* Application programmers should not be able to directly
|
||||
* construct implementation subclasses of this abstract subclass.
|
||||
*/
|
||||
public DOMService()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes action.run() to be executed synchronously on the
|
||||
* DOM action dispatching thread. This call will block until all
|
||||
* pending DOM actions have been processed and (then)
|
||||
* action.run() returns. This method should be used when an
|
||||
* application thread needs to access the browser's DOM.
|
||||
* It should not be called from the DOMActionDispatchThread.
|
||||
*
|
||||
* Note that if the DOMAction.run() method throws an uncaught
|
||||
* exception (on the DOM action dispatching thread), it's caught
|
||||
* and re-thrown, as an DOMAccessException, on the caller's thread.
|
||||
*
|
||||
* If the DOMAction.run() method throws any DOM security related
|
||||
* exception (on the DOM action dispatching thread), it's caught
|
||||
* and re-thrown, as an DOMSecurityException, on the caller's thread.
|
||||
*
|
||||
* @param action DOMAction.
|
||||
*/
|
||||
public abstract Object invokeAndWait(DOMAction action) throws DOMAccessException;
|
||||
|
||||
/**
|
||||
* Causes action.run() to be executed asynchronously on the
|
||||
* DOM action dispatching thread. This method should be used
|
||||
* when an application thread needs to access the browser's
|
||||
* DOM. It should not be called from the DOMActionDispatchThread.
|
||||
*
|
||||
* Note that if the DOMAction.run() method throws an uncaught
|
||||
* exception (on the DOM action dispatching thread), it will not be
|
||||
* caught and re-thrown on the caller's thread.
|
||||
*
|
||||
* @param action DOMAction.
|
||||
*/
|
||||
public abstract void invokeLater(DOMAction action);
|
||||
}
|
||||
60
jdkSrc/jdk8/com/sun/java/browser/dom/DOMServiceProvider.java
Normal file
60
jdkSrc/jdk8/com/sun/java/browser/dom/DOMServiceProvider.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.browser.dom;
|
||||
|
||||
public abstract class DOMServiceProvider
|
||||
{
|
||||
/**
|
||||
* An empty constructor is provided. Implementations should
|
||||
* provide a public constructor so that the DOMService
|
||||
* can instantiate instances of the implementation class.
|
||||
* Application programmers should not be able to directly
|
||||
* construct implementation subclasses of this abstract subclass.
|
||||
* The only way an application should be able to obtain a
|
||||
* reference to a DOMServiceProvider implementation
|
||||
* instance is by using the appropriate methods of the
|
||||
* DOMService.
|
||||
*/
|
||||
public DOMServiceProvider()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the DOMService can determine the association
|
||||
* between the obj and the underlying DOM in the browser.
|
||||
*/
|
||||
public abstract boolean canHandle(Object obj);
|
||||
|
||||
/**
|
||||
* Returns the Document object of the DOM.
|
||||
*/
|
||||
public abstract org.w3c.dom.Document getDocument(Object obj) throws DOMUnsupportedException;
|
||||
|
||||
/**
|
||||
* Returns the DOMImplemenation object of the DOM.
|
||||
*/
|
||||
public abstract org.w3c.dom.DOMImplementation getDOMImplementation();
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.browser.dom;
|
||||
|
||||
|
||||
public class DOMUnsupportedException extends Exception
|
||||
{
|
||||
/**
|
||||
* Constructs a new DOMUnsupportedException with no detail message.
|
||||
*/
|
||||
public DOMUnsupportedException()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new DOMUnsupportedException with the given detail message.
|
||||
*
|
||||
* @param msg Detail message.
|
||||
*/
|
||||
public DOMUnsupportedException(String msg)
|
||||
{
|
||||
this(null, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new DOMUnsupportedException with the given exception as a root clause.
|
||||
*
|
||||
* @param e Exception.
|
||||
*/
|
||||
public DOMUnsupportedException(Exception e)
|
||||
{
|
||||
this(e, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new DOMUnsupportedException with the given exception as a root clause and the given detail message.
|
||||
*
|
||||
* @param e Exception.
|
||||
* @param msg Detail message.
|
||||
*/
|
||||
public DOMUnsupportedException(Exception e, String msg)
|
||||
{
|
||||
this.ex = e;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the detail message of the error or null if there is no detail message.
|
||||
*/
|
||||
public String getMessage()
|
||||
{
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the root cause of the error or null if there is none.
|
||||
*/
|
||||
public Throwable getCause()
|
||||
{
|
||||
return ex;
|
||||
}
|
||||
|
||||
private Throwable ex;
|
||||
private String msg;
|
||||
}
|
||||
36
jdkSrc/jdk8/com/sun/java/browser/net/ProxyInfo.java
Normal file
36
jdkSrc/jdk8/com/sun/java/browser/net/ProxyInfo.java
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.browser.net;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Zhengyu Gu
|
||||
*/
|
||||
public interface ProxyInfo {
|
||||
public String getHost();
|
||||
public int getPort();
|
||||
public boolean isSocks();
|
||||
}
|
||||
61
jdkSrc/jdk8/com/sun/java/browser/net/ProxyService.java
Normal file
61
jdkSrc/jdk8/com/sun/java/browser/net/ProxyService.java
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.browser.net;
|
||||
|
||||
import java.net.URL;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Zhengyu Gu
|
||||
*/
|
||||
public class ProxyService extends Object {
|
||||
private static ProxyServiceProvider provider = null;
|
||||
|
||||
|
||||
public static void setProvider(ProxyServiceProvider p)
|
||||
throws IOException {
|
||||
if(null == provider)
|
||||
provider = p;
|
||||
else
|
||||
throw new IOException("Proxy service provider has already been set.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>The function returns proxy information of the specified URL.</p>
|
||||
* @param url URL
|
||||
* @return returns proxy information. If there is not proxy, returns null
|
||||
* @since 1.4
|
||||
*/
|
||||
public static ProxyInfo[] getProxyInfo(URL url)
|
||||
throws IOException {
|
||||
if(null == provider)
|
||||
throw new IOException("Proxy service provider is not yet set");
|
||||
|
||||
return provider.getProxyInfo(url);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.browser.net;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Zhengyu Gu
|
||||
*/
|
||||
public interface ProxyServiceProvider {
|
||||
public ProxyInfo[] getProxyInfo(URL url);
|
||||
}
|
||||
34
jdkSrc/jdk8/com/sun/java/swing/Painter.java
Normal file
34
jdkSrc/jdk8/com/sun/java/swing/Painter.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing;
|
||||
|
||||
/**
|
||||
* This class is preserved for backward compatibility with JDK 6.
|
||||
*
|
||||
* @deprecated Use {@link javax.swing.Painter} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Painter<T> extends javax.swing.Painter<T> {
|
||||
}
|
||||
222
jdkSrc/jdk8/com/sun/java/swing/SwingUtilities3.java
Normal file
222
jdkSrc/jdk8/com/sun/java/swing/SwingUtilities3.java
Normal file
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing;
|
||||
|
||||
import sun.awt.EventQueueDelegate;
|
||||
import sun.awt.AppContext;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.applet.Applet;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Window;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.RepaintManager;
|
||||
|
||||
/**
|
||||
* A collection of utility methods for Swing.
|
||||
* <p>
|
||||
* <b>WARNING:</b> While this class is public, it should not be treated as
|
||||
* public API and its API may change in incompatable ways between dot dot
|
||||
* releases and even patch releases. You should not rely on this class even
|
||||
* existing.
|
||||
*
|
||||
* This is a second part of sun.swing.SwingUtilities2. It is required
|
||||
* to provide services for JavaFX applets.
|
||||
*
|
||||
*/
|
||||
public class SwingUtilities3 {
|
||||
/**
|
||||
* The {@code clientProperty} key for delegate {@code RepaintManager}
|
||||
*/
|
||||
private static final Object DELEGATE_REPAINT_MANAGER_KEY =
|
||||
new StringBuilder("DelegateRepaintManagerKey");
|
||||
|
||||
/**
|
||||
* Registers delegate RepaintManager for {@code JComponent}.
|
||||
*/
|
||||
public static void setDelegateRepaintManager(JComponent component,
|
||||
RepaintManager repaintManager) {
|
||||
/* setting up flag in AppContext to speed up lookups in case
|
||||
* there are no delegate RepaintManagers used.
|
||||
*/
|
||||
AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
|
||||
Boolean.TRUE);
|
||||
|
||||
component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
|
||||
repaintManager);
|
||||
}
|
||||
|
||||
private static final Map<Container, Boolean> vsyncedMap =
|
||||
Collections.synchronizedMap(new WeakHashMap<Container, Boolean>());
|
||||
|
||||
/**
|
||||
* Sets vsyncRequested state for the {@code rootContainer}. If
|
||||
* {@code isRequested} is {@code true} then vsynced
|
||||
* {@code BufferStrategy} is enabled for this {@code rootContainer}.
|
||||
*
|
||||
* Note: requesting vsynced painting does not guarantee one. The outcome
|
||||
* depends on current RepaintManager's RepaintManager.PaintManager
|
||||
* and on the capabilities of the graphics hardware/software and what not.
|
||||
*
|
||||
* @param rootContainer topmost container. Should be either {@code Window}
|
||||
* or {@code Applet}
|
||||
* @param isRequested the value to set vsyncRequested state to
|
||||
*/
|
||||
public static void setVsyncRequested(Container rootContainer,
|
||||
boolean isRequested) {
|
||||
assert (rootContainer instanceof Applet) || (rootContainer instanceof Window);
|
||||
if (isRequested) {
|
||||
vsyncedMap.put(rootContainer, Boolean.TRUE);
|
||||
} else {
|
||||
vsyncedMap.remove(rootContainer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if vsync painting is requested for {@code rootContainer}
|
||||
*
|
||||
* @param rootContainer topmost container. Should be either Window or Applet
|
||||
* @return {@code true} if vsync painting is requested for {@code rootContainer}
|
||||
*/
|
||||
public static boolean isVsyncRequested(Container rootContainer) {
|
||||
assert (rootContainer instanceof Applet) || (rootContainer instanceof Window);
|
||||
return Boolean.TRUE == vsyncedMap.get(rootContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns delegate {@code RepaintManager} for {@code component} hierarchy.
|
||||
*/
|
||||
public static RepaintManager getDelegateRepaintManager(Component
|
||||
component) {
|
||||
RepaintManager delegate = null;
|
||||
if (Boolean.TRUE == SunToolkit.targetToAppContext(component)
|
||||
.get(DELEGATE_REPAINT_MANAGER_KEY)) {
|
||||
while (delegate == null && component != null) {
|
||||
while (component != null
|
||||
&& ! (component instanceof JComponent)) {
|
||||
component = component.getParent();
|
||||
}
|
||||
if (component != null) {
|
||||
delegate = (RepaintManager)
|
||||
((JComponent) component)
|
||||
.getClientProperty(DELEGATE_REPAINT_MANAGER_KEY);
|
||||
component = component.getParent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return delegate;
|
||||
}
|
||||
|
||||
/*
|
||||
* We use maps to avoid reflection. Hopefully it should perform better
|
||||
* this way.
|
||||
*/
|
||||
public static void setEventQueueDelegate(
|
||||
Map<String, Map<String, Object>> map) {
|
||||
EventQueueDelegate.setDelegate(new EventQueueDelegateFromMap(map));
|
||||
}
|
||||
|
||||
private static class EventQueueDelegateFromMap
|
||||
implements EventQueueDelegate.Delegate {
|
||||
private final AWTEvent[] afterDispatchEventArgument;
|
||||
private final Object[] afterDispatchHandleArgument;
|
||||
private final Callable<Void> afterDispatchCallable;
|
||||
|
||||
private final AWTEvent[] beforeDispatchEventArgument;
|
||||
private final Callable<Object> beforeDispatchCallable;
|
||||
|
||||
private final EventQueue[] getNextEventEventQueueArgument;
|
||||
private final Callable<AWTEvent> getNextEventCallable;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public EventQueueDelegateFromMap(Map<String, Map<String, Object>> objectMap) {
|
||||
Map<String, Object> methodMap = objectMap.get("afterDispatch");
|
||||
afterDispatchEventArgument = (AWTEvent[]) methodMap.get("event");
|
||||
afterDispatchHandleArgument = (Object[]) methodMap.get("handle");
|
||||
afterDispatchCallable = (Callable<Void>) methodMap.get("method");
|
||||
|
||||
methodMap = objectMap.get("beforeDispatch");
|
||||
beforeDispatchEventArgument = (AWTEvent[]) methodMap.get("event");
|
||||
beforeDispatchCallable = (Callable<Object>) methodMap.get("method");
|
||||
|
||||
methodMap = objectMap.get("getNextEvent");
|
||||
getNextEventEventQueueArgument =
|
||||
(EventQueue[]) methodMap.get("eventQueue");
|
||||
getNextEventCallable = (Callable<AWTEvent>) methodMap.get("method");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterDispatch(AWTEvent event, Object handle) throws InterruptedException {
|
||||
afterDispatchEventArgument[0] = event;
|
||||
afterDispatchHandleArgument[0] = handle;
|
||||
try {
|
||||
afterDispatchCallable.call();
|
||||
} catch (InterruptedException e) {
|
||||
throw e;
|
||||
} catch (RuntimeException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object beforeDispatch(AWTEvent event) throws InterruptedException {
|
||||
beforeDispatchEventArgument[0] = event;
|
||||
try {
|
||||
return beforeDispatchCallable.call();
|
||||
} catch (InterruptedException e) {
|
||||
throw e;
|
||||
} catch (RuntimeException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AWTEvent getNextEvent(EventQueue eventQueue) throws InterruptedException {
|
||||
getNextEventEventQueueArgument[0] = eventQueue;
|
||||
try {
|
||||
return getNextEventCallable.call();
|
||||
} catch (InterruptedException e) {
|
||||
throw e;
|
||||
} catch (RuntimeException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1303
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKColorChooserPanel.java
Normal file
1303
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKColorChooserPanel.java
Normal file
File diff suppressed because it is too large
Load Diff
167
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKColorType.java
Normal file
167
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKColorType.java
Normal file
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.gtk;
|
||||
|
||||
import javax.swing.plaf.synth.ColorType;
|
||||
import java.awt.Color;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
|
||||
/**
|
||||
* @author Scott Violet
|
||||
*/
|
||||
public class GTKColorType extends ColorType {
|
||||
// GTK allows you to specify the foreground and background in a
|
||||
// gtkrc, the rest (dark, mid, light) are calculated from these
|
||||
// values.
|
||||
public static final ColorType LIGHT = new GTKColorType("Light");
|
||||
public static final ColorType DARK = new GTKColorType("Dark");
|
||||
public static final ColorType MID = new GTKColorType("Mid");
|
||||
public static final ColorType BLACK = new GTKColorType("Black");
|
||||
public static final ColorType WHITE = new GTKColorType("White");
|
||||
|
||||
public static final int MAX_COUNT;
|
||||
|
||||
private static final float[] HLS_COLORS = new float[3];
|
||||
private static final Object HLS_COLOR_LOCK = new Object();
|
||||
|
||||
static {
|
||||
MAX_COUNT = WHITE.getID() + 1;
|
||||
}
|
||||
|
||||
private static int hlsToRGB(float h, float l, float s) {
|
||||
float m2 = (l <= .5f) ? (l * (1 + s)) : (l + s - l * s);
|
||||
float m1 = 2.0f * l - m2;
|
||||
float r, g, b;
|
||||
|
||||
if (s == 0.0) {
|
||||
if (h == 0.0) {
|
||||
r = g = b = l;
|
||||
}
|
||||
else {
|
||||
r = g = b = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
r = hlsValue(m1, m2, h + 120);
|
||||
g = hlsValue(m1, m2, h);
|
||||
b = hlsValue(m1, m2, h - 120);
|
||||
}
|
||||
return (((int)(r * 255)) << 16) | (((int)(g * 255.0)) << 8) |
|
||||
((int)(b * 255));
|
||||
}
|
||||
|
||||
private static float hlsValue(float n1, float n2, float h) {
|
||||
if (h > 360) {
|
||||
h -= 360;
|
||||
}
|
||||
else if (h < 0) {
|
||||
h += 360;
|
||||
}
|
||||
if (h < 60) {
|
||||
return n1 + (n2 - n1) * h / 60.0f;
|
||||
}
|
||||
else if (h < 180) {
|
||||
return n2;
|
||||
}
|
||||
else if (h < 240) {
|
||||
return n1 + (n2 - n1) * (240.0f - h) / 60.0f;
|
||||
}
|
||||
return n1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts from RGB color space to HLS colorspace.
|
||||
*/
|
||||
private static float[] rgbToHLS(int rgb, float[] hls) {
|
||||
float r = ((rgb & 0xFF0000) >> 16) / 255.0f;
|
||||
float g = ((rgb & 0xFF00) >> 8) / 255.0f;
|
||||
float b = (rgb & 0xFF) / 255.0f;
|
||||
|
||||
/* calculate lightness */
|
||||
float max = Math.max(Math.max(r, g), b);
|
||||
float min = Math.min(Math.min(r, g), b);
|
||||
float l = (max + min) / 2.0f;
|
||||
float s = 0;
|
||||
float h = 0;
|
||||
|
||||
if (max != min) {
|
||||
float delta = max - min;
|
||||
s = (l <= .5f) ? (delta / (max + min)) : (delta / (2.0f - max -min));
|
||||
if (r == max) {
|
||||
h = (g - b) / delta;
|
||||
}
|
||||
else if (g == max) {
|
||||
h = 2.0f + (b - r) / delta;
|
||||
}
|
||||
else {
|
||||
h = 4.0f + (r - g) / delta;
|
||||
}
|
||||
h *= 60.0f;
|
||||
if (h < 0) {
|
||||
h += 360.0f;
|
||||
}
|
||||
}
|
||||
if (hls == null) {
|
||||
hls = new float[3];
|
||||
}
|
||||
hls[0] = h;
|
||||
hls[1] = l;
|
||||
hls[2] = s;
|
||||
return hls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a new color derived from the passed in color.
|
||||
* The transformation is done in the HLS color space using the specified
|
||||
* arguments to scale.
|
||||
*
|
||||
* @param color Color to alter
|
||||
* @param hFactory Amount to scale the hue
|
||||
* @param lFactor Amount to scale the lightness
|
||||
* @param sFactory Amount to sacle saturation
|
||||
* @return newly created color
|
||||
*/
|
||||
static Color adjustColor(Color color, float hFactor, float lFactor,
|
||||
float sFactor) {
|
||||
float h;
|
||||
float l;
|
||||
float s;
|
||||
|
||||
synchronized(HLS_COLOR_LOCK) {
|
||||
float[] hls = rgbToHLS(color.getRGB(), HLS_COLORS);
|
||||
h = hls[0];
|
||||
l = hls[1];
|
||||
s = hls[2];
|
||||
}
|
||||
h = Math.min(360, hFactor * h);
|
||||
l = Math.min(1, lFactor * l);
|
||||
s = Math.min(1, sFactor * s);
|
||||
return new ColorUIResource(hlsToRGB(h, l, s));
|
||||
}
|
||||
|
||||
protected GTKColorType(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
||||
118
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKConstants.java
Normal file
118
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKConstants.java
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.gtk;
|
||||
|
||||
/**
|
||||
* @author Scott Violet
|
||||
*/
|
||||
public interface GTKConstants {
|
||||
|
||||
/**
|
||||
* Used to indicate a constant is not defined.
|
||||
*/
|
||||
public static final int UNDEFINED = -100;
|
||||
|
||||
/**
|
||||
* Java representation of native GtkIconSize enum
|
||||
*/
|
||||
public enum IconSize {
|
||||
INVALID,
|
||||
MENU,
|
||||
SMALL_TOOLBAR,
|
||||
LARGE_TOOLBAR,
|
||||
BUTTON,
|
||||
DND,
|
||||
DIALOG
|
||||
}
|
||||
|
||||
/**
|
||||
* Java representation of native GtkTextDirection enum
|
||||
*/
|
||||
public enum TextDirection {
|
||||
NONE,
|
||||
LTR,
|
||||
RTL
|
||||
}
|
||||
|
||||
/**
|
||||
* Java representation of native GtkShadowType enum
|
||||
*/
|
||||
public enum ShadowType {
|
||||
NONE,
|
||||
IN,
|
||||
OUT,
|
||||
ETCHED_IN,
|
||||
ETCHED_OUT
|
||||
}
|
||||
|
||||
/**
|
||||
* Java representation of native GtkStateType enum
|
||||
*/
|
||||
public enum StateType {
|
||||
NORMAL,
|
||||
ACTIVE,
|
||||
PRELIGHT,
|
||||
SELECTED,
|
||||
INSENSITIVE
|
||||
}
|
||||
|
||||
/**
|
||||
* Java representation of native GtkExpanderStyle enum
|
||||
*/
|
||||
public enum ExpanderStyle {
|
||||
COLLAPSED,
|
||||
SEMI_COLLAPSED,
|
||||
SEMI_EXPANDED,
|
||||
EXPANDED,
|
||||
}
|
||||
|
||||
/**
|
||||
* Java representation of native GtkPositionType enum
|
||||
*/
|
||||
public enum PositionType {
|
||||
LEFT,
|
||||
RIGHT,
|
||||
TOP,
|
||||
BOTTOM
|
||||
}
|
||||
|
||||
/**
|
||||
* Java representation of native GtkArrowType enum
|
||||
*/
|
||||
public enum ArrowType {
|
||||
UP,
|
||||
DOWN,
|
||||
LEFT,
|
||||
RIGHT
|
||||
}
|
||||
|
||||
/**
|
||||
* Java representation of native GtkOrientation enum
|
||||
*/
|
||||
public enum Orientation {
|
||||
HORIZONTAL,
|
||||
VERTICAL
|
||||
}
|
||||
}
|
||||
646
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKEngine.java
Normal file
646
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKEngine.java
Normal file
@@ -0,0 +1,646 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.gtk;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.util.HashMap;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.synth.*;
|
||||
|
||||
import com.sun.java.swing.plaf.gtk.GTKConstants.ArrowType;
|
||||
import com.sun.java.swing.plaf.gtk.GTKConstants.ExpanderStyle;
|
||||
import com.sun.java.swing.plaf.gtk.GTKConstants.Orientation;
|
||||
import com.sun.java.swing.plaf.gtk.GTKConstants.PositionType;
|
||||
import com.sun.java.swing.plaf.gtk.GTKConstants.ShadowType;
|
||||
import com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection;
|
||||
|
||||
import sun.awt.image.SunWritableRaster;
|
||||
import sun.swing.ImageCache;
|
||||
|
||||
/**
|
||||
* GTKEngine delegates all painting job to native GTK libraries.
|
||||
*
|
||||
* Painting with GTKEngine looks like this:
|
||||
* First, startPainting() is called. It prepares an offscreen buffer of the
|
||||
* required size.
|
||||
* Then, any number of paintXXX() methods can be called. They effectively ignore
|
||||
* the Graphics parameter and draw to the offscreen buffer.
|
||||
* Finally, finishPainting() should be called. It fills the data buffer passed
|
||||
* in with the image data.
|
||||
*
|
||||
* @author Josh Outwater
|
||||
*/
|
||||
class GTKEngine {
|
||||
|
||||
final static GTKEngine INSTANCE = new GTKEngine();
|
||||
|
||||
/** Size of the image cache */
|
||||
private static final int CACHE_SIZE = 50;
|
||||
|
||||
/** This enum mirrors that in gtk2_interface.h */
|
||||
static enum WidgetType {
|
||||
BUTTON, CHECK_BOX, CHECK_BOX_MENU_ITEM, COLOR_CHOOSER,
|
||||
COMBO_BOX, COMBO_BOX_ARROW_BUTTON, COMBO_BOX_TEXT_FIELD,
|
||||
DESKTOP_ICON, DESKTOP_PANE, EDITOR_PANE, FORMATTED_TEXT_FIELD,
|
||||
HANDLE_BOX, HPROGRESS_BAR,
|
||||
HSCROLL_BAR, HSCROLL_BAR_BUTTON_LEFT, HSCROLL_BAR_BUTTON_RIGHT,
|
||||
HSCROLL_BAR_TRACK, HSCROLL_BAR_THUMB,
|
||||
HSEPARATOR, HSLIDER, HSLIDER_TRACK, HSLIDER_THUMB, HSPLIT_PANE_DIVIDER,
|
||||
INTERNAL_FRAME, INTERNAL_FRAME_TITLE_PANE, IMAGE, LABEL, LIST, MENU,
|
||||
MENU_BAR, MENU_ITEM, MENU_ITEM_ACCELERATOR, OPTION_PANE, PANEL,
|
||||
PASSWORD_FIELD, POPUP_MENU, POPUP_MENU_SEPARATOR,
|
||||
RADIO_BUTTON, RADIO_BUTTON_MENU_ITEM, ROOT_PANE, SCROLL_PANE,
|
||||
SPINNER, SPINNER_ARROW_BUTTON, SPINNER_TEXT_FIELD,
|
||||
SPLIT_PANE, TABBED_PANE, TABBED_PANE_TAB_AREA, TABBED_PANE_CONTENT,
|
||||
TABBED_PANE_TAB, TABLE, TABLE_HEADER, TEXT_AREA, TEXT_FIELD, TEXT_PANE,
|
||||
TITLED_BORDER,
|
||||
TOGGLE_BUTTON, TOOL_BAR, TOOL_BAR_DRAG_WINDOW, TOOL_BAR_SEPARATOR,
|
||||
TOOL_TIP, TREE, TREE_CELL, VIEWPORT, VPROGRESS_BAR,
|
||||
VSCROLL_BAR, VSCROLL_BAR_BUTTON_UP, VSCROLL_BAR_BUTTON_DOWN,
|
||||
VSCROLL_BAR_TRACK, VSCROLL_BAR_THUMB,
|
||||
VSEPARATOR, VSLIDER, VSLIDER_TRACK, VSLIDER_THUMB,
|
||||
VSPLIT_PANE_DIVIDER
|
||||
}
|
||||
|
||||
/**
|
||||
* Representation of GtkSettings properties.
|
||||
* When we need more settings we can add them here and
|
||||
* to all implementations of getGTKSetting().
|
||||
*/
|
||||
static enum Settings {
|
||||
GTK_FONT_NAME,
|
||||
GTK_ICON_SIZES,
|
||||
GTK_CURSOR_BLINK,
|
||||
GTK_CURSOR_BLINK_TIME
|
||||
}
|
||||
|
||||
/* Custom regions are needed for representing regions that don't exist
|
||||
* in the original Region class.
|
||||
*/
|
||||
static class CustomRegion extends Region {
|
||||
/*
|
||||
* TITLED_BORDER Region is mapped to GtkFrame class which can draw
|
||||
* titled borders around components.
|
||||
*/
|
||||
static Region TITLED_BORDER = new CustomRegion("TitledBorder");
|
||||
|
||||
private CustomRegion(String name) {
|
||||
super(name, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static HashMap<Region, Object> regionToWidgetTypeMap;
|
||||
private ImageCache cache = new ImageCache(CACHE_SIZE);
|
||||
private int x0, y0, w0, h0;
|
||||
private Graphics graphics;
|
||||
private Object[] cacheArgs;
|
||||
|
||||
private native void native_paint_arrow(
|
||||
int widgetType, int state, int shadowType, String detail,
|
||||
int x, int y, int width, int height, int arrowType);
|
||||
private native void native_paint_box(
|
||||
int widgetType, int state, int shadowType, String detail,
|
||||
int x, int y, int width, int height, int synthState, int dir);
|
||||
private native void native_paint_box_gap(
|
||||
int widgetType, int state, int shadowType, String detail,
|
||||
int x, int y, int width, int height,
|
||||
int gapSide, int gapX, int gapWidth);
|
||||
private native void native_paint_check(
|
||||
int widgetType, int synthState, String detail,
|
||||
int x, int y, int width, int height);
|
||||
private native void native_paint_expander(
|
||||
int widgetType, int state, String detail,
|
||||
int x, int y, int width, int height, int expanderStyle);
|
||||
private native void native_paint_extension(
|
||||
int widgetType, int state, int shadowType, String detail,
|
||||
int x, int y, int width, int height, int placement);
|
||||
private native void native_paint_flat_box(
|
||||
int widgetType, int state, int shadowType, String detail,
|
||||
int x, int y, int width, int height, boolean hasFocus);
|
||||
private native void native_paint_focus(
|
||||
int widgetType, int state, String detail,
|
||||
int x, int y, int width, int height);
|
||||
private native void native_paint_handle(
|
||||
int widgetType, int state, int shadowType, String detail,
|
||||
int x, int y, int width, int height, int orientation);
|
||||
private native void native_paint_hline(
|
||||
int widgetType, int state, String detail,
|
||||
int x, int y, int width, int height);
|
||||
private native void native_paint_option(
|
||||
int widgetType, int synthState, String detail,
|
||||
int x, int y, int width, int height);
|
||||
private native void native_paint_shadow(
|
||||
int widgetType, int state, int shadowType, String detail,
|
||||
int x, int y, int width, int height, int synthState, int dir);
|
||||
private native void native_paint_slider(
|
||||
int widgetType, int state, int shadowType, String detail, int x,
|
||||
int y, int width, int height, int orientation, boolean hasFocus);
|
||||
private native void native_paint_vline(
|
||||
int widgetType, int state, String detail,
|
||||
int x, int y, int width, int height);
|
||||
private native void native_paint_background(
|
||||
int widgetType, int state, int x, int y, int width, int height);
|
||||
private native Object native_get_gtk_setting(int property);
|
||||
private native void nativeSetRangeValue(int widgetType, double value,
|
||||
double min, double max,
|
||||
double visible);
|
||||
|
||||
private native void nativeStartPainting(int w, int h);
|
||||
private native int nativeFinishPainting(int[] buffer, int width, int height);
|
||||
private native void native_switch_theme();
|
||||
|
||||
static {
|
||||
// Make sure the awt toolkit is loaded so we have access to native
|
||||
// methods.
|
||||
Toolkit.getDefaultToolkit();
|
||||
|
||||
// Initialize regionToWidgetTypeMap
|
||||
regionToWidgetTypeMap = new HashMap<Region, Object>(50);
|
||||
regionToWidgetTypeMap.put(Region.ARROW_BUTTON, new WidgetType[] {
|
||||
WidgetType.SPINNER_ARROW_BUTTON,
|
||||
WidgetType.COMBO_BOX_ARROW_BUTTON,
|
||||
WidgetType.HSCROLL_BAR_BUTTON_LEFT,
|
||||
WidgetType.HSCROLL_BAR_BUTTON_RIGHT,
|
||||
WidgetType.VSCROLL_BAR_BUTTON_UP,
|
||||
WidgetType.VSCROLL_BAR_BUTTON_DOWN});
|
||||
regionToWidgetTypeMap.put(Region.BUTTON, WidgetType.BUTTON);
|
||||
regionToWidgetTypeMap.put(Region.CHECK_BOX, WidgetType.CHECK_BOX);
|
||||
regionToWidgetTypeMap.put(Region.CHECK_BOX_MENU_ITEM,
|
||||
WidgetType.CHECK_BOX_MENU_ITEM);
|
||||
regionToWidgetTypeMap.put(Region.COLOR_CHOOSER, WidgetType.COLOR_CHOOSER);
|
||||
regionToWidgetTypeMap.put(Region.FILE_CHOOSER, WidgetType.OPTION_PANE);
|
||||
regionToWidgetTypeMap.put(Region.COMBO_BOX, WidgetType.COMBO_BOX);
|
||||
regionToWidgetTypeMap.put(Region.DESKTOP_ICON, WidgetType.DESKTOP_ICON);
|
||||
regionToWidgetTypeMap.put(Region.DESKTOP_PANE, WidgetType.DESKTOP_PANE);
|
||||
regionToWidgetTypeMap.put(Region.EDITOR_PANE, WidgetType.EDITOR_PANE);
|
||||
regionToWidgetTypeMap.put(Region.FORMATTED_TEXT_FIELD, new WidgetType[] {
|
||||
WidgetType.FORMATTED_TEXT_FIELD, WidgetType.SPINNER_TEXT_FIELD});
|
||||
regionToWidgetTypeMap.put(GTKRegion.HANDLE_BOX, WidgetType.HANDLE_BOX);
|
||||
regionToWidgetTypeMap.put(Region.INTERNAL_FRAME,
|
||||
WidgetType.INTERNAL_FRAME);
|
||||
regionToWidgetTypeMap.put(Region.INTERNAL_FRAME_TITLE_PANE,
|
||||
WidgetType.INTERNAL_FRAME_TITLE_PANE);
|
||||
regionToWidgetTypeMap.put(Region.LABEL, new WidgetType[] {
|
||||
WidgetType.LABEL, WidgetType.COMBO_BOX_TEXT_FIELD});
|
||||
regionToWidgetTypeMap.put(Region.LIST, WidgetType.LIST);
|
||||
regionToWidgetTypeMap.put(Region.MENU, WidgetType.MENU);
|
||||
regionToWidgetTypeMap.put(Region.MENU_BAR, WidgetType.MENU_BAR);
|
||||
regionToWidgetTypeMap.put(Region.MENU_ITEM, WidgetType.MENU_ITEM);
|
||||
regionToWidgetTypeMap.put(Region.MENU_ITEM_ACCELERATOR,
|
||||
WidgetType.MENU_ITEM_ACCELERATOR);
|
||||
regionToWidgetTypeMap.put(Region.OPTION_PANE, WidgetType.OPTION_PANE);
|
||||
regionToWidgetTypeMap.put(Region.PANEL, WidgetType.PANEL);
|
||||
regionToWidgetTypeMap.put(Region.PASSWORD_FIELD,
|
||||
WidgetType.PASSWORD_FIELD);
|
||||
regionToWidgetTypeMap.put(Region.POPUP_MENU, WidgetType.POPUP_MENU);
|
||||
regionToWidgetTypeMap.put(Region.POPUP_MENU_SEPARATOR,
|
||||
WidgetType.POPUP_MENU_SEPARATOR);
|
||||
regionToWidgetTypeMap.put(Region.PROGRESS_BAR, new WidgetType[] {
|
||||
WidgetType.HPROGRESS_BAR, WidgetType.VPROGRESS_BAR});
|
||||
regionToWidgetTypeMap.put(Region.RADIO_BUTTON, WidgetType.RADIO_BUTTON);
|
||||
regionToWidgetTypeMap.put(Region.RADIO_BUTTON_MENU_ITEM,
|
||||
WidgetType.RADIO_BUTTON_MENU_ITEM);
|
||||
regionToWidgetTypeMap.put(Region.ROOT_PANE, WidgetType.ROOT_PANE);
|
||||
regionToWidgetTypeMap.put(Region.SCROLL_BAR, new WidgetType[] {
|
||||
WidgetType.HSCROLL_BAR, WidgetType.VSCROLL_BAR});
|
||||
regionToWidgetTypeMap.put(Region.SCROLL_BAR_THUMB, new WidgetType[] {
|
||||
WidgetType.HSCROLL_BAR_THUMB, WidgetType.VSCROLL_BAR_THUMB});
|
||||
regionToWidgetTypeMap.put(Region.SCROLL_BAR_TRACK, new WidgetType[] {
|
||||
WidgetType.HSCROLL_BAR_TRACK, WidgetType.VSCROLL_BAR_TRACK});
|
||||
regionToWidgetTypeMap.put(Region.SCROLL_PANE, WidgetType.SCROLL_PANE);
|
||||
regionToWidgetTypeMap.put(Region.SEPARATOR, new WidgetType[] {
|
||||
WidgetType.HSEPARATOR, WidgetType.VSEPARATOR});
|
||||
regionToWidgetTypeMap.put(Region.SLIDER, new WidgetType[] {
|
||||
WidgetType.HSLIDER, WidgetType.VSLIDER});
|
||||
regionToWidgetTypeMap.put(Region.SLIDER_THUMB, new WidgetType[] {
|
||||
WidgetType.HSLIDER_THUMB, WidgetType.VSLIDER_THUMB});
|
||||
regionToWidgetTypeMap.put(Region.SLIDER_TRACK, new WidgetType[] {
|
||||
WidgetType.HSLIDER_TRACK, WidgetType.VSLIDER_TRACK});
|
||||
regionToWidgetTypeMap.put(Region.SPINNER, WidgetType.SPINNER);
|
||||
regionToWidgetTypeMap.put(Region.SPLIT_PANE, WidgetType.SPLIT_PANE);
|
||||
regionToWidgetTypeMap.put(Region.SPLIT_PANE_DIVIDER, new WidgetType[] {
|
||||
WidgetType.HSPLIT_PANE_DIVIDER, WidgetType.VSPLIT_PANE_DIVIDER});
|
||||
regionToWidgetTypeMap.put(Region.TABBED_PANE, WidgetType.TABBED_PANE);
|
||||
regionToWidgetTypeMap.put(Region.TABBED_PANE_CONTENT,
|
||||
WidgetType.TABBED_PANE_CONTENT);
|
||||
regionToWidgetTypeMap.put(Region.TABBED_PANE_TAB,
|
||||
WidgetType.TABBED_PANE_TAB);
|
||||
regionToWidgetTypeMap.put(Region.TABBED_PANE_TAB_AREA,
|
||||
WidgetType.TABBED_PANE_TAB_AREA);
|
||||
regionToWidgetTypeMap.put(Region.TABLE, WidgetType.TABLE);
|
||||
regionToWidgetTypeMap.put(Region.TABLE_HEADER, WidgetType.TABLE_HEADER);
|
||||
regionToWidgetTypeMap.put(Region.TEXT_AREA, WidgetType.TEXT_AREA);
|
||||
regionToWidgetTypeMap.put(Region.TEXT_FIELD, new WidgetType[] {
|
||||
WidgetType.TEXT_FIELD, WidgetType.COMBO_BOX_TEXT_FIELD});
|
||||
regionToWidgetTypeMap.put(Region.TEXT_PANE, WidgetType.TEXT_PANE);
|
||||
regionToWidgetTypeMap.put(CustomRegion.TITLED_BORDER, WidgetType.TITLED_BORDER);
|
||||
regionToWidgetTypeMap.put(Region.TOGGLE_BUTTON, WidgetType.TOGGLE_BUTTON);
|
||||
regionToWidgetTypeMap.put(Region.TOOL_BAR, WidgetType.TOOL_BAR);
|
||||
regionToWidgetTypeMap.put(Region.TOOL_BAR_CONTENT, WidgetType.TOOL_BAR);
|
||||
regionToWidgetTypeMap.put(Region.TOOL_BAR_DRAG_WINDOW,
|
||||
WidgetType.TOOL_BAR_DRAG_WINDOW);
|
||||
regionToWidgetTypeMap.put(Region.TOOL_BAR_SEPARATOR,
|
||||
WidgetType.TOOL_BAR_SEPARATOR);
|
||||
regionToWidgetTypeMap.put(Region.TOOL_TIP, WidgetType.TOOL_TIP);
|
||||
regionToWidgetTypeMap.put(Region.TREE, WidgetType.TREE);
|
||||
regionToWidgetTypeMap.put(Region.TREE_CELL, WidgetType.TREE_CELL);
|
||||
regionToWidgetTypeMap.put(Region.VIEWPORT, WidgetType.VIEWPORT);
|
||||
}
|
||||
|
||||
/** Translate Region and JComponent into WidgetType ordinals */
|
||||
static WidgetType getWidgetType(JComponent c, Region id) {
|
||||
Object value = regionToWidgetTypeMap.get(id);
|
||||
|
||||
if (value instanceof WidgetType) {
|
||||
return (WidgetType)value;
|
||||
}
|
||||
|
||||
WidgetType[] widgets = (WidgetType[])value;
|
||||
if (c == null ) {
|
||||
return widgets[0];
|
||||
}
|
||||
|
||||
if (c instanceof JScrollBar) {
|
||||
return (((JScrollBar)c).getOrientation() == JScrollBar.HORIZONTAL) ?
|
||||
widgets[0] : widgets[1];
|
||||
} else if (c instanceof JSeparator) {
|
||||
JSeparator separator = (JSeparator)c;
|
||||
|
||||
/* We should return correrct WidgetType if the seperator is inserted
|
||||
* in Menu/PopupMenu/ToolBar. BugID: 6465603
|
||||
*/
|
||||
if (separator.getParent() instanceof JPopupMenu) {
|
||||
return WidgetType.POPUP_MENU_SEPARATOR;
|
||||
} else if (separator.getParent() instanceof JToolBar) {
|
||||
return WidgetType.TOOL_BAR_SEPARATOR;
|
||||
}
|
||||
|
||||
return (separator.getOrientation() == JSeparator.HORIZONTAL) ?
|
||||
widgets[0] : widgets[1];
|
||||
} else if (c instanceof JSlider) {
|
||||
return (((JSlider)c).getOrientation() == JSlider.HORIZONTAL) ?
|
||||
widgets[0] : widgets[1];
|
||||
} else if (c instanceof JProgressBar) {
|
||||
return (((JProgressBar)c).getOrientation() == JProgressBar.HORIZONTAL) ?
|
||||
widgets[0] : widgets[1];
|
||||
} else if (c instanceof JSplitPane) {
|
||||
return (((JSplitPane)c).getOrientation() == JSplitPane.HORIZONTAL_SPLIT) ?
|
||||
widgets[1] : widgets[0];
|
||||
} else if (id == Region.LABEL) {
|
||||
/*
|
||||
* For all ListCellRenderers we will use COMBO_BOX_TEXT_FIELD widget
|
||||
* type because we can get correct insets. List items however won't be
|
||||
* drawn as a text entry (see GTKPainter.paintLabelBackground).
|
||||
*/
|
||||
if (c instanceof ListCellRenderer) {
|
||||
return widgets[1];
|
||||
} else {
|
||||
return widgets[0];
|
||||
}
|
||||
} else if (id == Region.TEXT_FIELD) {
|
||||
String name = c.getName();
|
||||
if (name != null && name.startsWith("ComboBox")) {
|
||||
return widgets[1];
|
||||
} else {
|
||||
return widgets[0];
|
||||
}
|
||||
} else if (id == Region.FORMATTED_TEXT_FIELD) {
|
||||
String name = c.getName();
|
||||
if (name != null && name.startsWith("Spinner")) {
|
||||
return widgets[1];
|
||||
} else {
|
||||
return widgets[0];
|
||||
}
|
||||
} else if (id == Region.ARROW_BUTTON) {
|
||||
if (c.getParent() instanceof JScrollBar) {
|
||||
Integer prop = (Integer)
|
||||
c.getClientProperty("__arrow_direction__");
|
||||
int dir = (prop != null) ?
|
||||
prop.intValue() : SwingConstants.WEST;
|
||||
switch (dir) {
|
||||
case SwingConstants.WEST:
|
||||
return WidgetType.HSCROLL_BAR_BUTTON_LEFT;
|
||||
case SwingConstants.EAST:
|
||||
return WidgetType.HSCROLL_BAR_BUTTON_RIGHT;
|
||||
case SwingConstants.NORTH:
|
||||
return WidgetType.VSCROLL_BAR_BUTTON_UP;
|
||||
case SwingConstants.SOUTH:
|
||||
return WidgetType.VSCROLL_BAR_BUTTON_DOWN;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
} else if (c.getParent() instanceof JComboBox) {
|
||||
return WidgetType.COMBO_BOX_ARROW_BUTTON;
|
||||
} else {
|
||||
return WidgetType.SPINNER_ARROW_BUTTON;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int getTextDirection(SynthContext context) {
|
||||
TextDirection dir = TextDirection.NONE;
|
||||
JComponent comp = context.getComponent();
|
||||
if (comp != null) {
|
||||
ComponentOrientation co = comp.getComponentOrientation();
|
||||
if (co != null) {
|
||||
dir = co.isLeftToRight() ?
|
||||
TextDirection.LTR : TextDirection.RTL;
|
||||
}
|
||||
}
|
||||
return dir.ordinal();
|
||||
}
|
||||
|
||||
public void paintArrow(Graphics g, SynthContext context,
|
||||
Region id, int state, ShadowType shadowType, ArrowType direction,
|
||||
String detail, int x, int y, int w, int h) {
|
||||
|
||||
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_arrow(widget, state, shadowType.ordinal(),
|
||||
detail, x - x0, y - y0, w, h, direction.ordinal());
|
||||
}
|
||||
|
||||
public void paintBox(Graphics g, SynthContext context,
|
||||
Region id, int state, ShadowType shadowType,
|
||||
String detail, int x, int y, int w, int h) {
|
||||
|
||||
int gtkState =
|
||||
GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int synthState = context.getComponentState();
|
||||
int dir = getTextDirection(context);
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_box(widget, gtkState, shadowType.ordinal(),
|
||||
detail, x - x0, y - y0, w, h, synthState, dir);
|
||||
}
|
||||
|
||||
public void paintBoxGap(Graphics g, SynthContext context,
|
||||
Region id, int state, ShadowType shadowType,
|
||||
String detail, int x, int y, int w, int h,
|
||||
PositionType boxGapType, int tabBegin, int size) {
|
||||
|
||||
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_box_gap(widget, state, shadowType.ordinal(), detail,
|
||||
x - x0, y - y0, w, h, boxGapType.ordinal(), tabBegin, size);
|
||||
}
|
||||
|
||||
public void paintCheck(Graphics g, SynthContext context,
|
||||
Region id, String detail, int x, int y, int w, int h) {
|
||||
|
||||
int synthState = context.getComponentState();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_check(widget, synthState, detail, x - x0, y - y0, w, h);
|
||||
}
|
||||
|
||||
public void paintExpander(Graphics g, SynthContext context,
|
||||
Region id, int state, ExpanderStyle expanderStyle, String detail,
|
||||
int x, int y, int w, int h) {
|
||||
|
||||
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_expander(widget, state, detail, x - x0, y - y0, w, h,
|
||||
expanderStyle.ordinal());
|
||||
}
|
||||
|
||||
public void paintExtension(Graphics g, SynthContext context,
|
||||
Region id, int state, ShadowType shadowType, String detail,
|
||||
int x, int y, int w, int h, PositionType placement, int tabIndex) {
|
||||
|
||||
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_extension(widget, state, shadowType.ordinal(), detail,
|
||||
x - x0, y - y0, w, h, placement.ordinal());
|
||||
}
|
||||
|
||||
public void paintFlatBox(Graphics g, SynthContext context,
|
||||
Region id, int state, ShadowType shadowType, String detail,
|
||||
int x, int y, int w, int h, ColorType colorType) {
|
||||
|
||||
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_flat_box(widget, state, shadowType.ordinal(), detail,
|
||||
x - x0, y - y0, w, h,
|
||||
context.getComponent().hasFocus());
|
||||
}
|
||||
|
||||
public void paintFocus(Graphics g, SynthContext context,
|
||||
Region id, int state, String detail, int x, int y, int w, int h) {
|
||||
|
||||
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_focus(widget, state, detail, x - x0, y - y0, w, h);
|
||||
}
|
||||
|
||||
public void paintHandle(Graphics g, SynthContext context,
|
||||
Region id, int state, ShadowType shadowType, String detail,
|
||||
int x, int y, int w, int h, Orientation orientation) {
|
||||
|
||||
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_handle(widget, state, shadowType.ordinal(), detail,
|
||||
x - x0, y - y0, w, h, orientation.ordinal());
|
||||
}
|
||||
|
||||
public void paintHline(Graphics g, SynthContext context,
|
||||
Region id, int state, String detail, int x, int y, int w, int h) {
|
||||
|
||||
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_hline(widget, state, detail, x - x0, y - y0, w, h);
|
||||
}
|
||||
|
||||
public void paintOption(Graphics g, SynthContext context,
|
||||
Region id, String detail, int x, int y, int w, int h) {
|
||||
|
||||
int synthState = context.getComponentState();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_option(widget, synthState, detail, x - x0, y - y0, w, h);
|
||||
}
|
||||
|
||||
public void paintShadow(Graphics g, SynthContext context,
|
||||
Region id, int state, ShadowType shadowType, String detail,
|
||||
int x, int y, int w, int h) {
|
||||
|
||||
int gtkState =
|
||||
GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int synthState = context.getComponentState();
|
||||
Container parent = context.getComponent().getParent();
|
||||
if(GTKLookAndFeel.is3()) {
|
||||
if (parent != null && parent.getParent() instanceof JComboBox) {
|
||||
if (parent.getParent().hasFocus()) {
|
||||
synthState |= SynthConstants.FOCUSED;
|
||||
}
|
||||
}
|
||||
}
|
||||
int dir = getTextDirection(context);
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_shadow(widget, gtkState, shadowType.ordinal(), detail,
|
||||
x - x0, y - y0, w, h, synthState, dir);
|
||||
}
|
||||
|
||||
public void paintSlider(Graphics g, SynthContext context,
|
||||
Region id, int state, ShadowType shadowType, String detail, int x,
|
||||
int y, int w, int h, Orientation orientation, boolean hasFocus) {
|
||||
|
||||
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_slider(widget, state, shadowType.ordinal(), detail,
|
||||
x - x0, y - y0, w, h, orientation.ordinal(), hasFocus);
|
||||
}
|
||||
|
||||
public void paintVline(Graphics g, SynthContext context,
|
||||
Region id, int state, String detail, int x, int y, int w, int h) {
|
||||
|
||||
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_vline(widget, state, detail, x - x0, y - y0, w, h);
|
||||
}
|
||||
|
||||
public void paintBackground(Graphics g, SynthContext context,
|
||||
Region id, int state, Color color, int x, int y, int w, int h) {
|
||||
|
||||
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
native_paint_background(widget, state, x - x0, y - y0, w, h);
|
||||
}
|
||||
|
||||
private final static ColorModel[] COLOR_MODELS = {
|
||||
// Transparency.OPAQUE
|
||||
new DirectColorModel(24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000),
|
||||
// Transparency.BITMASK
|
||||
new DirectColorModel(25, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x01000000),
|
||||
// Transparency.TRANSLUCENT
|
||||
ColorModel.getRGBdefault(),
|
||||
};
|
||||
|
||||
private final static int[][] BAND_OFFSETS = {
|
||||
{ 0x00ff0000, 0x0000ff00, 0x000000ff }, // OPAQUE
|
||||
{ 0x00ff0000, 0x0000ff00, 0x000000ff, 0x01000000 }, // BITMASK
|
||||
{ 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 } // TRANSLUCENT
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Paint a cached image identified by its size and a set of additional
|
||||
* arguments, if there's one.
|
||||
*
|
||||
* @return true if a cached image has been painted, false otherwise
|
||||
*/
|
||||
public boolean paintCachedImage(Graphics g,
|
||||
int x, int y, int w, int h, Object... args) {
|
||||
if (w <= 0 || h <= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// look for cached image
|
||||
Image img = cache.getImage(getClass(), null, w, h, args);
|
||||
if (img != null) {
|
||||
g.drawImage(img, x, y, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a native offscreen buffer of the specified size.
|
||||
*/
|
||||
public void startPainting(Graphics g,
|
||||
int x, int y, int w, int h, Object... args) {
|
||||
nativeStartPainting(w, h);
|
||||
x0 = x;
|
||||
y0 = y;
|
||||
w0 = w;
|
||||
h0 = h;
|
||||
graphics = g;
|
||||
cacheArgs = args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method that delegates to finishPainting() with
|
||||
* caching enabled.
|
||||
*/
|
||||
public BufferedImage finishPainting() {
|
||||
return finishPainting(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to indicate that painting is finished. We create a new
|
||||
* BufferedImage from the offscreen buffer, (optionally) cache it,
|
||||
* and paint it.
|
||||
*/
|
||||
public BufferedImage finishPainting(boolean useCache) {
|
||||
DataBufferInt dataBuffer = new DataBufferInt(w0 * h0);
|
||||
// Note that stealData() requires a markDirty() afterwards
|
||||
// since we modify the data in it.
|
||||
int transparency =
|
||||
nativeFinishPainting(SunWritableRaster.stealData(dataBuffer, 0),
|
||||
w0, h0);
|
||||
SunWritableRaster.markDirty(dataBuffer);
|
||||
|
||||
int[] bands = BAND_OFFSETS[transparency - 1];
|
||||
WritableRaster raster = Raster.createPackedRaster(
|
||||
dataBuffer, w0, h0, w0, bands, null);
|
||||
|
||||
ColorModel cm = COLOR_MODELS[transparency - 1];
|
||||
BufferedImage img = new BufferedImage(cm, raster, false, null);
|
||||
if (useCache) {
|
||||
cache.setImage(getClass(), null, w0, h0, cacheArgs, img);
|
||||
}
|
||||
graphics.drawImage(img, x0, y0, null);
|
||||
return img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify native layer of theme change, and flush cache
|
||||
*/
|
||||
public void themeChanged() {
|
||||
synchronized(sun.awt.UNIXToolkit.GTK_LOCK) {
|
||||
native_switch_theme();
|
||||
}
|
||||
cache.flush();
|
||||
}
|
||||
|
||||
/* GtkSettings enum mirrors that in gtk2_interface.h */
|
||||
public Object getSetting(Settings property) {
|
||||
synchronized(sun.awt.UNIXToolkit.GTK_LOCK) {
|
||||
return native_get_gtk_setting(property.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the GtkAdjustment values for the native GtkRange widget
|
||||
* associated with the given region (e.g. SLIDER, SCROLL_BAR).
|
||||
*/
|
||||
void setRangeValue(SynthContext context, Region id,
|
||||
double value, double min, double max, double visible) {
|
||||
int widget = getWidgetType(context.getComponent(), id).ordinal();
|
||||
nativeSetRangeValue(widget, value, min, max, visible);
|
||||
}
|
||||
}
|
||||
1402
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java
Normal file
1402
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java
Normal file
File diff suppressed because it is too large
Load Diff
127
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKGraphicsUtils.java
Normal file
127
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKGraphicsUtils.java
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.gtk;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.synth.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
/**
|
||||
* @author Joshua Outwater
|
||||
*/
|
||||
class GTKGraphicsUtils extends SynthGraphicsUtils {
|
||||
public void paintText(SynthContext context, Graphics g, String text,
|
||||
int x, int y, int mnemonicIndex) {
|
||||
if (text == null || text.length() <= 0) {
|
||||
// We don't need to paint empty strings
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.getRegion() == Region.INTERNAL_FRAME_TITLE_PANE) {
|
||||
// Metacity handles painting of text on internal frame title,
|
||||
// ignore this.
|
||||
return;
|
||||
}
|
||||
int componentState = context.getComponentState();
|
||||
String themeName = GTKLookAndFeel.getGtkThemeName();
|
||||
if (themeName != null && themeName.startsWith("blueprint") &&
|
||||
shouldShadowText(context.getRegion(), componentState)) {
|
||||
|
||||
g.setColor(Color.BLACK);
|
||||
super.paintText(context, g, text, x+1, y+1, mnemonicIndex);
|
||||
g.setColor(Color.WHITE);
|
||||
}
|
||||
super.paintText(context, g, text, x, y, mnemonicIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints text at the specified location. This will not attempt to
|
||||
* render the text as html nor will it offset by the insets of the
|
||||
* component.
|
||||
*
|
||||
* @param ss SynthContext
|
||||
* @param g Graphics used to render string in.
|
||||
* @param text Text to render
|
||||
* @param bounds Bounds of the text to be drawn.
|
||||
* @param mnemonicIndex Index to draw string at.
|
||||
*/
|
||||
public void paintText(SynthContext context, Graphics g, String text,
|
||||
Rectangle bounds, int mnemonicIndex) {
|
||||
if (text == null || text.length() <= 0) {
|
||||
// We don't need to paint empty strings
|
||||
return;
|
||||
}
|
||||
|
||||
Region id = context.getRegion();
|
||||
if ((id == Region.RADIO_BUTTON ||
|
||||
id == Region.CHECK_BOX ||
|
||||
id == Region.TABBED_PANE_TAB) &&
|
||||
(context.getComponentState() & SynthConstants.FOCUSED) != 0)
|
||||
{
|
||||
JComponent source = context.getComponent();
|
||||
if (!(source instanceof AbstractButton) ||
|
||||
((AbstractButton)source).isFocusPainted()) {
|
||||
|
||||
// The "bounds" parameter encompasses only the actual text;
|
||||
// when drawing the focus, we need to expand that bounding
|
||||
// box by "focus-line-width" plus "focus-padding". Note that
|
||||
// the layout process for these components will have already
|
||||
// taken these values into account, so there should always
|
||||
// be enough space allocated for drawing the focus indicator.
|
||||
int synthState = context.getComponentState();
|
||||
GTKStyle style = (GTKStyle)context.getStyle();
|
||||
int focusSize =
|
||||
style.getClassSpecificIntValue(context,
|
||||
"focus-line-width", 1);
|
||||
int focusPad =
|
||||
style.getClassSpecificIntValue(context,
|
||||
"focus-padding", 1);
|
||||
int totalFocus = focusSize + focusPad;
|
||||
int x = bounds.x - totalFocus;
|
||||
int y = bounds.y - totalFocus;
|
||||
int w = bounds.width + (2 * totalFocus);
|
||||
int h = bounds.height + (2 * totalFocus);
|
||||
|
||||
Color color = g.getColor();
|
||||
GTKPainter.INSTANCE.paintFocus(context, g, id,
|
||||
synthState, "checkbutton",
|
||||
x, y, w, h);
|
||||
g.setColor(color);
|
||||
}
|
||||
}
|
||||
super.paintText(context, g, text, bounds, mnemonicIndex);
|
||||
}
|
||||
|
||||
private static boolean shouldShadowText(Region id, int state) {
|
||||
int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state);
|
||||
return((gtkState == SynthConstants.MOUSE_OVER) &&
|
||||
(id == Region.MENU ||
|
||||
id == Region.MENU_ITEM ||
|
||||
id == Region.CHECK_BOX_MENU_ITEM ||
|
||||
id == Region.RADIO_BUTTON_MENU_ITEM));
|
||||
}
|
||||
}
|
||||
363
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKIconFactory.java
Normal file
363
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKIconFactory.java
Normal file
@@ -0,0 +1,363 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.gtk;
|
||||
|
||||
import java.util.*;
|
||||
import javax.swing.plaf.synth.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.lang.reflect.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
import sun.swing.plaf.synth.*;
|
||||
import com.sun.java.swing.plaf.gtk.GTKConstants.ArrowType;
|
||||
import com.sun.java.swing.plaf.gtk.GTKConstants.ExpanderStyle;
|
||||
import com.sun.java.swing.plaf.gtk.GTKConstants.Orientation;
|
||||
import com.sun.java.swing.plaf.gtk.GTKConstants.ShadowType;
|
||||
|
||||
/**
|
||||
*/
|
||||
class GTKIconFactory {
|
||||
static final int CHECK_ICON_EXTRA_INSET = 1;
|
||||
static final int DEFAULT_ICON_SPACING = 2;
|
||||
static final int DEFAULT_ICON_SIZE = 13;
|
||||
static final int DEFAULT_TOGGLE_MENU_ITEM_SIZE = 12; // For pre-gtk2.4
|
||||
|
||||
private static final String RADIO_BUTTON_ICON = "paintRadioButtonIcon";
|
||||
private static final String CHECK_BOX_ICON = "paintCheckBoxIcon";
|
||||
private static final String MENU_ARROW_ICON = "paintMenuArrowIcon";
|
||||
private static final String CHECK_BOX_MENU_ITEM_CHECK_ICON =
|
||||
"paintCheckBoxMenuItemCheckIcon";
|
||||
private static final String RADIO_BUTTON_MENU_ITEM_CHECK_ICON =
|
||||
"paintRadioButtonMenuItemCheckIcon";
|
||||
private static final String TREE_EXPANDED_ICON = "paintTreeExpandedIcon";
|
||||
private static final String TREE_COLLAPSED_ICON = "paintTreeCollapsedIcon";
|
||||
private static final String ASCENDING_SORT_ICON = "paintAscendingSortIcon";
|
||||
private static final String DESCENDING_SORT_ICON = "paintDescendingSortIcon";
|
||||
private static final String TOOL_BAR_HANDLE_ICON = "paintToolBarHandleIcon";
|
||||
|
||||
private static Map<String, DelegatingIcon> iconsPool =
|
||||
Collections.synchronizedMap(new HashMap<String, DelegatingIcon>());
|
||||
|
||||
private static DelegatingIcon getIcon(String methodName) {
|
||||
DelegatingIcon result = iconsPool.get(methodName);
|
||||
if (result == null) {
|
||||
if (methodName == TREE_COLLAPSED_ICON ||
|
||||
methodName == TREE_EXPANDED_ICON)
|
||||
{
|
||||
result = new SynthExpanderIcon(methodName);
|
||||
|
||||
} else if (methodName == TOOL_BAR_HANDLE_ICON) {
|
||||
result = new ToolBarHandleIcon();
|
||||
|
||||
} else if (methodName == MENU_ARROW_ICON) {
|
||||
result = new MenuArrowIcon();
|
||||
|
||||
} else {
|
||||
result = new DelegatingIcon(methodName);
|
||||
}
|
||||
iconsPool.put(methodName, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Sort arrow
|
||||
//
|
||||
public static Icon getAscendingSortIcon() {
|
||||
return getIcon(ASCENDING_SORT_ICON);
|
||||
}
|
||||
|
||||
public static Icon getDescendingSortIcon() {
|
||||
return getIcon(DESCENDING_SORT_ICON);
|
||||
}
|
||||
|
||||
//
|
||||
// Tree methods
|
||||
//
|
||||
public static SynthIcon getTreeExpandedIcon() {
|
||||
return getIcon(TREE_EXPANDED_ICON);
|
||||
}
|
||||
|
||||
public static SynthIcon getTreeCollapsedIcon() {
|
||||
return getIcon(TREE_COLLAPSED_ICON);
|
||||
}
|
||||
|
||||
//
|
||||
// Radio button
|
||||
//
|
||||
public static SynthIcon getRadioButtonIcon() {
|
||||
return getIcon(RADIO_BUTTON_ICON);
|
||||
}
|
||||
|
||||
//
|
||||
// CheckBox
|
||||
//
|
||||
public static SynthIcon getCheckBoxIcon() {
|
||||
return getIcon(CHECK_BOX_ICON);
|
||||
}
|
||||
|
||||
//
|
||||
// Menus
|
||||
//
|
||||
public static SynthIcon getMenuArrowIcon() {
|
||||
return getIcon(MENU_ARROW_ICON);
|
||||
}
|
||||
|
||||
public static SynthIcon getCheckBoxMenuItemCheckIcon() {
|
||||
return getIcon(CHECK_BOX_MENU_ITEM_CHECK_ICON);
|
||||
}
|
||||
|
||||
public static SynthIcon getRadioButtonMenuItemCheckIcon() {
|
||||
return getIcon(RADIO_BUTTON_MENU_ITEM_CHECK_ICON);
|
||||
}
|
||||
|
||||
//
|
||||
// ToolBar Handle
|
||||
//
|
||||
public static SynthIcon getToolBarHandleIcon() {
|
||||
return getIcon(TOOL_BAR_HANDLE_ICON);
|
||||
}
|
||||
|
||||
static void resetIcons() {
|
||||
synchronized (iconsPool) {
|
||||
for (DelegatingIcon di: iconsPool.values()) {
|
||||
di.resetIconDimensions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class DelegatingIcon extends SynthIcon implements
|
||||
UIResource {
|
||||
private static final Class[] PARAM_TYPES = new Class[] {
|
||||
SynthContext.class, Graphics.class, int.class,
|
||||
int.class, int.class, int.class, int.class
|
||||
};
|
||||
|
||||
private Object method;
|
||||
int iconDimension = -1;
|
||||
|
||||
DelegatingIcon(String methodName ){
|
||||
this.method = methodName;
|
||||
}
|
||||
|
||||
public void paintIcon(SynthContext context, Graphics g,
|
||||
int x, int y, int w, int h) {
|
||||
if (context != null) {
|
||||
GTKPainter.INSTANCE.paintIcon(context, g,
|
||||
getMethod(), x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
public int getIconWidth(SynthContext context) {
|
||||
return getIconDimension(context);
|
||||
}
|
||||
|
||||
public int getIconHeight(SynthContext context) {
|
||||
return getIconDimension(context);
|
||||
}
|
||||
|
||||
void resetIconDimensions() {
|
||||
iconDimension = -1;
|
||||
}
|
||||
|
||||
protected Method getMethod() {
|
||||
if (method instanceof String) {
|
||||
method = resolveMethod((String)method);
|
||||
}
|
||||
return (Method)method;
|
||||
}
|
||||
|
||||
protected Class[] getMethodParamTypes() {
|
||||
return PARAM_TYPES;
|
||||
}
|
||||
|
||||
private Method resolveMethod(String name) {
|
||||
try {
|
||||
return GTKPainter.class.getMethod(name, getMethodParamTypes());
|
||||
} catch (NoSuchMethodException e) {
|
||||
assert false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
int getIconDimension(SynthContext context) {
|
||||
if (iconDimension >= 0) {
|
||||
return iconDimension;
|
||||
}
|
||||
|
||||
if (context == null) {
|
||||
return DEFAULT_ICON_SIZE;
|
||||
}
|
||||
|
||||
Region region = context.getRegion();
|
||||
GTKStyle style = (GTKStyle) context.getStyle();
|
||||
if (GTKLookAndFeel.is3() && region == Region.MENU) {
|
||||
Object value = style.getClassSpecificValue("arrow-scaling");
|
||||
if (value instanceof Number) {
|
||||
iconDimension = (int)(((Number) value).floatValue() *
|
||||
(style.getFont(context).getSize2D() +
|
||||
2 * style.getClassSpecificIntValue(context,
|
||||
"indicator-spacing", DEFAULT_ICON_SPACING)));
|
||||
if (iconDimension > 0) {
|
||||
return iconDimension;
|
||||
}
|
||||
}
|
||||
}
|
||||
iconDimension = style.getClassSpecificIntValue(context,
|
||||
"indicator-size",
|
||||
(region == Region.CHECK_BOX_MENU_ITEM ||
|
||||
region == Region.RADIO_BUTTON_MENU_ITEM) ?
|
||||
DEFAULT_TOGGLE_MENU_ITEM_SIZE : DEFAULT_ICON_SIZE);
|
||||
|
||||
if (region == Region.CHECK_BOX || region == Region.RADIO_BUTTON) {
|
||||
iconDimension += 2 * style.getClassSpecificIntValue(context,
|
||||
"indicator-spacing", DEFAULT_ICON_SPACING);
|
||||
} else if (region == Region.CHECK_BOX_MENU_ITEM ||
|
||||
region == Region.RADIO_BUTTON_MENU_ITEM) {
|
||||
iconDimension += 2 * CHECK_ICON_EXTRA_INSET;
|
||||
}
|
||||
return iconDimension;
|
||||
}
|
||||
}
|
||||
|
||||
private static class SynthExpanderIcon extends DelegatingIcon {
|
||||
SynthExpanderIcon(String method) {
|
||||
super(method);
|
||||
}
|
||||
|
||||
public void paintIcon(SynthContext context, Graphics g, int x, int y,
|
||||
int w, int h) {
|
||||
if (context != null) {
|
||||
super.paintIcon(context, g, x, y, w, h);
|
||||
updateSizeIfNecessary(context);
|
||||
}
|
||||
}
|
||||
|
||||
int getIconDimension(SynthContext context) {
|
||||
updateSizeIfNecessary(context);
|
||||
return (iconDimension == -1) ? DEFAULT_ICON_SIZE :
|
||||
iconDimension;
|
||||
}
|
||||
|
||||
private void updateSizeIfNecessary(SynthContext context) {
|
||||
if (iconDimension == -1 && context != null) {
|
||||
iconDimension = context.getStyle().getInt(context,
|
||||
"Tree.expanderSize", 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GTK has a separate widget for the handle box, to mirror this
|
||||
// we create a unique icon per ToolBar and lookup the style for the
|
||||
// HandleBox.
|
||||
private static class ToolBarHandleIcon extends DelegatingIcon {
|
||||
private static final Class[] PARAM_TYPES = new Class[] {
|
||||
SynthContext.class, Graphics.class, int.class,
|
||||
int.class, int.class, int.class, int.class, Orientation.class,
|
||||
};
|
||||
|
||||
private SynthStyle style;
|
||||
|
||||
public ToolBarHandleIcon() {
|
||||
super(TOOL_BAR_HANDLE_ICON);
|
||||
}
|
||||
|
||||
protected Class[] getMethodParamTypes() {
|
||||
return PARAM_TYPES;
|
||||
}
|
||||
|
||||
public void paintIcon(SynthContext context, Graphics g, int x, int y,
|
||||
int w, int h) {
|
||||
if (context != null) {
|
||||
JToolBar toolbar = (JToolBar)context.getComponent();
|
||||
Orientation orientation =
|
||||
(toolbar.getOrientation() == JToolBar.HORIZONTAL ?
|
||||
Orientation.HORIZONTAL : Orientation.VERTICAL);
|
||||
|
||||
if (style == null) {
|
||||
style = SynthLookAndFeel.getStyleFactory().getStyle(
|
||||
context.getComponent(), GTKRegion.HANDLE_BOX);
|
||||
}
|
||||
context = new SynthContext(toolbar, GTKRegion.HANDLE_BOX,
|
||||
style, SynthConstants.ENABLED);
|
||||
|
||||
GTKPainter.INSTANCE.paintIcon(context, g,
|
||||
getMethod(), x, y, w, h, orientation);
|
||||
}
|
||||
}
|
||||
|
||||
public int getIconWidth(SynthContext context) {
|
||||
if (context == null) {
|
||||
return 10;
|
||||
}
|
||||
if (((JToolBar)context.getComponent()).getOrientation() ==
|
||||
JToolBar.HORIZONTAL) {
|
||||
return 10;
|
||||
} else {
|
||||
return context.getComponent().getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
public int getIconHeight(SynthContext context) {
|
||||
if (context == null) {
|
||||
return 10;
|
||||
}
|
||||
if (((JToolBar)context.getComponent()).getOrientation() ==
|
||||
JToolBar.HORIZONTAL) {
|
||||
return context.getComponent().getHeight();
|
||||
} else {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class MenuArrowIcon extends DelegatingIcon {
|
||||
private static final Class[] PARAM_TYPES = new Class[] {
|
||||
SynthContext.class, Graphics.class, int.class,
|
||||
int.class, int.class, int.class, int.class, ArrowType.class,
|
||||
};
|
||||
|
||||
public MenuArrowIcon() {
|
||||
super(MENU_ARROW_ICON);
|
||||
}
|
||||
|
||||
protected Class[] getMethodParamTypes() {
|
||||
return PARAM_TYPES;
|
||||
}
|
||||
|
||||
public void paintIcon(SynthContext context, Graphics g, int x, int y,
|
||||
int w, int h) {
|
||||
if (context != null) {
|
||||
ArrowType arrowDir = ArrowType.RIGHT;
|
||||
if (!context.getComponent().getComponentOrientation().isLeftToRight()) {
|
||||
arrowDir = ArrowType.LEFT;
|
||||
}
|
||||
GTKPainter.INSTANCE.paintIcon(context, g,
|
||||
getMethod(), x, y, w, h, arrowDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1757
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java
Normal file
1757
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java
Normal file
File diff suppressed because it is too large
Load Diff
1602
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKPainter.java
Normal file
1602
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKPainter.java
Normal file
File diff suppressed because it is too large
Load Diff
42
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKRegion.java
Normal file
42
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKRegion.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.gtk;
|
||||
|
||||
import javax.swing.plaf.synth.Region;
|
||||
|
||||
/**
|
||||
* A typesafe enumeration of the distinct rendering portions specific
|
||||
* to GTK.
|
||||
*
|
||||
* @author Scott Violet
|
||||
*/
|
||||
class GTKRegion extends Region {
|
||||
public static final Region HANDLE_BOX = new GTKRegion("HandleBox", null,
|
||||
true);
|
||||
|
||||
protected GTKRegion(String name, String ui, boolean subregion) {
|
||||
super(name, ui, subregion);
|
||||
}
|
||||
}
|
||||
1197
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKStyle.java
Normal file
1197
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKStyle.java
Normal file
File diff suppressed because it is too large
Load Diff
188
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java
Normal file
188
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.gtk;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.synth.*;
|
||||
import com.sun.java.swing.plaf.gtk.GTKEngine.WidgetType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Scott Violet
|
||||
*/
|
||||
class GTKStyleFactory extends SynthStyleFactory {
|
||||
|
||||
/**
|
||||
* Saves all styles that have been accessed. In most common cases,
|
||||
* the hash key is simply the WidgetType, but in more complex cases
|
||||
* it will be a ComplexKey object that contains arguments to help
|
||||
* differentiate similar styles.
|
||||
*/
|
||||
private final Map<Object, GTKStyle> stylesCache;
|
||||
|
||||
private Font defaultFont;
|
||||
|
||||
GTKStyleFactory() {
|
||||
stylesCache = new HashMap<Object, GTKStyle>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <code>GTKStyle</code> to use based on the
|
||||
* <code>Region</code> id
|
||||
*
|
||||
* @param c this parameter isn't used, may be null.
|
||||
* @param id of the region to get the style.
|
||||
*/
|
||||
public synchronized SynthStyle getStyle(JComponent c, Region id) {
|
||||
WidgetType wt = GTKEngine.getWidgetType(c, id);
|
||||
|
||||
Object key = null;
|
||||
if (id == Region.SCROLL_BAR) {
|
||||
// The style/insets of a scrollbar can depend on a number of
|
||||
// factors (see GTKStyle.getScrollBarInsets()) so use a
|
||||
// complex key here.
|
||||
if (c != null) {
|
||||
JScrollBar sb = (JScrollBar)c;
|
||||
boolean sp = (sb.getParent() instanceof JScrollPane);
|
||||
boolean horiz = (sb.getOrientation() == JScrollBar.HORIZONTAL);
|
||||
boolean ltr = sb.getComponentOrientation().isLeftToRight();
|
||||
boolean focusable = sb.isFocusable();
|
||||
key = new ComplexKey(wt, sp, horiz, ltr, focusable);
|
||||
}
|
||||
}
|
||||
else if (id == Region.CHECK_BOX || id == Region.RADIO_BUTTON) {
|
||||
// The style/insets of a checkbox or radiobutton can depend
|
||||
// on the component orientation, so use a complex key here.
|
||||
if (c != null) {
|
||||
boolean ltr = c.getComponentOrientation().isLeftToRight();
|
||||
key = new ComplexKey(wt, ltr);
|
||||
}
|
||||
}
|
||||
else if (id == Region.BUTTON) {
|
||||
// The style/insets of a button can depend on whether it is
|
||||
// default capable or in a toolbar, so use a complex key here.
|
||||
if (c != null) {
|
||||
JButton btn = (JButton)c;
|
||||
boolean toolButton = (btn.getParent() instanceof JToolBar);
|
||||
boolean defaultCapable = btn.isDefaultCapable();
|
||||
key = new ComplexKey(wt, toolButton, defaultCapable);
|
||||
}
|
||||
} else if (id == Region.MENU) {
|
||||
if (c instanceof JMenu && ((JMenu) c).isTopLevelMenu() &&
|
||||
UIManager.getBoolean("Menu.useMenuBarForTopLevelMenus")) {
|
||||
wt = WidgetType.MENU_BAR;
|
||||
}
|
||||
}
|
||||
|
||||
if (key == null) {
|
||||
// Otherwise, just use the WidgetType as the key.
|
||||
key = wt;
|
||||
}
|
||||
|
||||
GTKStyle result = stylesCache.get(key);
|
||||
if (result == null) {
|
||||
result = new GTKStyle(defaultFont, wt);
|
||||
stylesCache.put(key, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void initStyles(Font defaultFont) {
|
||||
this.defaultFont = defaultFont;
|
||||
stylesCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a hash key used for fetching GTKStyle objects from the
|
||||
* cache. In most cases only the WidgetType is used for lookup, but
|
||||
* in some complex cases, other Object arguments can be specified
|
||||
* via a ComplexKey to differentiate the various styles.
|
||||
*/
|
||||
private static class ComplexKey {
|
||||
private final WidgetType wt;
|
||||
private final Object[] args;
|
||||
|
||||
ComplexKey(WidgetType wt, Object... args) {
|
||||
this.wt = wt;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = wt.hashCode();
|
||||
if (args != null) {
|
||||
for (Object arg : args) {
|
||||
hash = hash*29 + (arg == null ? 0 : arg.hashCode());
|
||||
}
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof ComplexKey)) {
|
||||
return false;
|
||||
}
|
||||
ComplexKey that = (ComplexKey)o;
|
||||
if (this.wt == that.wt) {
|
||||
if (this.args == null && that.args == null) {
|
||||
return true;
|
||||
}
|
||||
if (this.args != null && that.args != null &&
|
||||
this.args.length == that.args.length)
|
||||
{
|
||||
for (int i = 0; i < this.args.length; i++) {
|
||||
Object a1 = this.args[i];
|
||||
Object a2 = that.args[i];
|
||||
if (!(a1==null ? a2==null : a1.equals(a2))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String str = "ComplexKey[wt=" + wt;
|
||||
if (args != null) {
|
||||
str += ",args=[";
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
str += args[i];
|
||||
if (i < args.length-1) str += ",";
|
||||
}
|
||||
str += "]";
|
||||
}
|
||||
str += "]";
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
2159
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/Metacity.java
Normal file
2159
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/Metacity.java
Normal file
File diff suppressed because it is too large
Load Diff
233
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/PangoFonts.java
Normal file
233
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/PangoFonts.java
Normal file
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.gtk;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import sun.font.FontConfigManager;
|
||||
import sun.font.FontUtilities;
|
||||
|
||||
/**
|
||||
* @author Shannon Hickey
|
||||
* @author Leif Samuelsson
|
||||
*/
|
||||
class PangoFonts {
|
||||
|
||||
public static final String CHARS_DIGITS = "0123456789";
|
||||
|
||||
/**
|
||||
* Calculate a default scale factor for fonts in this L&F to match
|
||||
* the reported resolution of the screen.
|
||||
* Java 2D specified a default user-space scale of 72dpi.
|
||||
* This is unlikely to correspond to that of the real screen.
|
||||
* The Xserver reports a value which may be used to adjust for this.
|
||||
* and Java 2D exposes it via a normalizing transform.
|
||||
* However many Xservers report a hard-coded 90dpi whilst others report a
|
||||
* calculated value based on possibly incorrect data.
|
||||
* That is something that must be solved at the X11 level
|
||||
* Note that in an X11 multi-screen environment, the default screen
|
||||
* is the one used by the JRE so it is safe to use it here.
|
||||
*/
|
||||
private static double fontScale;
|
||||
|
||||
static {
|
||||
fontScale = 1.0d;
|
||||
GraphicsEnvironment ge =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
|
||||
if (!ge.isHeadless()) {
|
||||
GraphicsConfiguration gc =
|
||||
ge.getDefaultScreenDevice().getDefaultConfiguration();
|
||||
AffineTransform at = gc.getNormalizingTransform();
|
||||
fontScale = at.getScaleY();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parses a String containing a pango font description and returns
|
||||
* a Font object.
|
||||
*
|
||||
* @param pangoName a String describing a pango font
|
||||
* e.g. "Sans Italic 10"
|
||||
* @return a Font object as a FontUIResource
|
||||
* or null if no suitable font could be created.
|
||||
*/
|
||||
static Font lookupFont(String pangoName) {
|
||||
String family = "";
|
||||
int style = Font.PLAIN;
|
||||
int size = 10;
|
||||
|
||||
StringTokenizer tok = new StringTokenizer(pangoName);
|
||||
|
||||
while (tok.hasMoreTokens()) {
|
||||
String word = tok.nextToken();
|
||||
|
||||
if (word.equalsIgnoreCase("italic")) {
|
||||
style |= Font.ITALIC;
|
||||
} else if (word.equalsIgnoreCase("bold")) {
|
||||
style |= Font.BOLD;
|
||||
} else if (CHARS_DIGITS.indexOf(word.charAt(0)) != -1) {
|
||||
try {
|
||||
size = Integer.parseInt(word);
|
||||
} catch (NumberFormatException ex) {
|
||||
}
|
||||
} else {
|
||||
if (family.length() > 0) {
|
||||
family += " ";
|
||||
}
|
||||
|
||||
family += word;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Java 2D font point sizes are in a user-space scale of 72dpi.
|
||||
* GTK allows a user to configure a "dpi" property used to scale
|
||||
* the fonts used to match a user's preference.
|
||||
* To match the font size of GTK apps we need to obtain this DPI and
|
||||
* adjust as follows:
|
||||
* Some versions of GTK use XSETTINGS if available to dynamically
|
||||
* monitor user-initiated changes in the DPI to be used by GTK
|
||||
* apps. This value is also made available as the Xft.dpi X resource.
|
||||
* This is presumably a function of the font preferences API and/or
|
||||
* the manner in which it requests the toolkit to update the default
|
||||
* for the desktop. This dual approach is probably necessary since
|
||||
* other versions of GTK - or perhaps some apps - determine the size
|
||||
* to use only at start-up from that X resource.
|
||||
* If that resource is not set then GTK scales for the DPI resolution
|
||||
* reported by the Xserver using the formula
|
||||
* DisplayHeight(dpy, screen) / DisplayHeightMM(dpy, screen) * 25.4
|
||||
* (25.4mm == 1 inch).
|
||||
* JDK tracks the Xft.dpi XSETTINGS property directly so it can
|
||||
* dynamically change font size by tracking just that value.
|
||||
* If that resource is not available use the same fall back formula
|
||||
* as GTK (see calculation for fontScale).
|
||||
*
|
||||
* GTK's default setting for Xft.dpi is 96 dpi (and it seems -1
|
||||
* apparently also can mean that "default"). However this default
|
||||
* isn't used if there's no property set. The real default in the
|
||||
* absence of a resource is the Xserver reported dpi.
|
||||
* Finally this DPI is used to calculate the nearest Java 2D font
|
||||
* 72 dpi font size.
|
||||
* There are cases in which JDK behaviour may not exactly mimic
|
||||
* GTK native app behaviour :
|
||||
* 1) When a GTK app is not able to dynamically track the changes
|
||||
* (does not use XSETTINGS), JDK will resize but other apps will
|
||||
* not. This is OK as JDK is exhibiting preferred behaviour and
|
||||
* this is probably how all later GTK apps will behave
|
||||
* 2) When a GTK app does not use XSETTINGS and for some reason
|
||||
* the XRDB property is not present. JDK will pick up XSETTINGS
|
||||
* and the GTK app will use the Xserver default. Since its
|
||||
* impossible for JDK to know that some other GTK app is not
|
||||
* using XSETTINGS its impossible to account for this and in any
|
||||
* case for it to be a problem the values would have to be different.
|
||||
* It also seems unlikely to arise except when a user explicitly
|
||||
* deletes the X resource database entry.
|
||||
* There also some other issues to be aware of for the future:
|
||||
* GTK specifies the Xft.dpi value as server-wide which when used
|
||||
* on systems with 2 distinct X screens with different physical DPI
|
||||
* the font sizes will inevitably appear different. It would have
|
||||
* been a more user-friendly design to further adjust that one
|
||||
* setting depending on the screen resolution to achieve perceived
|
||||
* equivalent sizes. If such a change were ever to be made in GTK
|
||||
* we would need to update for that.
|
||||
*/
|
||||
double dsize = size;
|
||||
int dpi = 96;
|
||||
Object value =
|
||||
Toolkit.getDefaultToolkit().getDesktopProperty("gnome.Xft/DPI");
|
||||
if (value instanceof Integer) {
|
||||
dpi = ((Integer)value).intValue() / 1024;
|
||||
if (dpi == -1) {
|
||||
dpi = 96;
|
||||
}
|
||||
if (dpi < 50) { /* 50 dpi is the minimum value gnome allows */
|
||||
dpi = 50;
|
||||
}
|
||||
/* The Java rasteriser assumes pts are in a user space of
|
||||
* 72 dpi, so we need to adjust for that.
|
||||
*/
|
||||
dsize = ((double)(dpi * size)/ 72.0);
|
||||
} else {
|
||||
/* If there's no property, GTK scales for the resolution
|
||||
* reported by the Xserver using the formula listed above.
|
||||
* fontScale already accounts for the 72 dpi Java 2D space.
|
||||
*/
|
||||
dsize = size * fontScale;
|
||||
}
|
||||
|
||||
/* Round size to nearest integer pt size */
|
||||
size = (int)(dsize + 0.5);
|
||||
if (size < 1) {
|
||||
size = 1;
|
||||
}
|
||||
|
||||
String fcFamilyLC = family.toLowerCase();
|
||||
if (FontUtilities.mapFcName(fcFamilyLC) != null) {
|
||||
/* family is a Fc/Pango logical font which we need to expand. */
|
||||
Font font = FontUtilities.getFontConfigFUIR(fcFamilyLC, style, size);
|
||||
font = font.deriveFont(style, (float)dsize);
|
||||
return new FontUIResource(font);
|
||||
} else {
|
||||
/* It's a physical font which we will create with a fallback */
|
||||
Font font = new Font(family, style, size);
|
||||
/* a roundabout way to set the font size in floating points */
|
||||
font = font.deriveFont(style, (float)dsize);
|
||||
FontUIResource fuir = new FontUIResource(font);
|
||||
return FontUtilities.getCompositeFontUIResource(fuir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a String containing a pango font description and returns
|
||||
* the (unscaled) font size as an integer.
|
||||
*
|
||||
* @param pangoName a String describing a pango font
|
||||
* @return the size of the font described by pangoName (e.g. if
|
||||
* pangoName is "Sans Italic 10", then this method returns 10)
|
||||
*/
|
||||
static int getFontSize(String pangoName) {
|
||||
int size = 10;
|
||||
|
||||
StringTokenizer tok = new StringTokenizer(pangoName);
|
||||
while (tok.hasMoreTokens()) {
|
||||
String word = tok.nextToken();
|
||||
|
||||
if (CHARS_DIGITS.indexOf(word.charAt(0)) != -1) {
|
||||
try {
|
||||
size = Integer.parseInt(word);
|
||||
} catch (NumberFormatException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
831
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/XColors.java
Normal file
831
jdkSrc/jdk8/com/sun/java/swing/plaf/gtk/XColors.java
Normal file
@@ -0,0 +1,831 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.gtk;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Arrays;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
|
||||
/**
|
||||
* @author Shannon Hickey
|
||||
*/
|
||||
class XColors {
|
||||
|
||||
private static class XColor implements Comparable {
|
||||
String name;
|
||||
|
||||
int red;
|
||||
int green;
|
||||
int blue;
|
||||
|
||||
XColor(String name, int red, int green, int blue) {
|
||||
this.name = name;
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
}
|
||||
|
||||
Color toColor() {
|
||||
return new ColorUIResource(red, green, blue);
|
||||
}
|
||||
|
||||
public int compareTo(Object o) {
|
||||
XColor other = (XColor)o;
|
||||
|
||||
return name.compareTo(other.name);
|
||||
}
|
||||
}
|
||||
|
||||
private static XColor key = new XColor("", -1, -1, -1);
|
||||
|
||||
static Color lookupColor(String name) {
|
||||
key.name = name.toLowerCase();
|
||||
|
||||
int pos = Arrays.binarySearch(colors, key);
|
||||
|
||||
if (pos < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return colors[pos].toColor();
|
||||
}
|
||||
|
||||
private static final XColor[] colors = {
|
||||
new XColor("alice blue", 240, 248, 255),
|
||||
new XColor("aliceblue", 240, 248, 255),
|
||||
new XColor("antique white", 250, 235, 215),
|
||||
new XColor("antiquewhite", 250, 235, 215),
|
||||
new XColor("antiquewhite1", 255, 239, 219),
|
||||
new XColor("antiquewhite2", 238, 223, 204),
|
||||
new XColor("antiquewhite3", 205, 192, 176),
|
||||
new XColor("antiquewhite4", 139, 131, 120),
|
||||
new XColor("aquamarine", 127, 255, 212),
|
||||
new XColor("aquamarine1", 127, 255, 212),
|
||||
new XColor("aquamarine2", 118, 238, 198),
|
||||
new XColor("aquamarine3", 102, 205, 170),
|
||||
new XColor("aquamarine4", 69, 139, 116),
|
||||
new XColor("azure", 240, 255, 255),
|
||||
new XColor("azure1", 240, 255, 255),
|
||||
new XColor("azure2", 224, 238, 238),
|
||||
new XColor("azure3", 193, 205, 205),
|
||||
new XColor("azure4", 131, 139, 139),
|
||||
new XColor("beige", 245, 245, 220),
|
||||
new XColor("bisque", 255, 228, 196),
|
||||
new XColor("bisque1", 255, 228, 196),
|
||||
new XColor("bisque2", 238, 213, 183),
|
||||
new XColor("bisque3", 205, 183, 158),
|
||||
new XColor("bisque4", 139, 125, 107),
|
||||
new XColor("black", 0, 0, 0),
|
||||
new XColor("blanched almond", 255, 235, 205),
|
||||
new XColor("blanchedalmond", 255, 235, 205),
|
||||
new XColor("blue", 0, 0, 255),
|
||||
new XColor("blue violet", 138, 43, 226),
|
||||
new XColor("blue1", 0, 0, 255),
|
||||
new XColor("blue2", 0, 0, 238),
|
||||
new XColor("blue3", 0, 0, 205),
|
||||
new XColor("blue4", 0, 0, 139),
|
||||
new XColor("blueviolet", 138, 43, 226),
|
||||
new XColor("brown", 165, 42, 42),
|
||||
new XColor("brown1", 255, 64, 64),
|
||||
new XColor("brown2", 238, 59, 59),
|
||||
new XColor("brown3", 205, 51, 51),
|
||||
new XColor("brown4", 139, 35, 35),
|
||||
new XColor("burlywood", 222, 184, 135),
|
||||
new XColor("burlywood1", 255, 211, 155),
|
||||
new XColor("burlywood2", 238, 197, 145),
|
||||
new XColor("burlywood3", 205, 170, 125),
|
||||
new XColor("burlywood4", 139, 115, 85),
|
||||
new XColor("cadet blue", 95, 158, 160),
|
||||
new XColor("cadetblue", 95, 158, 160),
|
||||
new XColor("cadetblue1", 152, 245, 255),
|
||||
new XColor("cadetblue2", 142, 229, 238),
|
||||
new XColor("cadetblue3", 122, 197, 205),
|
||||
new XColor("cadetblue4", 83, 134, 139),
|
||||
new XColor("chartreuse", 127, 255, 0),
|
||||
new XColor("chartreuse1", 127, 255, 0),
|
||||
new XColor("chartreuse2", 118, 238, 0),
|
||||
new XColor("chartreuse3", 102, 205, 0),
|
||||
new XColor("chartreuse4", 69, 139, 0),
|
||||
new XColor("chocolate", 210, 105, 30),
|
||||
new XColor("chocolate1", 255, 127, 36),
|
||||
new XColor("chocolate2", 238, 118, 33),
|
||||
new XColor("chocolate3", 205, 102, 29),
|
||||
new XColor("chocolate4", 139, 69, 19),
|
||||
new XColor("coral", 255, 127, 80),
|
||||
new XColor("coral1", 255, 114, 86),
|
||||
new XColor("coral2", 238, 106, 80),
|
||||
new XColor("coral3", 205, 91, 69),
|
||||
new XColor("coral4", 139, 62, 47),
|
||||
new XColor("cornflower blue", 100, 149, 237),
|
||||
new XColor("cornflowerblue", 100, 149, 237),
|
||||
new XColor("cornsilk", 255, 248, 220),
|
||||
new XColor("cornsilk1", 255, 248, 220),
|
||||
new XColor("cornsilk2", 238, 232, 205),
|
||||
new XColor("cornsilk3", 205, 200, 177),
|
||||
new XColor("cornsilk4", 139, 136, 120),
|
||||
new XColor("cyan", 0, 255, 255),
|
||||
new XColor("cyan1", 0, 255, 255),
|
||||
new XColor("cyan2", 0, 238, 238),
|
||||
new XColor("cyan3", 0, 205, 205),
|
||||
new XColor("cyan4", 0, 139, 139),
|
||||
new XColor("dark blue", 0, 0, 139),
|
||||
new XColor("dark cyan", 0, 139, 139),
|
||||
new XColor("dark goldenrod", 184, 134, 11),
|
||||
new XColor("dark gray", 169, 169, 169),
|
||||
new XColor("dark green", 0, 100, 0),
|
||||
new XColor("dark grey", 169, 169, 169),
|
||||
new XColor("dark khaki", 189, 183, 107),
|
||||
new XColor("dark magenta", 139, 0, 139),
|
||||
new XColor("dark olive green", 85, 107, 47),
|
||||
new XColor("dark orange", 255, 140, 0),
|
||||
new XColor("dark orchid", 153, 50, 204),
|
||||
new XColor("dark red", 139, 0, 0),
|
||||
new XColor("dark salmon", 233, 150, 122),
|
||||
new XColor("dark sea green", 143, 188, 143),
|
||||
new XColor("dark slate blue", 72, 61, 139),
|
||||
new XColor("dark slate gray", 47, 79, 79),
|
||||
new XColor("dark slate grey", 47, 79, 79),
|
||||
new XColor("dark turquoise", 0, 206, 209),
|
||||
new XColor("dark violet", 148, 0, 211),
|
||||
new XColor("darkblue", 0, 0, 139),
|
||||
new XColor("darkcyan", 0, 139, 139),
|
||||
new XColor("darkgoldenrod", 184, 134, 11),
|
||||
new XColor("darkgoldenrod1", 255, 185, 15),
|
||||
new XColor("darkgoldenrod2", 238, 173, 14),
|
||||
new XColor("darkgoldenrod3", 205, 149, 12),
|
||||
new XColor("darkgoldenrod4", 139, 101, 8),
|
||||
new XColor("darkgray", 169, 169, 169),
|
||||
new XColor("darkgreen", 0, 100, 0),
|
||||
new XColor("darkgrey", 169, 169, 169),
|
||||
new XColor("darkkhaki", 189, 183, 107),
|
||||
new XColor("darkmagenta", 139, 0, 139),
|
||||
new XColor("darkolivegreen", 85, 107, 47),
|
||||
new XColor("darkolivegreen1", 202, 255, 112),
|
||||
new XColor("darkolivegreen2", 188, 238, 104),
|
||||
new XColor("darkolivegreen3", 162, 205, 90),
|
||||
new XColor("darkolivegreen4", 110, 139, 61),
|
||||
new XColor("darkorange", 255, 140, 0),
|
||||
new XColor("darkorange1", 255, 127, 0),
|
||||
new XColor("darkorange2", 238, 118, 0),
|
||||
new XColor("darkorange3", 205, 102, 0),
|
||||
new XColor("darkorange4", 139, 69, 0),
|
||||
new XColor("darkorchid", 153, 50, 204),
|
||||
new XColor("darkorchid1", 191, 62, 255),
|
||||
new XColor("darkorchid2", 178, 58, 238),
|
||||
new XColor("darkorchid3", 154, 50, 205),
|
||||
new XColor("darkorchid4", 104, 34, 139),
|
||||
new XColor("darkred", 139, 0, 0),
|
||||
new XColor("darksalmon", 233, 150, 122),
|
||||
new XColor("darkseagreen", 143, 188, 143),
|
||||
new XColor("darkseagreen1", 193, 255, 193),
|
||||
new XColor("darkseagreen2", 180, 238, 180),
|
||||
new XColor("darkseagreen3", 155, 205, 155),
|
||||
new XColor("darkseagreen4", 105, 139, 105),
|
||||
new XColor("darkslateblue", 72, 61, 139),
|
||||
new XColor("darkslategray", 47, 79, 79),
|
||||
new XColor("darkslategray1", 151, 255, 255),
|
||||
new XColor("darkslategray2", 141, 238, 238),
|
||||
new XColor("darkslategray3", 121, 205, 205),
|
||||
new XColor("darkslategray4", 82, 139, 139),
|
||||
new XColor("darkslategrey", 47, 79, 79),
|
||||
new XColor("darkturquoise", 0, 206, 209),
|
||||
new XColor("darkviolet", 148, 0, 211),
|
||||
new XColor("deep pink", 255, 20, 147),
|
||||
new XColor("deep sky blue", 0, 191, 255),
|
||||
new XColor("deeppink", 255, 20, 147),
|
||||
new XColor("deeppink1", 255, 20, 147),
|
||||
new XColor("deeppink2", 238, 18, 137),
|
||||
new XColor("deeppink3", 205, 16, 118),
|
||||
new XColor("deeppink4", 139, 10, 80),
|
||||
new XColor("deepskyblue", 0, 191, 255),
|
||||
new XColor("deepskyblue1", 0, 191, 255),
|
||||
new XColor("deepskyblue2", 0, 178, 238),
|
||||
new XColor("deepskyblue3", 0, 154, 205),
|
||||
new XColor("deepskyblue4", 0, 104, 139),
|
||||
new XColor("dim gray", 105, 105, 105),
|
||||
new XColor("dim grey", 105, 105, 105),
|
||||
new XColor("dimgray", 105, 105, 105),
|
||||
new XColor("dimgrey", 105, 105, 105),
|
||||
new XColor("dodger blue", 30, 144, 255),
|
||||
new XColor("dodgerblue", 30, 144, 255),
|
||||
new XColor("dodgerblue1", 30, 144, 255),
|
||||
new XColor("dodgerblue2", 28, 134, 238),
|
||||
new XColor("dodgerblue3", 24, 116, 205),
|
||||
new XColor("dodgerblue4", 16, 78, 139),
|
||||
new XColor("firebrick", 178, 34, 34),
|
||||
new XColor("firebrick1", 255, 48, 48),
|
||||
new XColor("firebrick2", 238, 44, 44),
|
||||
new XColor("firebrick3", 205, 38, 38),
|
||||
new XColor("firebrick4", 139, 26, 26),
|
||||
new XColor("floral white", 255, 250, 240),
|
||||
new XColor("floralwhite", 255, 250, 240),
|
||||
new XColor("forest green", 34, 139, 34),
|
||||
new XColor("forestgreen", 34, 139, 34),
|
||||
new XColor("gainsboro", 220, 220, 220),
|
||||
new XColor("ghost white", 248, 248, 255),
|
||||
new XColor("ghostwhite", 248, 248, 255),
|
||||
new XColor("gold", 255, 215, 0),
|
||||
new XColor("gold1", 255, 215, 0),
|
||||
new XColor("gold2", 238, 201, 0),
|
||||
new XColor("gold3", 205, 173, 0),
|
||||
new XColor("gold4", 139, 117, 0),
|
||||
new XColor("goldenrod", 218, 165, 32),
|
||||
new XColor("goldenrod1", 255, 193, 37),
|
||||
new XColor("goldenrod2", 238, 180, 34),
|
||||
new XColor("goldenrod3", 205, 155, 29),
|
||||
new XColor("goldenrod4", 139, 105, 20),
|
||||
new XColor("gray", 190, 190, 190),
|
||||
new XColor("gray0", 0, 0, 0),
|
||||
new XColor("gray1", 3, 3, 3),
|
||||
new XColor("gray10", 26, 26, 26),
|
||||
new XColor("gray100", 255, 255, 255),
|
||||
new XColor("gray11", 28, 28, 28),
|
||||
new XColor("gray12", 31, 31, 31),
|
||||
new XColor("gray13", 33, 33, 33),
|
||||
new XColor("gray14", 36, 36, 36),
|
||||
new XColor("gray15", 38, 38, 38),
|
||||
new XColor("gray16", 41, 41, 41),
|
||||
new XColor("gray17", 43, 43, 43),
|
||||
new XColor("gray18", 46, 46, 46),
|
||||
new XColor("gray19", 48, 48, 48),
|
||||
new XColor("gray2", 5, 5, 5),
|
||||
new XColor("gray20", 51, 51, 51),
|
||||
new XColor("gray21", 54, 54, 54),
|
||||
new XColor("gray22", 56, 56, 56),
|
||||
new XColor("gray23", 59, 59, 59),
|
||||
new XColor("gray24", 61, 61, 61),
|
||||
new XColor("gray25", 64, 64, 64),
|
||||
new XColor("gray26", 66, 66, 66),
|
||||
new XColor("gray27", 69, 69, 69),
|
||||
new XColor("gray28", 71, 71, 71),
|
||||
new XColor("gray29", 74, 74, 74),
|
||||
new XColor("gray3", 8, 8, 8),
|
||||
new XColor("gray30", 77, 77, 77),
|
||||
new XColor("gray31", 79, 79, 79),
|
||||
new XColor("gray32", 82, 82, 82),
|
||||
new XColor("gray33", 84, 84, 84),
|
||||
new XColor("gray34", 87, 87, 87),
|
||||
new XColor("gray35", 89, 89, 89),
|
||||
new XColor("gray36", 92, 92, 92),
|
||||
new XColor("gray37", 94, 94, 94),
|
||||
new XColor("gray38", 97, 97, 97),
|
||||
new XColor("gray39", 99, 99, 99),
|
||||
new XColor("gray4", 10, 10, 10),
|
||||
new XColor("gray40", 102, 102, 102),
|
||||
new XColor("gray41", 105, 105, 105),
|
||||
new XColor("gray42", 107, 107, 107),
|
||||
new XColor("gray43", 110, 110, 110),
|
||||
new XColor("gray44", 112, 112, 112),
|
||||
new XColor("gray45", 115, 115, 115),
|
||||
new XColor("gray46", 117, 117, 117),
|
||||
new XColor("gray47", 120, 120, 120),
|
||||
new XColor("gray48", 122, 122, 122),
|
||||
new XColor("gray49", 125, 125, 125),
|
||||
new XColor("gray5", 13, 13, 13),
|
||||
new XColor("gray50", 127, 127, 127),
|
||||
new XColor("gray51", 130, 130, 130),
|
||||
new XColor("gray52", 133, 133, 133),
|
||||
new XColor("gray53", 135, 135, 135),
|
||||
new XColor("gray54", 138, 138, 138),
|
||||
new XColor("gray55", 140, 140, 140),
|
||||
new XColor("gray56", 143, 143, 143),
|
||||
new XColor("gray57", 145, 145, 145),
|
||||
new XColor("gray58", 148, 148, 148),
|
||||
new XColor("gray59", 150, 150, 150),
|
||||
new XColor("gray6", 15, 15, 15),
|
||||
new XColor("gray60", 153, 153, 153),
|
||||
new XColor("gray61", 156, 156, 156),
|
||||
new XColor("gray62", 158, 158, 158),
|
||||
new XColor("gray63", 161, 161, 161),
|
||||
new XColor("gray64", 163, 163, 163),
|
||||
new XColor("gray65", 166, 166, 166),
|
||||
new XColor("gray66", 168, 168, 168),
|
||||
new XColor("gray67", 171, 171, 171),
|
||||
new XColor("gray68", 173, 173, 173),
|
||||
new XColor("gray69", 176, 176, 176),
|
||||
new XColor("gray7", 18, 18, 18),
|
||||
new XColor("gray70", 179, 179, 179),
|
||||
new XColor("gray71", 181, 181, 181),
|
||||
new XColor("gray72", 184, 184, 184),
|
||||
new XColor("gray73", 186, 186, 186),
|
||||
new XColor("gray74", 189, 189, 189),
|
||||
new XColor("gray75", 191, 191, 191),
|
||||
new XColor("gray76", 194, 194, 194),
|
||||
new XColor("gray77", 196, 196, 196),
|
||||
new XColor("gray78", 199, 199, 199),
|
||||
new XColor("gray79", 201, 201, 201),
|
||||
new XColor("gray8", 20, 20, 20),
|
||||
new XColor("gray80", 204, 204, 204),
|
||||
new XColor("gray81", 207, 207, 207),
|
||||
new XColor("gray82", 209, 209, 209),
|
||||
new XColor("gray83", 212, 212, 212),
|
||||
new XColor("gray84", 214, 214, 214),
|
||||
new XColor("gray85", 217, 217, 217),
|
||||
new XColor("gray86", 219, 219, 219),
|
||||
new XColor("gray87", 222, 222, 222),
|
||||
new XColor("gray88", 224, 224, 224),
|
||||
new XColor("gray89", 227, 227, 227),
|
||||
new XColor("gray9", 23, 23, 23),
|
||||
new XColor("gray90", 229, 229, 229),
|
||||
new XColor("gray91", 232, 232, 232),
|
||||
new XColor("gray92", 235, 235, 235),
|
||||
new XColor("gray93", 237, 237, 237),
|
||||
new XColor("gray94", 240, 240, 240),
|
||||
new XColor("gray95", 242, 242, 242),
|
||||
new XColor("gray96", 245, 245, 245),
|
||||
new XColor("gray97", 247, 247, 247),
|
||||
new XColor("gray98", 250, 250, 250),
|
||||
new XColor("gray99", 252, 252, 252),
|
||||
new XColor("green", 0, 255, 0),
|
||||
new XColor("green yellow", 173, 255, 47),
|
||||
new XColor("green1", 0, 255, 0),
|
||||
new XColor("green2", 0, 238, 0),
|
||||
new XColor("green3", 0, 205, 0),
|
||||
new XColor("green4", 0, 139, 0),
|
||||
new XColor("greenyellow", 173, 255, 47),
|
||||
new XColor("grey", 190, 190, 190),
|
||||
new XColor("grey0", 0, 0, 0),
|
||||
new XColor("grey1", 3, 3, 3),
|
||||
new XColor("grey10", 26, 26, 26),
|
||||
new XColor("grey100", 255, 255, 255),
|
||||
new XColor("grey11", 28, 28, 28),
|
||||
new XColor("grey12", 31, 31, 31),
|
||||
new XColor("grey13", 33, 33, 33),
|
||||
new XColor("grey14", 36, 36, 36),
|
||||
new XColor("grey15", 38, 38, 38),
|
||||
new XColor("grey16", 41, 41, 41),
|
||||
new XColor("grey17", 43, 43, 43),
|
||||
new XColor("grey18", 46, 46, 46),
|
||||
new XColor("grey19", 48, 48, 48),
|
||||
new XColor("grey2", 5, 5, 5),
|
||||
new XColor("grey20", 51, 51, 51),
|
||||
new XColor("grey21", 54, 54, 54),
|
||||
new XColor("grey22", 56, 56, 56),
|
||||
new XColor("grey23", 59, 59, 59),
|
||||
new XColor("grey24", 61, 61, 61),
|
||||
new XColor("grey25", 64, 64, 64),
|
||||
new XColor("grey26", 66, 66, 66),
|
||||
new XColor("grey27", 69, 69, 69),
|
||||
new XColor("grey28", 71, 71, 71),
|
||||
new XColor("grey29", 74, 74, 74),
|
||||
new XColor("grey3", 8, 8, 8),
|
||||
new XColor("grey30", 77, 77, 77),
|
||||
new XColor("grey31", 79, 79, 79),
|
||||
new XColor("grey32", 82, 82, 82),
|
||||
new XColor("grey33", 84, 84, 84),
|
||||
new XColor("grey34", 87, 87, 87),
|
||||
new XColor("grey35", 89, 89, 89),
|
||||
new XColor("grey36", 92, 92, 92),
|
||||
new XColor("grey37", 94, 94, 94),
|
||||
new XColor("grey38", 97, 97, 97),
|
||||
new XColor("grey39", 99, 99, 99),
|
||||
new XColor("grey4", 10, 10, 10),
|
||||
new XColor("grey40", 102, 102, 102),
|
||||
new XColor("grey41", 105, 105, 105),
|
||||
new XColor("grey42", 107, 107, 107),
|
||||
new XColor("grey43", 110, 110, 110),
|
||||
new XColor("grey44", 112, 112, 112),
|
||||
new XColor("grey45", 115, 115, 115),
|
||||
new XColor("grey46", 117, 117, 117),
|
||||
new XColor("grey47", 120, 120, 120),
|
||||
new XColor("grey48", 122, 122, 122),
|
||||
new XColor("grey49", 125, 125, 125),
|
||||
new XColor("grey5", 13, 13, 13),
|
||||
new XColor("grey50", 127, 127, 127),
|
||||
new XColor("grey51", 130, 130, 130),
|
||||
new XColor("grey52", 133, 133, 133),
|
||||
new XColor("grey53", 135, 135, 135),
|
||||
new XColor("grey54", 138, 138, 138),
|
||||
new XColor("grey55", 140, 140, 140),
|
||||
new XColor("grey56", 143, 143, 143),
|
||||
new XColor("grey57", 145, 145, 145),
|
||||
new XColor("grey58", 148, 148, 148),
|
||||
new XColor("grey59", 150, 150, 150),
|
||||
new XColor("grey6", 15, 15, 15),
|
||||
new XColor("grey60", 153, 153, 153),
|
||||
new XColor("grey61", 156, 156, 156),
|
||||
new XColor("grey62", 158, 158, 158),
|
||||
new XColor("grey63", 161, 161, 161),
|
||||
new XColor("grey64", 163, 163, 163),
|
||||
new XColor("grey65", 166, 166, 166),
|
||||
new XColor("grey66", 168, 168, 168),
|
||||
new XColor("grey67", 171, 171, 171),
|
||||
new XColor("grey68", 173, 173, 173),
|
||||
new XColor("grey69", 176, 176, 176),
|
||||
new XColor("grey7", 18, 18, 18),
|
||||
new XColor("grey70", 179, 179, 179),
|
||||
new XColor("grey71", 181, 181, 181),
|
||||
new XColor("grey72", 184, 184, 184),
|
||||
new XColor("grey73", 186, 186, 186),
|
||||
new XColor("grey74", 189, 189, 189),
|
||||
new XColor("grey75", 191, 191, 191),
|
||||
new XColor("grey76", 194, 194, 194),
|
||||
new XColor("grey77", 196, 196, 196),
|
||||
new XColor("grey78", 199, 199, 199),
|
||||
new XColor("grey79", 201, 201, 201),
|
||||
new XColor("grey8", 20, 20, 20),
|
||||
new XColor("grey80", 204, 204, 204),
|
||||
new XColor("grey81", 207, 207, 207),
|
||||
new XColor("grey82", 209, 209, 209),
|
||||
new XColor("grey83", 212, 212, 212),
|
||||
new XColor("grey84", 214, 214, 214),
|
||||
new XColor("grey85", 217, 217, 217),
|
||||
new XColor("grey86", 219, 219, 219),
|
||||
new XColor("grey87", 222, 222, 222),
|
||||
new XColor("grey88", 224, 224, 224),
|
||||
new XColor("grey89", 227, 227, 227),
|
||||
new XColor("grey9", 23, 23, 23),
|
||||
new XColor("grey90", 229, 229, 229),
|
||||
new XColor("grey91", 232, 232, 232),
|
||||
new XColor("grey92", 235, 235, 235),
|
||||
new XColor("grey93", 237, 237, 237),
|
||||
new XColor("grey94", 240, 240, 240),
|
||||
new XColor("grey95", 242, 242, 242),
|
||||
new XColor("grey96", 245, 245, 245),
|
||||
new XColor("grey97", 247, 247, 247),
|
||||
new XColor("grey98", 250, 250, 250),
|
||||
new XColor("grey99", 252, 252, 252),
|
||||
new XColor("honeydew", 240, 255, 240),
|
||||
new XColor("honeydew1", 240, 255, 240),
|
||||
new XColor("honeydew2", 224, 238, 224),
|
||||
new XColor("honeydew3", 193, 205, 193),
|
||||
new XColor("honeydew4", 131, 139, 131),
|
||||
new XColor("hot pink", 255, 105, 180),
|
||||
new XColor("hotpink", 255, 105, 180),
|
||||
new XColor("hotpink1", 255, 110, 180),
|
||||
new XColor("hotpink2", 238, 106, 167),
|
||||
new XColor("hotpink3", 205, 96, 144),
|
||||
new XColor("hotpink4", 139, 58, 98),
|
||||
new XColor("indian red", 205, 92, 92),
|
||||
new XColor("indianred", 205, 92, 92),
|
||||
new XColor("indianred1", 255, 106, 106),
|
||||
new XColor("indianred2", 238, 99, 99),
|
||||
new XColor("indianred3", 205, 85, 85),
|
||||
new XColor("indianred4", 139, 58, 58),
|
||||
new XColor("ivory", 255, 255, 240),
|
||||
new XColor("ivory1", 255, 255, 240),
|
||||
new XColor("ivory2", 238, 238, 224),
|
||||
new XColor("ivory3", 205, 205, 193),
|
||||
new XColor("ivory4", 139, 139, 131),
|
||||
new XColor("khaki", 240, 230, 140),
|
||||
new XColor("khaki1", 255, 246, 143),
|
||||
new XColor("khaki2", 238, 230, 133),
|
||||
new XColor("khaki3", 205, 198, 115),
|
||||
new XColor("khaki4", 139, 134, 78),
|
||||
new XColor("lavender", 230, 230, 250),
|
||||
new XColor("lavender blush", 255, 240, 245),
|
||||
new XColor("lavenderblush", 255, 240, 245),
|
||||
new XColor("lavenderblush1", 255, 240, 245),
|
||||
new XColor("lavenderblush2", 238, 224, 229),
|
||||
new XColor("lavenderblush3", 205, 193, 197),
|
||||
new XColor("lavenderblush4", 139, 131, 134),
|
||||
new XColor("lawn green", 124, 252, 0),
|
||||
new XColor("lawngreen", 124, 252, 0),
|
||||
new XColor("lemon chiffon", 255, 250, 205),
|
||||
new XColor("lemonchiffon", 255, 250, 205),
|
||||
new XColor("lemonchiffon1", 255, 250, 205),
|
||||
new XColor("lemonchiffon2", 238, 233, 191),
|
||||
new XColor("lemonchiffon3", 205, 201, 165),
|
||||
new XColor("lemonchiffon4", 139, 137, 112),
|
||||
new XColor("light blue", 173, 216, 230),
|
||||
new XColor("light coral", 240, 128, 128),
|
||||
new XColor("light cyan", 224, 255, 255),
|
||||
new XColor("light goldenrod", 238, 221, 130),
|
||||
new XColor("light goldenrod yellow", 250, 250, 210),
|
||||
new XColor("light gray", 211, 211, 211),
|
||||
new XColor("light green", 144, 238, 144),
|
||||
new XColor("light grey", 211, 211, 211),
|
||||
new XColor("light pink", 255, 182, 193),
|
||||
new XColor("light salmon", 255, 160, 122),
|
||||
new XColor("light sea green", 32, 178, 170),
|
||||
new XColor("light sky blue", 135, 206, 250),
|
||||
new XColor("light slate blue", 132, 112, 255),
|
||||
new XColor("light slate gray", 119, 136, 153),
|
||||
new XColor("light slate grey", 119, 136, 153),
|
||||
new XColor("light steel blue", 176, 196, 222),
|
||||
new XColor("light yellow", 255, 255, 224),
|
||||
new XColor("lightblue", 173, 216, 230),
|
||||
new XColor("lightblue1", 191, 239, 255),
|
||||
new XColor("lightblue2", 178, 223, 238),
|
||||
new XColor("lightblue3", 154, 192, 205),
|
||||
new XColor("lightblue4", 104, 131, 139),
|
||||
new XColor("lightcoral", 240, 128, 128),
|
||||
new XColor("lightcyan", 224, 255, 255),
|
||||
new XColor("lightcyan1", 224, 255, 255),
|
||||
new XColor("lightcyan2", 209, 238, 238),
|
||||
new XColor("lightcyan3", 180, 205, 205),
|
||||
new XColor("lightcyan4", 122, 139, 139),
|
||||
new XColor("lightgoldenrod", 238, 221, 130),
|
||||
new XColor("lightgoldenrod1", 255, 236, 139),
|
||||
new XColor("lightgoldenrod2", 238, 220, 130),
|
||||
new XColor("lightgoldenrod3", 205, 190, 112),
|
||||
new XColor("lightgoldenrod4", 139, 129, 76),
|
||||
new XColor("lightgoldenrodyellow", 250, 250, 210),
|
||||
new XColor("lightgray", 211, 211, 211),
|
||||
new XColor("lightgreen", 144, 238, 144),
|
||||
new XColor("lightgrey", 211, 211, 211),
|
||||
new XColor("lightpink", 255, 182, 193),
|
||||
new XColor("lightpink1", 255, 174, 185),
|
||||
new XColor("lightpink2", 238, 162, 173),
|
||||
new XColor("lightpink3", 205, 140, 149),
|
||||
new XColor("lightpink4", 139, 95, 101),
|
||||
new XColor("lightsalmon", 255, 160, 122),
|
||||
new XColor("lightsalmon1", 255, 160, 122),
|
||||
new XColor("lightsalmon2", 238, 149, 114),
|
||||
new XColor("lightsalmon3", 205, 129, 98),
|
||||
new XColor("lightsalmon4", 139, 87, 66),
|
||||
new XColor("lightseagreen", 32, 178, 170),
|
||||
new XColor("lightskyblue", 135, 206, 250),
|
||||
new XColor("lightskyblue1", 176, 226, 255),
|
||||
new XColor("lightskyblue2", 164, 211, 238),
|
||||
new XColor("lightskyblue3", 141, 182, 205),
|
||||
new XColor("lightskyblue4", 96, 123, 139),
|
||||
new XColor("lightslateblue", 132, 112, 255),
|
||||
new XColor("lightslategray", 119, 136, 153),
|
||||
new XColor("lightslategrey", 119, 136, 153),
|
||||
new XColor("lightsteelblue", 176, 196, 222),
|
||||
new XColor("lightsteelblue1", 202, 225, 255),
|
||||
new XColor("lightsteelblue2", 188, 210, 238),
|
||||
new XColor("lightsteelblue3", 162, 181, 205),
|
||||
new XColor("lightsteelblue4", 110, 123, 139),
|
||||
new XColor("lightyellow", 255, 255, 224),
|
||||
new XColor("lightyellow1", 255, 255, 224),
|
||||
new XColor("lightyellow2", 238, 238, 209),
|
||||
new XColor("lightyellow3", 205, 205, 180),
|
||||
new XColor("lightyellow4", 139, 139, 122),
|
||||
new XColor("lime green", 50, 205, 50),
|
||||
new XColor("limegreen", 50, 205, 50),
|
||||
new XColor("linen", 250, 240, 230),
|
||||
new XColor("magenta", 255, 0, 255),
|
||||
new XColor("magenta1", 255, 0, 255),
|
||||
new XColor("magenta2", 238, 0, 238),
|
||||
new XColor("magenta3", 205, 0, 205),
|
||||
new XColor("magenta4", 139, 0, 139),
|
||||
new XColor("maroon", 176, 48, 96),
|
||||
new XColor("maroon1", 255, 52, 179),
|
||||
new XColor("maroon2", 238, 48, 167),
|
||||
new XColor("maroon3", 205, 41, 144),
|
||||
new XColor("maroon4", 139, 28, 98),
|
||||
new XColor("medium aquamarine", 102, 205, 170),
|
||||
new XColor("medium blue", 0, 0, 205),
|
||||
new XColor("medium orchid", 186, 85, 211),
|
||||
new XColor("medium purple", 147, 112, 219),
|
||||
new XColor("medium sea green", 60, 179, 113),
|
||||
new XColor("medium slate blue", 123, 104, 238),
|
||||
new XColor("medium spring green", 0, 250, 154),
|
||||
new XColor("medium turquoise", 72, 209, 204),
|
||||
new XColor("medium violet red", 199, 21, 133),
|
||||
new XColor("mediumaquamarine", 102, 205, 170),
|
||||
new XColor("mediumblue", 0, 0, 205),
|
||||
new XColor("mediumorchid", 186, 85, 211),
|
||||
new XColor("mediumorchid1", 224, 102, 255),
|
||||
new XColor("mediumorchid2", 209, 95, 238),
|
||||
new XColor("mediumorchid3", 180, 82, 205),
|
||||
new XColor("mediumorchid4", 122, 55, 139),
|
||||
new XColor("mediumpurple", 147, 112, 219),
|
||||
new XColor("mediumpurple1", 171, 130, 255),
|
||||
new XColor("mediumpurple2", 159, 121, 238),
|
||||
new XColor("mediumpurple3", 137, 104, 205),
|
||||
new XColor("mediumpurple4", 93, 71, 139),
|
||||
new XColor("mediumseagreen", 60, 179, 113),
|
||||
new XColor("mediumslateblue", 123, 104, 238),
|
||||
new XColor("mediumspringgreen", 0, 250, 154),
|
||||
new XColor("mediumturquoise", 72, 209, 204),
|
||||
new XColor("mediumvioletred", 199, 21, 133),
|
||||
new XColor("midnight blue", 25, 25, 112),
|
||||
new XColor("midnightblue", 25, 25, 112),
|
||||
new XColor("mint cream", 245, 255, 250),
|
||||
new XColor("mintcream", 245, 255, 250),
|
||||
new XColor("misty rose", 255, 228, 225),
|
||||
new XColor("mistyrose", 255, 228, 225),
|
||||
new XColor("mistyrose1", 255, 228, 225),
|
||||
new XColor("mistyrose2", 238, 213, 210),
|
||||
new XColor("mistyrose3", 205, 183, 181),
|
||||
new XColor("mistyrose4", 139, 125, 123),
|
||||
new XColor("moccasin", 255, 228, 181),
|
||||
new XColor("navajo white", 255, 222, 173),
|
||||
new XColor("navajowhite", 255, 222, 173),
|
||||
new XColor("navajowhite1", 255, 222, 173),
|
||||
new XColor("navajowhite2", 238, 207, 161),
|
||||
new XColor("navajowhite3", 205, 179, 139),
|
||||
new XColor("navajowhite4", 139, 121, 94),
|
||||
new XColor("navy", 0, 0, 128),
|
||||
new XColor("navy blue", 0, 0, 128),
|
||||
new XColor("navyblue", 0, 0, 128),
|
||||
new XColor("old lace", 253, 245, 230),
|
||||
new XColor("oldlace", 253, 245, 230),
|
||||
new XColor("olive drab", 107, 142, 35),
|
||||
new XColor("olivedrab", 107, 142, 35),
|
||||
new XColor("olivedrab1", 192, 255, 62),
|
||||
new XColor("olivedrab2", 179, 238, 58),
|
||||
new XColor("olivedrab3", 154, 205, 50),
|
||||
new XColor("olivedrab4", 105, 139, 34),
|
||||
new XColor("orange", 255, 165, 0),
|
||||
new XColor("orange red", 255, 69, 0),
|
||||
new XColor("orange1", 255, 165, 0),
|
||||
new XColor("orange2", 238, 154, 0),
|
||||
new XColor("orange3", 205, 133, 0),
|
||||
new XColor("orange4", 139, 90, 0),
|
||||
new XColor("orangered", 255, 69, 0),
|
||||
new XColor("orangered1", 255, 69, 0),
|
||||
new XColor("orangered2", 238, 64, 0),
|
||||
new XColor("orangered3", 205, 55, 0),
|
||||
new XColor("orangered4", 139, 37, 0),
|
||||
new XColor("orchid", 218, 112, 214),
|
||||
new XColor("orchid1", 255, 131, 250),
|
||||
new XColor("orchid2", 238, 122, 233),
|
||||
new XColor("orchid3", 205, 105, 201),
|
||||
new XColor("orchid4", 139, 71, 137),
|
||||
new XColor("pale goldenrod", 238, 232, 170),
|
||||
new XColor("pale green", 152, 251, 152),
|
||||
new XColor("pale turquoise", 175, 238, 238),
|
||||
new XColor("pale violet red", 219, 112, 147),
|
||||
new XColor("palegoldenrod", 238, 232, 170),
|
||||
new XColor("palegreen", 152, 251, 152),
|
||||
new XColor("palegreen1", 154, 255, 154),
|
||||
new XColor("palegreen2", 144, 238, 144),
|
||||
new XColor("palegreen3", 124, 205, 124),
|
||||
new XColor("palegreen4", 84, 139, 84),
|
||||
new XColor("paleturquoise", 175, 238, 238),
|
||||
new XColor("paleturquoise1", 187, 255, 255),
|
||||
new XColor("paleturquoise2", 174, 238, 238),
|
||||
new XColor("paleturquoise3", 150, 205, 205),
|
||||
new XColor("paleturquoise4", 102, 139, 139),
|
||||
new XColor("palevioletred", 219, 112, 147),
|
||||
new XColor("palevioletred1", 255, 130, 171),
|
||||
new XColor("palevioletred2", 238, 121, 159),
|
||||
new XColor("palevioletred3", 205, 104, 137),
|
||||
new XColor("palevioletred4", 139, 71, 93),
|
||||
new XColor("papaya whip", 255, 239, 213),
|
||||
new XColor("papayawhip", 255, 239, 213),
|
||||
new XColor("peach puff", 255, 218, 185),
|
||||
new XColor("peachpuff", 255, 218, 185),
|
||||
new XColor("peachpuff1", 255, 218, 185),
|
||||
new XColor("peachpuff2", 238, 203, 173),
|
||||
new XColor("peachpuff3", 205, 175, 149),
|
||||
new XColor("peachpuff4", 139, 119, 101),
|
||||
new XColor("peru", 205, 133, 63),
|
||||
new XColor("pink", 255, 192, 203),
|
||||
new XColor("pink1", 255, 181, 197),
|
||||
new XColor("pink2", 238, 169, 184),
|
||||
new XColor("pink3", 205, 145, 158),
|
||||
new XColor("pink4", 139, 99, 108),
|
||||
new XColor("plum", 221, 160, 221),
|
||||
new XColor("plum1", 255, 187, 255),
|
||||
new XColor("plum2", 238, 174, 238),
|
||||
new XColor("plum3", 205, 150, 205),
|
||||
new XColor("plum4", 139, 102, 139),
|
||||
new XColor("powder blue", 176, 224, 230),
|
||||
new XColor("powderblue", 176, 224, 230),
|
||||
new XColor("purple", 160, 32, 240),
|
||||
new XColor("purple1", 155, 48, 255),
|
||||
new XColor("purple2", 145, 44, 238),
|
||||
new XColor("purple3", 125, 38, 205),
|
||||
new XColor("purple4", 85, 26, 139),
|
||||
new XColor("red", 255, 0, 0),
|
||||
new XColor("red1", 255, 0, 0),
|
||||
new XColor("red2", 238, 0, 0),
|
||||
new XColor("red3", 205, 0, 0),
|
||||
new XColor("red4", 139, 0, 0),
|
||||
new XColor("rosy brown", 188, 143, 143),
|
||||
new XColor("rosybrown", 188, 143, 143),
|
||||
new XColor("rosybrown1", 255, 193, 193),
|
||||
new XColor("rosybrown2", 238, 180, 180),
|
||||
new XColor("rosybrown3", 205, 155, 155),
|
||||
new XColor("rosybrown4", 139, 105, 105),
|
||||
new XColor("royal blue", 65, 105, 225),
|
||||
new XColor("royalblue", 65, 105, 225),
|
||||
new XColor("royalblue1", 72, 118, 255),
|
||||
new XColor("royalblue2", 67, 110, 238),
|
||||
new XColor("royalblue3", 58, 95, 205),
|
||||
new XColor("royalblue4", 39, 64, 139),
|
||||
new XColor("saddle brown", 139, 69, 19),
|
||||
new XColor("saddlebrown", 139, 69, 19),
|
||||
new XColor("salmon", 250, 128, 114),
|
||||
new XColor("salmon1", 255, 140, 105),
|
||||
new XColor("salmon2", 238, 130, 98),
|
||||
new XColor("salmon3", 205, 112, 84),
|
||||
new XColor("salmon4", 139, 76, 57),
|
||||
new XColor("sandy brown", 244, 164, 96),
|
||||
new XColor("sandybrown", 244, 164, 96),
|
||||
new XColor("sea green", 46, 139, 87),
|
||||
new XColor("seagreen", 46, 139, 87),
|
||||
new XColor("seagreen1", 84, 255, 159),
|
||||
new XColor("seagreen2", 78, 238, 148),
|
||||
new XColor("seagreen3", 67, 205, 128),
|
||||
new XColor("seagreen4", 46, 139, 87),
|
||||
new XColor("seashell", 255, 245, 238),
|
||||
new XColor("seashell1", 255, 245, 238),
|
||||
new XColor("seashell2", 238, 229, 222),
|
||||
new XColor("seashell3", 205, 197, 191),
|
||||
new XColor("seashell4", 139, 134, 130),
|
||||
new XColor("sienna", 160, 82, 45),
|
||||
new XColor("sienna1", 255, 130, 71),
|
||||
new XColor("sienna2", 238, 121, 66),
|
||||
new XColor("sienna3", 205, 104, 57),
|
||||
new XColor("sienna4", 139, 71, 38),
|
||||
new XColor("sky blue", 135, 206, 235),
|
||||
new XColor("skyblue", 135, 206, 235),
|
||||
new XColor("skyblue1", 135, 206, 255),
|
||||
new XColor("skyblue2", 126, 192, 238),
|
||||
new XColor("skyblue3", 108, 166, 205),
|
||||
new XColor("skyblue4", 74, 112, 139),
|
||||
new XColor("slate blue", 106, 90, 205),
|
||||
new XColor("slate gray", 112, 128, 144),
|
||||
new XColor("slate grey", 112, 128, 144),
|
||||
new XColor("slateblue", 106, 90, 205),
|
||||
new XColor("slateblue1", 131, 111, 255),
|
||||
new XColor("slateblue2", 122, 103, 238),
|
||||
new XColor("slateblue3", 105, 89, 205),
|
||||
new XColor("slateblue4", 71, 60, 139),
|
||||
new XColor("slategray", 112, 128, 144),
|
||||
new XColor("slategray1", 198, 226, 255),
|
||||
new XColor("slategray2", 185, 211, 238),
|
||||
new XColor("slategray3", 159, 182, 205),
|
||||
new XColor("slategray4", 108, 123, 139),
|
||||
new XColor("slategrey", 112, 128, 144),
|
||||
new XColor("snow", 255, 250, 250),
|
||||
new XColor("snow1", 255, 250, 250),
|
||||
new XColor("snow2", 238, 233, 233),
|
||||
new XColor("snow3", 205, 201, 201),
|
||||
new XColor("snow4", 139, 137, 137),
|
||||
new XColor("spring green", 0, 255, 127),
|
||||
new XColor("springgreen", 0, 255, 127),
|
||||
new XColor("springgreen1", 0, 255, 127),
|
||||
new XColor("springgreen2", 0, 238, 118),
|
||||
new XColor("springgreen3", 0, 205, 102),
|
||||
new XColor("springgreen4", 0, 139, 69),
|
||||
new XColor("steel blue", 70, 130, 180),
|
||||
new XColor("steelblue", 70, 130, 180),
|
||||
new XColor("steelblue1", 99, 184, 255),
|
||||
new XColor("steelblue2", 92, 172, 238),
|
||||
new XColor("steelblue3", 79, 148, 205),
|
||||
new XColor("steelblue4", 54, 100, 139),
|
||||
new XColor("tan", 210, 180, 140),
|
||||
new XColor("tan1", 255, 165, 79),
|
||||
new XColor("tan2", 238, 154, 73),
|
||||
new XColor("tan3", 205, 133, 63),
|
||||
new XColor("tan4", 139, 90, 43),
|
||||
new XColor("thistle", 216, 191, 216),
|
||||
new XColor("thistle1", 255, 225, 255),
|
||||
new XColor("thistle2", 238, 210, 238),
|
||||
new XColor("thistle3", 205, 181, 205),
|
||||
new XColor("thistle4", 139, 123, 139),
|
||||
new XColor("tomato", 255, 99, 71),
|
||||
new XColor("tomato1", 255, 99, 71),
|
||||
new XColor("tomato2", 238, 92, 66),
|
||||
new XColor("tomato3", 205, 79, 57),
|
||||
new XColor("tomato4", 139, 54, 38),
|
||||
new XColor("turquoise", 64, 224, 208),
|
||||
new XColor("turquoise1", 0, 245, 255),
|
||||
new XColor("turquoise2", 0, 229, 238),
|
||||
new XColor("turquoise3", 0, 197, 205),
|
||||
new XColor("turquoise4", 0, 134, 139),
|
||||
new XColor("violet", 238, 130, 238),
|
||||
new XColor("violet red", 208, 32, 144),
|
||||
new XColor("violetred", 208, 32, 144),
|
||||
new XColor("violetred1", 255, 62, 150),
|
||||
new XColor("violetred2", 238, 58, 140),
|
||||
new XColor("violetred3", 205, 50, 120),
|
||||
new XColor("violetred4", 139, 34, 82),
|
||||
new XColor("wheat", 245, 222, 179),
|
||||
new XColor("wheat1", 255, 231, 186),
|
||||
new XColor("wheat2", 238, 216, 174),
|
||||
new XColor("wheat3", 205, 186, 150),
|
||||
new XColor("wheat4", 139, 126, 102),
|
||||
new XColor("white", 255, 255, 255),
|
||||
new XColor("white smoke", 245, 245, 245),
|
||||
new XColor("whitesmoke", 245, 245, 245),
|
||||
new XColor("yellow", 255, 255, 0),
|
||||
new XColor("yellow green", 154, 205, 50),
|
||||
new XColor("yellow1", 255, 255, 0),
|
||||
new XColor("yellow2", 238, 238, 0),
|
||||
new XColor("yellow3", 205, 205, 0),
|
||||
new XColor("yellow4", 139, 139, 0),
|
||||
new XColor("yellowgreen", 154, 205, 5)
|
||||
};
|
||||
|
||||
}
|
||||
734
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifBorders.java
Normal file
734
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifBorders.java
Normal file
@@ -0,0 +1,734 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import sun.swing.SwingUtilities2;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
/**
|
||||
* Factory object that can vend Icons appropriate for the basic L & F.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Amy Fowler
|
||||
*/
|
||||
public class MotifBorders {
|
||||
|
||||
public static class BevelBorder extends AbstractBorder implements UIResource {
|
||||
private Color darkShadow = UIManager.getColor("controlShadow");
|
||||
private Color lightShadow = UIManager.getColor("controlLtHighlight");
|
||||
private boolean isRaised;
|
||||
|
||||
public BevelBorder(boolean isRaised, Color darkShadow, Color lightShadow) {
|
||||
this.isRaised = isRaised;
|
||||
this.darkShadow = darkShadow;
|
||||
this.lightShadow = lightShadow;
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
|
||||
g.setColor((isRaised) ? lightShadow : darkShadow);
|
||||
g.drawLine(x, y, x+w-1, y); // top
|
||||
g.drawLine(x, y+h-1, x, y+1); // left
|
||||
|
||||
g.setColor((isRaised) ? darkShadow : lightShadow);
|
||||
g.drawLine(x+1, y+h-1, x+w-1, y+h-1); // bottom
|
||||
g.drawLine(x+w-1, y+h-1, x+w-1, y+1); // right
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
insets.set(1, 1, 1, 1);
|
||||
return insets;
|
||||
}
|
||||
|
||||
public boolean isOpaque(Component c) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class FocusBorder extends AbstractBorder implements UIResource {
|
||||
private Color focus;
|
||||
private Color control;
|
||||
|
||||
public FocusBorder(Color control, Color focus) {
|
||||
this.control = control;
|
||||
this.focus = focus;
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
|
||||
if (c.hasFocus()) {
|
||||
g.setColor(focus);
|
||||
g.drawRect(x, y, w-1, h-1);
|
||||
} else {
|
||||
g.setColor(control);
|
||||
g.drawRect(x, y, w-1, h-1);
|
||||
}
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
insets.set(1, 1, 1, 1);
|
||||
return insets;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class ButtonBorder extends AbstractBorder implements UIResource {
|
||||
protected Color focus = UIManager.getColor("activeCaptionBorder");
|
||||
protected Color shadow = UIManager.getColor("Button.shadow");
|
||||
protected Color highlight = UIManager.getColor("Button.light");
|
||||
protected Color darkShadow;
|
||||
|
||||
public ButtonBorder(Color shadow, Color highlight, Color darkShadow, Color focus) {
|
||||
this.shadow = shadow;
|
||||
this.highlight = highlight;
|
||||
this.darkShadow = darkShadow;
|
||||
this.focus = focus;
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
|
||||
boolean isPressed = false;
|
||||
boolean hasFocus = false;
|
||||
boolean canBeDefault = false;
|
||||
boolean isDefault = false;
|
||||
|
||||
if (c instanceof AbstractButton) {
|
||||
AbstractButton b = (AbstractButton)c;
|
||||
ButtonModel model = b.getModel();
|
||||
|
||||
isPressed = (model.isArmed() && model.isPressed());
|
||||
hasFocus = (model.isArmed() && isPressed) ||
|
||||
(b.isFocusPainted() && b.hasFocus());
|
||||
if (b instanceof JButton) {
|
||||
canBeDefault = ((JButton)b).isDefaultCapable();
|
||||
isDefault = ((JButton)b).isDefaultButton();
|
||||
}
|
||||
}
|
||||
int bx1 = x+1;
|
||||
int by1 = y+1;
|
||||
int bx2 = x+w-2;
|
||||
int by2 = y+h-2;
|
||||
|
||||
if (canBeDefault) {
|
||||
if (isDefault) {
|
||||
g.setColor(shadow);
|
||||
g.drawLine(x+3, y+3, x+3, y+h-4);
|
||||
g.drawLine(x+3, y+3, x+w-4, y+3);
|
||||
|
||||
g.setColor(highlight);
|
||||
g.drawLine(x+4, y+h-4, x+w-4, y+h-4);
|
||||
g.drawLine(x+w-4, y+3, x+w-4, y+h-4);
|
||||
}
|
||||
bx1 +=6;
|
||||
by1 += 6;
|
||||
bx2 -= 6;
|
||||
by2 -= 6;
|
||||
}
|
||||
|
||||
if (hasFocus) {
|
||||
g.setColor(focus);
|
||||
if (isDefault) {
|
||||
g.drawRect(x, y, w-1, h-1);
|
||||
} else {
|
||||
g.drawRect(bx1-1, by1-1, bx2-bx1+2, by2-by1+2);
|
||||
}
|
||||
}
|
||||
|
||||
g.setColor(isPressed? shadow : highlight);
|
||||
g.drawLine(bx1, by1, bx2, by1);
|
||||
g.drawLine(bx1, by1, bx1, by2);
|
||||
|
||||
g.setColor(isPressed? highlight : shadow);
|
||||
g.drawLine(bx2, by1+1, bx2, by2);
|
||||
g.drawLine(bx1+1, by2, bx2, by2);
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
int thickness = (c instanceof JButton && ((JButton)c).isDefaultCapable())? 8 : 2;
|
||||
insets.set(thickness, thickness, thickness, thickness);
|
||||
return insets;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ToggleButtonBorder extends ButtonBorder {
|
||||
|
||||
public ToggleButtonBorder(Color shadow, Color highlight, Color darkShadow, Color focus) {
|
||||
super(shadow, highlight, darkShadow, focus);
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y,
|
||||
int width, int height) {
|
||||
if (c instanceof AbstractButton) {
|
||||
AbstractButton b = (AbstractButton)c;
|
||||
ButtonModel model = b.getModel();
|
||||
|
||||
if (model.isArmed() && model.isPressed() || model.isSelected()) {
|
||||
drawBezel(g, x, y, width, height,
|
||||
(model.isPressed() || model.isSelected()),
|
||||
b.isFocusPainted() && b.hasFocus(), shadow, highlight, darkShadow, focus);
|
||||
} else {
|
||||
drawBezel(g, x, y, width, height,
|
||||
false, b.isFocusPainted() && b.hasFocus(),
|
||||
shadow, highlight, darkShadow, focus);
|
||||
}
|
||||
} else {
|
||||
drawBezel(g, x, y, width, height, false, false,
|
||||
shadow, highlight, darkShadow, focus);
|
||||
}
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
insets.set(2, 2, 3, 3);
|
||||
return insets;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MenuBarBorder extends ButtonBorder {
|
||||
|
||||
public MenuBarBorder(Color shadow, Color highlight, Color darkShadow, Color focus) {
|
||||
super(shadow, highlight, darkShadow, focus);
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
if (!(c instanceof JMenuBar)) {
|
||||
return;
|
||||
}
|
||||
JMenuBar menuBar = (JMenuBar)c;
|
||||
if (menuBar.isBorderPainted() == true) {
|
||||
// this draws the MenuBar border
|
||||
Dimension size = menuBar.getSize();
|
||||
drawBezel(g,x,y,size.width,size.height,false,false,
|
||||
shadow, highlight, darkShadow, focus);
|
||||
}
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
insets.set(6, 6, 6, 6);
|
||||
return insets;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FrameBorder extends AbstractBorder implements UIResource {
|
||||
|
||||
JComponent jcomp;
|
||||
Color frameHighlight;
|
||||
Color frameColor;
|
||||
Color frameShadow;
|
||||
|
||||
// The width of the border
|
||||
public final static int BORDER_SIZE = 5;
|
||||
|
||||
/** Constructs an FrameBorder for the JComponent <b>comp</b>.
|
||||
*/
|
||||
public FrameBorder(JComponent comp) {
|
||||
jcomp = comp;
|
||||
}
|
||||
|
||||
/** Sets the FrameBorder's JComponent.
|
||||
*/
|
||||
public void setComponent(JComponent comp) {
|
||||
jcomp = comp;
|
||||
}
|
||||
|
||||
/** Returns the FrameBorder's JComponent.
|
||||
* @see #setComponent
|
||||
*/
|
||||
public JComponent component() {
|
||||
return jcomp;
|
||||
}
|
||||
|
||||
protected Color getFrameHighlight() {
|
||||
return frameHighlight;
|
||||
}
|
||||
|
||||
protected Color getFrameColor() {
|
||||
return frameColor;
|
||||
}
|
||||
|
||||
protected Color getFrameShadow() {
|
||||
return frameShadow;
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets newInsets) {
|
||||
newInsets.set(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE);
|
||||
return newInsets;
|
||||
}
|
||||
|
||||
/** Draws the FrameBorder's top border.
|
||||
*/
|
||||
protected boolean drawTopBorder(Component c, Graphics g,
|
||||
int x, int y, int width, int height) {
|
||||
Rectangle titleBarRect = new Rectangle(x, y, width, BORDER_SIZE);
|
||||
if (!g.getClipBounds().intersects(titleBarRect)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int maxX = width - 1;
|
||||
int maxY = BORDER_SIZE - 1;
|
||||
|
||||
// Draw frame
|
||||
g.setColor(frameColor);
|
||||
g.drawLine(x, y + 2, maxX - 2, y + 2);
|
||||
g.drawLine(x, y + 3, maxX - 2, y + 3);
|
||||
g.drawLine(x, y + 4, maxX - 2, y + 4);
|
||||
|
||||
// Draw highlights
|
||||
g.setColor(frameHighlight);
|
||||
g.drawLine(x, y, maxX, y);
|
||||
g.drawLine(x, y + 1, maxX, y + 1);
|
||||
g.drawLine(x, y + 2, x, y + 4);
|
||||
g.drawLine(x + 1, y + 2, x + 1, y + 4);
|
||||
|
||||
// Draw shadows
|
||||
g.setColor(frameShadow);
|
||||
g.drawLine(x + 4, y + 4, maxX - 4, y + 4);
|
||||
g.drawLine(maxX, y + 1, maxX, maxY);
|
||||
g.drawLine(maxX - 1, y + 2, maxX - 1, maxY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Draws the FrameBorder's left border.
|
||||
*/
|
||||
protected boolean drawLeftBorder(Component c, Graphics g, int x, int y,
|
||||
int width, int height) {
|
||||
Rectangle borderRect =
|
||||
new Rectangle(0, 0, getBorderInsets(c).left, height);
|
||||
if (!g.getClipBounds().intersects(borderRect)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int startY = BORDER_SIZE;
|
||||
|
||||
g.setColor(frameHighlight);
|
||||
g.drawLine(x, startY, x, height - 1);
|
||||
g.drawLine(x + 1, startY, x + 1, height - 2);
|
||||
|
||||
g.setColor(frameColor);
|
||||
g.fillRect(x + 2, startY, x + 2, height - 3);
|
||||
|
||||
g.setColor(frameShadow);
|
||||
g.drawLine(x + 4, startY, x + 4, height - 5);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Draws the FrameBorder's right border.
|
||||
*/
|
||||
protected boolean drawRightBorder(Component c, Graphics g, int x, int y,
|
||||
int width, int height) {
|
||||
Rectangle borderRect = new Rectangle(
|
||||
width - getBorderInsets(c).right, 0,
|
||||
getBorderInsets(c).right, height);
|
||||
if (!g.getClipBounds().intersects(borderRect)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int startX = width - getBorderInsets(c).right;
|
||||
int startY = BORDER_SIZE;
|
||||
|
||||
g.setColor(frameColor);
|
||||
g.fillRect(startX + 1, startY, 2, height - 1);
|
||||
|
||||
g.setColor(frameShadow);
|
||||
g.fillRect(startX + 3, startY, 2, height - 1);
|
||||
|
||||
g.setColor(frameHighlight);
|
||||
g.drawLine(startX, startY, startX, height - 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Draws the FrameBorder's bottom border.
|
||||
*/
|
||||
protected boolean drawBottomBorder(Component c, Graphics g, int x, int y,
|
||||
int width, int height) {
|
||||
Rectangle borderRect;
|
||||
int marginHeight, startY;
|
||||
|
||||
borderRect = new Rectangle(0, height - getBorderInsets(c).bottom,
|
||||
width, getBorderInsets(c).bottom);
|
||||
if (!g.getClipBounds().intersects(borderRect)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
startY = height - getBorderInsets(c).bottom;
|
||||
|
||||
g.setColor(frameShadow);
|
||||
g.drawLine(x + 1, height - 1, width - 1, height - 1);
|
||||
g.drawLine(x + 2, height - 2, width - 2, height - 2);
|
||||
|
||||
g.setColor(frameColor);
|
||||
g.fillRect(x + 2, startY + 1, width - 4, 2);
|
||||
|
||||
g.setColor(frameHighlight);
|
||||
g.drawLine(x + 5, startY, width - 5, startY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true if the associated component has focus.
|
||||
protected boolean isActiveFrame() {
|
||||
return jcomp.hasFocus();
|
||||
}
|
||||
|
||||
/** Draws the FrameBorder in the given Rect. Calls
|
||||
* <b>drawTitleBar</b>, <b>drawLeftBorder</b>, <b>drawRightBorder</b> and
|
||||
* <b>drawBottomBorder</b>.
|
||||
*/
|
||||
public void paintBorder(Component c, Graphics g,
|
||||
int x, int y, int width, int height) {
|
||||
if (isActiveFrame()) {
|
||||
frameColor = UIManager.getColor("activeCaptionBorder");
|
||||
} else {
|
||||
frameColor = UIManager.getColor("inactiveCaptionBorder");
|
||||
}
|
||||
frameHighlight = frameColor.brighter();
|
||||
frameShadow = frameColor.darker().darker();
|
||||
|
||||
drawTopBorder(c, g, x, y, width, height);
|
||||
drawLeftBorder(c, g, x, y, width, height);
|
||||
drawRightBorder(c, g, x, y, width, height);
|
||||
drawBottomBorder(c, g, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InternalFrameBorder extends FrameBorder {
|
||||
|
||||
JInternalFrame frame;
|
||||
|
||||
// The size of the bounding box for Motif frame corners.
|
||||
public final static int CORNER_SIZE = 24;
|
||||
|
||||
/** Constructs an InternalFrameBorder for the InternalFrame
|
||||
* <b>aFrame</b>.
|
||||
*/
|
||||
public InternalFrameBorder(JInternalFrame aFrame) {
|
||||
super(aFrame);
|
||||
frame = aFrame;
|
||||
}
|
||||
|
||||
/** Sets the InternalFrameBorder's InternalFrame.
|
||||
*/
|
||||
public void setFrame(JInternalFrame aFrame) {
|
||||
frame = aFrame;
|
||||
}
|
||||
|
||||
/** Returns the InternalFrameBorder's InternalFrame.
|
||||
* @see #setFrame
|
||||
*/
|
||||
public JInternalFrame frame() {
|
||||
return frame;
|
||||
}
|
||||
|
||||
/** Returns the width of the InternalFrameBorder's resize controls,
|
||||
* appearing along the InternalFrameBorder's bottom border. Clicking
|
||||
* and dragging within these controls lets the user change both the
|
||||
* InternalFrame's width and height, while dragging between the controls
|
||||
* constrains resizing to just the vertical dimension. Override this
|
||||
* method if you implement your own bottom border painting and use a
|
||||
* resize control with a different size.
|
||||
*/
|
||||
public int resizePartWidth() {
|
||||
if (!frame.isResizable()) {
|
||||
return 0;
|
||||
}
|
||||
return FrameBorder.BORDER_SIZE;
|
||||
}
|
||||
|
||||
/** Draws the InternalFrameBorder's top border.
|
||||
*/
|
||||
protected boolean drawTopBorder(Component c, Graphics g,
|
||||
int x, int y, int width, int height) {
|
||||
if (super.drawTopBorder(c, g, x, y, width, height) &&
|
||||
frame.isResizable()) {
|
||||
g.setColor(getFrameShadow());
|
||||
g.drawLine(CORNER_SIZE - 1, y + 1, CORNER_SIZE - 1, y + 4);
|
||||
g.drawLine(width - CORNER_SIZE - 1, y + 1,
|
||||
width - CORNER_SIZE - 1, y + 4);
|
||||
|
||||
g.setColor(getFrameHighlight());
|
||||
g.drawLine(CORNER_SIZE, y, CORNER_SIZE, y + 4);
|
||||
g.drawLine(width - CORNER_SIZE, y, width - CORNER_SIZE, y + 4);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Draws the InternalFrameBorder's left border.
|
||||
*/
|
||||
protected boolean drawLeftBorder(Component c, Graphics g, int x, int y,
|
||||
int width, int height) {
|
||||
if (super.drawLeftBorder(c, g, x, y, width, height) &&
|
||||
frame.isResizable()) {
|
||||
g.setColor(getFrameHighlight());
|
||||
int topY = y + CORNER_SIZE;
|
||||
g.drawLine(x, topY, x + 4, topY);
|
||||
int bottomY = height - CORNER_SIZE;
|
||||
g.drawLine(x + 1, bottomY, x + 5, bottomY);
|
||||
g.setColor(getFrameShadow());
|
||||
g.drawLine(x + 1, topY - 1, x + 5, topY - 1);
|
||||
g.drawLine(x + 1, bottomY - 1, x + 5, bottomY - 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Draws the InternalFrameBorder's right border.
|
||||
*/
|
||||
protected boolean drawRightBorder(Component c, Graphics g, int x, int y,
|
||||
int width, int height) {
|
||||
if (super.drawRightBorder(c, g, x, y, width, height) &&
|
||||
frame.isResizable()) {
|
||||
int startX = width - getBorderInsets(c).right;
|
||||
g.setColor(getFrameHighlight());
|
||||
int topY = y + CORNER_SIZE;
|
||||
g.drawLine(startX, topY, width - 2, topY);
|
||||
int bottomY = height - CORNER_SIZE;
|
||||
g.drawLine(startX + 1, bottomY, startX + 3, bottomY);
|
||||
g.setColor(getFrameShadow());
|
||||
g.drawLine(startX + 1, topY - 1, width - 2, topY - 1);
|
||||
g.drawLine(startX + 1, bottomY - 1, startX + 3, bottomY - 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Draws the InternalFrameBorder's bottom border.
|
||||
*/
|
||||
protected boolean drawBottomBorder(Component c, Graphics g, int x, int y,
|
||||
int width, int height) {
|
||||
if (super.drawBottomBorder(c, g, x, y, width, height) &&
|
||||
frame.isResizable()) {
|
||||
int startY = height - getBorderInsets(c).bottom;
|
||||
|
||||
g.setColor(getFrameShadow());
|
||||
g.drawLine(CORNER_SIZE - 1, startY + 1,
|
||||
CORNER_SIZE - 1, height - 1);
|
||||
g.drawLine(width - CORNER_SIZE, startY + 1,
|
||||
width - CORNER_SIZE, height - 1);
|
||||
|
||||
g.setColor(getFrameHighlight());
|
||||
g.drawLine(CORNER_SIZE, startY, CORNER_SIZE, height - 2);
|
||||
g.drawLine(width - CORNER_SIZE + 1, startY,
|
||||
width - CORNER_SIZE + 1, height - 2);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns true if the associated internal frame has focus.
|
||||
protected boolean isActiveFrame() {
|
||||
return frame.isSelected();
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawBezel(Graphics g, int x, int y, int w, int h,
|
||||
boolean isPressed, boolean hasFocus,
|
||||
Color shadow, Color highlight,
|
||||
Color darkShadow, Color focus) {
|
||||
|
||||
Color oldColor = g.getColor();
|
||||
g.translate(x, y);
|
||||
|
||||
if (isPressed) {
|
||||
if (hasFocus){
|
||||
g.setColor(focus);
|
||||
g.drawRect(0, 0, w-1, h-1);
|
||||
}
|
||||
g.setColor(shadow); // inner border
|
||||
g.drawRect(1, 1, w-3, h-3);
|
||||
|
||||
g.setColor(highlight); // inner 3D border
|
||||
g.drawLine(2, h-3, w-3, h-3);
|
||||
g.drawLine(w-3, 2, w-3, h-4);
|
||||
|
||||
} else {
|
||||
if (hasFocus) {
|
||||
g.setColor(focus);
|
||||
g.drawRect(0, 0, w-1, h-1);
|
||||
|
||||
g.setColor(highlight); // inner 3D border
|
||||
g.drawLine(1, 1, 1, h-3);
|
||||
g.drawLine(2, 1, w-4, 1);
|
||||
|
||||
g.setColor(shadow);
|
||||
g.drawLine(2, h-3, w-3, h-3);
|
||||
g.drawLine(w-3, 1, w-3, h-4);
|
||||
|
||||
g.setColor(darkShadow); // black drop shadow __|
|
||||
g.drawLine(1, h-2, w-2, h-2);
|
||||
g.drawLine(w-2, h-2, w-2, 1);
|
||||
} else {
|
||||
g.setColor(highlight); // inner 3D border
|
||||
g.drawLine(1,1,1,h-3);
|
||||
g.drawLine(2,1,w-4,1);
|
||||
g.setColor(shadow);
|
||||
g.drawLine(2,h-3,w-3,h-3);
|
||||
g.drawLine(w-3,1,w-3,h-4);
|
||||
|
||||
g.setColor(darkShadow); // black drop shadow __|
|
||||
g.drawLine(1,h-2,w-2,h-2);
|
||||
g.drawLine(w-2,h-2,w-2,0);
|
||||
|
||||
}
|
||||
g.translate(-x, -y);
|
||||
}
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
|
||||
public static class MotifPopupMenuBorder extends AbstractBorder implements UIResource {
|
||||
protected Font font;
|
||||
protected Color background;
|
||||
protected Color foreground;
|
||||
protected Color shadowColor;
|
||||
protected Color highlightColor;
|
||||
|
||||
// Space between the border and text
|
||||
static protected final int TEXT_SPACING = 2;
|
||||
|
||||
// Space for the separator under the title
|
||||
static protected final int GROOVE_HEIGHT = 2;
|
||||
|
||||
/**
|
||||
* Creates a MotifPopupMenuBorder instance
|
||||
*
|
||||
*/
|
||||
public MotifPopupMenuBorder(
|
||||
Font titleFont,
|
||||
Color bgColor,
|
||||
Color fgColor,
|
||||
Color shadow,
|
||||
Color highlight) {
|
||||
this.font = titleFont;
|
||||
this.background = bgColor;
|
||||
this.foreground = fgColor;
|
||||
this.shadowColor = shadow;
|
||||
this.highlightColor = highlight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the border for the specified component with the
|
||||
* specified position and size.
|
||||
* @param c the component for which this border is being painted
|
||||
* @param g the paint graphics
|
||||
* @param x the x position of the painted border
|
||||
* @param y the y position of the painted border
|
||||
* @param width the width of the painted border
|
||||
* @param height the height of the painted border
|
||||
*/
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
if (!(c instanceof JPopupMenu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Font origFont = g.getFont();
|
||||
Color origColor = g.getColor();
|
||||
JPopupMenu popup = (JPopupMenu)c;
|
||||
|
||||
String title = popup.getLabel();
|
||||
if (title == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
g.setFont(font);
|
||||
|
||||
FontMetrics fm = SwingUtilities2.getFontMetrics(popup, g, font);
|
||||
int fontHeight = fm.getHeight();
|
||||
int descent = fm.getDescent();
|
||||
int ascent = fm.getAscent();
|
||||
Point textLoc = new Point();
|
||||
int stringWidth = SwingUtilities2.stringWidth(popup, fm,
|
||||
title);
|
||||
|
||||
textLoc.y = y + ascent + TEXT_SPACING;
|
||||
textLoc.x = x + ((width - stringWidth) / 2);
|
||||
|
||||
g.setColor(background);
|
||||
g.fillRect(textLoc.x - TEXT_SPACING, textLoc.y - (fontHeight-descent),
|
||||
stringWidth + (2 * TEXT_SPACING), fontHeight - descent);
|
||||
g.setColor(foreground);
|
||||
SwingUtilities2.drawString(popup, g, title, textLoc.x, textLoc.y);
|
||||
|
||||
MotifGraphicsUtils.drawGroove(g, x, textLoc.y + TEXT_SPACING,
|
||||
width, GROOVE_HEIGHT,
|
||||
shadowColor, highlightColor);
|
||||
|
||||
g.setFont(origFont);
|
||||
g.setColor(origColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinitialize the insets parameter with this Border's current Insets.
|
||||
* @param c the component for which this border insets value applies
|
||||
* @param insets the object to be reinitialized
|
||||
*/
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
if (!(c instanceof JPopupMenu)) {
|
||||
return insets;
|
||||
}
|
||||
FontMetrics fm;
|
||||
int descent = 0;
|
||||
int ascent = 16;
|
||||
|
||||
String title = ((JPopupMenu)c).getLabel();
|
||||
if (title == null) {
|
||||
insets.left = insets.top = insets.right = insets.bottom = 0;
|
||||
return insets;
|
||||
}
|
||||
|
||||
fm = c.getFontMetrics(font);
|
||||
|
||||
if(fm != null) {
|
||||
descent = fm.getDescent();
|
||||
ascent = fm.getAscent();
|
||||
}
|
||||
|
||||
insets.top += ascent + descent + TEXT_SPACING + GROOVE_HEIGHT;
|
||||
return insets;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.event.*;
|
||||
|
||||
/**
|
||||
* Button Listener
|
||||
* <p>
|
||||
*
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
public class MotifButtonListener extends BasicButtonListener {
|
||||
public MotifButtonListener(AbstractButton b ) {
|
||||
super(b);
|
||||
}
|
||||
|
||||
protected void checkOpacity(AbstractButton b) {
|
||||
b.setOpaque( false );
|
||||
}
|
||||
}
|
||||
150
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifButtonUI.java
Normal file
150
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifButtonUI.java
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
/**
|
||||
* MotifButton implementation
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
public class MotifButtonUI extends BasicButtonUI {
|
||||
|
||||
protected Color selectColor;
|
||||
|
||||
private boolean defaults_initialized = false;
|
||||
|
||||
private static final Object MOTIF_BUTTON_UI_KEY = new Object();
|
||||
|
||||
// ********************************
|
||||
// Create PLAF
|
||||
// ********************************
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
MotifButtonUI motifButtonUI =
|
||||
(MotifButtonUI) appContext.get(MOTIF_BUTTON_UI_KEY);
|
||||
if (motifButtonUI == null) {
|
||||
motifButtonUI = new MotifButtonUI();
|
||||
appContext.put(MOTIF_BUTTON_UI_KEY, motifButtonUI);
|
||||
}
|
||||
return motifButtonUI;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Create Listeners
|
||||
// ********************************
|
||||
protected BasicButtonListener createButtonListener(AbstractButton b){
|
||||
return new MotifButtonListener(b);
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Install Defaults
|
||||
// ********************************
|
||||
public void installDefaults(AbstractButton b) {
|
||||
super.installDefaults(b);
|
||||
if(!defaults_initialized) {
|
||||
selectColor = UIManager.getColor(getPropertyPrefix() + "select");
|
||||
defaults_initialized = true;
|
||||
}
|
||||
LookAndFeel.installProperty(b, "opaque", Boolean.FALSE);
|
||||
}
|
||||
|
||||
protected void uninstallDefaults(AbstractButton b) {
|
||||
super.uninstallDefaults(b);
|
||||
defaults_initialized = false;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Default Accessors
|
||||
// ********************************
|
||||
|
||||
protected Color getSelectColor() {
|
||||
return selectColor;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Paint Methods
|
||||
// ********************************
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
fillContentArea( g, (AbstractButton)c , c.getBackground() );
|
||||
super.paint(g,c);
|
||||
}
|
||||
|
||||
// Overridden to ensure we don't paint icon over button borders.
|
||||
protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect) {
|
||||
Shape oldClip = g.getClip();
|
||||
Rectangle newClip =
|
||||
AbstractBorder.getInteriorRectangle(c, c.getBorder(), 0, 0,
|
||||
c.getWidth(), c.getHeight());
|
||||
|
||||
Rectangle r = oldClip.getBounds();
|
||||
newClip =
|
||||
SwingUtilities.computeIntersection(r.x, r.y, r.width, r.height,
|
||||
newClip);
|
||||
g.setClip(newClip);
|
||||
super.paintIcon(g, c, iconRect);
|
||||
g.setClip(oldClip);
|
||||
}
|
||||
|
||||
protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect){
|
||||
// focus painting is handled by the border
|
||||
}
|
||||
|
||||
protected void paintButtonPressed(Graphics g, AbstractButton b) {
|
||||
|
||||
fillContentArea( g, b , selectColor );
|
||||
|
||||
}
|
||||
|
||||
protected void fillContentArea( Graphics g, AbstractButton b, Color fillColor) {
|
||||
|
||||
if (b.isContentAreaFilled()) {
|
||||
Insets margin = b.getMargin();
|
||||
Insets insets = b.getInsets();
|
||||
Dimension size = b.getSize();
|
||||
g.setColor(fillColor);
|
||||
g.fillRect(insets.left - margin.left,
|
||||
insets.top - margin.top,
|
||||
size.width - (insets.left-margin.left) - (insets.right - margin.right),
|
||||
size.height - (insets.top-margin.top) - (insets.bottom - margin.bottom));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicButtonListener;
|
||||
import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
|
||||
/**
|
||||
* MotifCheckboxMenuItem implementation
|
||||
* <p>
|
||||
*
|
||||
* @author Georges Saab
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
public class MotifCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI
|
||||
{
|
||||
protected ChangeListener changeListener;
|
||||
|
||||
public static ComponentUI createUI(JComponent b) {
|
||||
return new MotifCheckBoxMenuItemUI();
|
||||
}
|
||||
|
||||
protected void installListeners() {
|
||||
super.installListeners();
|
||||
changeListener = createChangeListener(menuItem);
|
||||
menuItem.addChangeListener(changeListener);
|
||||
}
|
||||
|
||||
protected void uninstallListeners() {
|
||||
super.uninstallListeners();
|
||||
menuItem.removeChangeListener(changeListener);
|
||||
}
|
||||
|
||||
protected ChangeListener createChangeListener(JComponent c) {
|
||||
return new ChangeHandler();
|
||||
}
|
||||
|
||||
protected class ChangeHandler implements ChangeListener {
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JMenuItem c = (JMenuItem)e.getSource();
|
||||
LookAndFeel.installProperty(c, "borderPainted", c.isArmed());
|
||||
}
|
||||
}
|
||||
|
||||
protected MouseInputListener createMouseInputListener(JComponent c) {
|
||||
return new MouseInputHandler();
|
||||
}
|
||||
|
||||
|
||||
protected class MouseInputHandler implements MouseInputListener {
|
||||
public void mouseClicked(MouseEvent e) {}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
|
||||
manager.setSelectedPath(getPath());
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
MenuSelectionManager manager =
|
||||
MenuSelectionManager.defaultManager();
|
||||
JMenuItem menuItem = (JMenuItem)e.getComponent();
|
||||
Point p = e.getPoint();
|
||||
if(p.x >= 0 && p.x < menuItem.getWidth() &&
|
||||
p.y >= 0 && p.y < menuItem.getHeight()) {
|
||||
manager.clearSelectedPath();
|
||||
menuItem.doClick(0);
|
||||
} else {
|
||||
manager.processMouseEvent(e);
|
||||
}
|
||||
}
|
||||
public void mouseEntered(MouseEvent e) {}
|
||||
public void mouseExited(MouseEvent e) {}
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
MenuSelectionManager.defaultManager().processMouseEvent(e);
|
||||
}
|
||||
public void mouseMoved(MouseEvent e) { }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* MotifCheckBox implementation
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
public class MotifCheckBoxUI extends MotifRadioButtonUI {
|
||||
|
||||
private static final Object MOTIF_CHECK_BOX_UI_KEY = new Object();
|
||||
|
||||
private final static String propertyPrefix = "CheckBox" + ".";
|
||||
|
||||
private boolean defaults_initialized = false;
|
||||
|
||||
|
||||
// ********************************
|
||||
// Create PLAF
|
||||
// ********************************
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
MotifCheckBoxUI motifCheckBoxUI =
|
||||
(MotifCheckBoxUI) appContext.get(MOTIF_CHECK_BOX_UI_KEY);
|
||||
if (motifCheckBoxUI == null) {
|
||||
motifCheckBoxUI = new MotifCheckBoxUI();
|
||||
appContext.put(MOTIF_CHECK_BOX_UI_KEY, motifCheckBoxUI);
|
||||
}
|
||||
return motifCheckBoxUI;
|
||||
}
|
||||
|
||||
public String getPropertyPrefix() {
|
||||
return propertyPrefix;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Defaults
|
||||
// ********************************
|
||||
public void installDefaults(AbstractButton b) {
|
||||
super.installDefaults(b);
|
||||
if(!defaults_initialized) {
|
||||
icon = UIManager.getIcon(getPropertyPrefix() + "icon");
|
||||
defaults_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void uninstallDefaults(AbstractButton b) {
|
||||
super.uninstallDefaults(b);
|
||||
defaults_initialized = false;
|
||||
}
|
||||
}
|
||||
361
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifComboBoxUI.java
Normal file
361
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifComboBoxUI.java
Normal file
@@ -0,0 +1,361 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import java.io.Serializable;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
|
||||
/**
|
||||
* ComboBox motif look and feel
|
||||
* <p> * <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Arnaud Weber
|
||||
*/
|
||||
public class MotifComboBoxUI extends BasicComboBoxUI implements Serializable {
|
||||
Icon arrowIcon;
|
||||
static final int HORIZ_MARGIN = 3;
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new MotifComboBoxUI();
|
||||
}
|
||||
|
||||
public void installUI(JComponent c) {
|
||||
super.installUI(c);
|
||||
arrowIcon = new MotifComboBoxArrowIcon(UIManager.getColor("controlHighlight"),
|
||||
UIManager.getColor("controlShadow"),
|
||||
UIManager.getColor("control"));
|
||||
|
||||
Runnable initCode = new Runnable() {
|
||||
public void run(){
|
||||
if ( motifGetEditor() != null ) {
|
||||
motifGetEditor().setBackground( UIManager.getColor( "text" ) );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SwingUtilities.invokeLater( initCode );
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize( JComponent c ) {
|
||||
if ( !isMinimumSizeDirty ) {
|
||||
return new Dimension( cachedMinimumSize );
|
||||
}
|
||||
Dimension size;
|
||||
Insets insets = getInsets();
|
||||
size = getDisplaySize();
|
||||
size.height += insets.top + insets.bottom;
|
||||
int buttonSize = iconAreaWidth();
|
||||
size.width += insets.left + insets.right + buttonSize;
|
||||
|
||||
cachedMinimumSize.setSize( size.width, size.height );
|
||||
isMinimumSizeDirty = false;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
protected ComboPopup createPopup() {
|
||||
return new MotifComboPopup( comboBox );
|
||||
}
|
||||
|
||||
/**
|
||||
* Overriden to empty the MouseMotionListener.
|
||||
*/
|
||||
protected class MotifComboPopup extends BasicComboPopup {
|
||||
|
||||
public MotifComboPopup( JComboBox comboBox ) {
|
||||
super( comboBox );
|
||||
}
|
||||
|
||||
/**
|
||||
* Motif combo popup should not track the mouse in the list.
|
||||
*/
|
||||
public MouseMotionListener createListMouseMotionListener() {
|
||||
return new MouseMotionAdapter() {};
|
||||
}
|
||||
|
||||
public KeyListener createKeyListener() {
|
||||
return super.createKeyListener();
|
||||
}
|
||||
|
||||
protected class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler {
|
||||
protected InvocationKeyHandler() {
|
||||
MotifComboPopup.this.super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void installComponents() {
|
||||
if ( comboBox.isEditable() ) {
|
||||
addEditor();
|
||||
}
|
||||
|
||||
comboBox.add( currentValuePane );
|
||||
}
|
||||
|
||||
protected void uninstallComponents() {
|
||||
removeEditor();
|
||||
comboBox.removeAll();
|
||||
}
|
||||
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
boolean hasFocus = comboBox.hasFocus();
|
||||
Rectangle r;
|
||||
|
||||
if (comboBox.isEnabled()) {
|
||||
g.setColor(comboBox.getBackground());
|
||||
} else {
|
||||
g.setColor(UIManager.getColor("ComboBox.disabledBackground"));
|
||||
}
|
||||
g.fillRect(0,0,c.getWidth(),c.getHeight());
|
||||
|
||||
if ( !comboBox.isEditable() ) {
|
||||
r = rectangleForCurrentValue();
|
||||
paintCurrentValue(g,r,hasFocus);
|
||||
}
|
||||
r = rectangleForArrowIcon();
|
||||
arrowIcon.paintIcon(c,g,r.x,r.y);
|
||||
if ( !comboBox.isEditable() ) {
|
||||
Border border = comboBox.getBorder();
|
||||
Insets in;
|
||||
if ( border != null ) {
|
||||
in = border.getBorderInsets(comboBox);
|
||||
}
|
||||
else {
|
||||
in = new Insets( 0, 0, 0, 0 );
|
||||
}
|
||||
// Draw the separation
|
||||
if(MotifGraphicsUtils.isLeftToRight(comboBox)) {
|
||||
r.x -= (HORIZ_MARGIN + 2);
|
||||
}
|
||||
else {
|
||||
r.x += r.width + HORIZ_MARGIN + 1;
|
||||
}
|
||||
r.y = in.top;
|
||||
r.width = 1;
|
||||
r.height = comboBox.getBounds().height - in.bottom - in.top;
|
||||
g.setColor(UIManager.getColor("controlShadow"));
|
||||
g.fillRect(r.x,r.y,r.width,r.height);
|
||||
r.x++;
|
||||
g.setColor(UIManager.getColor("controlHighlight"));
|
||||
g.fillRect(r.x,r.y,r.width,r.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void paintCurrentValue(Graphics g,Rectangle bounds,boolean hasFocus) {
|
||||
ListCellRenderer renderer = comboBox.getRenderer();
|
||||
Component c;
|
||||
Dimension d;
|
||||
c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);
|
||||
c.setFont(comboBox.getFont());
|
||||
if ( comboBox.isEnabled() ) {
|
||||
c.setForeground(comboBox.getForeground());
|
||||
c.setBackground(comboBox.getBackground());
|
||||
}
|
||||
else {
|
||||
c.setForeground(UIManager.getColor("ComboBox.disabledForeground"));
|
||||
c.setBackground(UIManager.getColor("ComboBox.disabledBackground"));
|
||||
}
|
||||
d = c.getPreferredSize();
|
||||
currentValuePane.paintComponent(g,c,comboBox,bounds.x,bounds.y,
|
||||
bounds.width,d.height);
|
||||
}
|
||||
|
||||
protected Rectangle rectangleForArrowIcon() {
|
||||
Rectangle b = comboBox.getBounds();
|
||||
Border border = comboBox.getBorder();
|
||||
Insets in;
|
||||
if ( border != null ) {
|
||||
in = border.getBorderInsets(comboBox);
|
||||
}
|
||||
else {
|
||||
in = new Insets( 0, 0, 0, 0 );
|
||||
}
|
||||
b.x = in.left;
|
||||
b.y = in.top;
|
||||
b.width -= (in.left + in.right);
|
||||
b.height -= (in.top + in.bottom);
|
||||
|
||||
if(MotifGraphicsUtils.isLeftToRight(comboBox)) {
|
||||
b.x = b.x + b.width - HORIZ_MARGIN - arrowIcon.getIconWidth();
|
||||
}
|
||||
else {
|
||||
b.x += HORIZ_MARGIN;
|
||||
}
|
||||
b.y = b.y + (b.height - arrowIcon.getIconHeight()) / 2;
|
||||
b.width = arrowIcon.getIconWidth();
|
||||
b.height = arrowIcon.getIconHeight();
|
||||
return b;
|
||||
}
|
||||
|
||||
protected Rectangle rectangleForCurrentValue() {
|
||||
int width = comboBox.getWidth();
|
||||
int height = comboBox.getHeight();
|
||||
Insets insets = getInsets();
|
||||
if(MotifGraphicsUtils.isLeftToRight(comboBox)) {
|
||||
return new Rectangle(insets.left, insets.top,
|
||||
(width - (insets.left + insets.right)) -
|
||||
iconAreaWidth(),
|
||||
height - (insets.top + insets.bottom));
|
||||
}
|
||||
else {
|
||||
return new Rectangle(insets.left + iconAreaWidth(), insets.top,
|
||||
(width - (insets.left + insets.right)) -
|
||||
iconAreaWidth(),
|
||||
height - (insets.top + insets.bottom));
|
||||
}
|
||||
}
|
||||
|
||||
public int iconAreaWidth() {
|
||||
if ( comboBox.isEditable() )
|
||||
return arrowIcon.getIconWidth() + (2 * HORIZ_MARGIN);
|
||||
else
|
||||
return arrowIcon.getIconWidth() + (3 * HORIZ_MARGIN) + 2;
|
||||
}
|
||||
|
||||
public void configureEditor() {
|
||||
super.configureEditor();
|
||||
editor.setBackground( UIManager.getColor( "text" ) );
|
||||
}
|
||||
|
||||
protected LayoutManager createLayoutManager() {
|
||||
return new ComboBoxLayoutManager();
|
||||
}
|
||||
|
||||
private Component motifGetEditor() {
|
||||
return editor;
|
||||
}
|
||||
|
||||
/**
|
||||
* This inner class is marked "public" due to a compiler bug.
|
||||
* This class should be treated as a "protected" inner class.
|
||||
* Instantiate it only within subclasses of <FooUI>.
|
||||
*/
|
||||
public class ComboBoxLayoutManager extends BasicComboBoxUI.ComboBoxLayoutManager {
|
||||
public ComboBoxLayoutManager() {
|
||||
MotifComboBoxUI.this.super();
|
||||
}
|
||||
public void layoutContainer(Container parent) {
|
||||
if ( motifGetEditor() != null ) {
|
||||
Rectangle cvb = rectangleForCurrentValue();
|
||||
cvb.x += 1;
|
||||
cvb.y += 1;
|
||||
cvb.width -= 1;
|
||||
cvb.height -= 2;
|
||||
motifGetEditor().setBounds(cvb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class MotifComboBoxArrowIcon implements Icon, Serializable {
|
||||
private Color lightShadow;
|
||||
private Color darkShadow;
|
||||
private Color fill;
|
||||
|
||||
public MotifComboBoxArrowIcon(Color lightShadow, Color darkShadow, Color fill) {
|
||||
this.lightShadow = lightShadow;
|
||||
this.darkShadow = darkShadow;
|
||||
this.fill = fill;
|
||||
}
|
||||
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int xo, int yo) {
|
||||
int w = getIconWidth();
|
||||
int h = getIconHeight();
|
||||
|
||||
g.setColor(lightShadow);
|
||||
g.drawLine(xo, yo, xo+w-1, yo);
|
||||
g.drawLine(xo, yo+1, xo+w-3, yo+1);
|
||||
g.setColor(darkShadow);
|
||||
g.drawLine(xo+w-2, yo+1, xo+w-1, yo+1);
|
||||
|
||||
for ( int x = xo+1, y = yo+2, dx = w-6; y+1 < yo+h; y += 2 ) {
|
||||
g.setColor(lightShadow);
|
||||
g.drawLine(x, y, x+1, y);
|
||||
g.drawLine(x, y+1, x+1, y+1);
|
||||
if ( dx > 0 ) {
|
||||
g.setColor(fill);
|
||||
g.drawLine(x+2, y, x+1+dx, y);
|
||||
g.drawLine(x+2, y+1, x+1+dx, y+1);
|
||||
}
|
||||
g.setColor(darkShadow);
|
||||
g.drawLine(x+dx+2, y, x+dx+3, y);
|
||||
g.drawLine(x+dx+2, y+1, x+dx+3, y+1);
|
||||
x += 1;
|
||||
dx -= 2;
|
||||
}
|
||||
|
||||
g.setColor(darkShadow);
|
||||
g.drawLine(xo+(w/2), yo+h-1, xo+(w/2), yo+h-1);
|
||||
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
return 11;
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
return 11;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*{@inheritDoc}
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected PropertyChangeListener createPropertyChangeListener() {
|
||||
return new MotifPropertyChangeListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* This class should be made "protected" in future releases.
|
||||
*/
|
||||
private class MotifPropertyChangeListener
|
||||
extends BasicComboBoxUI.PropertyChangeHandler {
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
super.propertyChange(e);
|
||||
String propertyName = e.getPropertyName();
|
||||
if (propertyName == "enabled") {
|
||||
if (comboBox.isEnabled()) {
|
||||
Component editor = motifGetEditor();
|
||||
if (editor != null) {
|
||||
editor.setBackground(UIManager.getColor("text"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import sun.swing.SwingUtilities2;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import java.beans.*;
|
||||
import java.util.EventListener;
|
||||
import java.io.Serializable;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.AWTAccessor.MouseEventAccessor;
|
||||
|
||||
/**
|
||||
* Motif rendition of the component.
|
||||
*
|
||||
* @author Thomas Ball
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
public class MotifDesktopIconUI extends BasicDesktopIconUI
|
||||
{
|
||||
protected DesktopIconActionListener desktopIconActionListener;
|
||||
protected DesktopIconMouseListener desktopIconMouseListener;
|
||||
|
||||
protected Icon defaultIcon;
|
||||
protected IconButton iconButton;
|
||||
protected IconLabel iconLabel;
|
||||
|
||||
// This is only used for its system menu, but we need a reference to it so
|
||||
// we can remove its listeners.
|
||||
private MotifInternalFrameTitlePane sysMenuTitlePane;
|
||||
|
||||
JPopupMenu systemMenu;
|
||||
EventListener mml;
|
||||
|
||||
final static int LABEL_HEIGHT = 18;
|
||||
final static int LABEL_DIVIDER = 4; // padding between icon and label
|
||||
|
||||
final static Font defaultTitleFont =
|
||||
new Font(Font.SANS_SERIF, Font.PLAIN, 12);
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new MotifDesktopIconUI();
|
||||
}
|
||||
|
||||
public MotifDesktopIconUI() {
|
||||
}
|
||||
|
||||
protected void installDefaults(){
|
||||
super.installDefaults();
|
||||
setDefaultIcon(UIManager.getIcon("DesktopIcon.icon"));
|
||||
iconButton = createIconButton(defaultIcon);
|
||||
// An underhanded way of creating a system popup menu.
|
||||
sysMenuTitlePane = new MotifInternalFrameTitlePane(frame);
|
||||
systemMenu = sysMenuTitlePane.getSystemMenu();
|
||||
|
||||
MotifBorders.FrameBorder border = new MotifBorders.FrameBorder(desktopIcon);
|
||||
desktopIcon.setLayout(new BorderLayout());
|
||||
iconButton.setBorder(border);
|
||||
desktopIcon.add(iconButton, BorderLayout.CENTER);
|
||||
iconLabel = createIconLabel(frame);
|
||||
iconLabel.setBorder(border);
|
||||
desktopIcon.add(iconLabel, BorderLayout.SOUTH);
|
||||
desktopIcon.setSize(desktopIcon.getPreferredSize());
|
||||
desktopIcon.validate();
|
||||
JLayeredPane.putLayer(desktopIcon, JLayeredPane.getLayer(frame));
|
||||
}
|
||||
|
||||
protected void installComponents(){
|
||||
}
|
||||
|
||||
protected void uninstallComponents(){
|
||||
}
|
||||
|
||||
protected void installListeners(){
|
||||
super.installListeners();
|
||||
desktopIconActionListener = createDesktopIconActionListener();
|
||||
desktopIconMouseListener = createDesktopIconMouseListener();
|
||||
iconButton.addActionListener(desktopIconActionListener);
|
||||
iconButton.addMouseListener(desktopIconMouseListener);
|
||||
iconLabel.addMouseListener(desktopIconMouseListener);
|
||||
}
|
||||
|
||||
JInternalFrame.JDesktopIcon getDesktopIcon(){
|
||||
return desktopIcon;
|
||||
}
|
||||
|
||||
void setDesktopIcon(JInternalFrame.JDesktopIcon d){
|
||||
desktopIcon = d;
|
||||
}
|
||||
|
||||
JInternalFrame getFrame(){
|
||||
return frame;
|
||||
}
|
||||
|
||||
void setFrame(JInternalFrame f){
|
||||
frame = f ;
|
||||
}
|
||||
|
||||
protected void showSystemMenu(){
|
||||
systemMenu.show(iconButton, 0, getDesktopIcon().getHeight());
|
||||
}
|
||||
|
||||
protected void hideSystemMenu(){
|
||||
systemMenu.setVisible(false);
|
||||
}
|
||||
|
||||
protected IconLabel createIconLabel(JInternalFrame frame){
|
||||
return new IconLabel(frame);
|
||||
}
|
||||
|
||||
protected IconButton createIconButton(Icon i){
|
||||
return new IconButton(i);
|
||||
}
|
||||
|
||||
protected DesktopIconActionListener createDesktopIconActionListener(){
|
||||
return new DesktopIconActionListener();
|
||||
}
|
||||
|
||||
protected DesktopIconMouseListener createDesktopIconMouseListener(){
|
||||
return new DesktopIconMouseListener();
|
||||
}
|
||||
|
||||
protected void uninstallDefaults(){
|
||||
super.uninstallDefaults();
|
||||
desktopIcon.setLayout(null);
|
||||
desktopIcon.remove(iconButton);
|
||||
desktopIcon.remove(iconLabel);
|
||||
}
|
||||
|
||||
protected void uninstallListeners(){
|
||||
super.uninstallListeners();
|
||||
iconButton.removeActionListener(desktopIconActionListener);
|
||||
iconButton.removeMouseListener(desktopIconMouseListener);
|
||||
sysMenuTitlePane.uninstallListeners();
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize(JComponent c) {
|
||||
JInternalFrame iframe = desktopIcon.getInternalFrame();
|
||||
|
||||
int w = defaultIcon.getIconWidth();
|
||||
int h = defaultIcon.getIconHeight() + LABEL_HEIGHT + LABEL_DIVIDER;
|
||||
|
||||
Border border = iframe.getBorder();
|
||||
if(border != null) {
|
||||
w += border.getBorderInsets(iframe).left +
|
||||
border.getBorderInsets(iframe).right;
|
||||
h += border.getBorderInsets(iframe).bottom +
|
||||
border.getBorderInsets(iframe).top;
|
||||
}
|
||||
|
||||
return new Dimension(w, h);
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
return getMinimumSize(c);
|
||||
}
|
||||
|
||||
public Dimension getMaximumSize(JComponent c){
|
||||
return getMinimumSize(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default desktop icon.
|
||||
*/
|
||||
public Icon getDefaultIcon() {
|
||||
return defaultIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon used as the default desktop icon.
|
||||
*/
|
||||
public void setDefaultIcon(Icon newIcon) {
|
||||
defaultIcon = newIcon;
|
||||
}
|
||||
|
||||
protected class IconLabel extends JPanel {
|
||||
JInternalFrame frame;
|
||||
|
||||
IconLabel(JInternalFrame f) {
|
||||
super();
|
||||
this.frame = f;
|
||||
setFont(defaultTitleFont);
|
||||
|
||||
// Forward mouse events to titlebar for moves.
|
||||
addMouseMotionListener(new MouseMotionListener() {
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
});
|
||||
addMouseListener(new MouseListener() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mouseExited(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void forwardEventToParent(MouseEvent e) {
|
||||
MouseEvent newEvent = new MouseEvent(
|
||||
getParent(), e.getID(), e.getWhen(), e.getModifiers(),
|
||||
e.getX(), e.getY(), e.getXOnScreen(),
|
||||
e.getYOnScreen(), e.getClickCount(),
|
||||
e.isPopupTrigger(), MouseEvent.NOBUTTON);
|
||||
MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor();
|
||||
meAccessor.setCausedByTouchEvent(newEvent,
|
||||
meAccessor.isCausedByTouchEvent(e));
|
||||
getParent().dispatchEvent(newEvent);
|
||||
}
|
||||
|
||||
public boolean isFocusTraversable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize() {
|
||||
return new Dimension(defaultIcon.getIconWidth() + 1,
|
||||
LABEL_HEIGHT + LABEL_DIVIDER);
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
String title = frame.getTitle();
|
||||
FontMetrics fm = frame.getFontMetrics(defaultTitleFont);
|
||||
int w = 4;
|
||||
if (title != null) {
|
||||
w += SwingUtilities2.stringWidth(frame, fm, title);
|
||||
}
|
||||
return new Dimension(w, LABEL_HEIGHT + LABEL_DIVIDER);
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
|
||||
// touch-up frame
|
||||
int maxX = getWidth() - 1;
|
||||
Color shadow =
|
||||
UIManager.getColor("inactiveCaptionBorder").darker().darker();
|
||||
g.setColor(shadow);
|
||||
g.setClip(0, 0, getWidth(), getHeight());
|
||||
g.drawLine(maxX - 1, 1, maxX - 1, 1);
|
||||
g.drawLine(maxX, 0, maxX, 0);
|
||||
|
||||
// fill background
|
||||
g.setColor(UIManager.getColor("inactiveCaption"));
|
||||
g.fillRect(2, 1, maxX - 3, LABEL_HEIGHT + 1);
|
||||
|
||||
// draw text -- clipping to truncate text like CDE/Motif
|
||||
g.setClip(2, 1, maxX - 4, LABEL_HEIGHT);
|
||||
int y = LABEL_HEIGHT - SwingUtilities2.getFontMetrics(frame, g).
|
||||
getDescent();
|
||||
g.setColor(UIManager.getColor("inactiveCaptionText"));
|
||||
String title = frame.getTitle();
|
||||
if (title != null) {
|
||||
SwingUtilities2.drawString(frame, g, title, 4, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected class IconButton extends JButton {
|
||||
Icon icon;
|
||||
|
||||
IconButton(Icon icon) {
|
||||
super(icon);
|
||||
this.icon = icon;
|
||||
// Forward mouse events to titlebar for moves.
|
||||
addMouseMotionListener(new MouseMotionListener() {
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
});
|
||||
addMouseListener(new MouseListener() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (!systemMenu.isShowing()) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
}
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mouseExited(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void forwardEventToParent(MouseEvent e) {
|
||||
MouseEvent newEvent = new MouseEvent(
|
||||
getParent(), e.getID(), e.getWhen(), e.getModifiers(),
|
||||
e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(),
|
||||
e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON );
|
||||
MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor();
|
||||
meAccessor.setCausedByTouchEvent(newEvent,
|
||||
meAccessor.isCausedByTouchEvent(e));
|
||||
getParent().dispatchEvent(newEvent);
|
||||
}
|
||||
|
||||
public boolean isFocusTraversable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected class DesktopIconActionListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent e){
|
||||
systemMenu.show(iconButton, 0, getDesktopIcon().getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
protected class DesktopIconMouseListener extends MouseAdapter {
|
||||
// if we drag or move we should deengage the popup
|
||||
public void mousePressed(MouseEvent e){
|
||||
if (e.getClickCount() > 1) {
|
||||
try {
|
||||
getFrame().setIcon(false);
|
||||
} catch (PropertyVetoException e2){ }
|
||||
systemMenu.setVisible(false);
|
||||
/* the mouse release will not get reported correctly,
|
||||
because the icon will no longer be in the hierarchy;
|
||||
maybe that should be fixed, but until it is, we need
|
||||
to do the required cleanup here. */
|
||||
getFrame().getDesktopPane().getDesktopManager().endDraggingFrame((JComponent)e.getSource());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import javax.swing.plaf.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author David Kloba
|
||||
*/
|
||||
public class MotifDesktopPaneUI extends javax.swing.plaf.basic.BasicDesktopPaneUI
|
||||
{
|
||||
|
||||
/// DesktopPaneUI methods
|
||||
public static ComponentUI createUI(JComponent d) {
|
||||
return new MotifDesktopPaneUI();
|
||||
}
|
||||
|
||||
public MotifDesktopPaneUI() {
|
||||
}
|
||||
|
||||
protected void installDesktopManager() {
|
||||
desktopManager = desktop.getDesktopManager();
|
||||
if(desktopManager == null) {
|
||||
desktopManager = new MotifDesktopManager();
|
||||
desktop.setDesktopManager(desktopManager);
|
||||
((MotifDesktopManager)desktopManager).adjustIcons(desktop);
|
||||
}
|
||||
}
|
||||
|
||||
public Insets getInsets(JComponent c) {return new Insets(0,0,0,0);}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
/// DragPane class
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
private class DragPane extends JComponent {
|
||||
public void paint(Graphics g) {
|
||||
g.setColor(Color.darkGray);
|
||||
g.drawRect(0, 0, getWidth()-1, getHeight()-1);
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
/// MotifDesktopManager class
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
private class MotifDesktopManager extends DefaultDesktopManager implements Serializable, UIResource {
|
||||
JComponent dragPane;
|
||||
boolean usingDragPane = false;
|
||||
private transient JLayeredPane layeredPaneForDragPane;
|
||||
int iconWidth, iconHeight;
|
||||
|
||||
// PENDING(klobad) this should be optimized
|
||||
public void setBoundsForFrame(JComponent f, int newX, int newY,
|
||||
int newWidth, int newHeight) {
|
||||
if(!usingDragPane) {
|
||||
boolean didResize;
|
||||
didResize = (f.getWidth() != newWidth || f.getHeight() != newHeight);
|
||||
Rectangle r = f.getBounds();
|
||||
f.setBounds(newX, newY, newWidth, newHeight);
|
||||
SwingUtilities.computeUnion(newX, newY, newWidth, newHeight, r);
|
||||
f.getParent().repaint(r.x, r.y, r.width, r.height);
|
||||
if(didResize) {
|
||||
f.validate();
|
||||
}
|
||||
} else {
|
||||
Rectangle r = dragPane.getBounds();
|
||||
dragPane.setBounds(newX, newY, newWidth, newHeight);
|
||||
SwingUtilities.computeUnion(newX, newY, newWidth, newHeight, r);
|
||||
dragPane.getParent().repaint(r.x, r.y, r.width, r.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void beginDraggingFrame(JComponent f) {
|
||||
usingDragPane = false;
|
||||
if(f.getParent() instanceof JLayeredPane) {
|
||||
if(dragPane == null)
|
||||
dragPane = new DragPane();
|
||||
layeredPaneForDragPane = (JLayeredPane)f.getParent();
|
||||
layeredPaneForDragPane.setLayer(dragPane, Integer.MAX_VALUE);
|
||||
dragPane.setBounds(f.getX(), f.getY(), f.getWidth(), f.getHeight());
|
||||
layeredPaneForDragPane.add(dragPane);
|
||||
usingDragPane = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void dragFrame(JComponent f, int newX, int newY) {
|
||||
setBoundsForFrame(f, newX, newY, f.getWidth(), f.getHeight());
|
||||
}
|
||||
|
||||
public void endDraggingFrame(JComponent f) {
|
||||
if(usingDragPane) {
|
||||
layeredPaneForDragPane.remove(dragPane);
|
||||
usingDragPane = false;
|
||||
if (f instanceof JInternalFrame) {
|
||||
setBoundsForFrame(f, dragPane.getX(), dragPane.getY(),
|
||||
dragPane.getWidth(), dragPane.getHeight());
|
||||
} else if (f instanceof JInternalFrame.JDesktopIcon) {
|
||||
adjustBoundsForIcon((JInternalFrame.JDesktopIcon)f,
|
||||
dragPane.getX(), dragPane.getY());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void beginResizingFrame(JComponent f, int direction) {
|
||||
usingDragPane = false;
|
||||
if(f.getParent() instanceof JLayeredPane) {
|
||||
if(dragPane == null)
|
||||
dragPane = new DragPane();
|
||||
JLayeredPane p = (JLayeredPane)f.getParent();
|
||||
p.setLayer(dragPane, Integer.MAX_VALUE);
|
||||
dragPane.setBounds(f.getX(), f.getY(),
|
||||
f.getWidth(), f.getHeight());
|
||||
p.add(dragPane);
|
||||
usingDragPane = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void resizeFrame(JComponent f, int newX, int newY,
|
||||
int newWidth, int newHeight) {
|
||||
setBoundsForFrame(f, newX, newY, newWidth, newHeight);
|
||||
}
|
||||
|
||||
public void endResizingFrame(JComponent f) {
|
||||
if(usingDragPane) {
|
||||
JLayeredPane p = (JLayeredPane)f.getParent();
|
||||
p.remove(dragPane);
|
||||
usingDragPane = false;
|
||||
setBoundsForFrame(f, dragPane.getX(), dragPane.getY(),
|
||||
dragPane.getWidth(), dragPane.getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
public void iconifyFrame(JInternalFrame f) {
|
||||
JInternalFrame.JDesktopIcon icon = f.getDesktopIcon();
|
||||
Point p = icon.getLocation();
|
||||
adjustBoundsForIcon(icon, p.x, p.y);
|
||||
super.iconifyFrame(f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change positions of icons in the desktop pane so that
|
||||
* they do not overlap
|
||||
*/
|
||||
protected void adjustIcons(JDesktopPane desktop) {
|
||||
// We need to know Motif icon size
|
||||
JInternalFrame.JDesktopIcon icon = new JInternalFrame.JDesktopIcon(
|
||||
new JInternalFrame());
|
||||
Dimension iconSize = icon.getPreferredSize();
|
||||
iconWidth = iconSize.width;
|
||||
iconHeight = iconSize.height;
|
||||
|
||||
JInternalFrame[] frames = desktop.getAllFrames();
|
||||
for (int i=0; i<frames.length; i++) {
|
||||
icon = frames[i].getDesktopIcon();
|
||||
Point ip = icon.getLocation();
|
||||
adjustBoundsForIcon(icon, ip.x, ip.y);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Change positions of icon so that it doesn't overlap
|
||||
* other icons.
|
||||
*/
|
||||
protected void adjustBoundsForIcon(JInternalFrame.JDesktopIcon icon,
|
||||
int x, int y) {
|
||||
JDesktopPane c = icon.getDesktopPane();
|
||||
|
||||
int maxy = c.getHeight();
|
||||
int w = iconWidth;
|
||||
int h = iconHeight;
|
||||
c.repaint(x, y, w, h);
|
||||
x = x < 0 ? 0 : x;
|
||||
y = y < 0 ? 0 : y;
|
||||
|
||||
/* Fix for disappearing icons. If the y value is maxy then this
|
||||
* algorithm would place the icon in a non-displayed cell. Never
|
||||
* to be ssen again.*/
|
||||
y = y >= maxy ? (maxy - 1) : y;
|
||||
|
||||
/* Compute the offset for the cell we are trying to go in. */
|
||||
int lx = (x / w) * w;
|
||||
int ygap = maxy % h;
|
||||
int ly = ((y-ygap) / h) * h + ygap;
|
||||
|
||||
/* How far are we into the cell we dropped the icon in. */
|
||||
int dx = x - lx;
|
||||
int dy = y - ly;
|
||||
|
||||
/* Set coordinates for the icon. */
|
||||
x = dx < w/2 ? lx: lx + w;
|
||||
y = dy < h/2 ? ly: ((ly + h) < maxy ? ly + h: ly);
|
||||
|
||||
while (getIconAt(c, icon, x, y) != null) {
|
||||
x += w;
|
||||
}
|
||||
|
||||
/* Cancel the move if the x value was moved off screen. */
|
||||
if (x > c.getWidth()) {
|
||||
return;
|
||||
}
|
||||
if (icon.getParent() != null) {
|
||||
setBoundsForFrame(icon, x, y, w, h);
|
||||
} else {
|
||||
icon.setLocation(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
protected JInternalFrame.JDesktopIcon getIconAt(JDesktopPane desktop,
|
||||
JInternalFrame.JDesktopIcon icon, int x, int y) {
|
||||
|
||||
JInternalFrame.JDesktopIcon currentIcon = null;
|
||||
Component[] components = desktop.getComponents();
|
||||
|
||||
for (int i=0; i<components.length; i++) {
|
||||
Component comp = components[i];
|
||||
if (comp instanceof JInternalFrame.JDesktopIcon &&
|
||||
comp != icon) {
|
||||
|
||||
Point p = comp.getLocation();
|
||||
if (p.x == x && p.y == y) {
|
||||
return (JInternalFrame.JDesktopIcon)comp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}; /// END of MotifDesktopManager
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicEditorPaneUI;
|
||||
|
||||
/**
|
||||
* Provides the look and feel for an pluggable content-type text editor.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Timothy Prinzing
|
||||
*/
|
||||
public class MotifEditorPaneUI extends BasicEditorPaneUI {
|
||||
|
||||
/**
|
||||
* Creates a UI for the JTextPane.
|
||||
*
|
||||
* @param c the JTextPane component
|
||||
* @return the UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new MotifEditorPaneUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object to use for a caret. By default an
|
||||
* instance of MotifTextUI.MotifCaret is created. This method
|
||||
* can be redefined to provide something else that implements
|
||||
* the Caret interface.
|
||||
*
|
||||
* @return the caret object
|
||||
*/
|
||||
protected Caret createCaret() {
|
||||
return MotifTextUI.createCaret();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,854 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.beans.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import sun.awt.shell.ShellFolder;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
/**
|
||||
* Motif FileChooserUI.
|
||||
*
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public class MotifFileChooserUI extends BasicFileChooserUI {
|
||||
|
||||
private FilterComboBoxModel filterComboBoxModel;
|
||||
|
||||
protected JList<File> directoryList = null;
|
||||
protected JList<File> fileList = null;
|
||||
|
||||
protected JTextField pathField = null;
|
||||
protected JComboBox<FileFilter> filterComboBox = null;
|
||||
protected JTextField filenameTextField = null;
|
||||
|
||||
private static final Dimension hstrut10 = new Dimension(10, 1);
|
||||
private static final Dimension vstrut10 = new Dimension(1, 10);
|
||||
|
||||
private static final Insets insets = new Insets(10, 10, 10, 10);
|
||||
|
||||
private static Dimension prefListSize = new Dimension(75, 150);
|
||||
|
||||
private static Dimension WITH_ACCELERATOR_PREF_SIZE = new Dimension(650, 450);
|
||||
private static Dimension PREF_SIZE = new Dimension(350, 450);
|
||||
private static final int MIN_WIDTH = 200;
|
||||
private static final int MIN_HEIGHT = 300;
|
||||
private static Dimension PREF_ACC_SIZE = new Dimension(10, 10);
|
||||
private static Dimension ZERO_ACC_SIZE = new Dimension(1, 1);
|
||||
|
||||
private static Dimension MAX_SIZE = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
|
||||
|
||||
private static final Insets buttonMargin = new Insets(3, 3, 3, 3);
|
||||
|
||||
private JPanel bottomPanel;
|
||||
|
||||
protected JButton approveButton;
|
||||
|
||||
private String enterFolderNameLabelText = null;
|
||||
private int enterFolderNameLabelMnemonic = 0;
|
||||
private String enterFileNameLabelText = null;
|
||||
private int enterFileNameLabelMnemonic = 0;
|
||||
|
||||
private String filesLabelText = null;
|
||||
private int filesLabelMnemonic = 0;
|
||||
|
||||
private String foldersLabelText = null;
|
||||
private int foldersLabelMnemonic = 0;
|
||||
|
||||
private String pathLabelText = null;
|
||||
private int pathLabelMnemonic = 0;
|
||||
|
||||
private String filterLabelText = null;
|
||||
private int filterLabelMnemonic = 0;
|
||||
|
||||
private JLabel fileNameLabel;
|
||||
|
||||
private void populateFileNameLabel() {
|
||||
if (getFileChooser().getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) {
|
||||
fileNameLabel.setText(enterFolderNameLabelText);
|
||||
fileNameLabel.setDisplayedMnemonic(enterFolderNameLabelMnemonic);
|
||||
} else {
|
||||
fileNameLabel.setText(enterFileNameLabelText);
|
||||
fileNameLabel.setDisplayedMnemonic(enterFileNameLabelMnemonic);
|
||||
}
|
||||
}
|
||||
|
||||
private String fileNameString(File file) {
|
||||
if (file == null) {
|
||||
return null;
|
||||
} else {
|
||||
JFileChooser fc = getFileChooser();
|
||||
if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
|
||||
return file.getPath();
|
||||
} else {
|
||||
return file.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String fileNameString(File[] files) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (int i = 0; files != null && i < files.length; i++) {
|
||||
if (i > 0) {
|
||||
buf.append(" ");
|
||||
}
|
||||
if (files.length > 1) {
|
||||
buf.append("\"");
|
||||
}
|
||||
buf.append(fileNameString(files[i]));
|
||||
if (files.length > 1) {
|
||||
buf.append("\"");
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public MotifFileChooserUI(JFileChooser filechooser) {
|
||||
super(filechooser);
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
if(filenameTextField != null) {
|
||||
return filenameTextField.getText();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFileName(String filename) {
|
||||
if(filenameTextField != null) {
|
||||
filenameTextField.setText(filename);
|
||||
}
|
||||
}
|
||||
|
||||
public String getDirectoryName() {
|
||||
return pathField.getText();
|
||||
}
|
||||
|
||||
public void setDirectoryName(String dirname) {
|
||||
pathField.setText(dirname);
|
||||
}
|
||||
|
||||
public void ensureFileIsVisible(JFileChooser fc, File f) {
|
||||
// PENDING(jeff)
|
||||
}
|
||||
|
||||
public void rescanCurrentDirectory(JFileChooser fc) {
|
||||
getModel().validateFileCache();
|
||||
}
|
||||
|
||||
public PropertyChangeListener createPropertyChangeListener(JFileChooser fc) {
|
||||
return new PropertyChangeListener() {
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
String prop = e.getPropertyName();
|
||||
if(prop.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
|
||||
File f = (File) e.getNewValue();
|
||||
if(f != null) {
|
||||
setFileName(getFileChooser().getName(f));
|
||||
}
|
||||
} else if (prop.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) {
|
||||
File[] files = (File[]) e.getNewValue();
|
||||
JFileChooser fc = getFileChooser();
|
||||
if (files != null && files.length > 0 && (files.length > 1 || fc.isDirectorySelectionEnabled()
|
||||
|| !files[0].isDirectory())) {
|
||||
setFileName(fileNameString(files));
|
||||
}
|
||||
} else if (prop.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
|
||||
fileList.clearSelection();
|
||||
} else if(prop.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
|
||||
directoryList.clearSelection();
|
||||
ListSelectionModel sm = directoryList.getSelectionModel();
|
||||
if (sm instanceof DefaultListSelectionModel) {
|
||||
((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0);
|
||||
sm.setAnchorSelectionIndex(0);
|
||||
}
|
||||
fileList.clearSelection();
|
||||
sm = fileList.getSelectionModel();
|
||||
if (sm instanceof DefaultListSelectionModel) {
|
||||
((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0);
|
||||
sm.setAnchorSelectionIndex(0);
|
||||
}
|
||||
File currentDirectory = getFileChooser().getCurrentDirectory();
|
||||
if(currentDirectory != null) {
|
||||
try {
|
||||
setDirectoryName(ShellFolder.getNormalizedFile((File)e.getNewValue()).getPath());
|
||||
} catch (IOException ioe) {
|
||||
setDirectoryName(((File)e.getNewValue()).getAbsolutePath());
|
||||
}
|
||||
if ((getFileChooser().getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY) && !getFileChooser().isMultiSelectionEnabled()) {
|
||||
setFileName(getDirectoryName());
|
||||
}
|
||||
}
|
||||
} else if(prop.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {
|
||||
if (fileNameLabel != null) {
|
||||
populateFileNameLabel();
|
||||
}
|
||||
directoryList.clearSelection();
|
||||
} else if (prop.equals(JFileChooser.MULTI_SELECTION_ENABLED_CHANGED_PROPERTY)) {
|
||||
if(getFileChooser().isMultiSelectionEnabled()) {
|
||||
fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
} else {
|
||||
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
fileList.clearSelection();
|
||||
getFileChooser().setSelectedFiles(null);
|
||||
}
|
||||
} else if (prop.equals(JFileChooser.ACCESSORY_CHANGED_PROPERTY)) {
|
||||
if(getAccessoryPanel() != null) {
|
||||
if(e.getOldValue() != null) {
|
||||
getAccessoryPanel().remove((JComponent) e.getOldValue());
|
||||
}
|
||||
JComponent accessory = (JComponent) e.getNewValue();
|
||||
if(accessory != null) {
|
||||
getAccessoryPanel().add(accessory, BorderLayout.CENTER);
|
||||
getAccessoryPanel().setPreferredSize(PREF_ACC_SIZE);
|
||||
getAccessoryPanel().setMaximumSize(MAX_SIZE);
|
||||
} else {
|
||||
getAccessoryPanel().setPreferredSize(ZERO_ACC_SIZE);
|
||||
getAccessoryPanel().setMaximumSize(ZERO_ACC_SIZE);
|
||||
}
|
||||
}
|
||||
} else if (prop.equals(JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY) ||
|
||||
prop.equals(JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY) ||
|
||||
prop.equals(JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY)) {
|
||||
approveButton.setText(getApproveButtonText(getFileChooser()));
|
||||
approveButton.setToolTipText(getApproveButtonToolTipText(getFileChooser()));
|
||||
} else if (prop.equals(JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY)) {
|
||||
doControlButtonsChanged(e);
|
||||
} else if (prop.equals("componentOrientation")) {
|
||||
ComponentOrientation o = (ComponentOrientation)e.getNewValue();
|
||||
JFileChooser cc = (JFileChooser)e.getSource();
|
||||
if (o != (ComponentOrientation)e.getOldValue()) {
|
||||
cc.applyComponentOrientation(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// ComponentUI Interface Implementation methods
|
||||
//
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new MotifFileChooserUI((JFileChooser)c);
|
||||
}
|
||||
|
||||
public void installUI(JComponent c) {
|
||||
super.installUI(c);
|
||||
}
|
||||
|
||||
public void uninstallUI(JComponent c) {
|
||||
c.removePropertyChangeListener(filterComboBoxModel);
|
||||
approveButton.removeActionListener(getApproveSelectionAction());
|
||||
filenameTextField.removeActionListener(getApproveSelectionAction());
|
||||
super.uninstallUI(c);
|
||||
}
|
||||
|
||||
public void installComponents(JFileChooser fc) {
|
||||
fc.setLayout(new BorderLayout(10, 10));
|
||||
fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);
|
||||
|
||||
JPanel interior = new JPanel() {
|
||||
public Insets getInsets() {
|
||||
return insets;
|
||||
}
|
||||
};
|
||||
interior.setInheritsPopupMenu(true);
|
||||
align(interior);
|
||||
interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));
|
||||
|
||||
fc.add(interior, BorderLayout.CENTER);
|
||||
|
||||
// PENDING(jeff) - I18N
|
||||
JLabel l = new JLabel(pathLabelText);
|
||||
l.setDisplayedMnemonic(pathLabelMnemonic);
|
||||
align(l);
|
||||
interior.add(l);
|
||||
|
||||
File currentDirectory = fc.getCurrentDirectory();
|
||||
String curDirName = null;
|
||||
if(currentDirectory != null) {
|
||||
curDirName = currentDirectory.getPath();
|
||||
}
|
||||
pathField = new JTextField(curDirName) {
|
||||
public Dimension getMaximumSize() {
|
||||
Dimension d = super.getMaximumSize();
|
||||
d.height = getPreferredSize().height;
|
||||
return d;
|
||||
}
|
||||
};
|
||||
pathField.setInheritsPopupMenu(true);
|
||||
l.setLabelFor(pathField);
|
||||
align(pathField);
|
||||
|
||||
// Change to folder on return
|
||||
pathField.addActionListener(getUpdateAction());
|
||||
interior.add(pathField);
|
||||
|
||||
interior.add(Box.createRigidArea(vstrut10));
|
||||
|
||||
|
||||
// CENTER: left, right accessory
|
||||
JPanel centerPanel = new JPanel();
|
||||
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS));
|
||||
align(centerPanel);
|
||||
|
||||
// left panel - Filter & folderList
|
||||
JPanel leftPanel = new JPanel();
|
||||
leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
|
||||
align(leftPanel);
|
||||
|
||||
// add the filter PENDING(jeff) - I18N
|
||||
l = new JLabel(filterLabelText);
|
||||
l.setDisplayedMnemonic(filterLabelMnemonic);
|
||||
align(l);
|
||||
leftPanel.add(l);
|
||||
|
||||
filterComboBox = new JComboBox<FileFilter>() {
|
||||
public Dimension getMaximumSize() {
|
||||
Dimension d = super.getMaximumSize();
|
||||
d.height = getPreferredSize().height;
|
||||
return d;
|
||||
}
|
||||
};
|
||||
filterComboBox.setInheritsPopupMenu(true);
|
||||
l.setLabelFor(filterComboBox);
|
||||
filterComboBoxModel = createFilterComboBoxModel();
|
||||
filterComboBox.setModel(filterComboBoxModel);
|
||||
filterComboBox.setRenderer(createFilterComboBoxRenderer());
|
||||
fc.addPropertyChangeListener(filterComboBoxModel);
|
||||
align(filterComboBox);
|
||||
leftPanel.add(filterComboBox);
|
||||
|
||||
// leftPanel.add(Box.createRigidArea(vstrut10));
|
||||
|
||||
// Add the Folder List PENDING(jeff) - I18N
|
||||
l = new JLabel(foldersLabelText);
|
||||
l.setDisplayedMnemonic(foldersLabelMnemonic);
|
||||
align(l);
|
||||
leftPanel.add(l);
|
||||
JScrollPane sp = createDirectoryList();
|
||||
sp.getVerticalScrollBar().setFocusable(false);
|
||||
sp.getHorizontalScrollBar().setFocusable(false);
|
||||
sp.setInheritsPopupMenu(true);
|
||||
l.setLabelFor(sp.getViewport().getView());
|
||||
leftPanel.add(sp);
|
||||
leftPanel.setInheritsPopupMenu(true);
|
||||
|
||||
|
||||
// create files list
|
||||
JPanel rightPanel = new JPanel();
|
||||
align(rightPanel);
|
||||
rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS));
|
||||
rightPanel.setInheritsPopupMenu(true);
|
||||
|
||||
l = new JLabel(filesLabelText);
|
||||
l.setDisplayedMnemonic(filesLabelMnemonic);
|
||||
align(l);
|
||||
rightPanel.add(l);
|
||||
sp = createFilesList();
|
||||
l.setLabelFor(sp.getViewport().getView());
|
||||
rightPanel.add(sp);
|
||||
sp.setInheritsPopupMenu(true);
|
||||
|
||||
centerPanel.add(leftPanel);
|
||||
centerPanel.add(Box.createRigidArea(hstrut10));
|
||||
centerPanel.add(rightPanel);
|
||||
centerPanel.setInheritsPopupMenu(true);
|
||||
|
||||
JComponent accessoryPanel = getAccessoryPanel();
|
||||
JComponent accessory = fc.getAccessory();
|
||||
if(accessoryPanel != null) {
|
||||
if(accessory == null) {
|
||||
accessoryPanel.setPreferredSize(ZERO_ACC_SIZE);
|
||||
accessoryPanel.setMaximumSize(ZERO_ACC_SIZE);
|
||||
} else {
|
||||
getAccessoryPanel().add(accessory, BorderLayout.CENTER);
|
||||
accessoryPanel.setPreferredSize(PREF_ACC_SIZE);
|
||||
accessoryPanel.setMaximumSize(MAX_SIZE);
|
||||
}
|
||||
align(accessoryPanel);
|
||||
centerPanel.add(accessoryPanel);
|
||||
accessoryPanel.setInheritsPopupMenu(true);
|
||||
}
|
||||
interior.add(centerPanel);
|
||||
interior.add(Box.createRigidArea(vstrut10));
|
||||
|
||||
// add the filename field PENDING(jeff) - I18N
|
||||
fileNameLabel = new JLabel();
|
||||
populateFileNameLabel();
|
||||
align(fileNameLabel);
|
||||
interior.add(fileNameLabel);
|
||||
|
||||
filenameTextField = new JTextField() {
|
||||
public Dimension getMaximumSize() {
|
||||
Dimension d = super.getMaximumSize();
|
||||
d.height = getPreferredSize().height;
|
||||
return d;
|
||||
}
|
||||
};
|
||||
filenameTextField.setInheritsPopupMenu(true);
|
||||
fileNameLabel.setLabelFor(filenameTextField);
|
||||
filenameTextField.addActionListener(getApproveSelectionAction());
|
||||
align(filenameTextField);
|
||||
filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT);
|
||||
interior.add(filenameTextField);
|
||||
|
||||
bottomPanel = getBottomPanel();
|
||||
bottomPanel.add(new JSeparator(), BorderLayout.NORTH);
|
||||
|
||||
// Add buttons
|
||||
JPanel buttonPanel = new JPanel();
|
||||
align(buttonPanel);
|
||||
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
|
||||
buttonPanel.add(Box.createGlue());
|
||||
|
||||
approveButton = new JButton(getApproveButtonText(fc)) {
|
||||
public Dimension getMaximumSize() {
|
||||
return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
|
||||
}
|
||||
};
|
||||
approveButton.setMnemonic(getApproveButtonMnemonic(fc));
|
||||
approveButton.setToolTipText(getApproveButtonToolTipText(fc));
|
||||
approveButton.setInheritsPopupMenu(true);
|
||||
align(approveButton);
|
||||
approveButton.setMargin(buttonMargin);
|
||||
approveButton.addActionListener(getApproveSelectionAction());
|
||||
buttonPanel.add(approveButton);
|
||||
buttonPanel.add(Box.createGlue());
|
||||
|
||||
JButton updateButton = new JButton(updateButtonText) {
|
||||
public Dimension getMaximumSize() {
|
||||
return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
|
||||
}
|
||||
};
|
||||
updateButton.setMnemonic(updateButtonMnemonic);
|
||||
updateButton.setToolTipText(updateButtonToolTipText);
|
||||
updateButton.setInheritsPopupMenu(true);
|
||||
align(updateButton);
|
||||
updateButton.setMargin(buttonMargin);
|
||||
updateButton.addActionListener(getUpdateAction());
|
||||
buttonPanel.add(updateButton);
|
||||
buttonPanel.add(Box.createGlue());
|
||||
|
||||
JButton cancelButton = new JButton(cancelButtonText) {
|
||||
public Dimension getMaximumSize() {
|
||||
return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
|
||||
}
|
||||
};
|
||||
cancelButton.setMnemonic(cancelButtonMnemonic);
|
||||
cancelButton.setToolTipText(cancelButtonToolTipText);
|
||||
cancelButton.setInheritsPopupMenu(true);
|
||||
align(cancelButton);
|
||||
cancelButton.setMargin(buttonMargin);
|
||||
cancelButton.addActionListener(getCancelSelectionAction());
|
||||
buttonPanel.add(cancelButton);
|
||||
buttonPanel.add(Box.createGlue());
|
||||
|
||||
JButton helpButton = new JButton(helpButtonText) {
|
||||
public Dimension getMaximumSize() {
|
||||
return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
|
||||
}
|
||||
};
|
||||
helpButton.setMnemonic(helpButtonMnemonic);
|
||||
helpButton.setToolTipText(helpButtonToolTipText);
|
||||
align(helpButton);
|
||||
helpButton.setMargin(buttonMargin);
|
||||
helpButton.setEnabled(false);
|
||||
helpButton.setInheritsPopupMenu(true);
|
||||
buttonPanel.add(helpButton);
|
||||
buttonPanel.add(Box.createGlue());
|
||||
buttonPanel.setInheritsPopupMenu(true);
|
||||
|
||||
bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
|
||||
bottomPanel.setInheritsPopupMenu(true);
|
||||
if (fc.getControlButtonsAreShown()) {
|
||||
fc.add(bottomPanel, BorderLayout.SOUTH);
|
||||
}
|
||||
}
|
||||
|
||||
protected JPanel getBottomPanel() {
|
||||
if (bottomPanel == null) {
|
||||
bottomPanel = new JPanel(new BorderLayout(0, 4));
|
||||
}
|
||||
return bottomPanel;
|
||||
}
|
||||
|
||||
private void doControlButtonsChanged(PropertyChangeEvent e) {
|
||||
if (getFileChooser().getControlButtonsAreShown()) {
|
||||
getFileChooser().add(bottomPanel,BorderLayout.SOUTH);
|
||||
} else {
|
||||
getFileChooser().remove(getBottomPanel());
|
||||
}
|
||||
}
|
||||
|
||||
public void uninstallComponents(JFileChooser fc) {
|
||||
fc.removeAll();
|
||||
bottomPanel = null;
|
||||
if (filterComboBoxModel != null) {
|
||||
fc.removePropertyChangeListener(filterComboBoxModel);
|
||||
}
|
||||
}
|
||||
|
||||
protected void installStrings(JFileChooser fc) {
|
||||
super.installStrings(fc);
|
||||
|
||||
Locale l = fc.getLocale();
|
||||
|
||||
enterFolderNameLabelText = UIManager.getString("FileChooser.enterFolderNameLabelText",l);
|
||||
enterFolderNameLabelMnemonic = getMnemonic("FileChooser.enterFolderNameLabelMnemonic", l);
|
||||
enterFileNameLabelText = UIManager.getString("FileChooser.enterFileNameLabelText",l);
|
||||
enterFileNameLabelMnemonic = getMnemonic("FileChooser.enterFileNameLabelMnemonic", l);
|
||||
|
||||
filesLabelText = UIManager.getString("FileChooser.filesLabelText",l);
|
||||
filesLabelMnemonic = getMnemonic("FileChooser.filesLabelMnemonic", l);
|
||||
|
||||
foldersLabelText = UIManager.getString("FileChooser.foldersLabelText",l);
|
||||
foldersLabelMnemonic = getMnemonic("FileChooser.foldersLabelMnemonic", l);
|
||||
|
||||
pathLabelText = UIManager.getString("FileChooser.pathLabelText",l);
|
||||
pathLabelMnemonic = getMnemonic("FileChooser.pathLabelMnemonic", l);
|
||||
|
||||
filterLabelText = UIManager.getString("FileChooser.filterLabelText",l);
|
||||
filterLabelMnemonic = getMnemonic("FileChooser.filterLabelMnemonic", l);
|
||||
}
|
||||
|
||||
private Integer getMnemonic(String key, Locale l) {
|
||||
return SwingUtilities2.getUIDefaultsInt(key, l);
|
||||
}
|
||||
|
||||
protected void installIcons(JFileChooser fc) {
|
||||
// Since motif doesn't have button icons, leave this empty
|
||||
// which overrides the supertype icon loading
|
||||
}
|
||||
|
||||
protected void uninstallIcons(JFileChooser fc) {
|
||||
// Since motif doesn't have button icons, leave this empty
|
||||
// which overrides the supertype icon loading
|
||||
}
|
||||
|
||||
protected JScrollPane createFilesList() {
|
||||
fileList = new JList<File>();
|
||||
|
||||
if(getFileChooser().isMultiSelectionEnabled()) {
|
||||
fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
} else {
|
||||
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
}
|
||||
|
||||
fileList.setModel(new MotifFileListModel());
|
||||
fileList.getSelectionModel().removeSelectionInterval(0, 0);
|
||||
fileList.setCellRenderer(new FileCellRenderer());
|
||||
fileList.addListSelectionListener(createListSelectionListener(getFileChooser()));
|
||||
fileList.addMouseListener(createDoubleClickListener(getFileChooser(), fileList));
|
||||
fileList.addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
JFileChooser chooser = getFileChooser();
|
||||
if (SwingUtilities.isLeftMouseButton(e) && !chooser.isMultiSelectionEnabled()) {
|
||||
int index = SwingUtilities2.loc2IndexFileList(fileList, e.getPoint());
|
||||
if (index >= 0) {
|
||||
File file = fileList.getModel().getElementAt(index);
|
||||
setFileName(chooser.getName(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
align(fileList);
|
||||
JScrollPane scrollpane = new JScrollPane(fileList);
|
||||
scrollpane.setPreferredSize(prefListSize);
|
||||
scrollpane.setMaximumSize(MAX_SIZE);
|
||||
align(scrollpane);
|
||||
fileList.setInheritsPopupMenu(true);
|
||||
scrollpane.setInheritsPopupMenu(true);
|
||||
return scrollpane;
|
||||
}
|
||||
|
||||
protected JScrollPane createDirectoryList() {
|
||||
directoryList = new JList<File>();
|
||||
align(directoryList);
|
||||
|
||||
directoryList.setCellRenderer(new DirectoryCellRenderer());
|
||||
directoryList.setModel(new MotifDirectoryListModel());
|
||||
directoryList.getSelectionModel().removeSelectionInterval(0, 0);
|
||||
directoryList.addMouseListener(createDoubleClickListener(getFileChooser(), directoryList));
|
||||
directoryList.addListSelectionListener(createListSelectionListener(getFileChooser()));
|
||||
directoryList.setInheritsPopupMenu(true);
|
||||
|
||||
JScrollPane scrollpane = new JScrollPane(directoryList);
|
||||
scrollpane.setMaximumSize(MAX_SIZE);
|
||||
scrollpane.setPreferredSize(prefListSize);
|
||||
scrollpane.setInheritsPopupMenu(true);
|
||||
align(scrollpane);
|
||||
return scrollpane;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
Dimension prefSize =
|
||||
(getFileChooser().getAccessory() != null) ? WITH_ACCELERATOR_PREF_SIZE : PREF_SIZE;
|
||||
Dimension d = c.getLayout().preferredLayoutSize(c);
|
||||
if (d != null) {
|
||||
return new Dimension(d.width < prefSize.width ? prefSize.width : d.width,
|
||||
d.height < prefSize.height ? prefSize.height : d.height);
|
||||
} else {
|
||||
return prefSize;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize(JComponent x) {
|
||||
return new Dimension(MIN_WIDTH, MIN_HEIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMaximumSize(JComponent x) {
|
||||
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
protected void align(JComponent c) {
|
||||
c.setAlignmentX(JComponent.LEFT_ALIGNMENT);
|
||||
c.setAlignmentY(JComponent.TOP_ALIGNMENT);
|
||||
}
|
||||
|
||||
protected class FileCellRenderer extends DefaultListCellRenderer {
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
setText(getFileChooser().getName((File) value));
|
||||
setInheritsPopupMenu(true);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected class DirectoryCellRenderer extends DefaultListCellRenderer {
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index,
|
||||
boolean isSelected, boolean cellHasFocus) {
|
||||
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
setText(getFileChooser().getName((File) value));
|
||||
setInheritsPopupMenu(true);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected class MotifDirectoryListModel extends AbstractListModel<File> implements ListDataListener {
|
||||
public MotifDirectoryListModel() {
|
||||
getModel().addListDataListener(this);
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return getModel().getDirectories().size();
|
||||
}
|
||||
|
||||
public File getElementAt(int index) {
|
||||
return getModel().getDirectories().elementAt(index);
|
||||
}
|
||||
|
||||
public void intervalAdded(ListDataEvent e) {
|
||||
fireIntervalAdded(this, e.getIndex0(), e.getIndex1());
|
||||
}
|
||||
|
||||
public void intervalRemoved(ListDataEvent e) {
|
||||
fireIntervalRemoved(this, e.getIndex0(), e.getIndex1());
|
||||
}
|
||||
|
||||
// PENDING(jeff) - this is inefficient - should sent out
|
||||
// incremental adjustment values instead of saying that the
|
||||
// whole list has changed.
|
||||
public void fireContentsChanged() {
|
||||
fireContentsChanged(this, 0, getModel().getDirectories().size()-1);
|
||||
}
|
||||
|
||||
// PENDING(jeff) - fire the correct interval changed - currently sending
|
||||
// out that everything has changed
|
||||
public void contentsChanged(ListDataEvent e) {
|
||||
fireContentsChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected class MotifFileListModel extends AbstractListModel<File> implements ListDataListener {
|
||||
public MotifFileListModel() {
|
||||
getModel().addListDataListener(this);
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return getModel().getFiles().size();
|
||||
}
|
||||
|
||||
public boolean contains(Object o) {
|
||||
return getModel().getFiles().contains(o);
|
||||
}
|
||||
|
||||
public int indexOf(Object o) {
|
||||
return getModel().getFiles().indexOf(o);
|
||||
}
|
||||
|
||||
public File getElementAt(int index) {
|
||||
return getModel().getFiles().elementAt(index);
|
||||
}
|
||||
|
||||
public void intervalAdded(ListDataEvent e) {
|
||||
fireIntervalAdded(this, e.getIndex0(), e.getIndex1());
|
||||
}
|
||||
|
||||
public void intervalRemoved(ListDataEvent e) {
|
||||
fireIntervalRemoved(this, e.getIndex0(), e.getIndex1());
|
||||
}
|
||||
|
||||
// PENDING(jeff) - this is inefficient - should sent out
|
||||
// incremental adjustment values instead of saying that the
|
||||
// whole list has changed.
|
||||
public void fireContentsChanged() {
|
||||
fireContentsChanged(this, 0, getModel().getFiles().size()-1);
|
||||
}
|
||||
|
||||
// PENDING(jeff) - fire the interval changed
|
||||
public void contentsChanged(ListDataEvent e) {
|
||||
fireContentsChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// DataModel for Types Comboxbox
|
||||
//
|
||||
protected FilterComboBoxModel createFilterComboBoxModel() {
|
||||
return new FilterComboBoxModel();
|
||||
}
|
||||
|
||||
//
|
||||
// Renderer for Types ComboBox
|
||||
//
|
||||
protected FilterComboBoxRenderer createFilterComboBoxRenderer() {
|
||||
return new FilterComboBoxRenderer();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render different type sizes and styles.
|
||||
*/
|
||||
public class FilterComboBoxRenderer extends DefaultListCellRenderer {
|
||||
public Component getListCellRendererComponent(JList list,
|
||||
Object value, int index, boolean isSelected,
|
||||
boolean cellHasFocus) {
|
||||
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
if (value != null && value instanceof FileFilter) {
|
||||
setText(((FileFilter)value).getDescription());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data model for a type-face selection combo-box.
|
||||
*/
|
||||
protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
|
||||
PropertyChangeListener {
|
||||
protected FileFilter[] filters;
|
||||
protected FilterComboBoxModel() {
|
||||
super();
|
||||
filters = getFileChooser().getChoosableFileFilters();
|
||||
}
|
||||
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
String prop = e.getPropertyName();
|
||||
if(prop.equals(JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)) {
|
||||
filters = (FileFilter[]) e.getNewValue();
|
||||
fireContentsChanged(this, -1, -1);
|
||||
} else if (prop.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
|
||||
fireContentsChanged(this, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedItem(Object filter) {
|
||||
if(filter != null) {
|
||||
getFileChooser().setFileFilter((FileFilter) filter);
|
||||
fireContentsChanged(this, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
public Object getSelectedItem() {
|
||||
// Ensure that the current filter is in the list.
|
||||
// NOTE: we shouldnt' have to do this, since JFileChooser adds
|
||||
// the filter to the choosable filters list when the filter
|
||||
// is set. Lets be paranoid just in case someone overrides
|
||||
// setFileFilter in JFileChooser.
|
||||
FileFilter currentFilter = getFileChooser().getFileFilter();
|
||||
boolean found = false;
|
||||
if(currentFilter != null) {
|
||||
for (FileFilter filter : filters) {
|
||||
if (filter == currentFilter) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
getFileChooser().addChoosableFileFilter(currentFilter);
|
||||
}
|
||||
}
|
||||
return getFileChooser().getFileFilter();
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
if(filters != null) {
|
||||
return filters.length;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public FileFilter getElementAt(int index) {
|
||||
if(index > getSize() - 1) {
|
||||
// This shouldn't happen. Try to recover gracefully.
|
||||
return getFileChooser().getFileFilter();
|
||||
}
|
||||
if(filters != null) {
|
||||
return filters[index];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected JButton getApproveButton(JFileChooser fc) {
|
||||
return approveButton;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,476 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.Container;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.text.View;
|
||||
|
||||
/*
|
||||
* @author Jeff Dinkins
|
||||
* @author Dave Kloba
|
||||
*/
|
||||
|
||||
public class MotifGraphicsUtils implements SwingConstants
|
||||
{
|
||||
/* Client Property keys for text and accelerator text widths */
|
||||
private static final String MAX_ACC_WIDTH = "maxAccWidth";
|
||||
|
||||
/**
|
||||
* Draws the point (<b>x</b>, <b>y</b>) in the current color.
|
||||
*/
|
||||
static void drawPoint(Graphics g, int x, int y) {
|
||||
g.drawLine(x, y, x, y);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convenience method for drawing a grooved line
|
||||
*
|
||||
*/
|
||||
public static void drawGroove(Graphics g, int x, int y, int w, int h,
|
||||
Color shadow, Color highlight)
|
||||
{
|
||||
Color oldColor = g.getColor(); // Make no net change to g
|
||||
g.translate(x, y);
|
||||
|
||||
g.setColor(shadow);
|
||||
g.drawRect(0, 0, w-2, h-2);
|
||||
|
||||
g.setColor(highlight);
|
||||
g.drawLine(1, h-3, 1, 1);
|
||||
g.drawLine(1, 1, w-3, 1);
|
||||
|
||||
g.drawLine(0, h-1, w-1, h-1);
|
||||
g.drawLine(w-1, h-1, w-1, 0);
|
||||
|
||||
g.translate(-x, -y);
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
|
||||
/** Draws <b>aString</b> in the rectangle defined by
|
||||
* (<b>x</b>, <b>y</b>, <b>width</b>, <b>height</b>).
|
||||
* <b>justification</b> specifies the text's justification, one of
|
||||
* LEFT, CENTER, or RIGHT.
|
||||
* <b>drawStringInRect()</b> does not clip to the rectangle, but instead
|
||||
* uses this rectangle and the desired justification to compute the point
|
||||
* at which to begin drawing the text.
|
||||
* @see #drawString
|
||||
*/
|
||||
public static void drawStringInRect(Graphics g, String aString, int x, int y,
|
||||
int width, int height, int justification) {
|
||||
drawStringInRect(null, g, aString, x, y, width, height, justification);
|
||||
}
|
||||
|
||||
static void drawStringInRect(JComponent c, Graphics g, String aString,
|
||||
int x, int y, int width, int height,
|
||||
int justification) {
|
||||
FontMetrics fontMetrics;
|
||||
int drawWidth, startX, startY, delta;
|
||||
|
||||
if (g.getFont() == null) {
|
||||
// throw new InconsistencyException("No font set");
|
||||
return;
|
||||
}
|
||||
fontMetrics = SwingUtilities2.getFontMetrics(c, g);
|
||||
if (fontMetrics == null) {
|
||||
// throw new InconsistencyException("No metrics for Font " + font());
|
||||
return;
|
||||
}
|
||||
|
||||
if (justification == CENTER) {
|
||||
drawWidth = SwingUtilities2.stringWidth(c, fontMetrics, aString);
|
||||
if (drawWidth > width) {
|
||||
drawWidth = width;
|
||||
}
|
||||
startX = x + (width - drawWidth) / 2;
|
||||
} else if (justification == RIGHT) {
|
||||
drawWidth = SwingUtilities2.stringWidth(c, fontMetrics, aString);
|
||||
if (drawWidth > width) {
|
||||
drawWidth = width;
|
||||
}
|
||||
startX = x + width - drawWidth;
|
||||
} else {
|
||||
startX = x;
|
||||
}
|
||||
|
||||
delta = (height - fontMetrics.getAscent() - fontMetrics.getDescent()) / 2;
|
||||
if (delta < 0) {
|
||||
delta = 0;
|
||||
}
|
||||
|
||||
startY = y + height - delta - fontMetrics.getDescent();
|
||||
|
||||
SwingUtilities2.drawString(c, g, aString, startX, startY);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not being used to paint menu item since
|
||||
* 6.0 This code left for compatibility only. Do not use or
|
||||
* override it, this will not cause any visible effect.
|
||||
*/
|
||||
public static void paintMenuItem(Graphics g, JComponent c,
|
||||
Icon checkIcon, Icon arrowIcon,
|
||||
Color background, Color foreground,
|
||||
int defaultTextIconGap)
|
||||
{
|
||||
|
||||
JMenuItem b = (JMenuItem) c;
|
||||
ButtonModel model = b.getModel();
|
||||
|
||||
Dimension size = b.getSize();
|
||||
Insets i = c.getInsets();
|
||||
|
||||
Rectangle viewRect = new Rectangle(size);
|
||||
|
||||
viewRect.x += i.left;
|
||||
viewRect.y += i.top;
|
||||
viewRect.width -= (i.right + viewRect.x);
|
||||
viewRect.height -= (i.bottom + viewRect.y);
|
||||
|
||||
Rectangle iconRect = new Rectangle();
|
||||
Rectangle textRect = new Rectangle();
|
||||
Rectangle acceleratorRect = new Rectangle();
|
||||
Rectangle checkRect = new Rectangle();
|
||||
Rectangle arrowRect = new Rectangle();
|
||||
|
||||
Font holdf = g.getFont();
|
||||
Font f = c.getFont();
|
||||
g.setFont(f);
|
||||
FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f);
|
||||
FontMetrics fmAccel = SwingUtilities2.getFontMetrics(
|
||||
c, g, UIManager.getFont("MenuItem.acceleratorFont"));
|
||||
|
||||
if (c.isOpaque()) {
|
||||
if (model.isArmed()|| (c instanceof JMenu && model.isSelected())) {
|
||||
g.setColor(background);
|
||||
} else {
|
||||
g.setColor(c.getBackground());
|
||||
}
|
||||
g.fillRect(0,0, size.width, size.height);
|
||||
}
|
||||
|
||||
// get Accelerator text
|
||||
KeyStroke accelerator = b.getAccelerator();
|
||||
String acceleratorText = "";
|
||||
if (accelerator != null) {
|
||||
int modifiers = accelerator.getModifiers();
|
||||
if (modifiers > 0) {
|
||||
acceleratorText = KeyEvent.getKeyModifiersText(modifiers);
|
||||
acceleratorText += "+";
|
||||
}
|
||||
acceleratorText += KeyEvent.getKeyText(accelerator.getKeyCode());
|
||||
}
|
||||
|
||||
// layout the text and icon
|
||||
String text = layoutMenuItem(c, fm, b.getText(), fmAccel,
|
||||
acceleratorText, b.getIcon(),
|
||||
checkIcon, arrowIcon,
|
||||
b.getVerticalAlignment(),
|
||||
b.getHorizontalAlignment(),
|
||||
b.getVerticalTextPosition(),
|
||||
b.getHorizontalTextPosition(),
|
||||
viewRect, iconRect,
|
||||
textRect, acceleratorRect,
|
||||
checkRect, arrowRect,
|
||||
b.getText() == null
|
||||
? 0 : defaultTextIconGap,
|
||||
defaultTextIconGap
|
||||
);
|
||||
|
||||
// Paint the Check
|
||||
Color holdc = g.getColor();
|
||||
if (checkIcon != null) {
|
||||
if(model.isArmed() || (c instanceof JMenu && model.isSelected()))
|
||||
g.setColor(foreground);
|
||||
checkIcon.paintIcon(c, g, checkRect.x, checkRect.y);
|
||||
g.setColor(holdc);
|
||||
}
|
||||
|
||||
// Paint the Icon
|
||||
if(b.getIcon() != null) {
|
||||
Icon icon;
|
||||
if(!model.isEnabled()) {
|
||||
icon = b.getDisabledIcon();
|
||||
} else if(model.isPressed() && model.isArmed()) {
|
||||
icon = b.getPressedIcon();
|
||||
if(icon == null) {
|
||||
// Use default icon
|
||||
icon = b.getIcon();
|
||||
}
|
||||
} else {
|
||||
icon = b.getIcon();
|
||||
}
|
||||
|
||||
if (icon!=null) {
|
||||
icon.paintIcon(c, g, iconRect.x, iconRect.y);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the Text
|
||||
if(text != null && !text.equals("")) {
|
||||
// Once BasicHTML becomes public, use BasicHTML.propertyKey
|
||||
// instead of the hardcoded string below!
|
||||
View v = (View) c.getClientProperty("html");
|
||||
if (v != null) {
|
||||
v.paint(g, textRect);
|
||||
} else {
|
||||
int mnemIndex = b.getDisplayedMnemonicIndex();
|
||||
|
||||
if(!model.isEnabled()) {
|
||||
// *** paint the text disabled
|
||||
g.setColor(b.getBackground().brighter());
|
||||
SwingUtilities2.drawStringUnderlineCharAt(b, g,text,
|
||||
mnemIndex,
|
||||
textRect.x, textRect.y + fmAccel.getAscent());
|
||||
g.setColor(b.getBackground().darker());
|
||||
SwingUtilities2.drawStringUnderlineCharAt(b, g,text,
|
||||
mnemIndex,
|
||||
textRect.x - 1, textRect.y + fmAccel.getAscent() - 1);
|
||||
|
||||
} else {
|
||||
// *** paint the text normally
|
||||
if (model.isArmed()|| (c instanceof JMenu && model.isSelected())) {
|
||||
g.setColor(foreground);
|
||||
} else {
|
||||
g.setColor(b.getForeground());
|
||||
}
|
||||
SwingUtilities2.drawStringUnderlineCharAt(b, g,text,
|
||||
mnemIndex,
|
||||
textRect.x,
|
||||
textRect.y + fm.getAscent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the Accelerator Text
|
||||
if(acceleratorText != null && !acceleratorText.equals("")) {
|
||||
|
||||
//Get the maxAccWidth from the parent to calculate the offset.
|
||||
int accOffset = 0;
|
||||
Container parent = b.getParent();
|
||||
if (parent != null && parent instanceof JComponent) {
|
||||
JComponent p = (JComponent) parent;
|
||||
Integer maxValueInt = (Integer) p.getClientProperty(MotifGraphicsUtils.MAX_ACC_WIDTH);
|
||||
int maxValue = maxValueInt != null ?
|
||||
maxValueInt.intValue() : acceleratorRect.width;
|
||||
|
||||
//Calculate the offset, with which the accelerator texts will be drawn with.
|
||||
accOffset = maxValue - acceleratorRect.width;
|
||||
}
|
||||
|
||||
g.setFont( UIManager.getFont("MenuItem.acceleratorFont") );
|
||||
if(!model.isEnabled()) {
|
||||
// *** paint the acceleratorText disabled
|
||||
g.setColor(b.getBackground().brighter());
|
||||
SwingUtilities2.drawString(c, g,acceleratorText,
|
||||
acceleratorRect.x - accOffset, acceleratorRect.y + fm.getAscent());
|
||||
g.setColor(b.getBackground().darker());
|
||||
SwingUtilities2.drawString(c, g,acceleratorText,
|
||||
acceleratorRect.x - accOffset - 1, acceleratorRect.y + fm.getAscent() - 1);
|
||||
} else {
|
||||
// *** paint the acceleratorText normally
|
||||
if (model.isArmed()|| (c instanceof JMenu && model.isSelected()))
|
||||
{
|
||||
g.setColor(foreground);
|
||||
} else {
|
||||
g.setColor(b.getForeground());
|
||||
}
|
||||
SwingUtilities2.drawString(c, g,acceleratorText,
|
||||
acceleratorRect.x - accOffset,
|
||||
acceleratorRect.y + fmAccel.getAscent());
|
||||
}
|
||||
}
|
||||
|
||||
// Paint the Arrow
|
||||
if (arrowIcon != null) {
|
||||
if(model.isArmed() || (c instanceof JMenu && model.isSelected()))
|
||||
g.setColor(foreground);
|
||||
if( !(b.getParent() instanceof JMenuBar) )
|
||||
arrowIcon.paintIcon(c, g, arrowRect.x, arrowRect.y);
|
||||
}
|
||||
|
||||
g.setColor(holdc);
|
||||
g.setFont(holdf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compute and return the location of the icons origin, the
|
||||
* location of origin of the text baseline, and a possibly clipped
|
||||
* version of the compound labels string. Locations are computed
|
||||
* relative to the viewR rectangle.
|
||||
*/
|
||||
|
||||
private static String layoutMenuItem(
|
||||
JComponent c,
|
||||
FontMetrics fm,
|
||||
String text,
|
||||
FontMetrics fmAccel,
|
||||
String acceleratorText,
|
||||
Icon icon,
|
||||
Icon checkIcon,
|
||||
Icon arrowIcon,
|
||||
int verticalAlignment,
|
||||
int horizontalAlignment,
|
||||
int verticalTextPosition,
|
||||
int horizontalTextPosition,
|
||||
Rectangle viewR,
|
||||
Rectangle iconR,
|
||||
Rectangle textR,
|
||||
Rectangle acceleratorR,
|
||||
Rectangle checkIconR,
|
||||
Rectangle arrowIconR,
|
||||
int textIconGap,
|
||||
int menuItemGap
|
||||
)
|
||||
{
|
||||
|
||||
SwingUtilities.layoutCompoundLabel(c,
|
||||
fm,
|
||||
text,
|
||||
icon,
|
||||
verticalAlignment,
|
||||
horizontalAlignment,
|
||||
verticalTextPosition,
|
||||
horizontalTextPosition,
|
||||
viewR,
|
||||
iconR,
|
||||
textR,
|
||||
textIconGap);
|
||||
|
||||
/* Initialize the acceelratorText bounds rectangle textR. If a null
|
||||
* or and empty String was specified we substitute "" here
|
||||
* and use 0,0,0,0 for acceleratorTextR.
|
||||
*/
|
||||
if( (acceleratorText == null) || acceleratorText.equals("") ) {
|
||||
acceleratorR.width = acceleratorR.height = 0;
|
||||
acceleratorText = "";
|
||||
}
|
||||
else {
|
||||
acceleratorR.width
|
||||
= SwingUtilities2.stringWidth(c, fmAccel, acceleratorText);
|
||||
acceleratorR.height = fmAccel.getHeight();
|
||||
}
|
||||
|
||||
/* Initialize the checkIcon bounds rectangle checkIconR.
|
||||
*/
|
||||
|
||||
if (checkIcon != null) {
|
||||
checkIconR.width = checkIcon.getIconWidth();
|
||||
checkIconR.height = checkIcon.getIconHeight();
|
||||
}
|
||||
else {
|
||||
checkIconR.width = checkIconR.height = 0;
|
||||
}
|
||||
|
||||
/* Initialize the arrowIcon bounds rectangle arrowIconR.
|
||||
*/
|
||||
|
||||
if (arrowIcon != null) {
|
||||
arrowIconR.width = arrowIcon.getIconWidth();
|
||||
arrowIconR.height = arrowIcon.getIconHeight();
|
||||
}
|
||||
else {
|
||||
arrowIconR.width = arrowIconR.height = 0;
|
||||
}
|
||||
|
||||
|
||||
Rectangle labelR = iconR.union(textR);
|
||||
if( MotifGraphicsUtils.isLeftToRight(c) ) {
|
||||
textR.x += checkIconR.width + menuItemGap;
|
||||
iconR.x += checkIconR.width + menuItemGap;
|
||||
|
||||
// Position the Accelerator text rect
|
||||
acceleratorR.x = viewR.x + viewR.width - arrowIconR.width
|
||||
- menuItemGap - acceleratorR.width;
|
||||
|
||||
// Position the Check and Arrow Icons
|
||||
checkIconR.x = viewR.x;
|
||||
arrowIconR.x = viewR.x + viewR.width - menuItemGap
|
||||
- arrowIconR.width;
|
||||
} else {
|
||||
textR.x -= (checkIconR.width + menuItemGap);
|
||||
iconR.x -= (checkIconR.width + menuItemGap);
|
||||
|
||||
// Position the Accelerator text rect
|
||||
acceleratorR.x = viewR.x + arrowIconR.width + menuItemGap;
|
||||
|
||||
// Position the Check and Arrow Icons
|
||||
checkIconR.x = viewR.x + viewR.width - checkIconR.width;
|
||||
arrowIconR.x = viewR.x + menuItemGap;
|
||||
}
|
||||
|
||||
// Align the accelertor text and the check and arrow icons vertically
|
||||
// with the center of the label rect.
|
||||
acceleratorR.y = labelR.y + (labelR.height/2) - (acceleratorR.height/2);
|
||||
arrowIconR.y = labelR.y + (labelR.height/2) - (arrowIconR.height/2);
|
||||
checkIconR.y = labelR.y + (labelR.height/2) - (checkIconR.height/2);
|
||||
|
||||
/*
|
||||
System.out.println("Layout: v=" +viewR+" c="+checkIconR+" i="+
|
||||
iconR+" t="+textR+" acc="+acceleratorR+" a="+arrowIconR);
|
||||
*/
|
||||
return text;
|
||||
}
|
||||
|
||||
private static void drawMenuBezel(Graphics g, Color background,
|
||||
int x, int y,
|
||||
int width, int height)
|
||||
{
|
||||
// shadowed button region
|
||||
g.setColor(background);
|
||||
g.fillRect(x,y,width,height);
|
||||
|
||||
g.setColor(background.brighter().brighter());
|
||||
g.drawLine(x+1, y+height-1, x+width-1, y+height-1);
|
||||
g.drawLine(x+width-1, y+height-2, x+width-1, y+1);
|
||||
|
||||
g.setColor(background.darker().darker());
|
||||
g.drawLine(x, y, x+width-2, y);
|
||||
g.drawLine(x, y+1, x, y+height-2);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Convenience function for determining ComponentOrientation. Helps us
|
||||
* avoid having Munge directives throughout the code.
|
||||
*/
|
||||
static boolean isLeftToRight( Component c ) {
|
||||
return c.getComponentOrientation().isLeftToRight();
|
||||
}
|
||||
}
|
||||
460
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifIconFactory.java
Normal file
460
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifIconFactory.java
Normal file
@@ -0,0 +1,460 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import javax.swing.plaf.UIResource;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Polygon;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Icon factory for the CDE/Motif Look and Feel
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* 1.20 04/27/99
|
||||
* @author Georges Saab
|
||||
*/
|
||||
public class MotifIconFactory implements Serializable
|
||||
{
|
||||
private static Icon checkBoxIcon;
|
||||
private static Icon radioButtonIcon;
|
||||
private static Icon menuItemCheckIcon;
|
||||
private static Icon menuItemArrowIcon;
|
||||
private static Icon menuArrowIcon;
|
||||
|
||||
public static Icon getMenuItemCheckIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Icon getMenuItemArrowIcon() {
|
||||
if (menuItemArrowIcon == null) {
|
||||
menuItemArrowIcon = new MenuItemArrowIcon();
|
||||
}
|
||||
return menuItemArrowIcon;
|
||||
}
|
||||
|
||||
public static Icon getMenuArrowIcon() {
|
||||
if (menuArrowIcon == null) {
|
||||
menuArrowIcon = new MenuArrowIcon();
|
||||
}
|
||||
return menuArrowIcon;
|
||||
}
|
||||
|
||||
public static Icon getCheckBoxIcon() {
|
||||
if (checkBoxIcon == null) {
|
||||
checkBoxIcon = new CheckBoxIcon();
|
||||
}
|
||||
return checkBoxIcon;
|
||||
}
|
||||
|
||||
public static Icon getRadioButtonIcon() {
|
||||
if (radioButtonIcon == null) {
|
||||
radioButtonIcon = new RadioButtonIcon();
|
||||
}
|
||||
return radioButtonIcon;
|
||||
}
|
||||
|
||||
private static class CheckBoxIcon implements Icon, UIResource, Serializable {
|
||||
final static int csize = 13;
|
||||
|
||||
private Color control = UIManager.getColor("control");
|
||||
private Color foreground = UIManager.getColor("CheckBox.foreground");
|
||||
private Color shadow = UIManager.getColor("controlShadow");
|
||||
private Color highlight = UIManager.getColor("controlHighlight");
|
||||
private Color lightShadow = UIManager.getColor("controlLightShadow");
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
AbstractButton b = (AbstractButton) c;
|
||||
ButtonModel model = b.getModel();
|
||||
|
||||
boolean flat = false;
|
||||
|
||||
if(b instanceof JCheckBox) {
|
||||
flat = ((JCheckBox)b).isBorderPaintedFlat();
|
||||
}
|
||||
|
||||
boolean isPressed = model.isPressed();
|
||||
boolean isArmed = model.isArmed();
|
||||
boolean isEnabled = model.isEnabled();
|
||||
boolean isSelected = model.isSelected();
|
||||
|
||||
// There are 4 "looks" to the Motif CheckBox:
|
||||
// drawCheckBezelOut - default unchecked state
|
||||
// drawBezel - when we uncheck in toggled state
|
||||
// drawCheckBezel - when we check in toggle state
|
||||
// drawCheckBezelIn - selected, mouseReleased
|
||||
boolean checkToggleIn = ((isPressed &&
|
||||
!isArmed &&
|
||||
isSelected) ||
|
||||
(isPressed &&
|
||||
isArmed &&
|
||||
!isSelected));
|
||||
boolean uncheckToggleOut = ((isPressed &&
|
||||
!isArmed &&
|
||||
!isSelected) ||
|
||||
(isPressed &&
|
||||
isArmed &&
|
||||
isSelected));
|
||||
|
||||
boolean checkIn = (!isPressed &&
|
||||
isArmed &&
|
||||
isSelected ||
|
||||
(!isPressed &&
|
||||
!isArmed &&
|
||||
isSelected));
|
||||
|
||||
|
||||
if(flat) {
|
||||
g.setColor(shadow);
|
||||
g.drawRect(x+2,y,csize-1,csize-1);
|
||||
if(uncheckToggleOut || checkToggleIn) {
|
||||
g.setColor(control);
|
||||
g.fillRect(x+3,y+1,csize-2,csize-2);
|
||||
}
|
||||
}
|
||||
|
||||
if (checkToggleIn) {
|
||||
// toggled from unchecked to checked
|
||||
drawCheckBezel(g,x,y,csize,true,false,false,flat);
|
||||
} else if (uncheckToggleOut) {
|
||||
// MotifBorderFactory.drawBezel(g,x,y,csize,csize,false,false);
|
||||
drawCheckBezel(g,x,y,csize,true,true,false,flat);
|
||||
} else if (checkIn) {
|
||||
// show checked, unpressed state
|
||||
drawCheckBezel(g,x,y,csize,false,false,true,flat);
|
||||
} else if(!flat) {
|
||||
// show unchecked state
|
||||
drawCheckBezelOut(g,x,y,csize);
|
||||
}
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
return csize;
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
return csize;
|
||||
}
|
||||
|
||||
public void drawCheckBezelOut(Graphics g, int x, int y, int csize){
|
||||
Color controlShadow = UIManager.getColor("controlShadow");
|
||||
|
||||
int w = csize;
|
||||
int h = csize;
|
||||
Color oldColor = g.getColor();
|
||||
|
||||
g.translate(x,y);
|
||||
g.setColor(highlight); // inner 3D border
|
||||
g.drawLine(0, 0, 0, h-1);
|
||||
g.drawLine(1, 0, w-1, 0);
|
||||
|
||||
g.setColor(shadow); // black drop shadow __|
|
||||
g.drawLine(1, h-1, w-1, h-1);
|
||||
g.drawLine(w-1, h-1, w-1, 1);
|
||||
g.translate(-x,-y);
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
|
||||
public void drawCheckBezel(Graphics g, int x, int y, int csize,
|
||||
boolean shade, boolean out, boolean check, boolean flat)
|
||||
{
|
||||
|
||||
|
||||
Color oldColor = g.getColor();
|
||||
g.translate(x, y);
|
||||
|
||||
|
||||
//bottom
|
||||
if(!flat) {
|
||||
if (out) {
|
||||
g.setColor(control);
|
||||
g.fillRect(1,1,csize-2,csize-2);
|
||||
g.setColor(shadow);
|
||||
} else {
|
||||
g.setColor(lightShadow);
|
||||
g.fillRect(0,0,csize,csize);
|
||||
g.setColor(highlight);
|
||||
}
|
||||
|
||||
g.drawLine(1,csize-1,csize-2,csize-1);
|
||||
if (shade) {
|
||||
g.drawLine(2,csize-2,csize-3,csize-2);
|
||||
g.drawLine(csize-2,2,csize-2 ,csize-1);
|
||||
if (out) {
|
||||
g.setColor(highlight);
|
||||
} else {
|
||||
g.setColor(shadow);
|
||||
}
|
||||
g.drawLine(1,2,1,csize-2);
|
||||
g.drawLine(1,1,csize-3,1);
|
||||
if (out) {
|
||||
g.setColor(shadow);
|
||||
} else {
|
||||
g.setColor(highlight);
|
||||
}
|
||||
}
|
||||
//right
|
||||
g.drawLine(csize-1,1,csize-1,csize-1);
|
||||
|
||||
//left
|
||||
if (out) {
|
||||
g.setColor(highlight);
|
||||
} else {
|
||||
g.setColor(shadow);
|
||||
}
|
||||
g.drawLine(0,1,0,csize-1);
|
||||
|
||||
//top
|
||||
g.drawLine(0,0,csize-1,0);
|
||||
}
|
||||
|
||||
if (check) {
|
||||
// draw check
|
||||
g.setColor(foreground);
|
||||
g.drawLine(csize-2,1,csize-2,2);
|
||||
g.drawLine(csize-3,2,csize-3,3);
|
||||
g.drawLine(csize-4,3,csize-4,4);
|
||||
g.drawLine(csize-5,4,csize-5,6);
|
||||
g.drawLine(csize-6,5,csize-6,8);
|
||||
g.drawLine(csize-7,6,csize-7,10);
|
||||
g.drawLine(csize-8,7,csize-8,10);
|
||||
g.drawLine(csize-9,6,csize-9,9);
|
||||
g.drawLine(csize-10,5,csize-10,8);
|
||||
g.drawLine(csize-11,5,csize-11,7);
|
||||
g.drawLine(csize-12,6,csize-12,6);
|
||||
}
|
||||
g.translate(-x, -y);
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
} // end class CheckBoxIcon
|
||||
|
||||
private static class RadioButtonIcon implements Icon, UIResource, Serializable {
|
||||
private Color dot = UIManager.getColor("activeCaptionBorder");
|
||||
private Color highlight = UIManager.getColor("controlHighlight");
|
||||
private Color shadow = UIManager.getColor("controlShadow");
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
// fill interior
|
||||
AbstractButton b = (AbstractButton) c;
|
||||
ButtonModel model = b.getModel();
|
||||
|
||||
int w = getIconWidth();
|
||||
int h = getIconHeight();
|
||||
|
||||
boolean isPressed = model.isPressed();
|
||||
boolean isArmed = model.isArmed();
|
||||
boolean isEnabled = model.isEnabled();
|
||||
boolean isSelected = model.isSelected();
|
||||
|
||||
boolean checkIn = ((isPressed &&
|
||||
!isArmed &&
|
||||
isSelected) ||
|
||||
(isPressed &&
|
||||
isArmed &&
|
||||
!isSelected)
|
||||
||
|
||||
(!isPressed &&
|
||||
isArmed &&
|
||||
isSelected ||
|
||||
(!isPressed &&
|
||||
!isArmed &&
|
||||
isSelected)));
|
||||
|
||||
if (checkIn){
|
||||
g.setColor(shadow);
|
||||
g.drawLine(x+5,y+0,x+8,y+0);
|
||||
g.drawLine(x+3,y+1,x+4,y+1);
|
||||
g.drawLine(x+9,y+1,x+9,y+1);
|
||||
g.drawLine(x+2,y+2,x+2,y+2);
|
||||
g.drawLine(x+1,y+3,x+1,y+3);
|
||||
g.drawLine(x,y+4,x,y+9);
|
||||
g.drawLine(x+1,y+10,x+1,y+10);
|
||||
g.drawLine(x+2,y+11,x+2,y+11);
|
||||
g.setColor(highlight);
|
||||
g.drawLine(x+3,y+12,x+4,y+12);
|
||||
g.drawLine(x+5,y+13,x+8,y+13);
|
||||
g.drawLine(x+9,y+12,x+10,y+12);
|
||||
g.drawLine(x+11,y+11,x+11,y+11);
|
||||
g.drawLine(x+12,y+10,x+12,y+10);
|
||||
g.drawLine(x+13,y+9,x+13,y+4);
|
||||
g.drawLine(x+12,y+3,x+12,y+3);
|
||||
g.drawLine(x+11,y+2,x+11,y+2);
|
||||
g.drawLine(x+10,y+1,x+10,y+1);
|
||||
g.setColor(dot);
|
||||
g.fillRect(x+4,y+5,6,4);
|
||||
g.drawLine(x+5,y+4,x+8,y+4);
|
||||
g.drawLine(x+5,y+9,x+8,y+9);
|
||||
}
|
||||
else {
|
||||
g.setColor(highlight);
|
||||
g.drawLine(x+5,y+0,x+8,y+0);
|
||||
g.drawLine(x+3,y+1,x+4,y+1);
|
||||
g.drawLine(x+9,y+1,x+9,y+1);
|
||||
g.drawLine(x+2,y+2,x+2,y+2);
|
||||
g.drawLine(x+1,y+3,x+1,y+3);
|
||||
g.drawLine(x,y+4,x,y+9);
|
||||
g.drawLine(x+1,y+10,x+1,y+10);
|
||||
g.drawLine(x+2,y+11,x+2,y+11);
|
||||
|
||||
g.setColor(shadow);
|
||||
g.drawLine(x+3,y+12,x+4,y+12);
|
||||
g.drawLine(x+5,y+13,x+8,y+13);
|
||||
g.drawLine(x+9,y+12,x+10,y+12);
|
||||
g.drawLine(x+11,y+11,x+11,y+11);
|
||||
g.drawLine(x+12,y+10,x+12,y+10);
|
||||
g.drawLine(x+13,y+9,x+13,y+4);
|
||||
g.drawLine(x+12,y+3,x+12,y+3);
|
||||
g.drawLine(x+11,y+2,x+11,y+2);
|
||||
g.drawLine(x+10,y+1,x+10,y+1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
return 14;
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
return 14;
|
||||
}
|
||||
} // end class RadioButtonIcon
|
||||
|
||||
private static class MenuItemCheckIcon implements Icon, UIResource, Serializable
|
||||
{
|
||||
public void paintIcon(Component c,Graphics g, int x, int y)
|
||||
{
|
||||
}
|
||||
public int getIconWidth() { return 0; }
|
||||
public int getIconHeight() { return 0; }
|
||||
} // end class MenuItemCheckIcon
|
||||
|
||||
|
||||
private static class MenuItemArrowIcon implements Icon, UIResource, Serializable
|
||||
{
|
||||
public void paintIcon(Component c,Graphics g, int x, int y)
|
||||
{
|
||||
}
|
||||
public int getIconWidth() { return 0; }
|
||||
public int getIconHeight() { return 0; }
|
||||
} // end class MenuItemArrowIcon
|
||||
|
||||
private static class MenuArrowIcon implements Icon, UIResource, Serializable
|
||||
{
|
||||
private Color focus = UIManager.getColor("windowBorder");
|
||||
private Color shadow = UIManager.getColor("controlShadow");
|
||||
private Color highlight = UIManager.getColor("controlHighlight");
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
AbstractButton b = (AbstractButton) c;
|
||||
ButtonModel model = b.getModel();
|
||||
|
||||
// These variables are kind of pointless as the following code
|
||||
// assumes the icon will be 10 x 10 regardless of their value.
|
||||
int w = getIconWidth();
|
||||
int h = getIconHeight();
|
||||
|
||||
Color oldColor = g.getColor();
|
||||
|
||||
if (model.isSelected()){
|
||||
if( MotifGraphicsUtils.isLeftToRight(c) ){
|
||||
g.setColor(shadow);
|
||||
g.fillRect(x+1,y+1,2,h);
|
||||
g.drawLine(x+4,y+2,x+4,y+2);
|
||||
g.drawLine(x+6,y+3,x+6,y+3);
|
||||
g.drawLine(x+8,y+4,x+8,y+5);
|
||||
g.setColor(focus);
|
||||
g.fillRect(x+2,y+2,2,h-2);
|
||||
g.fillRect(x+4,y+3,2,h-4);
|
||||
g.fillRect(x+6,y+4,2,h-6);
|
||||
g.setColor(highlight);
|
||||
g.drawLine(x+2,y+h,x+2,y+h);
|
||||
g.drawLine(x+4,y+h-1,x+4,y+h-1);
|
||||
g.drawLine(x+6,y+h-2,x+6,y+h-2);
|
||||
g.drawLine(x+8,y+h-4,x+8,y+h-3);
|
||||
} else {
|
||||
g.setColor(highlight);
|
||||
g.fillRect(x+7,y+1,2,10);
|
||||
g.drawLine(x+5,y+9,x+5,y+9);
|
||||
g.drawLine(x+3,y+8,x+3,y+8);
|
||||
g.drawLine(x+1,y+6,x+1,y+7);
|
||||
g.setColor(focus);
|
||||
g.fillRect(x+6,y+2,2,8);
|
||||
g.fillRect(x+4,y+3,2,6);
|
||||
g.fillRect(x+2,y+4,2,4);
|
||||
g.setColor(shadow);
|
||||
g.drawLine(x+1,y+4,x+1,y+5);
|
||||
g.drawLine(x+3,y+3,x+3,y+3);
|
||||
g.drawLine(x+5,y+2,x+5,y+2);
|
||||
g.drawLine(x+7,y+1,x+7,y+1);
|
||||
}
|
||||
} else {
|
||||
if( MotifGraphicsUtils.isLeftToRight(c) ){
|
||||
g.setColor(highlight);
|
||||
g.drawLine(x+1,y+1,x+1,y+h);
|
||||
g.drawLine(x+2,y+1,x+2,y+h-2);
|
||||
g.fillRect(x+3,y+2,2,2);
|
||||
g.fillRect(x+5,y+3,2,2);
|
||||
g.fillRect(x+7,y+4,2,2);
|
||||
g.setColor(shadow);
|
||||
g.drawLine(x+2,y+h-1,x+2,y+h);
|
||||
g.fillRect(x+3,y+h-2,2,2);
|
||||
g.fillRect(x+5,y+h-3,2,2);
|
||||
g.fillRect(x+7,y+h-4,2,2);
|
||||
g.setColor(oldColor);
|
||||
} else {
|
||||
g.setColor(highlight);
|
||||
g.fillRect(x+1,y+4,2,2);
|
||||
g.fillRect(x+3,y+3,2,2);
|
||||
g.fillRect(x+5,y+2,2,2);
|
||||
g.drawLine(x+7,y+1,x+7,y+2);
|
||||
g.setColor(shadow);
|
||||
g.fillRect(x+1,y+h-4,2,2);
|
||||
g.fillRect(x+3,y+h-3,2,2);
|
||||
g.fillRect(x+5,y+h-2,2,2);
|
||||
g.drawLine(x+7,y+3,x+7,y+h);
|
||||
g.drawLine(x+8,y+1,x+8,y+h);
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public int getIconWidth() { return 10; }
|
||||
public int getIconHeight() { return 10; }
|
||||
} // End class MenuArrowIcon
|
||||
}
|
||||
@@ -0,0 +1,389 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.event.InternalFrameEvent;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import java.util.EventListener;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.VetoableChangeListener;
|
||||
import java.beans.PropertyVetoException;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.AWTAccessor.MouseEventAccessor;
|
||||
|
||||
/**
|
||||
* Class that manages a Motif title bar
|
||||
*
|
||||
* @since 1.3
|
||||
*/
|
||||
public class MotifInternalFrameTitlePane
|
||||
extends BasicInternalFrameTitlePane implements LayoutManager, ActionListener, PropertyChangeListener
|
||||
{
|
||||
SystemButton systemButton;
|
||||
MinimizeButton minimizeButton;
|
||||
MaximizeButton maximizeButton;
|
||||
JPopupMenu systemMenu;
|
||||
Title title;
|
||||
Color color;
|
||||
Color highlight;
|
||||
Color shadow;
|
||||
|
||||
// The width and height of a title pane button
|
||||
public final static int BUTTON_SIZE = 19; // 17 + 1 pixel border
|
||||
|
||||
|
||||
public MotifInternalFrameTitlePane(JInternalFrame frame) {
|
||||
super(frame);
|
||||
}
|
||||
|
||||
protected void installDefaults() {
|
||||
setFont(UIManager.getFont("InternalFrame.titleFont"));
|
||||
setPreferredSize(new Dimension(100, BUTTON_SIZE));
|
||||
}
|
||||
|
||||
protected void uninstallListeners() {
|
||||
// Get around protected method in superclass
|
||||
super.uninstallListeners();
|
||||
}
|
||||
|
||||
protected PropertyChangeListener createPropertyChangeListener() {
|
||||
return this;
|
||||
}
|
||||
|
||||
protected LayoutManager createLayout() {
|
||||
return this;
|
||||
}
|
||||
|
||||
JPopupMenu getSystemMenu() {
|
||||
return systemMenu;
|
||||
}
|
||||
|
||||
protected void assembleSystemMenu() {
|
||||
systemMenu = new JPopupMenu();
|
||||
JMenuItem mi = systemMenu.add(restoreAction);
|
||||
mi.setMnemonic(getButtonMnemonic("restore"));
|
||||
mi = systemMenu.add(moveAction);
|
||||
mi.setMnemonic(getButtonMnemonic("move"));
|
||||
mi = systemMenu.add(sizeAction);
|
||||
mi.setMnemonic(getButtonMnemonic("size"));
|
||||
mi = systemMenu.add(iconifyAction);
|
||||
mi.setMnemonic(getButtonMnemonic("minimize"));
|
||||
mi = systemMenu.add(maximizeAction);
|
||||
mi.setMnemonic(getButtonMnemonic("maximize"));
|
||||
systemMenu.add(new JSeparator());
|
||||
mi = systemMenu.add(closeAction);
|
||||
mi.setMnemonic(getButtonMnemonic("close"));
|
||||
|
||||
systemButton = new SystemButton();
|
||||
systemButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
systemMenu.show(systemButton, 0, BUTTON_SIZE);
|
||||
}
|
||||
});
|
||||
|
||||
systemButton.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent evt) {
|
||||
try {
|
||||
frame.setSelected(true);
|
||||
} catch (PropertyVetoException pve) {
|
||||
}
|
||||
if ((evt.getClickCount() == 2)) {
|
||||
closeAction.actionPerformed(new
|
||||
ActionEvent(evt.getSource(),
|
||||
ActionEvent.ACTION_PERFORMED,
|
||||
null, evt.getWhen(), 0));
|
||||
systemMenu.setVisible(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static int getButtonMnemonic(String button) {
|
||||
try {
|
||||
return Integer.parseInt(UIManager.getString(
|
||||
"InternalFrameTitlePane." + button + "Button.mnemonic"));
|
||||
} catch (NumberFormatException e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
protected void createButtons() {
|
||||
minimizeButton = new MinimizeButton();
|
||||
minimizeButton.addActionListener(iconifyAction);
|
||||
|
||||
maximizeButton = new MaximizeButton();
|
||||
maximizeButton.addActionListener(maximizeAction);
|
||||
}
|
||||
|
||||
|
||||
protected void addSubComponents() {
|
||||
title = new Title(frame.getTitle());
|
||||
title.setFont(getFont());
|
||||
|
||||
add(systemButton);
|
||||
add(title);
|
||||
add(minimizeButton);
|
||||
add(maximizeButton);
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
}
|
||||
|
||||
void setColors(Color c, Color h, Color s) {
|
||||
color = c;
|
||||
highlight = h;
|
||||
shadow = s;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
}
|
||||
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String prop = evt.getPropertyName();
|
||||
JInternalFrame f = (JInternalFrame)evt.getSource();
|
||||
boolean value = false;
|
||||
if (JInternalFrame.IS_SELECTED_PROPERTY.equals(prop)) {
|
||||
repaint();
|
||||
} else if (prop.equals("maximizable")) {
|
||||
if ((Boolean)evt.getNewValue() == Boolean.TRUE)
|
||||
add(maximizeButton);
|
||||
else
|
||||
remove(maximizeButton);
|
||||
revalidate();
|
||||
repaint();
|
||||
} else if (prop.equals("iconable")) {
|
||||
if ((Boolean)evt.getNewValue() == Boolean.TRUE)
|
||||
add(minimizeButton);
|
||||
else
|
||||
remove(minimizeButton);
|
||||
revalidate();
|
||||
repaint();
|
||||
} else if (prop.equals(JInternalFrame.TITLE_PROPERTY)) {
|
||||
repaint();
|
||||
}
|
||||
enableActions();
|
||||
}
|
||||
|
||||
public void addLayoutComponent(String name, Component c) {}
|
||||
public void removeLayoutComponent(Component c) {}
|
||||
public Dimension preferredLayoutSize(Container c) {
|
||||
return minimumLayoutSize(c);
|
||||
}
|
||||
|
||||
public Dimension minimumLayoutSize(Container c) {
|
||||
return new Dimension(100, BUTTON_SIZE);
|
||||
}
|
||||
|
||||
public void layoutContainer(Container c) {
|
||||
int w = getWidth();
|
||||
systemButton.setBounds(0, 0, BUTTON_SIZE, BUTTON_SIZE);
|
||||
int x = w - BUTTON_SIZE;
|
||||
|
||||
if(frame.isMaximizable()) {
|
||||
maximizeButton.setBounds(x, 0, BUTTON_SIZE, BUTTON_SIZE);
|
||||
x -= BUTTON_SIZE;
|
||||
} else if(maximizeButton.getParent() != null) {
|
||||
maximizeButton.getParent().remove(maximizeButton);
|
||||
}
|
||||
|
||||
if(frame.isIconifiable()) {
|
||||
minimizeButton.setBounds(x, 0, BUTTON_SIZE, BUTTON_SIZE);
|
||||
x -= BUTTON_SIZE;
|
||||
} else if(minimizeButton.getParent() != null) {
|
||||
minimizeButton.getParent().remove(minimizeButton);
|
||||
}
|
||||
|
||||
title.setBounds(BUTTON_SIZE, 0, x, BUTTON_SIZE);
|
||||
}
|
||||
|
||||
protected void showSystemMenu(){
|
||||
systemMenu.show(systemButton, 0, BUTTON_SIZE);
|
||||
}
|
||||
|
||||
protected void hideSystemMenu(){
|
||||
systemMenu.setVisible(false);
|
||||
}
|
||||
|
||||
static Dimension buttonDimension = new Dimension(BUTTON_SIZE, BUTTON_SIZE);
|
||||
|
||||
private abstract class FrameButton extends JButton {
|
||||
|
||||
FrameButton() {
|
||||
super();
|
||||
setFocusPainted(false);
|
||||
setBorderPainted(false);
|
||||
}
|
||||
|
||||
public boolean isFocusTraversable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void requestFocus() {
|
||||
// ignore request.
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize() {
|
||||
return buttonDimension;
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return buttonDimension;
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
Dimension d = getSize();
|
||||
int maxX = d.width - 1;
|
||||
int maxY = d.height - 1;
|
||||
|
||||
// draw background
|
||||
g.setColor(color);
|
||||
g.fillRect(1, 1, d.width, d.height);
|
||||
|
||||
// draw border
|
||||
boolean pressed = getModel().isPressed();
|
||||
g.setColor(pressed ? shadow : highlight);
|
||||
g.drawLine(0, 0, maxX, 0);
|
||||
g.drawLine(0, 0, 0, maxY);
|
||||
g.setColor(pressed ? highlight : shadow);
|
||||
g.drawLine(1, maxY, maxX, maxY);
|
||||
g.drawLine(maxX, 1, maxX, maxY);
|
||||
}
|
||||
}
|
||||
|
||||
private class MinimizeButton extends FrameButton {
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
g.setColor(highlight);
|
||||
g.drawLine(7, 8, 7, 11);
|
||||
g.drawLine(7, 8, 10, 8);
|
||||
g.setColor(shadow);
|
||||
g.drawLine(8, 11, 10, 11);
|
||||
g.drawLine(11, 9, 11, 11);
|
||||
}
|
||||
}
|
||||
|
||||
private class MaximizeButton extends FrameButton {
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
int max = BUTTON_SIZE - 5;
|
||||
boolean isMaxed = frame.isMaximum();
|
||||
g.setColor(isMaxed ? shadow : highlight);
|
||||
g.drawLine(4, 4, 4, max);
|
||||
g.drawLine(4, 4, max, 4);
|
||||
g.setColor(isMaxed ? highlight : shadow);
|
||||
g.drawLine(5, max, max, max);
|
||||
g.drawLine(max, 5, max, max);
|
||||
}
|
||||
}
|
||||
|
||||
private class SystemButton extends FrameButton {
|
||||
public boolean isFocusTraversable() { return false; }
|
||||
public void requestFocus() {}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
g.setColor(highlight);
|
||||
g.drawLine(4, 8, 4, 11);
|
||||
g.drawLine(4, 8, BUTTON_SIZE - 5, 8);
|
||||
g.setColor(shadow);
|
||||
g.drawLine(5, 11, BUTTON_SIZE - 5, 11);
|
||||
g.drawLine(BUTTON_SIZE - 5, 9, BUTTON_SIZE - 5, 11);
|
||||
}
|
||||
}
|
||||
|
||||
private class Title extends FrameButton {
|
||||
Title(String title) {
|
||||
super();
|
||||
setText(title);
|
||||
setHorizontalAlignment(SwingConstants.CENTER);
|
||||
setBorder(BorderFactory.createBevelBorder(
|
||||
BevelBorder.RAISED,
|
||||
UIManager.getColor("activeCaptionBorder"),
|
||||
UIManager.getColor("inactiveCaptionBorder")));
|
||||
|
||||
// Forward mouse events to titlebar for moves.
|
||||
addMouseMotionListener(new MouseMotionListener() {
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
});
|
||||
addMouseListener(new MouseListener() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
public void mouseExited(MouseEvent e) {
|
||||
forwardEventToParent(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void forwardEventToParent(MouseEvent e) {
|
||||
MouseEvent newEvent = new MouseEvent(
|
||||
getParent(), e.getID(), e.getWhen(), e.getModifiers(),
|
||||
e.getX(), e.getY(), e.getXOnScreen(),
|
||||
e.getYOnScreen(), e.getClickCount(),
|
||||
e.isPopupTrigger(), MouseEvent.NOBUTTON);
|
||||
MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor();
|
||||
meAccessor.setCausedByTouchEvent(newEvent,
|
||||
meAccessor.isCausedByTouchEvent(e));
|
||||
getParent().dispatchEvent(newEvent);
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
if (frame.isSelected()) {
|
||||
g.setColor(UIManager.getColor("activeCaptionText"));
|
||||
} else {
|
||||
g.setColor(UIManager.getColor("inactiveCaptionText"));
|
||||
}
|
||||
Dimension d = getSize();
|
||||
String frameTitle = frame.getTitle();
|
||||
if (frameTitle != null) {
|
||||
MotifGraphicsUtils.drawStringInRect(frame, g, frameTitle,
|
||||
0, 0, d.width, d.height,
|
||||
SwingConstants.CENTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
|
||||
/**
|
||||
* A Motif L&F implementation of InternalFrame.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Tom Ball
|
||||
*/
|
||||
public class MotifInternalFrameUI extends BasicInternalFrameUI {
|
||||
|
||||
Color color;
|
||||
Color highlight;
|
||||
Color shadow;
|
||||
MotifInternalFrameTitlePane titlePane;
|
||||
|
||||
/**
|
||||
* As of Java 2 platform v1.3 this previously undocumented field is no
|
||||
* longer used.
|
||||
* Key bindings are now defined by the LookAndFeel, please refer to
|
||||
* the key bindings specification for further details.
|
||||
*
|
||||
* @deprecated As of Java 2 platform v1.3.
|
||||
*/
|
||||
@Deprecated
|
||||
protected KeyStroke closeMenuKey;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// ComponentUI Interface Implementation methods
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
public static ComponentUI createUI(JComponent w) {
|
||||
return new MotifInternalFrameUI((JInternalFrame)w);
|
||||
}
|
||||
|
||||
public MotifInternalFrameUI(JInternalFrame w) {
|
||||
super(w);
|
||||
}
|
||||
|
||||
public void installUI(JComponent c) {
|
||||
super.installUI(c);
|
||||
setColors((JInternalFrame)c);
|
||||
}
|
||||
|
||||
protected void installDefaults() {
|
||||
Border frameBorder = frame.getBorder();
|
||||
frame.setLayout(internalFrameLayout = createLayoutManager());
|
||||
if (frameBorder == null || frameBorder instanceof UIResource) {
|
||||
frame.setBorder(new MotifBorders.InternalFrameBorder(frame));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void installKeyboardActions(){
|
||||
super.installKeyboardActions();
|
||||
// We replace the
|
||||
// we use JPopup in our TitlePane so need escape support
|
||||
closeMenuKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
|
||||
}
|
||||
|
||||
|
||||
protected void uninstallDefaults() {
|
||||
LookAndFeel.uninstallBorder(frame);
|
||||
frame.setLayout(null);
|
||||
internalFrameLayout = null;
|
||||
}
|
||||
|
||||
private JInternalFrame getFrame(){
|
||||
return frame;
|
||||
}
|
||||
|
||||
public JComponent createNorthPane(JInternalFrame w) {
|
||||
titlePane = new MotifInternalFrameTitlePane(w);
|
||||
return titlePane;
|
||||
}
|
||||
|
||||
public Dimension getMaximumSize(JComponent x) {
|
||||
return Toolkit.getDefaultToolkit().getScreenSize();
|
||||
}
|
||||
|
||||
protected void uninstallKeyboardActions(){
|
||||
super.uninstallKeyboardActions();
|
||||
if (isKeyBindingRegistered()){
|
||||
JInternalFrame.JDesktopIcon di = frame.getDesktopIcon();
|
||||
SwingUtilities.replaceUIActionMap(di, null);
|
||||
SwingUtilities.replaceUIInputMap(di, JComponent.WHEN_IN_FOCUSED_WINDOW,
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setupMenuOpenKey(){
|
||||
super.setupMenuOpenKey();
|
||||
ActionMap map = SwingUtilities.getUIActionMap(frame);
|
||||
if (map != null) {
|
||||
// BasicInternalFrameUI creates an action with the same name, we override
|
||||
// it as MotifInternalFrameTitlePane has a titlePane ivar that shadows the
|
||||
// titlePane ivar in BasicInternalFrameUI, making supers action throw
|
||||
// an NPE for us.
|
||||
map.put("showSystemMenu", new AbstractAction(){
|
||||
public void actionPerformed(ActionEvent e){
|
||||
titlePane.showSystemMenu();
|
||||
}
|
||||
public boolean isEnabled(){
|
||||
return isKeyBindingActive();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void setupMenuCloseKey(){
|
||||
ActionMap map = SwingUtilities.getUIActionMap(frame);
|
||||
if (map != null) {
|
||||
map.put("hideSystemMenu", new AbstractAction(){
|
||||
public void actionPerformed(ActionEvent e){
|
||||
titlePane.hideSystemMenu();
|
||||
}
|
||||
public boolean isEnabled(){
|
||||
return isKeyBindingActive();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Set up the bindings for the DesktopIcon, it is odd that
|
||||
// we install them, and not the desktop icon.
|
||||
JInternalFrame.JDesktopIcon di = frame.getDesktopIcon();
|
||||
InputMap diInputMap = SwingUtilities.getUIInputMap
|
||||
(di, JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
if (diInputMap == null) {
|
||||
Object[] bindings = (Object[])UIManager.get
|
||||
("DesktopIcon.windowBindings");
|
||||
if (bindings != null) {
|
||||
diInputMap = LookAndFeel.makeComponentInputMap(di, bindings);
|
||||
|
||||
SwingUtilities.replaceUIInputMap(di, JComponent.
|
||||
WHEN_IN_FOCUSED_WINDOW,
|
||||
diInputMap);
|
||||
}
|
||||
}
|
||||
ActionMap diActionMap = SwingUtilities.getUIActionMap(di);
|
||||
if (diActionMap == null) {
|
||||
diActionMap = new ActionMapUIResource();
|
||||
diActionMap.put("hideSystemMenu", new AbstractAction(){
|
||||
public void actionPerformed(ActionEvent e){
|
||||
JInternalFrame.JDesktopIcon icon = getFrame().
|
||||
getDesktopIcon();
|
||||
MotifDesktopIconUI micon = (MotifDesktopIconUI)icon.
|
||||
getUI();
|
||||
micon.hideSystemMenu();
|
||||
}
|
||||
public boolean isEnabled(){
|
||||
return isKeyBindingActive();
|
||||
}
|
||||
});
|
||||
SwingUtilities.replaceUIActionMap(di, diActionMap);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called when the frame becomes selected.
|
||||
*/
|
||||
protected void activateFrame(JInternalFrame f) {
|
||||
super.activateFrame(f);
|
||||
setColors(f);
|
||||
}
|
||||
/** This method is called when the frame is no longer selected.
|
||||
*/
|
||||
protected void deactivateFrame(JInternalFrame f) {
|
||||
setColors(f);
|
||||
super.deactivateFrame(f);
|
||||
}
|
||||
|
||||
void setColors(JInternalFrame frame) {
|
||||
if (frame.isSelected()) {
|
||||
color = UIManager.getColor("InternalFrame.activeTitleBackground");
|
||||
} else {
|
||||
color = UIManager.getColor("InternalFrame.inactiveTitleBackground");
|
||||
}
|
||||
highlight = color.brighter();
|
||||
shadow = color.darker().darker();
|
||||
titlePane.setColors(color, highlight, shadow);
|
||||
}
|
||||
}
|
||||
61
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifLabelUI.java
Normal file
61
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifLabelUI.java
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicLabelUI;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
|
||||
/**
|
||||
* A Motif L&F implementation of LabelUI.
|
||||
* This merely sets up new default values in MotifLookAndFeel.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Amy Fowler
|
||||
*/
|
||||
public class MotifLabelUI extends BasicLabelUI
|
||||
{
|
||||
private static final Object MOTIF_LABEL_UI_KEY = new Object();
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
MotifLabelUI motifLabelUI =
|
||||
(MotifLabelUI) appContext.get(MOTIF_LABEL_UI_KEY);
|
||||
if (motifLabelUI == null) {
|
||||
motifLabelUI = new MotifLabelUI();
|
||||
appContext.put(MOTIF_LABEL_UI_KEY, motifLabelUI);
|
||||
}
|
||||
return motifLabelUI;
|
||||
}
|
||||
}
|
||||
1281
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java
Normal file
1281
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Color;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicMenuBarUI;
|
||||
//REMIND
|
||||
import javax.swing.plaf.basic.*;
|
||||
|
||||
/**
|
||||
* A Windows L&F implementation of MenuBarUI. This implementation
|
||||
* is a "combined" view/controller.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Georges Saab
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
|
||||
public class MotifMenuBarUI extends BasicMenuBarUI
|
||||
{
|
||||
|
||||
public static ComponentUI createUI(JComponent x) {
|
||||
return new MotifMenuBarUI();
|
||||
}
|
||||
|
||||
} // end class
|
||||
109
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifMenuItemUI.java
Normal file
109
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifMenuItemUI.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicMenuItemUI;
|
||||
|
||||
|
||||
/**
|
||||
* MotifMenuItem implementation
|
||||
* <p>
|
||||
*
|
||||
* @author Rich Schiavi
|
||||
* @author Georges Saab
|
||||
*/
|
||||
public class MotifMenuItemUI extends BasicMenuItemUI
|
||||
{
|
||||
protected ChangeListener changeListener;
|
||||
|
||||
public static ComponentUI createUI(JComponent c)
|
||||
{
|
||||
return new MotifMenuItemUI();
|
||||
}
|
||||
|
||||
protected void installListeners() {
|
||||
super.installListeners();
|
||||
changeListener = createChangeListener(menuItem);
|
||||
menuItem.addChangeListener(changeListener);
|
||||
}
|
||||
|
||||
protected void uninstallListeners() {
|
||||
super.uninstallListeners();
|
||||
menuItem.removeChangeListener(changeListener);
|
||||
}
|
||||
|
||||
protected ChangeListener createChangeListener(JComponent c) {
|
||||
return new ChangeHandler();
|
||||
}
|
||||
|
||||
protected MouseInputListener createMouseInputListener(JComponent c) {
|
||||
return new MouseInputHandler();
|
||||
}
|
||||
|
||||
protected class ChangeHandler implements ChangeListener {
|
||||
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JMenuItem c = (JMenuItem)e.getSource();
|
||||
LookAndFeel.installProperty(c, "borderPainted",
|
||||
Boolean.valueOf(c.isArmed() || c.isSelected()));
|
||||
}
|
||||
}
|
||||
|
||||
protected class MouseInputHandler implements MouseInputListener {
|
||||
public void mouseClicked(MouseEvent e) {}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
|
||||
manager.setSelectedPath(getPath());
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
MenuSelectionManager manager =
|
||||
MenuSelectionManager.defaultManager();
|
||||
JMenuItem menuItem = (JMenuItem)e.getComponent();
|
||||
Point p = e.getPoint();
|
||||
if(p.x >= 0 && p.x < menuItem.getWidth() &&
|
||||
p.y >= 0 && p.y < menuItem.getHeight()) {
|
||||
manager.clearSelectedPath();
|
||||
menuItem.doClick(0);
|
||||
} else {
|
||||
manager.processMouseEvent(e);
|
||||
}
|
||||
}
|
||||
public void mouseEntered(MouseEvent e) {}
|
||||
public void mouseExited(MouseEvent e) {}
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
MenuSelectionManager.defaultManager().processMouseEvent(e);
|
||||
}
|
||||
public void mouseMoved(MouseEvent e) { }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.event.*;
|
||||
import javax.swing.MenuSelectionManager;
|
||||
|
||||
/**
|
||||
* A default MouseListener for menu elements
|
||||
*
|
||||
* @author Arnaud Weber
|
||||
*/
|
||||
class MotifMenuMouseListener extends MouseAdapter {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
MenuSelectionManager.defaultManager().processMouseEvent(e);
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
MenuSelectionManager.defaultManager().processMouseEvent(e);
|
||||
}
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
MenuSelectionManager.defaultManager().processMouseEvent(e);
|
||||
}
|
||||
public void mouseExited(MouseEvent e) {
|
||||
MenuSelectionManager.defaultManager().processMouseEvent(e);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.event.*;
|
||||
import javax.swing.MenuSelectionManager;
|
||||
|
||||
/**
|
||||
* A default MouseListener for menu elements
|
||||
*
|
||||
* @author Arnaud Weber
|
||||
*/
|
||||
class MotifMenuMouseMotionListener implements MouseMotionListener {
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
MenuSelectionManager.defaultManager().processMouseEvent(e);
|
||||
}
|
||||
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
MenuSelectionManager.defaultManager().processMouseEvent(e);
|
||||
}
|
||||
}
|
||||
151
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifMenuUI.java
Normal file
151
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifMenuUI.java
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
|
||||
|
||||
import javax.swing.plaf.basic.BasicMenuUI;
|
||||
|
||||
/**
|
||||
* A Motif L&F implementation of MenuUI.
|
||||
* <p>
|
||||
*
|
||||
* @author Georges Saab
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
public class MotifMenuUI extends BasicMenuUI
|
||||
{
|
||||
|
||||
public static ComponentUI createUI( JComponent x ) {
|
||||
return new MotifMenuUI();
|
||||
}
|
||||
|
||||
// These should not be necessary because BasicMenuUI does this,
|
||||
// and this class overrides createChangeListener.
|
||||
// protected void installListeners() {
|
||||
// super.installListeners();
|
||||
// changeListener = createChangeListener(menuItem);
|
||||
// menuItem.addChangeListener(changeListener);
|
||||
// }
|
||||
//
|
||||
// protected void uninstallListeners() {
|
||||
// super.uninstallListeners();
|
||||
// menuItem.removeChangeListener(changeListener);
|
||||
// }
|
||||
|
||||
protected ChangeListener createChangeListener(JComponent c) {
|
||||
return new MotifChangeHandler((JMenu)c, this);
|
||||
}
|
||||
|
||||
private boolean popupIsOpen(JMenu m,MenuElement me[]) {
|
||||
int i;
|
||||
JPopupMenu pm = m.getPopupMenu();
|
||||
|
||||
for(i=me.length-1;i>=0;i--) {
|
||||
if(me[i].getComponent() == pm)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected MouseInputListener createMouseInputListener(JComponent c) {
|
||||
return new MouseInputHandler();
|
||||
}
|
||||
|
||||
public class MotifChangeHandler extends ChangeHandler {
|
||||
public MotifChangeHandler(JMenu m, MotifMenuUI ui) {
|
||||
super(m, ui);
|
||||
}
|
||||
|
||||
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JMenuItem c = (JMenuItem)e.getSource();
|
||||
if (c.isArmed() || c.isSelected()) {
|
||||
c.setBorderPainted(true);
|
||||
// c.repaint();
|
||||
} else {
|
||||
c.setBorderPainted(false);
|
||||
}
|
||||
|
||||
super.stateChanged(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected class MouseInputHandler implements MouseInputListener {
|
||||
public void mouseClicked(MouseEvent e) {}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
|
||||
JMenu menu = (JMenu)e.getComponent();
|
||||
if(menu.isEnabled()) {
|
||||
if(menu.isTopLevelMenu()) {
|
||||
if(menu.isSelected()) {
|
||||
manager.clearSelectedPath();
|
||||
} else {
|
||||
Container cnt = menu.getParent();
|
||||
if(cnt != null && cnt instanceof JMenuBar) {
|
||||
MenuElement me[] = new MenuElement[2];
|
||||
me[0]=(MenuElement)cnt;
|
||||
me[1]=menu;
|
||||
manager.setSelectedPath(me);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MenuElement path[] = getPath();
|
||||
if (path.length > 0) {
|
||||
MenuElement newPath[] = new MenuElement[path.length+1];
|
||||
System.arraycopy(path,0,newPath,0,path.length);
|
||||
newPath[path.length] = menu.getPopupMenu();
|
||||
manager.setSelectedPath(newPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
MenuSelectionManager manager =
|
||||
MenuSelectionManager.defaultManager();
|
||||
JMenuItem menuItem = (JMenuItem)e.getComponent();
|
||||
Point p = e.getPoint();
|
||||
if(!(p.x >= 0 && p.x < menuItem.getWidth() &&
|
||||
p.y >= 0 && p.y < menuItem.getHeight())) {
|
||||
manager.processMouseEvent(e);
|
||||
}
|
||||
}
|
||||
public void mouseEntered(MouseEvent e) {}
|
||||
public void mouseExited(MouseEvent e) {}
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
MenuSelectionManager.defaultManager().processMouseEvent(e);
|
||||
}
|
||||
public void mouseMoved(MouseEvent e) { }
|
||||
}
|
||||
|
||||
}
|
||||
114
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifOptionPaneUI.java
Normal file
114
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifOptionPaneUI.java
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicOptionPaneUI;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
/**
|
||||
* Provides the CDE/Motif look and feel for a JOptionPane.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Scott Violet
|
||||
*/
|
||||
public class MotifOptionPaneUI extends BasicOptionPaneUI
|
||||
{
|
||||
/**
|
||||
* Creates a new MotifOptionPaneUI instance.
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent x) {
|
||||
return new MotifOptionPaneUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a Container containin the buttons. The buttons
|
||||
* are created by calling <code>getButtons</code>.
|
||||
*/
|
||||
protected Container createButtonArea() {
|
||||
Container b = super.createButtonArea();
|
||||
|
||||
if(b != null && b.getLayout() instanceof ButtonAreaLayout) {
|
||||
((ButtonAreaLayout)b.getLayout()).setCentersChildren(false);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null, CDE/Motif does not impose a minimum size.
|
||||
*/
|
||||
public Dimension getMinimumOptionPaneSize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Container createSeparator() {
|
||||
return new JPanel() {
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(10, 2);
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
int width = getWidth();
|
||||
g.setColor(Color.darkGray);
|
||||
g.drawLine(0, 0, width, 0);
|
||||
g.setColor(Color.white);
|
||||
g.drawLine(0, 1, width, 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and adds a JLabel representing the icon returned from
|
||||
* <code>getIcon</code> to <code>top</code>. This is messaged from
|
||||
* <code>createMessageArea</code>
|
||||
*/
|
||||
protected void addIcon(Container top) {
|
||||
/* Create the icon. */
|
||||
Icon sideIcon = getIcon();
|
||||
|
||||
if (sideIcon != null) {
|
||||
JLabel iconLabel = new JLabel(sideIcon);
|
||||
|
||||
iconLabel.setVerticalAlignment(SwingConstants.CENTER);
|
||||
top.add(iconLabel, "West");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicPasswordFieldUI;
|
||||
|
||||
/**
|
||||
* Provides the Motif look and feel for a password field.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Timothy Prinzing
|
||||
*/
|
||||
public class MotifPasswordFieldUI extends BasicPasswordFieldUI {
|
||||
|
||||
/**
|
||||
* Creates a UI for a JPasswordField.
|
||||
*
|
||||
* @param c the JPasswordField
|
||||
* @return the UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new MotifPasswordFieldUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object to use for a caret. By default an
|
||||
* instance of MotifTextUI.MotifCaret is created. This method
|
||||
* can be redefined to provide something else that implements
|
||||
* the Caret interface.
|
||||
*
|
||||
* @return the caret object
|
||||
*/
|
||||
protected Caret createCaret() {
|
||||
return MotifTextUI.createCaret();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Rectangle;
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
/**
|
||||
* A Motif L&F implementation of PopupMenuSeparatorUI. This implementation
|
||||
* is a "combined" view/controller.
|
||||
*
|
||||
* @author Jeff Shapiro
|
||||
*/
|
||||
|
||||
public class MotifPopupMenuSeparatorUI extends MotifSeparatorUI
|
||||
{
|
||||
public static ComponentUI createUI( JComponent c )
|
||||
{
|
||||
return new MotifPopupMenuSeparatorUI();
|
||||
}
|
||||
|
||||
public void paint( Graphics g, JComponent c )
|
||||
{
|
||||
Dimension s = c.getSize();
|
||||
|
||||
g.setColor( c.getForeground() );
|
||||
g.drawLine( 0, 0, s.width, 0 );
|
||||
|
||||
g.setColor( c.getBackground() );
|
||||
g.drawLine( 0, 1, s.width, 1 );
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize( JComponent c )
|
||||
{
|
||||
return new Dimension( 0, 2 );
|
||||
}
|
||||
|
||||
}
|
||||
114
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifPopupMenuUI.java
Normal file
114
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifPopupMenuUI.java
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import sun.swing.SwingUtilities2;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.border.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.LayoutManager;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicPopupMenuUI;
|
||||
|
||||
|
||||
/**
|
||||
* A Motif L&F implementation of PopupMenuUI.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Georges Saab
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
public class MotifPopupMenuUI extends BasicPopupMenuUI {
|
||||
private static Border border = null;
|
||||
private Font titleFont = null;
|
||||
|
||||
public static ComponentUI createUI(JComponent x) {
|
||||
return new MotifPopupMenuUI();
|
||||
}
|
||||
|
||||
/* This has to deal with the fact that the title may be wider than
|
||||
the widest child component.
|
||||
*/
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
LayoutManager layout = c.getLayout();
|
||||
Dimension d = layout.preferredLayoutSize(c);
|
||||
String title = ((JPopupMenu)c).getLabel();
|
||||
if (titleFont == null) {
|
||||
UIDefaults table = UIManager.getLookAndFeelDefaults();
|
||||
titleFont = table.getFont("PopupMenu.font");
|
||||
}
|
||||
FontMetrics fm = c.getFontMetrics(titleFont);
|
||||
int stringWidth = 0;
|
||||
|
||||
if (title!=null) {
|
||||
stringWidth += SwingUtilities2.stringWidth(c, fm, title);
|
||||
}
|
||||
|
||||
if (d.width < stringWidth) {
|
||||
d.width = stringWidth + 8;
|
||||
Insets i = c.getInsets();
|
||||
if (i!=null) {
|
||||
d.width += i.left + i.right;
|
||||
}
|
||||
if (border != null) {
|
||||
i = border.getBorderInsets(c);
|
||||
d.width += i.left + i.right;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ChangeListener createChangeListener(JPopupMenu m) {
|
||||
return new ChangeListener() {
|
||||
public void stateChanged(ChangeEvent e) {}
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isPopupTrigger(MouseEvent e) {
|
||||
return ((e.getID()==MouseEvent.MOUSE_PRESSED)
|
||||
&& ((e.getModifiers() & MouseEvent.BUTTON3_MASK)!=0));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.plaf.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.swing.plaf.basic.BasicProgressBarUI;
|
||||
|
||||
|
||||
/**
|
||||
* A Motif ProgressBarUI.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Michael C. Albers
|
||||
*/
|
||||
public class MotifProgressBarUI extends BasicProgressBarUI
|
||||
{
|
||||
/**
|
||||
* Creates the ProgressBar's UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent x) {
|
||||
return new MotifProgressBarUI();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicRadioButtonMenuItemUI;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* MotifRadioButtonMenuItem implementation
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Georges Saab
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
public class MotifRadioButtonMenuItemUI extends BasicRadioButtonMenuItemUI
|
||||
{
|
||||
protected ChangeListener changeListener;
|
||||
|
||||
public static ComponentUI createUI(JComponent b) {
|
||||
return new MotifRadioButtonMenuItemUI();
|
||||
}
|
||||
|
||||
protected void installListeners() {
|
||||
super.installListeners();
|
||||
changeListener = createChangeListener(menuItem);
|
||||
menuItem.addChangeListener(changeListener);
|
||||
}
|
||||
|
||||
protected void uninstallListeners() {
|
||||
super.uninstallListeners();
|
||||
menuItem.removeChangeListener(changeListener);
|
||||
}
|
||||
|
||||
protected ChangeListener createChangeListener(JComponent c) {
|
||||
return new ChangeHandler();
|
||||
}
|
||||
|
||||
protected class ChangeHandler implements ChangeListener, Serializable {
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
JMenuItem c = (JMenuItem)e.getSource();
|
||||
LookAndFeel.installProperty(c, "borderPainted", c.isArmed());
|
||||
}
|
||||
}
|
||||
|
||||
protected MouseInputListener createMouseInputListener(JComponent c) {
|
||||
return new MouseInputHandler();
|
||||
}
|
||||
|
||||
|
||||
protected class MouseInputHandler implements MouseInputListener {
|
||||
public void mouseClicked(MouseEvent e) {}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
MenuSelectionManager manager = MenuSelectionManager.defaultManager();
|
||||
manager.setSelectedPath(getPath());
|
||||
}
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
MenuSelectionManager manager =
|
||||
MenuSelectionManager.defaultManager();
|
||||
JMenuItem menuItem = (JMenuItem)e.getComponent();
|
||||
Point p = e.getPoint();
|
||||
if(p.x >= 0 && p.x < menuItem.getWidth() &&
|
||||
p.y >= 0 && p.y < menuItem.getHeight()) {
|
||||
manager.clearSelectedPath();
|
||||
menuItem.doClick(0);
|
||||
} else {
|
||||
manager.processMouseEvent(e);
|
||||
}
|
||||
}
|
||||
public void mouseEntered(MouseEvent e) {}
|
||||
public void mouseExited(MouseEvent e) {}
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
MenuSelectionManager.defaultManager().processMouseEvent(e);
|
||||
}
|
||||
public void mouseMoved(MouseEvent e) { }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.basic.BasicRadioButtonUI;
|
||||
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* RadioButtonUI implementation for MotifRadioButtonUI
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
public class MotifRadioButtonUI extends BasicRadioButtonUI {
|
||||
|
||||
private static final Object MOTIF_RADIO_BUTTON_UI_KEY = new Object();
|
||||
|
||||
protected Color focusColor;
|
||||
|
||||
private boolean defaults_initialized = false;
|
||||
|
||||
// ********************************
|
||||
// Create PLAF
|
||||
// ********************************
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
MotifRadioButtonUI motifRadioButtonUI =
|
||||
(MotifRadioButtonUI) appContext.get(MOTIF_RADIO_BUTTON_UI_KEY);
|
||||
if (motifRadioButtonUI == null) {
|
||||
motifRadioButtonUI = new MotifRadioButtonUI();
|
||||
appContext.put(MOTIF_RADIO_BUTTON_UI_KEY, motifRadioButtonUI);
|
||||
}
|
||||
return motifRadioButtonUI;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Install Defaults
|
||||
// ********************************
|
||||
public void installDefaults(AbstractButton b) {
|
||||
super.installDefaults(b);
|
||||
if(!defaults_initialized) {
|
||||
focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
|
||||
defaults_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void uninstallDefaults(AbstractButton b) {
|
||||
super.uninstallDefaults(b);
|
||||
defaults_initialized = false;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Default Accessors
|
||||
// ********************************
|
||||
|
||||
protected Color getFocusColor() {
|
||||
return focusColor;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Paint Methods
|
||||
// ********************************
|
||||
protected void paintFocus(Graphics g, Rectangle t, Dimension d){
|
||||
g.setColor(getFocusColor());
|
||||
g.drawRect(0,0,d.width-1,d.height-1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicArrowButton;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* Motif scroll bar button.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class MotifScrollBarButton extends BasicArrowButton
|
||||
{
|
||||
private Color darkShadow = UIManager.getColor("controlShadow");
|
||||
private Color lightShadow = UIManager.getColor("controlLtHighlight");
|
||||
|
||||
|
||||
public MotifScrollBarButton(int direction)
|
||||
{
|
||||
super(direction);
|
||||
|
||||
switch (direction) {
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
case EAST:
|
||||
case WEST:
|
||||
this.direction = direction;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("invalid direction");
|
||||
}
|
||||
|
||||
setRequestFocusEnabled(false);
|
||||
setOpaque(true);
|
||||
setBackground(UIManager.getColor("ScrollBar.background"));
|
||||
setForeground(UIManager.getColor("ScrollBar.foreground"));
|
||||
}
|
||||
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
switch (direction) {
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
return new Dimension(11, 12);
|
||||
case EAST:
|
||||
case WEST:
|
||||
default:
|
||||
return new Dimension(12, 11);
|
||||
}
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
|
||||
public Dimension getMaximumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
|
||||
public boolean isFocusTraversable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
int w = getWidth();
|
||||
int h = getHeight();
|
||||
|
||||
if (isOpaque()) {
|
||||
g.setColor(getBackground());
|
||||
g.fillRect(0, 0, w, h);
|
||||
}
|
||||
|
||||
boolean isPressed = getModel().isPressed();
|
||||
Color lead = (isPressed) ? darkShadow : lightShadow;
|
||||
Color trail = (isPressed) ? lightShadow : darkShadow;
|
||||
Color fill = getBackground();
|
||||
|
||||
int cx = w / 2;
|
||||
int cy = h / 2;
|
||||
int s = Math.min(w, h);
|
||||
|
||||
switch (direction) {
|
||||
case NORTH:
|
||||
g.setColor(lead);
|
||||
g.drawLine(cx, 0, cx, 0);
|
||||
for (int x = cx - 1, y = 1, dx = 1; y <= s - 2; y += 2) {
|
||||
g.setColor(lead);
|
||||
g.drawLine(x, y, x, y);
|
||||
if (y >= (s - 2)) {
|
||||
g.drawLine(x, y + 1, x, y + 1);
|
||||
}
|
||||
g.setColor(fill);
|
||||
g.drawLine(x + 1, y, x + dx, y);
|
||||
if (y < (s - 2)) {
|
||||
g.drawLine(x, y + 1, x + dx + 1, y + 1);
|
||||
}
|
||||
g.setColor(trail);
|
||||
g.drawLine(x + dx + 1, y, x + dx + 1, y);
|
||||
if (y >= (s - 2)) {
|
||||
g.drawLine(x + 1, y + 1, x + dx + 1, y + 1);
|
||||
}
|
||||
dx += 2;
|
||||
x -= 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
g.setColor(trail);
|
||||
g.drawLine(cx, s, cx, s);
|
||||
for (int x = cx - 1, y = s - 1, dx = 1; y >= 1; y -= 2) {
|
||||
g.setColor(lead);
|
||||
g.drawLine(x, y, x, y);
|
||||
if (y <= 2) {
|
||||
g.drawLine(x, y - 1, x + dx + 1, y - 1);
|
||||
}
|
||||
g.setColor(fill);
|
||||
g.drawLine(x + 1, y, x + dx, y);
|
||||
if (y > 2) {
|
||||
g.drawLine(x, y - 1, x + dx + 1, y - 1);
|
||||
}
|
||||
g.setColor(trail);
|
||||
g.drawLine(x + dx + 1, y, x + dx + 1, y);
|
||||
|
||||
dx += 2;
|
||||
x -= 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
g.setColor(lead);
|
||||
g.drawLine(s, cy, s, cy);
|
||||
for (int y = cy - 1, x = s - 1, dy = 1; x >= 1; x -= 2) {
|
||||
g.setColor(lead);
|
||||
g.drawLine(x, y, x, y);
|
||||
if (x <= 2) {
|
||||
g.drawLine(x - 1, y, x - 1, y + dy + 1);
|
||||
}
|
||||
g.setColor(fill);
|
||||
g.drawLine(x, y + 1, x, y + dy);
|
||||
if (x > 2) {
|
||||
g.drawLine(x - 1, y, x - 1, y + dy + 1);
|
||||
}
|
||||
g.setColor(trail);
|
||||
g.drawLine(x, y + dy + 1, x, y + dy + 1);
|
||||
|
||||
dy += 2;
|
||||
y -= 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
g.setColor(trail);
|
||||
g.drawLine(0, cy, 0, cy);
|
||||
for (int y = cy - 1, x = 1, dy = 1; x <= s - 2; x += 2) {
|
||||
g.setColor(lead);
|
||||
g.drawLine(x, y, x, y);
|
||||
if (x >= (s - 2)) {
|
||||
g.drawLine(x + 1, y, x + 1, y);
|
||||
}
|
||||
g.setColor(fill);
|
||||
g.drawLine(x, y + 1, x, y + dy);
|
||||
if (x < (s - 2)) {
|
||||
g.drawLine(x + 1, y, x + 1, y + dy + 1);
|
||||
}
|
||||
g.setColor(trail);
|
||||
g.drawLine(x, y + dy + 1, x, y + dy + 1);
|
||||
if (x >= (s - 2)) {
|
||||
g.drawLine(x + 1, y + 1, x + 1, y + dy + 1);
|
||||
}
|
||||
dy += 2;
|
||||
y -= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
106
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifScrollBarUI.java
Normal file
106
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifScrollBarUI.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JScrollBar;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicScrollBarUI;
|
||||
|
||||
import static sun.swing.SwingUtilities2.drawHLine;
|
||||
import static sun.swing.SwingUtilities2.drawVLine;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of ScrollBarUI for the Motif Look and Feel
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Rich Schiavi
|
||||
* @author Hans Muller
|
||||
*/
|
||||
public class MotifScrollBarUI extends BasicScrollBarUI
|
||||
{
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new MotifScrollBarUI();
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
Insets insets = c.getInsets();
|
||||
int dx = insets.left + insets.right;
|
||||
int dy = insets.top + insets.bottom;
|
||||
return (scrollbar.getOrientation() == JScrollBar.VERTICAL)
|
||||
? new Dimension(dx + 11, dy + 33)
|
||||
: new Dimension(dx + 33, dy + 11);
|
||||
}
|
||||
|
||||
protected JButton createDecreaseButton(int orientation) {
|
||||
return new MotifScrollBarButton(orientation);
|
||||
}
|
||||
|
||||
protected JButton createIncreaseButton(int orientation) {
|
||||
return new MotifScrollBarButton(orientation);
|
||||
}
|
||||
|
||||
public void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
|
||||
g.setColor(trackColor);
|
||||
g.fillRect(trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height);
|
||||
}
|
||||
|
||||
public void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
|
||||
if (thumbBounds.isEmpty() || !scrollbar.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int w = thumbBounds.width;
|
||||
int h = thumbBounds.height;
|
||||
|
||||
g.translate(thumbBounds.x, thumbBounds.y);
|
||||
g.setColor(thumbColor);
|
||||
g.fillRect(0, 0, w - 1, h - 1);
|
||||
|
||||
g.setColor(thumbHighlightColor);
|
||||
drawVLine(g, 0, 0, h - 1);
|
||||
drawHLine(g, 1, w - 1, 0);
|
||||
|
||||
g.setColor(thumbLightShadowColor);
|
||||
drawHLine(g, 1, w - 1, h - 1);
|
||||
drawVLine(g, w - 1, 1, h - 2);
|
||||
|
||||
g.translate(-thumbBounds.x, -thumbBounds.y);
|
||||
}
|
||||
}
|
||||
147
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifScrollPaneUI.java
Normal file
147
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifScrollPaneUI.java
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicScrollPaneUI;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
/**
|
||||
* A CDE/Motif L&F implementation of ScrollPaneUI.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Hans Muller
|
||||
*/
|
||||
public class MotifScrollPaneUI extends BasicScrollPaneUI
|
||||
{
|
||||
private final static Border vsbMarginBorderR = new EmptyBorder(0, 4, 0, 0);
|
||||
private final static Border vsbMarginBorderL = new EmptyBorder(0, 0, 0, 4);
|
||||
private final static Border hsbMarginBorder = new EmptyBorder(4, 0, 0, 0);
|
||||
|
||||
private CompoundBorder vsbBorder;
|
||||
private CompoundBorder hsbBorder;
|
||||
|
||||
private PropertyChangeListener propertyChangeHandler;
|
||||
|
||||
@Override
|
||||
protected void installListeners(JScrollPane scrollPane) {
|
||||
super.installListeners(scrollPane);
|
||||
propertyChangeHandler = createPropertyChangeHandler();
|
||||
scrollPane.addPropertyChangeListener(propertyChangeHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallListeners(JComponent scrollPane) {
|
||||
super.uninstallListeners(scrollPane);
|
||||
scrollPane.removePropertyChangeListener(propertyChangeHandler);
|
||||
}
|
||||
|
||||
private PropertyChangeListener createPropertyChangeHandler() {
|
||||
return new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
String propertyName = e.getPropertyName();
|
||||
|
||||
if (propertyName.equals("componentOrientation")) {
|
||||
JScrollPane pane = (JScrollPane)e.getSource();
|
||||
JScrollBar vsb = pane.getVerticalScrollBar();
|
||||
if (vsb != null && vsbBorder != null &&
|
||||
vsb.getBorder() == vsbBorder) {
|
||||
// The Border on the verticall scrollbar matches
|
||||
// what we installed, reset it.
|
||||
if (MotifGraphicsUtils.isLeftToRight(pane)) {
|
||||
vsbBorder = new CompoundBorder(vsbMarginBorderR,
|
||||
vsbBorder.getInsideBorder());
|
||||
} else {
|
||||
vsbBorder = new CompoundBorder(vsbMarginBorderL,
|
||||
vsbBorder.getInsideBorder());
|
||||
}
|
||||
vsb.setBorder(vsbBorder);
|
||||
}
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installDefaults(JScrollPane scrollpane) {
|
||||
super.installDefaults(scrollpane);
|
||||
|
||||
JScrollBar vsb = scrollpane.getVerticalScrollBar();
|
||||
if (vsb != null) {
|
||||
if (MotifGraphicsUtils.isLeftToRight(scrollpane)) {
|
||||
vsbBorder = new CompoundBorder(vsbMarginBorderR,
|
||||
vsb.getBorder());
|
||||
}
|
||||
else {
|
||||
vsbBorder = new CompoundBorder(vsbMarginBorderL,
|
||||
vsb.getBorder());
|
||||
}
|
||||
vsb.setBorder(vsbBorder);
|
||||
}
|
||||
|
||||
JScrollBar hsb = scrollpane.getHorizontalScrollBar();
|
||||
if (hsb != null) {
|
||||
hsbBorder = new CompoundBorder(hsbMarginBorder, hsb.getBorder());
|
||||
hsb.setBorder(hsbBorder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallDefaults(JScrollPane c) {
|
||||
super.uninstallDefaults(c);
|
||||
|
||||
JScrollBar vsb = scrollpane.getVerticalScrollBar();
|
||||
if (vsb != null) {
|
||||
if (vsb.getBorder() == vsbBorder) {
|
||||
vsb.setBorder(null);
|
||||
}
|
||||
vsbBorder = null;
|
||||
}
|
||||
|
||||
JScrollBar hsb = scrollpane.getHorizontalScrollBar();
|
||||
if (hsb != null) {
|
||||
if (hsb.getBorder() == hsbBorder) {
|
||||
hsb.setBorder(null);
|
||||
}
|
||||
hsbBorder = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static ComponentUI createUI(JComponent x) {
|
||||
return new MotifScrollPaneUI();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Rectangle;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicSeparatorUI;
|
||||
|
||||
/**
|
||||
* A Motif L&F implementation of SeparatorUI. This implementation
|
||||
* is a "combined" view/controller.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Georges Saab
|
||||
* @author Jeff Shapiro
|
||||
*/
|
||||
|
||||
public class MotifSeparatorUI extends BasicSeparatorUI
|
||||
{
|
||||
public static ComponentUI createUI( JComponent c )
|
||||
{
|
||||
return new MotifSeparatorUI();
|
||||
}
|
||||
|
||||
}
|
||||
162
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifSliderUI.java
Normal file
162
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifSliderUI.java
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicSliderUI;
|
||||
|
||||
import static sun.swing.SwingUtilities2.drawHLine;
|
||||
import static sun.swing.SwingUtilities2.drawVLine;
|
||||
|
||||
/**
|
||||
* Motif Slider
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public class MotifSliderUI extends BasicSliderUI {
|
||||
|
||||
static final Dimension PREFERRED_HORIZONTAL_SIZE = new Dimension(164, 15);
|
||||
static final Dimension PREFERRED_VERTICAL_SIZE = new Dimension(15, 164);
|
||||
|
||||
static final Dimension MINIMUM_HORIZONTAL_SIZE = new Dimension(43, 15);
|
||||
static final Dimension MINIMUM_VERTICAL_SIZE = new Dimension(15, 43);
|
||||
|
||||
/**
|
||||
* MotifSliderUI Constructor
|
||||
*/
|
||||
public MotifSliderUI(JSlider b) {
|
||||
super(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a MotifSliderUI object
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent b) {
|
||||
return new MotifSliderUI((JSlider)b);
|
||||
}
|
||||
|
||||
public Dimension getPreferredHorizontalSize() {
|
||||
return PREFERRED_HORIZONTAL_SIZE;
|
||||
}
|
||||
|
||||
public Dimension getPreferredVerticalSize() {
|
||||
return PREFERRED_VERTICAL_SIZE;
|
||||
}
|
||||
|
||||
public Dimension getMinimumHorizontalSize() {
|
||||
return MINIMUM_HORIZONTAL_SIZE;
|
||||
}
|
||||
|
||||
public Dimension getMinimumVerticalSize() {
|
||||
return MINIMUM_VERTICAL_SIZE;
|
||||
}
|
||||
|
||||
protected Dimension getThumbSize() {
|
||||
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
|
||||
return new Dimension( 30, 15 );
|
||||
}
|
||||
else {
|
||||
return new Dimension( 15, 30 );
|
||||
}
|
||||
}
|
||||
|
||||
public void paintFocus(Graphics g) {
|
||||
}
|
||||
|
||||
public void paintTrack(Graphics g) {
|
||||
}
|
||||
|
||||
public void paintThumb(Graphics g) {
|
||||
Rectangle knobBounds = thumbRect;
|
||||
|
||||
int x = knobBounds.x;
|
||||
int y = knobBounds.y;
|
||||
int w = knobBounds.width;
|
||||
int h = knobBounds.height;
|
||||
|
||||
if ( slider.isEnabled() ) {
|
||||
g.setColor(slider.getForeground());
|
||||
}
|
||||
else {
|
||||
// PENDING(jeff) - the thumb should be dithered when disabled
|
||||
g.setColor(slider.getForeground().darker());
|
||||
}
|
||||
|
||||
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
|
||||
g.translate(x, knobBounds.y-1);
|
||||
|
||||
// fill
|
||||
g.fillRect(0, 1, w, h - 1);
|
||||
|
||||
// highlight
|
||||
g.setColor(getHighlightColor());
|
||||
drawHLine(g, 0, w - 1, 1); // top
|
||||
drawVLine(g, 0, 1, h); // left
|
||||
drawVLine(g, w / 2, 2, h - 1); // center
|
||||
|
||||
// shadow
|
||||
g.setColor(getShadowColor());
|
||||
drawHLine(g, 0, w - 1, h); // bottom
|
||||
drawVLine(g, w - 1, 1, h); // right
|
||||
drawVLine(g, w / 2 - 1, 2, h); // center
|
||||
|
||||
g.translate(-x, -(knobBounds.y-1));
|
||||
}
|
||||
else {
|
||||
g.translate(knobBounds.x-1, 0);
|
||||
|
||||
// fill
|
||||
g.fillRect(1, y, w - 1, h);
|
||||
|
||||
// highlight
|
||||
g.setColor(getHighlightColor());
|
||||
drawHLine(g, 1, w, y); // top
|
||||
drawVLine(g, 1, y + 1, y + h - 1); // left
|
||||
drawHLine(g, 2, w - 1, y + h / 2); // center
|
||||
|
||||
// shadow
|
||||
g.setColor(getShadowColor());
|
||||
drawHLine(g, 2, w, y + h - 1); // bottom
|
||||
drawVLine(g, w, y + h - 1, y); // right
|
||||
drawHLine(g, 2, w - 1, y + h / 2 - 1);// center
|
||||
|
||||
g.translate(-(knobBounds.x-1), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.basic.BasicSplitPaneUI;
|
||||
import javax.swing.plaf.basic.BasicSplitPaneDivider;
|
||||
|
||||
|
||||
/**
|
||||
* Divider used for Motif split pane.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public class MotifSplitPaneDivider extends BasicSplitPaneDivider
|
||||
{
|
||||
/**
|
||||
* Default cursor, supers is package private, so we have to have one
|
||||
* too.
|
||||
*/
|
||||
private static final Cursor defaultCursor =
|
||||
Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
|
||||
|
||||
|
||||
public static final int minimumThumbSize = 6;
|
||||
public static final int defaultDividerSize = 18;
|
||||
|
||||
protected static final int pad = 6;
|
||||
|
||||
private int hThumbOffset = 30;
|
||||
private int vThumbOffset = 40;
|
||||
protected int hThumbWidth = 12;
|
||||
protected int hThumbHeight = 18;
|
||||
protected int vThumbWidth = 18;
|
||||
protected int vThumbHeight = 12;
|
||||
|
||||
protected Color highlightColor;
|
||||
protected Color shadowColor;
|
||||
protected Color focusedColor;
|
||||
|
||||
/**
|
||||
* Creates a new Motif SplitPaneDivider
|
||||
*/
|
||||
public MotifSplitPaneDivider(BasicSplitPaneUI ui) {
|
||||
super(ui);
|
||||
highlightColor = UIManager.getColor("SplitPane.highlight");
|
||||
shadowColor = UIManager.getColor("SplitPane.shadow");
|
||||
focusedColor = UIManager.getColor("SplitPane.activeThumb");
|
||||
setDividerSize(hThumbWidth + pad);
|
||||
}
|
||||
|
||||
/**
|
||||
* overrides to hardcode the size of the divider
|
||||
* PENDING(jeff) - rewrite JSplitPane so that this ins't needed
|
||||
*/
|
||||
public void setDividerSize(int newSize) {
|
||||
Insets insets = getInsets();
|
||||
int borderSize = 0;
|
||||
if (getBasicSplitPaneUI().getOrientation() ==
|
||||
JSplitPane.HORIZONTAL_SPLIT) {
|
||||
if (insets != null) {
|
||||
borderSize = insets.left + insets.right;
|
||||
}
|
||||
}
|
||||
else if (insets != null) {
|
||||
borderSize = insets.top + insets.bottom;
|
||||
}
|
||||
if (newSize < pad + minimumThumbSize + borderSize) {
|
||||
setDividerSize(pad + minimumThumbSize + borderSize);
|
||||
} else {
|
||||
vThumbHeight = hThumbWidth = newSize - pad - borderSize;
|
||||
super.setDividerSize(newSize);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the divider.
|
||||
*/
|
||||
// PENDING(jeff) - the thumb's location and size is currently hard coded.
|
||||
// It should be dynamic.
|
||||
public void paint(Graphics g) {
|
||||
Color bgColor = getBackground();
|
||||
Dimension size = getSize();
|
||||
|
||||
// fill
|
||||
g.setColor(getBackground());
|
||||
g.fillRect(0, 0, size.width, size.height);
|
||||
|
||||
if(getBasicSplitPaneUI().getOrientation() ==
|
||||
JSplitPane.HORIZONTAL_SPLIT) {
|
||||
int center = size.width/2;
|
||||
int x = center - hThumbWidth/2;
|
||||
int y = hThumbOffset;
|
||||
|
||||
// split line
|
||||
g.setColor(shadowColor);
|
||||
g.drawLine(center-1, 0, center-1, size.height);
|
||||
|
||||
g.setColor(highlightColor);
|
||||
g.drawLine(center, 0, center, size.height);
|
||||
|
||||
// draw thumb
|
||||
g.setColor((splitPane.hasFocus()) ? focusedColor :
|
||||
getBackground());
|
||||
g.fillRect(x+1, y+1, hThumbWidth-2, hThumbHeight-1);
|
||||
|
||||
g.setColor(highlightColor);
|
||||
g.drawLine(x, y, x+hThumbWidth-1, y); // top
|
||||
g.drawLine(x, y+1, x, y+hThumbHeight-1); // left
|
||||
|
||||
g.setColor(shadowColor);
|
||||
g.drawLine(x+1, y+hThumbHeight-1,
|
||||
x+hThumbWidth-1, y+hThumbHeight-1); // bottom
|
||||
g.drawLine(x+hThumbWidth-1, y+1,
|
||||
x+hThumbWidth-1, y+hThumbHeight-2); // right
|
||||
|
||||
} else {
|
||||
int center = size.height/2;
|
||||
int x = size.width - vThumbOffset;
|
||||
int y = size.height/2 - vThumbHeight/2;
|
||||
|
||||
// split line
|
||||
g.setColor(shadowColor);
|
||||
g.drawLine(0, center-1, size.width, center-1);
|
||||
|
||||
g.setColor(highlightColor);
|
||||
g.drawLine(0, center, size.width, center);
|
||||
|
||||
// draw thumb
|
||||
g.setColor((splitPane.hasFocus()) ? focusedColor :
|
||||
getBackground());
|
||||
g.fillRect(x+1, y+1, vThumbWidth-1, vThumbHeight-1);
|
||||
|
||||
g.setColor(highlightColor);
|
||||
g.drawLine(x, y, x+vThumbWidth, y); // top
|
||||
g.drawLine(x, y+1, x, y+vThumbHeight); // left
|
||||
|
||||
g.setColor(shadowColor);
|
||||
g.drawLine(x+1, y+vThumbHeight,
|
||||
x+vThumbWidth, y+vThumbHeight); // bottom
|
||||
g.drawLine(x+vThumbWidth, y+1,
|
||||
x+vThumbWidth, y+vThumbHeight-1); // right
|
||||
}
|
||||
super.paint(g);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The minimums size is the same as the preferredSize
|
||||
*/
|
||||
public Dimension getMinimumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SplitPaneUI that is using the receiver. This is completely
|
||||
* overriden from super to create a different MouseHandler.
|
||||
*/
|
||||
public void setBasicSplitPaneUI(BasicSplitPaneUI newUI) {
|
||||
if (splitPane != null) {
|
||||
splitPane.removePropertyChangeListener(this);
|
||||
if (mouseHandler != null) {
|
||||
splitPane.removeMouseListener(mouseHandler);
|
||||
splitPane.removeMouseMotionListener(mouseHandler);
|
||||
removeMouseListener(mouseHandler);
|
||||
removeMouseMotionListener(mouseHandler);
|
||||
mouseHandler = null;
|
||||
}
|
||||
}
|
||||
splitPaneUI = newUI;
|
||||
if (newUI != null) {
|
||||
splitPane = newUI.getSplitPane();
|
||||
if (splitPane != null) {
|
||||
if (mouseHandler == null) mouseHandler=new MotifMouseHandler();
|
||||
splitPane.addMouseListener(mouseHandler);
|
||||
splitPane.addMouseMotionListener(mouseHandler);
|
||||
addMouseListener(mouseHandler);
|
||||
addMouseMotionListener(mouseHandler);
|
||||
splitPane.addPropertyChangeListener(this);
|
||||
if (splitPane.isOneTouchExpandable()) {
|
||||
oneTouchExpandableChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
splitPane = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the point at <code>x</code>, <code>y</code>
|
||||
* is inside the thumb.
|
||||
*/
|
||||
private boolean isInThumb(int x, int y) {
|
||||
Dimension size = getSize();
|
||||
int thumbX;
|
||||
int thumbY;
|
||||
int thumbWidth;
|
||||
int thumbHeight;
|
||||
|
||||
if (getBasicSplitPaneUI().getOrientation() ==
|
||||
JSplitPane.HORIZONTAL_SPLIT) {
|
||||
int center = size.width/2;
|
||||
thumbX = center - hThumbWidth/2;
|
||||
thumbY = hThumbOffset;
|
||||
thumbWidth = hThumbWidth;
|
||||
thumbHeight = hThumbHeight;
|
||||
}
|
||||
else {
|
||||
int center = size.height/2;
|
||||
thumbX = size.width - vThumbOffset;
|
||||
thumbY = size.height/2 - vThumbHeight/2;
|
||||
thumbWidth = vThumbWidth;
|
||||
thumbHeight = vThumbHeight;
|
||||
}
|
||||
return (x >= thumbX && x < (thumbX + thumbWidth) &&
|
||||
y >= thumbY && y < (thumbY + thumbHeight));
|
||||
}
|
||||
|
||||
//
|
||||
// Two methods are exposed so that MotifMouseHandler can see the
|
||||
// superclass protected ivars
|
||||
//
|
||||
|
||||
private DragController getDragger() {
|
||||
return dragger;
|
||||
}
|
||||
|
||||
private JSplitPane getSplitPane() {
|
||||
return splitPane;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MouseHandler is subclassed to only pass off to super if the mouse
|
||||
* is in the thumb. Motif only allows dragging when the thumb is clicked
|
||||
* in.
|
||||
*/
|
||||
private class MotifMouseHandler extends MouseHandler {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
// Constrain the mouse pressed to the thumb.
|
||||
if (e.getSource() == MotifSplitPaneDivider.this &&
|
||||
getDragger() == null && getSplitPane().isEnabled() &&
|
||||
isInThumb(e.getX(), e.getY())) {
|
||||
super.mousePressed(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
if (getDragger() != null) {
|
||||
return;
|
||||
}
|
||||
if (!isInThumb(e.getX(), e.getY())) {
|
||||
if (getCursor() != defaultCursor) {
|
||||
setCursor(defaultCursor);
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.mouseMoved(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.plaf.basic.BasicSplitPaneUI;
|
||||
import javax.swing.plaf.basic.BasicSplitPaneDivider;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Motif rendition of a split pane.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public class MotifSplitPaneUI extends BasicSplitPaneUI
|
||||
{
|
||||
public MotifSplitPaneUI() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new MotifSplitPaneUI instance
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent x) {
|
||||
return new MotifSplitPaneUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the default divider.
|
||||
*/
|
||||
public BasicSplitPaneDivider createDefaultDivider() {
|
||||
return new MotifSplitPaneDivider(this);
|
||||
}
|
||||
|
||||
}
|
||||
306
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifTabbedPaneUI.java
Normal file
306
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifTabbedPaneUI.java
Normal file
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicTabbedPaneUI;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* A Motif L&F implementation of TabbedPaneUI.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Amy Fowler
|
||||
* @author Philip Milne
|
||||
*/
|
||||
public class MotifTabbedPaneUI extends BasicTabbedPaneUI
|
||||
{
|
||||
|
||||
// Instance variables initialized at installation
|
||||
|
||||
protected Color unselectedTabBackground;
|
||||
protected Color unselectedTabForeground;
|
||||
protected Color unselectedTabShadow;
|
||||
protected Color unselectedTabHighlight;
|
||||
|
||||
|
||||
// UI creation
|
||||
|
||||
public static ComponentUI createUI(JComponent tabbedPane) {
|
||||
return new MotifTabbedPaneUI();
|
||||
}
|
||||
|
||||
|
||||
// UI Installation/De-installation
|
||||
|
||||
|
||||
protected void installDefaults() {
|
||||
super.installDefaults();
|
||||
|
||||
unselectedTabBackground = UIManager.getColor("TabbedPane.unselectedTabBackground");
|
||||
unselectedTabForeground = UIManager.getColor("TabbedPane.unselectedTabForeground");
|
||||
unselectedTabShadow = UIManager.getColor("TabbedPane.unselectedTabShadow");
|
||||
unselectedTabHighlight = UIManager.getColor("TabbedPane.unselectedTabHighlight");
|
||||
}
|
||||
|
||||
protected void uninstallDefaults() {
|
||||
super.uninstallDefaults();
|
||||
|
||||
unselectedTabBackground = null;
|
||||
unselectedTabForeground = null;
|
||||
unselectedTabShadow = null;
|
||||
unselectedTabHighlight = null;
|
||||
}
|
||||
|
||||
// UI Rendering
|
||||
|
||||
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
|
||||
int selectedIndex,
|
||||
int x, int y, int w, int h) {
|
||||
Rectangle selRect = selectedIndex < 0? null :
|
||||
getTabBounds(selectedIndex, calcRect);
|
||||
g.setColor(lightHighlight);
|
||||
|
||||
// Draw unbroken line if tabs are not on TOP, OR
|
||||
// selected tab is not visible (SCROLL_TAB_LAYOUT)
|
||||
//
|
||||
if (tabPlacement != TOP || selectedIndex < 0 ||
|
||||
(selRect.x < x || selRect.x > x + w)) {
|
||||
g.drawLine(x, y, x+w-2, y);
|
||||
} else {
|
||||
// Break line to show visual connection to selected tab
|
||||
g.drawLine(x, y, selRect.x - 1, y);
|
||||
if (selRect.x + selRect.width < x + w - 2) {
|
||||
g.drawLine(selRect.x + selRect.width, y,
|
||||
x+w-2, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
|
||||
int selectedIndex,
|
||||
int x, int y, int w, int h) {
|
||||
Rectangle selRect = selectedIndex < 0? null :
|
||||
getTabBounds(selectedIndex, calcRect);
|
||||
g.setColor(shadow);
|
||||
|
||||
// Draw unbroken line if tabs are not on BOTTOM, OR
|
||||
// selected tab is not visible (SCROLL_TAB_LAYOUT)
|
||||
//
|
||||
if (tabPlacement != BOTTOM || selectedIndex < 0 ||
|
||||
(selRect.x < x || selRect.x > x + w)) {
|
||||
g.drawLine(x+1, y+h-1, x+w-1, y+h-1);
|
||||
} else {
|
||||
// Break line to show visual connection to selected tab
|
||||
g.drawLine(x+1, y+h-1, selRect.x - 1, y+h-1);
|
||||
if (selRect.x + selRect.width < x + w - 2) {
|
||||
g.drawLine(selRect.x + selRect.width, y+h-1, x+w-2, y+h-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
|
||||
int selectedIndex,
|
||||
int x, int y, int w, int h) {
|
||||
Rectangle selRect = selectedIndex < 0? null :
|
||||
getTabBounds(selectedIndex, calcRect);
|
||||
g.setColor(shadow);
|
||||
// Draw unbroken line if tabs are not on RIGHT, OR
|
||||
// selected tab is not visible (SCROLL_TAB_LAYOUT)
|
||||
//
|
||||
if (tabPlacement != RIGHT || selectedIndex < 0 ||
|
||||
(selRect.y < y || selRect.y > y + h)) {
|
||||
g.drawLine(x+w-1, y+1, x+w-1, y+h-1);
|
||||
} else {
|
||||
// Break line to show visual connection to selected tab
|
||||
g.drawLine(x+w-1, y+1, x+w-1, selRect.y - 1);
|
||||
if (selRect.y + selRect.height < y + h - 2 ) {
|
||||
g.drawLine(x+w-1, selRect.y + selRect.height,
|
||||
x+w-1, y+h-2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void paintTabBackground(Graphics g,
|
||||
int tabPlacement, int tabIndex,
|
||||
int x, int y, int w, int h,
|
||||
boolean isSelected ) {
|
||||
g.setColor(isSelected? tabPane.getBackgroundAt(tabIndex) : unselectedTabBackground);
|
||||
switch(tabPlacement) {
|
||||
case LEFT:
|
||||
g.fillRect(x+1, y+1, w-1, h-2);
|
||||
break;
|
||||
case RIGHT:
|
||||
g.fillRect(x, y+1, w-1, h-2);
|
||||
break;
|
||||
case BOTTOM:
|
||||
g.fillRect(x+1, y, w-2, h-3);
|
||||
g.drawLine(x+2, y+h-3, x+w-3, y+h-3);
|
||||
g.drawLine(x+3, y+h-2, x+w-4, y+h-2);
|
||||
break;
|
||||
case TOP:
|
||||
default:
|
||||
g.fillRect(x+1, y+3, w-2, h-3);
|
||||
g.drawLine(x+2, y+2, x+w-3, y+2);
|
||||
g.drawLine(x+3, y+1, x+w-4, y+1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void paintTabBorder(Graphics g,
|
||||
int tabPlacement, int tabIndex,
|
||||
int x, int y, int w, int h,
|
||||
boolean isSelected) {
|
||||
g.setColor(isSelected? lightHighlight : unselectedTabHighlight);
|
||||
|
||||
switch(tabPlacement) {
|
||||
case LEFT:
|
||||
g.drawLine(x, y+2, x, y+h-3);
|
||||
g.drawLine(x+1, y+1, x+1, y+2);
|
||||
g.drawLine(x+2, y, x+2, y+1);
|
||||
g.drawLine(x+3, y, x+w-1, y);
|
||||
g.setColor(isSelected? shadow : unselectedTabShadow);
|
||||
g.drawLine(x+1, y+h-3, x+1, y+h-2);
|
||||
g.drawLine(x+2, y+h-2, x+2, y+h-1);
|
||||
g.drawLine(x+3, y+h-1, x+w-1, y+h-1);
|
||||
break;
|
||||
case RIGHT:
|
||||
g.drawLine(x, y, x+w-3, y);
|
||||
g.setColor(isSelected? shadow : unselectedTabShadow);
|
||||
g.drawLine(x+w-3, y, x+w-3, y+1);
|
||||
g.drawLine(x+w-2, y+1, x+w-2, y+2);
|
||||
g.drawLine(x+w-1, y+2, x+w-1, y+h-3);
|
||||
g.drawLine(x+w-2, y+h-3, x+w-2, y+h-2);
|
||||
g.drawLine(x+w-3, y+h-2, x+w-3, y+h-1);
|
||||
g.drawLine(x, y+h-1, x+w-3, y+h-1);
|
||||
break;
|
||||
case BOTTOM:
|
||||
g.drawLine(x, y, x, y+h-3);
|
||||
g.drawLine(x+1, y+h-3, x+1, y+h-2);
|
||||
g.drawLine(x+2, y+h-2, x+2, y+h-1);
|
||||
g.setColor(isSelected? shadow : unselectedTabShadow);
|
||||
g.drawLine(x+3, y+h-1, x+w-4, y+h-1);
|
||||
g.drawLine(x+w-3, y+h-2, x+w-3, y+h-1);
|
||||
g.drawLine(x+w-2, y+h-3, x+w-2, y+h-2);
|
||||
g.drawLine(x+w-1, y, x+w-1, y+h-3);
|
||||
break;
|
||||
case TOP:
|
||||
default:
|
||||
g.drawLine(x, y+2, x, y+h-1);
|
||||
g.drawLine(x+1, y+1, x+1, y+2);
|
||||
g.drawLine(x+2, y, x+2, y+1);
|
||||
g.drawLine(x+3, y, x+w-4, y);
|
||||
g.setColor(isSelected? shadow : unselectedTabShadow);
|
||||
g.drawLine(x+w-3, y, x+w-3, y+1);
|
||||
g.drawLine(x+w-2, y+1, x+w-2, y+2);
|
||||
g.drawLine(x+w-1, y+2, x+w-1, y+h-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void paintFocusIndicator(Graphics g, int tabPlacement,
|
||||
Rectangle[] rects, int tabIndex,
|
||||
Rectangle iconRect, Rectangle textRect,
|
||||
boolean isSelected) {
|
||||
Rectangle tabRect = rects[tabIndex];
|
||||
if (tabPane.hasFocus() && isSelected) {
|
||||
int x, y, w, h;
|
||||
g.setColor(focus);
|
||||
switch(tabPlacement) {
|
||||
case LEFT:
|
||||
x = tabRect.x + 3;
|
||||
y = tabRect.y + 3;
|
||||
w = tabRect.width - 6;
|
||||
h = tabRect.height - 7;
|
||||
break;
|
||||
case RIGHT:
|
||||
x = tabRect.x + 2;
|
||||
y = tabRect.y + 3;
|
||||
w = tabRect.width - 6;
|
||||
h = tabRect.height - 7;
|
||||
break;
|
||||
case BOTTOM:
|
||||
x = tabRect.x + 3;
|
||||
y = tabRect.y + 2;
|
||||
w = tabRect.width - 7;
|
||||
h = tabRect.height - 6;
|
||||
break;
|
||||
case TOP:
|
||||
default:
|
||||
x = tabRect.x + 3;
|
||||
y = tabRect.y + 3;
|
||||
w = tabRect.width - 7;
|
||||
h = tabRect.height - 6;
|
||||
}
|
||||
g.drawRect(x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
protected int getTabRunIndent(int tabPlacement, int run) {
|
||||
return run*3;
|
||||
}
|
||||
|
||||
protected int getTabRunOverlay(int tabPlacement) {
|
||||
tabRunOverlay = (tabPlacement == LEFT || tabPlacement == RIGHT)?
|
||||
(int)Math.round((float)maxTabWidth * .10) :
|
||||
(int)Math.round((float)maxTabHeight * .22);
|
||||
|
||||
// Ensure that runover lay is not more than insets
|
||||
// 2 pixel offset is set from insets to each run
|
||||
switch(tabPlacement) {
|
||||
case LEFT:
|
||||
if( tabRunOverlay > tabInsets.right - 2 )
|
||||
tabRunOverlay = tabInsets.right - 2 ;
|
||||
break;
|
||||
case RIGHT:
|
||||
if( tabRunOverlay > tabInsets.left - 2 )
|
||||
tabRunOverlay = tabInsets.left - 2 ;
|
||||
break;
|
||||
case TOP:
|
||||
if( tabRunOverlay > tabInsets.bottom - 2 )
|
||||
tabRunOverlay = tabInsets.bottom - 2 ;
|
||||
break;
|
||||
case BOTTOM:
|
||||
if( tabRunOverlay > tabInsets.top - 2 )
|
||||
tabRunOverlay = tabInsets.top - 2 ;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return tabRunOverlay;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicTextAreaUI;
|
||||
|
||||
/**
|
||||
* Provides the look and feel for a plain text editor. In this
|
||||
* implementation the default UI is extended to act as a simple
|
||||
* view factory.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Timothy Prinzing
|
||||
*/
|
||||
public class MotifTextAreaUI extends BasicTextAreaUI {
|
||||
|
||||
/**
|
||||
* Creates a UI for a JTextArea.
|
||||
*
|
||||
* @param ta a text area
|
||||
* @return the UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent ta) {
|
||||
return new MotifTextAreaUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object to use for a caret. By default an
|
||||
* instance of MotifTextUI.MotifCaret is created. This method
|
||||
* can be redefined to provide something else that implements
|
||||
* the Caret interface.
|
||||
*
|
||||
* @return the caret object
|
||||
*/
|
||||
protected Caret createCaret() {
|
||||
return MotifTextUI.createCaret();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicTextFieldUI;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.text.Caret;
|
||||
|
||||
/**
|
||||
* Provides the Motif look and feel for a text field.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Timothy Prinzing
|
||||
*/
|
||||
public class MotifTextFieldUI extends BasicTextFieldUI {
|
||||
|
||||
/**
|
||||
* Creates a UI for a JTextField.
|
||||
*
|
||||
* @param c the text field
|
||||
* @return the UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new MotifTextFieldUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object to use for a caret. By default an
|
||||
* instance of MotifTextUI.MotifCaret is created. This method
|
||||
* can be redefined to provide something else that implements
|
||||
* the Caret interface.
|
||||
*
|
||||
* @return the caret object
|
||||
*/
|
||||
protected Caret createCaret() {
|
||||
return MotifTextUI.createCaret();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicTextPaneUI;
|
||||
|
||||
/**
|
||||
* Provides the look and feel for a styled text editor.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Timothy Prinzing
|
||||
*/
|
||||
public class MotifTextPaneUI extends BasicTextPaneUI {
|
||||
|
||||
/**
|
||||
* Creates a UI for the JTextPane.
|
||||
*
|
||||
* @param c the JTextPane object
|
||||
* @return the UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new MotifTextPaneUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object to use for a caret. By default an
|
||||
* instance of MotifTextUI.MotifCaret is created. This method
|
||||
* can be redefined to provide something else that implements
|
||||
* the Caret interface.
|
||||
*
|
||||
* @return the caret object
|
||||
*/
|
||||
protected Caret createCaret() {
|
||||
return MotifTextUI.createCaret();
|
||||
}
|
||||
|
||||
}
|
||||
175
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifTextUI.java
Normal file
175
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifTextUI.java
Normal file
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
/**
|
||||
* Provides the look and feel features that are common across
|
||||
* the Motif/CDE text LAF implementations.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Timothy Prinzing
|
||||
*/
|
||||
public class MotifTextUI {
|
||||
|
||||
/**
|
||||
* Creates the object to use for a caret for all of the Motif
|
||||
* text components. The caret is rendered as an I-beam on Motif.
|
||||
*
|
||||
* @return the caret object
|
||||
*/
|
||||
public static Caret createCaret() {
|
||||
return new MotifCaret();
|
||||
}
|
||||
|
||||
/**
|
||||
* The motif caret is rendered as an I beam.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public static class MotifCaret extends DefaultCaret implements UIResource {
|
||||
|
||||
/**
|
||||
* Called when the component containing the caret gains
|
||||
* focus. This is implemented to repaint the component
|
||||
* so the focus rectangle will be re-rendered, as well
|
||||
* as providing the superclass behavior.
|
||||
*
|
||||
* @param e the focus event
|
||||
* @see FocusListener#focusGained
|
||||
*/
|
||||
public void focusGained(FocusEvent e) {
|
||||
super.focusGained(e);
|
||||
getComponent().repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the component containing the caret loses
|
||||
* focus. This is implemented to set the caret to visibility
|
||||
* to false.
|
||||
*
|
||||
* @param e the focus event
|
||||
* @see FocusListener#focusLost
|
||||
*/
|
||||
public void focusLost(FocusEvent e) {
|
||||
super.focusLost(e);
|
||||
getComponent().repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Damages the area surrounding the caret to cause
|
||||
* it to be repainted. If paint() is reimplemented,
|
||||
* this method should also be reimplemented.
|
||||
*
|
||||
* @param r the current location of the caret, does nothing if null
|
||||
* @see #paint
|
||||
*/
|
||||
protected void damage(Rectangle r) {
|
||||
if (r != null) {
|
||||
x = r.x - IBeamOverhang - 1;
|
||||
y = r.y;
|
||||
width = r.width + (2 * IBeamOverhang) + 3;
|
||||
height = r.height;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the caret as a vertical line. If this is reimplemented
|
||||
* the damage method should also be reimplemented as it assumes the
|
||||
* shape of the caret is a vertical line. Does nothing if isVisible()
|
||||
* is false. The caret color is derived from getCaretColor() if
|
||||
* the component has focus, else from getDisabledTextColor().
|
||||
*
|
||||
* @param g the graphics context
|
||||
* @see #damage
|
||||
*/
|
||||
public void paint(Graphics g) {
|
||||
if(isVisible()) {
|
||||
try {
|
||||
JTextComponent c = getComponent();
|
||||
Color fg = c.hasFocus() ? c.getCaretColor() :
|
||||
c.getDisabledTextColor();
|
||||
TextUI mapper = c.getUI();
|
||||
int dot = getDot();
|
||||
Rectangle r = mapper.modelToView(c, dot);
|
||||
int x0 = r.x - IBeamOverhang;
|
||||
int x1 = r.x + IBeamOverhang;
|
||||
int y0 = r.y + 1;
|
||||
int y1 = r.y + r.height - 2;
|
||||
g.setColor(fg);
|
||||
g.drawLine(r.x, y0, r.x, y1);
|
||||
g.drawLine(x0, y0, x1, y0);
|
||||
g.drawLine(x0, y1, x1, y1);
|
||||
} catch (BadLocationException e) {
|
||||
// can't render I guess
|
||||
//System.err.println("Can't render caret");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static final int IBeamOverhang = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default bindings all keymaps implementing the Motif feel.
|
||||
*/
|
||||
static final JTextComponent.KeyBinding[] defaultBindings = {
|
||||
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT,
|
||||
InputEvent.CTRL_MASK),
|
||||
DefaultEditorKit.copyAction),
|
||||
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT,
|
||||
InputEvent.SHIFT_MASK),
|
||||
DefaultEditorKit.pasteAction),
|
||||
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,
|
||||
InputEvent.SHIFT_MASK),
|
||||
DefaultEditorKit.cutAction),
|
||||
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,
|
||||
InputEvent.SHIFT_MASK),
|
||||
DefaultEditorKit.selectionBackwardAction),
|
||||
new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
|
||||
InputEvent.SHIFT_MASK),
|
||||
DefaultEditorKit.selectionForwardAction),
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
|
||||
|
||||
/**
|
||||
* BasicToggleButton implementation
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
public class MotifToggleButtonUI extends BasicToggleButtonUI
|
||||
{
|
||||
private static final Object MOTIF_TOGGLE_BUTTON_UI_KEY = new Object();
|
||||
|
||||
protected Color selectColor;
|
||||
|
||||
private boolean defaults_initialized = false;
|
||||
|
||||
// ********************************
|
||||
// Create PLAF
|
||||
// ********************************
|
||||
public static ComponentUI createUI(JComponent b) {
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
MotifToggleButtonUI motifToggleButtonUI =
|
||||
(MotifToggleButtonUI) appContext.get(MOTIF_TOGGLE_BUTTON_UI_KEY);
|
||||
if (motifToggleButtonUI == null) {
|
||||
motifToggleButtonUI = new MotifToggleButtonUI();
|
||||
appContext.put(MOTIF_TOGGLE_BUTTON_UI_KEY, motifToggleButtonUI);
|
||||
}
|
||||
return motifToggleButtonUI;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Install Defaults
|
||||
// ********************************
|
||||
public void installDefaults(AbstractButton b) {
|
||||
super.installDefaults(b);
|
||||
if(!defaults_initialized) {
|
||||
selectColor = UIManager.getColor(getPropertyPrefix() + "select");
|
||||
defaults_initialized = true;
|
||||
}
|
||||
LookAndFeel.installProperty(b, "opaque", Boolean.FALSE);
|
||||
}
|
||||
|
||||
protected void uninstallDefaults(AbstractButton b) {
|
||||
super.uninstallDefaults(b);
|
||||
defaults_initialized = false;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Default Accessors
|
||||
// ********************************
|
||||
|
||||
protected Color getSelectColor() {
|
||||
return selectColor;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Paint Methods
|
||||
// ********************************
|
||||
protected void paintButtonPressed(Graphics g, AbstractButton b) {
|
||||
if (b.isContentAreaFilled()) {
|
||||
Color oldColor = g.getColor();
|
||||
Dimension size = b.getSize();
|
||||
Insets insets = b.getInsets();
|
||||
Insets margin = b.getMargin();
|
||||
|
||||
if(b.getBackground() instanceof UIResource) {
|
||||
g.setColor(getSelectColor());
|
||||
}
|
||||
g.fillRect(insets.left - margin.left,
|
||||
insets.top - margin.top,
|
||||
size.width - (insets.left-margin.left) - (insets.right - margin.right),
|
||||
size.height - (insets.top-margin.top) - (insets.bottom - margin.bottom));
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
}
|
||||
|
||||
public Insets getInsets(JComponent c) {
|
||||
Border border = c.getBorder();
|
||||
Insets i = border != null? border.getBorderInsets(c) : new Insets(0,0,0,0);
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.tree.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Motif rendered to display a tree cell.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public class MotifTreeCellRenderer extends DefaultTreeCellRenderer
|
||||
{
|
||||
static final int LEAF_SIZE = 13;
|
||||
static final Icon LEAF_ICON = new IconUIResource(new TreeLeafIcon());
|
||||
|
||||
public MotifTreeCellRenderer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static Icon loadLeafIcon() {
|
||||
return LEAF_ICON;
|
||||
}
|
||||
|
||||
/**
|
||||
* Icon for a node with no children.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public static class TreeLeafIcon implements Icon, Serializable {
|
||||
|
||||
Color bg;
|
||||
Color shadow;
|
||||
Color highlight;
|
||||
|
||||
public TreeLeafIcon() {
|
||||
bg = UIManager.getColor("Tree.iconBackground");
|
||||
shadow = UIManager.getColor("Tree.iconShadow");
|
||||
highlight = UIManager.getColor("Tree.iconHighlight");
|
||||
}
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
g.setColor(bg);
|
||||
|
||||
y -= 3;
|
||||
g.fillRect(x + 4, y + 7, 5, 5);
|
||||
|
||||
g.drawLine(x + 6, y + 6, x + 6, y + 6);
|
||||
g.drawLine(x + 3, y + 9, x + 3, y + 9);
|
||||
g.drawLine(x + 6, y + 12, x + 6, y + 12);
|
||||
g.drawLine(x + 9, y + 9, x + 9, y + 9);
|
||||
|
||||
g.setColor(highlight);
|
||||
g.drawLine(x + 2, y + 9, x + 5, y + 6);
|
||||
g.drawLine(x + 3, y + 10, x + 5, y + 12);
|
||||
|
||||
g.setColor(shadow);
|
||||
g.drawLine(x + 6, y + 13, x + 10, y + 9);
|
||||
g.drawLine(x + 9, y + 8, x + 7, y + 6);
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
return LEAF_SIZE;
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
return LEAF_SIZE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
166
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifTreeUI.java
Normal file
166
jdkSrc/jdk8/com/sun/java/swing/plaf/motif/MotifTreeUI.java
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.motif;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.tree.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
|
||||
/**
|
||||
* Motif rendition of the tree component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public class MotifTreeUI extends BasicTreeUI
|
||||
{
|
||||
static final int HALF_SIZE = 7;
|
||||
static final int SIZE = 14;
|
||||
|
||||
/**
|
||||
* creates a UI object to represent a Motif Tree widget
|
||||
*/
|
||||
public MotifTreeUI() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void installUI(JComponent c) {
|
||||
super.installUI(c);
|
||||
}
|
||||
|
||||
// BasicTreeUI overrides
|
||||
|
||||
protected void paintVerticalLine( Graphics g, JComponent c, int x, int top, int bottom )
|
||||
{
|
||||
if (tree.getComponentOrientation().isLeftToRight()) {
|
||||
g.fillRect( x, top, 2, bottom - top + 2 );
|
||||
} else {
|
||||
g.fillRect( x - 1, top, 2, bottom - top + 2 );
|
||||
}
|
||||
}
|
||||
|
||||
protected void paintHorizontalLine( Graphics g, JComponent c, int y, int left, int right )
|
||||
{
|
||||
g.fillRect( left, y, right - left + 1, 2 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The minus sign button icon.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public static class MotifExpandedIcon implements Icon, Serializable {
|
||||
static Color bg;
|
||||
static Color fg;
|
||||
static Color highlight;
|
||||
static Color shadow;
|
||||
|
||||
public MotifExpandedIcon() {
|
||||
bg = UIManager.getColor("Tree.iconBackground");
|
||||
fg = UIManager.getColor("Tree.iconForeground");
|
||||
highlight = UIManager.getColor("Tree.iconHighlight");
|
||||
shadow = UIManager.getColor("Tree.iconShadow");
|
||||
}
|
||||
|
||||
public static Icon createExpandedIcon() {
|
||||
return new MotifExpandedIcon();
|
||||
}
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
g.setColor(highlight);
|
||||
g.drawLine(x, y, x+SIZE-1, y);
|
||||
g.drawLine(x, y+1, x, y+SIZE-1);
|
||||
|
||||
g.setColor(shadow);
|
||||
g.drawLine(x+SIZE-1, y+1, x+SIZE-1, y+SIZE-1);
|
||||
g.drawLine(x+1, y+SIZE-1, x+SIZE-1, y+SIZE-1);
|
||||
|
||||
g.setColor(bg);
|
||||
g.fillRect(x+1, y+1, SIZE-2, SIZE-2);
|
||||
|
||||
g.setColor(fg);
|
||||
g.drawLine(x+3, y+HALF_SIZE-1, x+SIZE-4, y+HALF_SIZE-1);
|
||||
g.drawLine(x+3, y+HALF_SIZE, x+SIZE-4, y+HALF_SIZE);
|
||||
}
|
||||
|
||||
public int getIconWidth() { return SIZE; }
|
||||
public int getIconHeight() { return SIZE; }
|
||||
}
|
||||
|
||||
/**
|
||||
* The plus sign button icon.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public static class MotifCollapsedIcon extends MotifExpandedIcon {
|
||||
public static Icon createCollapsedIcon() {
|
||||
return new MotifCollapsedIcon();
|
||||
}
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
super.paintIcon(c, g, x, y);
|
||||
g.drawLine(x + HALF_SIZE-1, y + 3, x + HALF_SIZE-1, y + (SIZE - 4));
|
||||
g.drawLine(x + HALF_SIZE, y + 3, x + HALF_SIZE, y + (SIZE - 4));
|
||||
}
|
||||
}
|
||||
|
||||
public static ComponentUI createUI(JComponent x) {
|
||||
return new MotifTreeUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default cell renderer that is used to do the
|
||||
* stamping of each node.
|
||||
*/
|
||||
public TreeCellRenderer createDefaultCellRenderer() {
|
||||
return new MotifTreeCellRenderer();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sun.java.swing.plaf.motif.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class motif extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
|
||||
{ "FileChooser.cancelButton.textAndMnemonic", "Cancel" },
|
||||
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Abort file chooser dialog." },
|
||||
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "E&nter file name:" },
|
||||
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Enter folder name:" },
|
||||
{ "FileChooser.filesLabel.textAndMnemonic", "F&iles" },
|
||||
{ "FileChooser.filterLabel.textAndMnemonic", "Filte&r" },
|
||||
{ "FileChooser.foldersLabel.textAndMnemonic", "Fo&lders" },
|
||||
{ "FileChooser.helpButton.textAndMnemonic", "Help" },
|
||||
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "FileChooser help." },
|
||||
{ "FileChooser.openButton.textAndMnemonic", "OK" },
|
||||
{ "FileChooser.openButtonToolTip.textAndMnemonic", "Open selected file." },
|
||||
{ "FileChooser.openDialogTitle.textAndMnemonic", "Open" },
|
||||
{ "FileChooser.pathLabel.textAndMnemonic", "Enter &path or folder name:" },
|
||||
{ "FileChooser.saveButton.textAndMnemonic", "Save" },
|
||||
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Save selected file." },
|
||||
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Save" },
|
||||
{ "FileChooser.updateButton.textAndMnemonic", "Update" },
|
||||
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Update directory listing." },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sun.java.swing.plaf.motif.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class motif_de extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
|
||||
{ "FileChooser.cancelButton.textAndMnemonic", "Abbrechen" },
|
||||
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Dialogfeld f\u00FCr Dateiauswahl schlie\u00DFen." },
|
||||
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "Dateina&me eingeben:" },
|
||||
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Ordnernamen eingeben:" },
|
||||
{ "FileChooser.filesLabel.textAndMnemonic", "Date&ien" },
|
||||
{ "FileChooser.filterLabel.textAndMnemonic", "Filte&r" },
|
||||
{ "FileChooser.foldersLabel.textAndMnemonic", "Ord&ner" },
|
||||
{ "FileChooser.helpButton.textAndMnemonic", "Hilfe" },
|
||||
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "FileChooser-Hilfe." },
|
||||
{ "FileChooser.openButton.textAndMnemonic", "OK" },
|
||||
{ "FileChooser.openButtonToolTip.textAndMnemonic", "Ausgew\u00E4hlte Datei \u00F6ffnen." },
|
||||
{ "FileChooser.openDialogTitle.textAndMnemonic", "\u00D6ffnen" },
|
||||
{ "FileChooser.pathLabel.textAndMnemonic", "&Pfad- oder Ordnername eingeben:" },
|
||||
{ "FileChooser.saveButton.textAndMnemonic", "Speichern" },
|
||||
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Ausgew\u00E4hlte Datei speichern." },
|
||||
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Speichern" },
|
||||
{ "FileChooser.updateButton.textAndMnemonic", "Aktualisieren" },
|
||||
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Verzeichnisliste aktualisieren." },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sun.java.swing.plaf.motif.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class motif_es extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
|
||||
{ "FileChooser.cancelButton.textAndMnemonic", "Cancelar" },
|
||||
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Abortar cuadro de di\u00E1logo del selector de archivos." },
|
||||
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "I&ntroducir nombre de archivo:" },
|
||||
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Introducir nombre de carpeta:" },
|
||||
{ "FileChooser.filesLabel.textAndMnemonic", "Arch&ivos" },
|
||||
{ "FileChooser.filterLabel.textAndMnemonic", "Filt&ro" },
|
||||
{ "FileChooser.foldersLabel.textAndMnemonic", "Carpe&tas" },
|
||||
{ "FileChooser.helpButton.textAndMnemonic", "Ayuda" },
|
||||
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "Ayuda del selector de archivos." },
|
||||
{ "FileChooser.openButton.textAndMnemonic", "Aceptar" },
|
||||
{ "FileChooser.openButtonToolTip.textAndMnemonic", "Abrir archivo seleccionado." },
|
||||
{ "FileChooser.openDialogTitle.textAndMnemonic", "Abrir" },
|
||||
{ "FileChooser.pathLabel.textAndMnemonic", "Introducir nombre de ruta de acceso o car&peta:" },
|
||||
{ "FileChooser.saveButton.textAndMnemonic", "Guardar" },
|
||||
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Guardar archivo seleccionado." },
|
||||
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Guardar" },
|
||||
{ "FileChooser.updateButton.textAndMnemonic", "Actualizar" },
|
||||
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Actualizar lista de directorios." },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sun.java.swing.plaf.motif.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class motif_fr extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
|
||||
{ "FileChooser.cancelButton.textAndMnemonic", "Annuler" },
|
||||
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Ferme la bo\u00EEte de dialogue du s\u00E9lecteur de fichiers." },
|
||||
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "E&ntrez le nom du fichier :" },
|
||||
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Entrez le nom du dossier :" },
|
||||
{ "FileChooser.filesLabel.textAndMnemonic", "F&ichiers" },
|
||||
{ "FileChooser.filterLabel.textAndMnemonic", "Filt&re" },
|
||||
{ "FileChooser.foldersLabel.textAndMnemonic", "&Dossiers" },
|
||||
{ "FileChooser.helpButton.textAndMnemonic", "Aide" },
|
||||
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "Aide du s\u00E9lecteur de fichiers" },
|
||||
{ "FileChooser.openButton.textAndMnemonic", "OK" },
|
||||
{ "FileChooser.openButtonToolTip.textAndMnemonic", "Ouvre le fichier s\u00E9lectionn\u00E9." },
|
||||
{ "FileChooser.openDialogTitle.textAndMnemonic", "Ouvrir" },
|
||||
{ "FileChooser.pathLabel.textAndMnemonic", "Entrez le c&hemin ou le nom du dossier :" },
|
||||
{ "FileChooser.saveButton.textAndMnemonic", "Enregistrer" },
|
||||
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Enregistre le fichier s\u00E9lectionn\u00E9." },
|
||||
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Enregistrer" },
|
||||
{ "FileChooser.updateButton.textAndMnemonic", "Mettre \u00E0 jour" },
|
||||
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Met \u00E0 jour la liste des r\u00E9pertoires." },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sun.java.swing.plaf.motif.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class motif_it extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
|
||||
{ "FileChooser.cancelButton.textAndMnemonic", "Annulla" },
|
||||
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Chiude la finestra di dialogo di selezione file." },
|
||||
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "Immettere il &nome file: " },
|
||||
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Nome cartella:" },
|
||||
{ "FileChooser.filesLabel.textAndMnemonic", "F&ile" },
|
||||
{ "FileChooser.filterLabel.textAndMnemonic", "Filt&ro" },
|
||||
{ "FileChooser.foldersLabel.textAndMnemonic", "Car&telle" },
|
||||
{ "FileChooser.helpButton.textAndMnemonic", "?" },
|
||||
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "Guida FileChooser." },
|
||||
{ "FileChooser.openButton.textAndMnemonic", "OK" },
|
||||
{ "FileChooser.openButtonToolTip.textAndMnemonic", "Apre il file selezionato." },
|
||||
{ "FileChooser.openDialogTitle.textAndMnemonic", "Apri" },
|
||||
{ "FileChooser.pathLabel.textAndMnemonic", "&Percorso o nome cartella:" },
|
||||
{ "FileChooser.saveButton.textAndMnemonic", "Salva" },
|
||||
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Salva il file selezionato." },
|
||||
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Salva" },
|
||||
{ "FileChooser.updateButton.textAndMnemonic", "Aggiorna" },
|
||||
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Aggiorna lista directory." },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sun.java.swing.plaf.motif.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class motif_ja extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
|
||||
{ "FileChooser.cancelButton.textAndMnemonic", "\u53D6\u6D88" },
|
||||
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "\u30D5\u30A1\u30A4\u30EB\u30FB\u30C1\u30E5\u30FC\u30B6\u30FB\u30C0\u30A4\u30A2\u30ED\u30B0\u3092\u7D42\u4E86\u3057\u307E\u3059\u3002" },
|
||||
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "\u30D5\u30A1\u30A4\u30EB\u540D\u3092\u5165\u529B(&N):" },
|
||||
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "\u30D5\u30A9\u30EB\u30C0\u540D\u3092\u5165\u529B:" },
|
||||
{ "FileChooser.filesLabel.textAndMnemonic", "\u30D5\u30A1\u30A4\u30EB(&I)" },
|
||||
{ "FileChooser.filterLabel.textAndMnemonic", "\u30D5\u30A3\u30EB\u30BF(&R)" },
|
||||
{ "FileChooser.foldersLabel.textAndMnemonic", "\u30D5\u30A9\u30EB\u30C0(&L)" },
|
||||
{ "FileChooser.helpButton.textAndMnemonic", "\u30D8\u30EB\u30D7" },
|
||||
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "FileChooser\u306E\u30D8\u30EB\u30D7\u3067\u3059\u3002" },
|
||||
{ "FileChooser.openButton.textAndMnemonic", "OK" },
|
||||
{ "FileChooser.openButtonToolTip.textAndMnemonic", "\u9078\u629E\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u958B\u304D\u307E\u3059\u3002" },
|
||||
{ "FileChooser.openDialogTitle.textAndMnemonic", "\u958B\u304F" },
|
||||
{ "FileChooser.pathLabel.textAndMnemonic", "\u30D1\u30B9\u307E\u305F\u306F\u30D5\u30A9\u30EB\u30C0\u540D\u3092\u5165\u529B(&P):" },
|
||||
{ "FileChooser.saveButton.textAndMnemonic", "\u4FDD\u5B58" },
|
||||
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "\u9078\u629E\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u4FDD\u5B58\u3057\u307E\u3059\u3002" },
|
||||
{ "FileChooser.saveDialogTitle.textAndMnemonic", "\u4FDD\u5B58" },
|
||||
{ "FileChooser.updateButton.textAndMnemonic", "\u66F4\u65B0" },
|
||||
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30EA\u30B9\u30C8\u3092\u66F4\u65B0\u3057\u307E\u3059\u3002" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sun.java.swing.plaf.motif.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class motif_ko extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
|
||||
{ "FileChooser.cancelButton.textAndMnemonic", "\uCDE8\uC18C" },
|
||||
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "\uD30C\uC77C \uC120\uD0DD\uAE30 \uB300\uD654\uC0C1\uC790\uB97C \uC911\uB2E8\uD569\uB2C8\uB2E4." },
|
||||
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "\uD30C\uC77C \uC774\uB984 \uC785\uB825(&N):" },
|
||||
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "\uD3F4\uB354 \uC774\uB984 \uC785\uB825:" },
|
||||
{ "FileChooser.filesLabel.textAndMnemonic", "\uD30C\uC77C(&I)" },
|
||||
{ "FileChooser.filterLabel.textAndMnemonic", "\uD544\uD130(&R)" },
|
||||
{ "FileChooser.foldersLabel.textAndMnemonic", "\uD3F4\uB354(&L)" },
|
||||
{ "FileChooser.helpButton.textAndMnemonic", "\uB3C4\uC6C0\uB9D0" },
|
||||
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "FileChooser \uB3C4\uC6C0\uB9D0\uC785\uB2C8\uB2E4." },
|
||||
{ "FileChooser.openButton.textAndMnemonic", "\uD655\uC778" },
|
||||
{ "FileChooser.openButtonToolTip.textAndMnemonic", "\uC120\uD0DD\uB41C \uD30C\uC77C\uC744 \uC5FD\uB2C8\uB2E4." },
|
||||
{ "FileChooser.openDialogTitle.textAndMnemonic", "\uC5F4\uAE30" },
|
||||
{ "FileChooser.pathLabel.textAndMnemonic", "\uACBD\uB85C \uB610\uB294 \uD3F4\uB354 \uC774\uB984 \uC785\uB825(&P):" },
|
||||
{ "FileChooser.saveButton.textAndMnemonic", "\uC800\uC7A5" },
|
||||
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "\uC120\uD0DD\uB41C \uD30C\uC77C\uC744 \uC800\uC7A5\uD569\uB2C8\uB2E4." },
|
||||
{ "FileChooser.saveDialogTitle.textAndMnemonic", "\uC800\uC7A5" },
|
||||
{ "FileChooser.updateButton.textAndMnemonic", "\uC5C5\uB370\uC774\uD2B8" },
|
||||
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "\uB514\uB809\uD1A0\uB9AC \uBAA9\uB85D\uC744 \uC5C5\uB370\uC774\uD2B8\uD569\uB2C8\uB2E4." },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sun.java.swing.plaf.motif.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class motif_pt_BR extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
|
||||
{ "FileChooser.cancelButton.textAndMnemonic", "Cancelar" },
|
||||
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Abortar caixa de di\u00E1logo do seletor de arquivos." },
|
||||
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "I&nforme o nome do arquivo:" },
|
||||
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Informar nome da pasta:" },
|
||||
{ "FileChooser.filesLabel.textAndMnemonic", "Arqu&ivos" },
|
||||
{ "FileChooser.filterLabel.textAndMnemonic", "Filt&ro" },
|
||||
{ "FileChooser.foldersLabel.textAndMnemonic", "Pa&stas" },
|
||||
{ "FileChooser.helpButton.textAndMnemonic", "Ajuda" },
|
||||
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "Ajuda do FileChooser." },
|
||||
{ "FileChooser.openButton.textAndMnemonic", "OK" },
|
||||
{ "FileChooser.openButtonToolTip.textAndMnemonic", "Abrir arquivo selecionado." },
|
||||
{ "FileChooser.openDialogTitle.textAndMnemonic", "Abrir" },
|
||||
{ "FileChooser.pathLabel.textAndMnemonic", "Informar &caminho ou nome da pasta:" },
|
||||
{ "FileChooser.saveButton.textAndMnemonic", "Salvar" },
|
||||
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Salvar arquivo selecionado." },
|
||||
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Salvar" },
|
||||
{ "FileChooser.updateButton.textAndMnemonic", "Atualizar" },
|
||||
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Atualizar lista de diret\u00F3rios." },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sun.java.swing.plaf.motif.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class motif_sv extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
|
||||
{ "FileChooser.cancelButton.textAndMnemonic", "Avbryt" },
|
||||
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "Avbryt dialogrutan f\u00F6r filval." },
|
||||
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "A&nge filnamn:" },
|
||||
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "Ange ett mappnamn:" },
|
||||
{ "FileChooser.filesLabel.textAndMnemonic", "F&iler" },
|
||||
{ "FileChooser.filterLabel.textAndMnemonic", "Filte&r" },
|
||||
{ "FileChooser.foldersLabel.textAndMnemonic", "Ma&ppar" },
|
||||
{ "FileChooser.helpButton.textAndMnemonic", "Hj\u00E4lp" },
|
||||
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "Hj\u00E4lp f\u00F6r val av fil." },
|
||||
{ "FileChooser.openButton.textAndMnemonic", "OK" },
|
||||
{ "FileChooser.openButtonToolTip.textAndMnemonic", "\u00D6ppna vald fil." },
|
||||
{ "FileChooser.openDialogTitle.textAndMnemonic", "\u00D6ppna" },
|
||||
{ "FileChooser.pathLabel.textAndMnemonic", "Ange &s\u00F6kv\u00E4g eller mappnamn:" },
|
||||
{ "FileChooser.saveButton.textAndMnemonic", "Spara" },
|
||||
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "Spara vald fil." },
|
||||
{ "FileChooser.saveDialogTitle.textAndMnemonic", "Spara" },
|
||||
{ "FileChooser.updateButton.textAndMnemonic", "Uppdatera" },
|
||||
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "Uppdatera kataloglistan." },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sun.java.swing.plaf.motif.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class motif_zh_CN extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.acceptAllFileFilter.textAndMnemonic", "*" },
|
||||
{ "FileChooser.cancelButton.textAndMnemonic", "\u53D6\u6D88" },
|
||||
{ "FileChooser.cancelButtonToolTip.textAndMnemonic", "\u4E2D\u6B62\u6587\u4EF6\u9009\u62E9\u5668\u5BF9\u8BDD\u6846\u3002" },
|
||||
{ "FileChooser.enterFileNameLabel.textAndMnemonic", "\u8F93\u5165\u6587\u4EF6\u540D(&N):" },
|
||||
{ "FileChooser.enterFolderNameLabel.textAndMnemonic", "\u8F93\u5165\u6587\u4EF6\u5939\u540D:" },
|
||||
{ "FileChooser.filesLabel.textAndMnemonic", "\u6587\u4EF6(&I)" },
|
||||
{ "FileChooser.filterLabel.textAndMnemonic", "\u7B5B\u9009\u5668(&R)" },
|
||||
{ "FileChooser.foldersLabel.textAndMnemonic", "\u6587\u4EF6\u5939(&L)" },
|
||||
{ "FileChooser.helpButton.textAndMnemonic", "\u5E2E\u52A9" },
|
||||
{ "FileChooser.helpButtonToolTip.textAndMnemonic", "FileChooser \u5E2E\u52A9\u3002" },
|
||||
{ "FileChooser.openButton.textAndMnemonic", "\u786E\u5B9A" },
|
||||
{ "FileChooser.openButtonToolTip.textAndMnemonic", "\u6253\u5F00\u6240\u9009\u6587\u4EF6\u3002" },
|
||||
{ "FileChooser.openDialogTitle.textAndMnemonic", "\u6253\u5F00" },
|
||||
{ "FileChooser.pathLabel.textAndMnemonic", "\u8F93\u5165\u8DEF\u5F84\u6216\u6587\u4EF6\u5939\u540D(&P):" },
|
||||
{ "FileChooser.saveButton.textAndMnemonic", "\u4FDD\u5B58" },
|
||||
{ "FileChooser.saveButtonToolTip.textAndMnemonic", "\u4FDD\u5B58\u6240\u9009\u6587\u4EF6\u3002" },
|
||||
{ "FileChooser.saveDialogTitle.textAndMnemonic", "\u4FDD\u5B58" },
|
||||
{ "FileChooser.updateButton.textAndMnemonic", "\u66F4\u65B0" },
|
||||
{ "FileChooser.updateButtonToolTip.textAndMnemonic", "\u66F4\u65B0\u76EE\u5F55\u5217\u8868\u3002" },
|
||||
};
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user