feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
317
jdkSrc/jdk8/sun/awt/windows/ThemeReader.java
Normal file
317
jdkSrc/jdk8/sun/awt/windows/ThemeReader.java
Normal file
@@ -0,0 +1,317 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2017, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
/* !!!! WARNING !!!!
|
||||
* This class has to be in sync with
|
||||
* src/solaris/classes/sun/awt/windows/ThemeReader.java
|
||||
* while we continue to build WinL&F on solaris
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Implements Theme Support for Windows XP.
|
||||
*
|
||||
* @author Sergey Salishev
|
||||
* @author Bino George
|
||||
* @author Igor Kushnirskiy
|
||||
*/
|
||||
public final class ThemeReader {
|
||||
|
||||
private static final Map<String, Long> widgetToTheme = new HashMap<>();
|
||||
|
||||
// lock for the cache
|
||||
// reading should be done with readLock
|
||||
// writing with writeLock
|
||||
private static final ReadWriteLock readWriteLock =
|
||||
new ReentrantReadWriteLock();
|
||||
private static final Lock readLock = readWriteLock.readLock();
|
||||
private static final Lock writeLock = readWriteLock.writeLock();
|
||||
private static volatile boolean valid = false;
|
||||
private static volatile boolean isThemed;
|
||||
|
||||
static volatile boolean xpStyleEnabled;
|
||||
|
||||
static void flush() {
|
||||
// Could be called on Toolkit thread, so do not try to acquire locks
|
||||
// to avoid deadlock with theme initialization
|
||||
valid = false;
|
||||
}
|
||||
|
||||
private static native boolean initThemes();
|
||||
|
||||
public static boolean isThemed() {
|
||||
writeLock.lock();
|
||||
try {
|
||||
isThemed = initThemes();
|
||||
return isThemed;
|
||||
} finally {
|
||||
writeLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isXPStyleEnabled() {
|
||||
return xpStyleEnabled;
|
||||
}
|
||||
|
||||
// this should be called only with writeLock held
|
||||
private static Long getThemeImpl(String widget) {
|
||||
Long theme = widgetToTheme.get(widget);
|
||||
if (theme == null) {
|
||||
int i = widget.indexOf("::");
|
||||
if (i > 0) {
|
||||
// We're using the syntax "subAppName::controlName" here, as used by msstyles.
|
||||
// See documentation for SetWindowTheme on MSDN.
|
||||
setWindowTheme(widget.substring(0, i));
|
||||
theme = openTheme(widget.substring(i+2));
|
||||
setWindowTheme(null);
|
||||
} else {
|
||||
theme = openTheme(widget);
|
||||
}
|
||||
widgetToTheme.put(widget, theme);
|
||||
}
|
||||
return theme;
|
||||
}
|
||||
|
||||
// returns theme value
|
||||
// this method should be invoked with readLock locked
|
||||
private static Long getTheme(String widget) {
|
||||
if (!isThemed) {
|
||||
throw new IllegalStateException("Themes are not loaded");
|
||||
}
|
||||
if (!valid) {
|
||||
readLock.unlock();
|
||||
writeLock.lock();
|
||||
try {
|
||||
if (!valid) {
|
||||
// Close old themes.
|
||||
for (Long value : widgetToTheme.values()) {
|
||||
closeTheme(value);
|
||||
}
|
||||
widgetToTheme.clear();
|
||||
valid = true;
|
||||
}
|
||||
} finally {
|
||||
readLock.lock();
|
||||
writeLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// mostly copied from the javadoc for ReentrantReadWriteLock
|
||||
Long theme = widgetToTheme.get(widget);
|
||||
if (theme == null) {
|
||||
readLock.unlock();
|
||||
writeLock.lock();
|
||||
try {
|
||||
theme = getThemeImpl(widget);
|
||||
} finally {
|
||||
readLock.lock();
|
||||
writeLock.unlock();// Unlock write, still hold read
|
||||
}
|
||||
}
|
||||
return theme;
|
||||
}
|
||||
|
||||
private static native void paintBackground(int[] buffer, long theme,
|
||||
int part, int state, int x,
|
||||
int y, int w, int h, int stride);
|
||||
|
||||
public static void paintBackground(int[] buffer, String widget,
|
||||
int part, int state, int x, int y, int w, int h, int stride) {
|
||||
readLock.lock();
|
||||
try {
|
||||
paintBackground(buffer, getTheme(widget), part, state, x, y, w, h, stride);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static native Insets getThemeMargins(long theme, int part,
|
||||
int state, int marginType);
|
||||
|
||||
public static Insets getThemeMargins(String widget, int part, int state, int marginType) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return getThemeMargins(getTheme(widget), part, state, marginType);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static native boolean isThemePartDefined(long theme, int part, int state);
|
||||
|
||||
public static boolean isThemePartDefined(String widget, int part, int state) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return isThemePartDefined(getTheme(widget), part, state);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static native Color getColor(long theme, int part, int state,
|
||||
int property);
|
||||
|
||||
public static Color getColor(String widget, int part, int state, int property) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return getColor(getTheme(widget), part, state, property);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static native int getInt(long theme, int part, int state,
|
||||
int property);
|
||||
|
||||
public static int getInt(String widget, int part, int state, int property) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return getInt(getTheme(widget), part, state, property);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static native int getEnum(long theme, int part, int state,
|
||||
int property);
|
||||
|
||||
public static int getEnum(String widget, int part, int state, int property) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return getEnum(getTheme(widget), part, state, property);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static native boolean getBoolean(long theme, int part, int state,
|
||||
int property);
|
||||
|
||||
public static boolean getBoolean(String widget, int part, int state,
|
||||
int property) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return getBoolean(getTheme(widget), part, state, property);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static native boolean getSysBoolean(long theme, int property);
|
||||
|
||||
public static boolean getSysBoolean(String widget, int property) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return getSysBoolean(getTheme(widget), property);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static native Point getPoint(long theme, int part, int state,
|
||||
int property);
|
||||
|
||||
public static Point getPoint(String widget, int part, int state, int property) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return getPoint(getTheme(widget), part, state, property);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static native Dimension getPosition(long theme, int part, int state,
|
||||
int property);
|
||||
|
||||
public static Dimension getPosition(String widget, int part, int state,
|
||||
int property) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return getPosition(getTheme(widget), part,state,property);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static native Dimension getPartSize(long theme, int part,
|
||||
int state);
|
||||
|
||||
public static Dimension getPartSize(String widget, int part, int state) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return getPartSize(getTheme(widget), part, state);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private static native long openTheme(String widget);
|
||||
|
||||
private static native void closeTheme(long theme);
|
||||
|
||||
private static native void setWindowTheme(String subAppName);
|
||||
|
||||
private static native long getThemeTransitionDuration(long theme, int part,
|
||||
int stateFrom, int stateTo, int propId);
|
||||
|
||||
public static long getThemeTransitionDuration(String widget, int part,
|
||||
int stateFrom, int stateTo, int propId) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return getThemeTransitionDuration(getTheme(widget),
|
||||
part, stateFrom, stateTo, propId);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static native boolean isGetThemeTransitionDurationDefined();
|
||||
|
||||
private static native Insets getThemeBackgroundContentMargins(long theme,
|
||||
int part, int state, int boundingWidth, int boundingHeight);
|
||||
|
||||
public static Insets getThemeBackgroundContentMargins(String widget,
|
||||
int part, int state, int boundingWidth, int boundingHeight) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return getThemeBackgroundContentMargins(getTheme(widget),
|
||||
part, state, boundingWidth, boundingHeight);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
362
jdkSrc/jdk8/sun/awt/windows/TranslucentWindowPainter.java
Normal file
362
jdkSrc/jdk8/sun/awt/windows/TranslucentWindowPainter.java
Normal file
@@ -0,0 +1,362 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Image;
|
||||
import java.awt.Window;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.security.AccessController;
|
||||
import sun.awt.image.BufImgSurfaceData;
|
||||
import sun.java2d.DestSurfaceProvider;
|
||||
import sun.java2d.InvalidPipeException;
|
||||
import sun.java2d.Surface;
|
||||
import sun.java2d.pipe.RenderQueue;
|
||||
import sun.java2d.pipe.BufferedContext;
|
||||
import sun.java2d.pipe.hw.AccelGraphicsConfig;
|
||||
import sun.java2d.pipe.hw.AccelSurface;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
import static java.awt.image.VolatileImage.*;
|
||||
import static sun.java2d.pipe.hw.AccelSurface.*;
|
||||
import static sun.java2d.pipe.hw.ContextCapabilities.*;
|
||||
|
||||
/**
|
||||
* This class handles the updates of the non-opaque windows.
|
||||
* The window associated with the peer is updated either given an image or
|
||||
* the window is repainted to an internal buffer which is then used to update
|
||||
* the window.
|
||||
*
|
||||
* Note: this class does not attempt to be thread safe, it is expected to be
|
||||
* called from a single thread (EDT).
|
||||
*/
|
||||
abstract class TranslucentWindowPainter {
|
||||
|
||||
protected Window window;
|
||||
protected WWindowPeer peer;
|
||||
|
||||
// REMIND: we probably would want to remove this later
|
||||
private static final boolean forceOpt =
|
||||
Boolean.valueOf(AccessController.doPrivileged(
|
||||
new GetPropertyAction("sun.java2d.twp.forceopt", "false")));
|
||||
private static final boolean forceSW =
|
||||
Boolean.valueOf(AccessController.doPrivileged(
|
||||
new GetPropertyAction("sun.java2d.twp.forcesw", "false")));
|
||||
|
||||
/**
|
||||
* Creates an instance of the painter for particular peer.
|
||||
*/
|
||||
public static TranslucentWindowPainter createInstance(WWindowPeer peer) {
|
||||
GraphicsConfiguration gc = peer.getGraphicsConfiguration();
|
||||
if (!forceSW && gc instanceof AccelGraphicsConfig) {
|
||||
String gcName = gc.getClass().getSimpleName();
|
||||
AccelGraphicsConfig agc = (AccelGraphicsConfig)gc;
|
||||
// this is a heuristic to check that we have a pcix board
|
||||
// (those have higher transfer rate from gpu to cpu)
|
||||
if ((agc.getContextCapabilities().getCaps() & CAPS_PS30) != 0 ||
|
||||
forceOpt)
|
||||
{
|
||||
// we check for name to avoid loading classes unnecessarily if
|
||||
// a pipeline isn't enabled
|
||||
if (gcName.startsWith("D3D")) {
|
||||
return new VIOptD3DWindowPainter(peer);
|
||||
} else if (forceOpt && gcName.startsWith("WGL")) {
|
||||
// on some boards (namely, ATI, even on pcix bus) ogl is
|
||||
// very slow reading pixels back so for now it is disabled
|
||||
// unless forced
|
||||
return new VIOptWGLWindowPainter(peer);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new BIWindowPainter(peer);
|
||||
}
|
||||
|
||||
protected TranslucentWindowPainter(WWindowPeer peer) {
|
||||
this.peer = peer;
|
||||
this.window = (Window)peer.getTarget();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates (if needed), clears (if requested) and returns the buffer
|
||||
* for this painter.
|
||||
*/
|
||||
protected abstract Image getBackBuffer(boolean clear);
|
||||
|
||||
/**
|
||||
* Updates the the window associated with this painter with the contents
|
||||
* of the passed image.
|
||||
* The image can not be null, and NPE will be thrown if it is.
|
||||
*/
|
||||
protected abstract boolean update(Image bb);
|
||||
|
||||
/**
|
||||
* Flushes the resources associated with the painter. They will be
|
||||
* recreated as needed.
|
||||
*/
|
||||
public abstract void flush();
|
||||
|
||||
/**
|
||||
* Updates the window associated with the painter.
|
||||
*
|
||||
* @param repaint indicates if the window should be completely repainted
|
||||
* to the back buffer using {@link java.awt.Window#paintAll} before update.
|
||||
*/
|
||||
public void updateWindow(boolean repaint) {
|
||||
boolean done = false;
|
||||
Image bb = getBackBuffer(repaint);
|
||||
while (!done) {
|
||||
if (repaint) {
|
||||
Graphics2D g = (Graphics2D)bb.getGraphics();
|
||||
try {
|
||||
window.paintAll(g);
|
||||
} finally {
|
||||
g.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
done = update(bb);
|
||||
if (!done) {
|
||||
repaint = true;
|
||||
bb = getBackBuffer(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final Image clearImage(Image bb) {
|
||||
Graphics2D g = (Graphics2D)bb.getGraphics();
|
||||
int w = bb.getWidth(null);
|
||||
int h = bb.getHeight(null);
|
||||
|
||||
g.setComposite(AlphaComposite.Src);
|
||||
g.setColor(new Color(0, 0, 0, 0));
|
||||
g.fillRect(0, 0, w, h);
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
/**
|
||||
* A painter which uses BufferedImage as the internal buffer. The window
|
||||
* is painted into this buffer, and the contents then are uploaded
|
||||
* into the layered window.
|
||||
*
|
||||
* This painter handles all types of images passed to its paint(Image)
|
||||
* method (VI, BI, regular Images).
|
||||
*/
|
||||
private static class BIWindowPainter extends TranslucentWindowPainter {
|
||||
private BufferedImage backBuffer;
|
||||
|
||||
protected BIWindowPainter(WWindowPeer peer) {
|
||||
super(peer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Image getBackBuffer(boolean clear) {
|
||||
int w = window.getWidth();
|
||||
int h = window.getHeight();
|
||||
if (backBuffer == null ||
|
||||
backBuffer.getWidth() != w ||
|
||||
backBuffer.getHeight() != h)
|
||||
{
|
||||
flush();
|
||||
backBuffer = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
|
||||
}
|
||||
return clear ? (BufferedImage)clearImage(backBuffer) : backBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean update(Image bb) {
|
||||
VolatileImage viBB = null;
|
||||
|
||||
if (bb instanceof BufferedImage) {
|
||||
BufferedImage bi = (BufferedImage)bb;
|
||||
int data[] =
|
||||
((DataBufferInt)bi.getRaster().getDataBuffer()).getData();
|
||||
peer.updateWindowImpl(data, bi.getWidth(), bi.getHeight());
|
||||
return true;
|
||||
} else if (bb instanceof VolatileImage) {
|
||||
viBB = (VolatileImage)bb;
|
||||
if (bb instanceof DestSurfaceProvider) {
|
||||
Surface s = ((DestSurfaceProvider)bb).getDestSurface();
|
||||
if (s instanceof BufImgSurfaceData) {
|
||||
// the image is probably lost, upload the data from the
|
||||
// backup surface to avoid creating another heap-based
|
||||
// image (the parent's buffer)
|
||||
int w = viBB.getWidth();
|
||||
int h = viBB.getHeight();
|
||||
BufImgSurfaceData bisd = (BufImgSurfaceData)s;
|
||||
int data[] = ((DataBufferInt)bisd.getRaster(0,0,w,h).
|
||||
getDataBuffer()).getData();
|
||||
peer.updateWindowImpl(data, w, h);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// copy the passed image into our own buffer, then upload
|
||||
BufferedImage bi = (BufferedImage)clearImage(backBuffer);
|
||||
|
||||
int data[] =
|
||||
((DataBufferInt)bi.getRaster().getDataBuffer()).getData();
|
||||
peer.updateWindowImpl(data, bi.getWidth(), bi.getHeight());
|
||||
|
||||
return (viBB != null ? !viBB.contentsLost() : true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
if (backBuffer != null) {
|
||||
backBuffer.flush();
|
||||
backBuffer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of the painter which uses VolatileImage as the internal buffer.
|
||||
* The window is painted into this VI and then copied into the parent's
|
||||
* Java heap-based buffer (which is then uploaded to the layered window)
|
||||
*/
|
||||
private static class VIWindowPainter extends BIWindowPainter {
|
||||
private VolatileImage viBB;
|
||||
|
||||
protected VIWindowPainter(WWindowPeer peer) {
|
||||
super(peer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Image getBackBuffer(boolean clear) {
|
||||
int w = window.getWidth();
|
||||
int h = window.getHeight();
|
||||
GraphicsConfiguration gc = peer.getGraphicsConfiguration();
|
||||
|
||||
if (viBB == null || viBB.getWidth() != w || viBB.getHeight() != h ||
|
||||
viBB.validate(gc) == IMAGE_INCOMPATIBLE)
|
||||
{
|
||||
flush();
|
||||
|
||||
if (gc instanceof AccelGraphicsConfig) {
|
||||
AccelGraphicsConfig agc = ((AccelGraphicsConfig)gc);
|
||||
viBB = agc.createCompatibleVolatileImage(w, h,
|
||||
TRANSLUCENT,
|
||||
RT_PLAIN);
|
||||
}
|
||||
if (viBB == null) {
|
||||
viBB = gc.createCompatibleVolatileImage(w, h, TRANSLUCENT);
|
||||
}
|
||||
viBB.validate(gc);
|
||||
}
|
||||
|
||||
return clear ? clearImage(viBB) : viBB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
if (viBB != null) {
|
||||
viBB.flush();
|
||||
viBB = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimized version of hw painter. Uses VolatileImages for the
|
||||
* buffer, and uses an optimized path to pull the data from those into
|
||||
* the layered window, bypassing Java heap-based image.
|
||||
*/
|
||||
private abstract static class VIOptWindowPainter extends VIWindowPainter {
|
||||
|
||||
protected VIOptWindowPainter(WWindowPeer peer) {
|
||||
super(peer);
|
||||
}
|
||||
|
||||
protected abstract boolean updateWindowAccel(long psdops, int w, int h);
|
||||
|
||||
@Override
|
||||
protected boolean update(Image bb) {
|
||||
if (bb instanceof DestSurfaceProvider) {
|
||||
Surface s = ((DestSurfaceProvider)bb).getDestSurface();
|
||||
if (s instanceof AccelSurface) {
|
||||
final int w = bb.getWidth(null);
|
||||
final int h = bb.getHeight(null);
|
||||
final boolean arr[] = { false };
|
||||
final AccelSurface as = (AccelSurface)s;
|
||||
RenderQueue rq = as.getContext().getRenderQueue();
|
||||
rq.lock();
|
||||
try {
|
||||
BufferedContext.validateContext(as);
|
||||
rq.flushAndInvokeNow(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
long psdops = as.getNativeOps();
|
||||
arr[0] = updateWindowAccel(psdops, w, h);
|
||||
}
|
||||
});
|
||||
} catch (InvalidPipeException e) {
|
||||
// ignore, false will be returned
|
||||
} finally {
|
||||
rq.unlock();
|
||||
}
|
||||
return arr[0];
|
||||
}
|
||||
}
|
||||
return super.update(bb);
|
||||
}
|
||||
}
|
||||
|
||||
private static class VIOptD3DWindowPainter extends VIOptWindowPainter {
|
||||
|
||||
protected VIOptD3DWindowPainter(WWindowPeer peer) {
|
||||
super(peer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean updateWindowAccel(long psdops, int w, int h) {
|
||||
// note: this method is executed on the toolkit thread, no sync is
|
||||
// necessary at the native level, and a pointer to peer can be used
|
||||
return sun.java2d.d3d.D3DSurfaceData.
|
||||
updateWindowAccelImpl(psdops, peer.getData(), w, h);
|
||||
}
|
||||
}
|
||||
|
||||
private static class VIOptWGLWindowPainter extends VIOptWindowPainter {
|
||||
|
||||
protected VIOptWGLWindowPainter(WWindowPeer peer) {
|
||||
super(peer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean updateWindowAccel(long psdops, int w, int h) {
|
||||
// note: part of this method which deals with GDI will be on the
|
||||
// toolkit thread
|
||||
return sun.java2d.opengl.WGLSurfaceData.
|
||||
updateWindowAccelImpl(psdops, peer, w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
jdkSrc/jdk8/sun/awt/windows/WBufferStrategy.java
Normal file
49
jdkSrc/jdk8/sun/awt/windows/WBufferStrategy.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Component;
|
||||
|
||||
/**
|
||||
* This sun-private class exists solely to get a handle to
|
||||
* the back buffer associated with a Component. If that
|
||||
* Component has a BufferStrategy with >1 buffer, then the
|
||||
* Image subclass associated with that buffer will be returned.
|
||||
* Note: the class is used by the JAWT3d.
|
||||
*/
|
||||
public final class WBufferStrategy {
|
||||
|
||||
private static native void initIDs(Class <?> componentClass);
|
||||
|
||||
static {
|
||||
initIDs(Component.class);
|
||||
}
|
||||
|
||||
public static native Image getDrawBuffer(Component comp);
|
||||
|
||||
}
|
||||
108
jdkSrc/jdk8/sun/awt/windows/WButtonPeer.java
Normal file
108
jdkSrc/jdk8/sun/awt/windows/WButtonPeer.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
final class WButtonPeer extends WComponentPeer implements ButtonPeer {
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
// ComponentPeer overrides
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
FontMetrics fm = getFontMetrics(((Button)target).getFont());
|
||||
String label = ((Button)target).getLabel();
|
||||
if ( label == null ) {
|
||||
label = "";
|
||||
}
|
||||
return new Dimension(fm.stringWidth(label) + 14,
|
||||
fm.getHeight() + 8);
|
||||
}
|
||||
@Override
|
||||
public boolean isFocusable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ButtonPeer implementation
|
||||
|
||||
@Override
|
||||
public native void setLabel(String label);
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WButtonPeer(Button target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
native void create(WComponentPeer peer);
|
||||
|
||||
// native callbacks
|
||||
|
||||
// NOTE: This is called on the privileged toolkit thread. Do not
|
||||
// call directly into user code using this thread!
|
||||
public void handleAction(final long when, final int modifiers) {
|
||||
// Fixed 5064013: the InvocationEvent time should be equals
|
||||
// the time of the ActionEvent
|
||||
WToolkit.executeOnEventHandlerThread(target, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
|
||||
((Button)target).getActionCommand(),
|
||||
when, modifiers));
|
||||
}
|
||||
}, when);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shouldClearRectBeforePaint() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method IDs
|
||||
*/
|
||||
private static native void initIDs();
|
||||
|
||||
@Override
|
||||
public boolean handleJavaKeyEvent(KeyEvent e) {
|
||||
switch (e.getID()) {
|
||||
case KeyEvent.KEY_RELEASED:
|
||||
if (e.getKeyCode() == KeyEvent.VK_SPACE){
|
||||
handleAction(e.getWhen(), e.getModifiers());
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
116
jdkSrc/jdk8/sun/awt/windows/WCanvasPeer.java
Normal file
116
jdkSrc/jdk8/sun/awt/windows/WCanvasPeer.java
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.peer.CanvasPeer;
|
||||
|
||||
import sun.awt.PaintEventDispatcher;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
class WCanvasPeer extends WComponentPeer implements CanvasPeer {
|
||||
|
||||
private boolean eraseBackground;
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WCanvasPeer(Component target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
native void create(WComponentPeer parent);
|
||||
|
||||
@Override
|
||||
void initialize() {
|
||||
eraseBackground = !SunToolkit.getSunAwtNoerasebackground();
|
||||
boolean eraseBackgroundOnResize = SunToolkit.getSunAwtErasebackgroundonresize();
|
||||
// Optimization: the default value in the native code is true, so we
|
||||
// call setNativeBackgroundErase only when the value changes to false
|
||||
if (!PaintEventDispatcher.getPaintEventDispatcher().
|
||||
shouldDoNativeBackgroundErase((Component)target)) {
|
||||
eraseBackground = false;
|
||||
}
|
||||
setNativeBackgroundErase(eraseBackground, eraseBackgroundOnResize);
|
||||
super.initialize();
|
||||
Color bg = ((Component)target).getBackground();
|
||||
if (bg != null) {
|
||||
setBackground(bg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
Dimension d = ((Component)target).getSize();
|
||||
if (g instanceof Graphics2D ||
|
||||
g instanceof sun.awt.Graphics2Delegate) {
|
||||
// background color is setup correctly, so just use clearRect
|
||||
g.clearRect(0, 0, d.width, d.height);
|
||||
} else {
|
||||
// emulate clearRect
|
||||
g.setColor(((Component)target).getBackground());
|
||||
g.fillRect(0, 0, d.width, d.height);
|
||||
g.setColor(((Component)target).getForeground());
|
||||
}
|
||||
super.paint(g);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldClearRectBeforePaint() {
|
||||
return eraseBackground;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disables background erasing for this canvas, both for resizing
|
||||
* and not-resizing repaints.
|
||||
*/
|
||||
void disableBackgroundErase() {
|
||||
eraseBackground = false;
|
||||
setNativeBackgroundErase(false, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets background erasing flags at the native level. If {@code
|
||||
* doErase} is set to {@code true}, canvas background is erased on
|
||||
* every repaint. If {@code doErase} is {@code false} and {@code
|
||||
* doEraseOnResize} is {@code true}, then background is only erased
|
||||
* on resizing repaints. If both {@code doErase} and {@code
|
||||
* doEraseOnResize} are false, then background is never erased.
|
||||
*/
|
||||
private native void setNativeBackgroundErase(boolean doErase,
|
||||
boolean doEraseOnResize);
|
||||
|
||||
@Override
|
||||
public GraphicsConfiguration getAppropriateGraphicsConfiguration(
|
||||
GraphicsConfiguration gc)
|
||||
{
|
||||
return gc;
|
||||
}
|
||||
}
|
||||
61
jdkSrc/jdk8/sun/awt/windows/WCheckboxMenuItemPeer.java
Normal file
61
jdkSrc/jdk8/sun/awt/windows/WCheckboxMenuItemPeer.java
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.CheckboxMenuItem;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.peer.CheckboxMenuItemPeer;
|
||||
|
||||
final class WCheckboxMenuItemPeer extends WMenuItemPeer
|
||||
implements CheckboxMenuItemPeer {
|
||||
|
||||
// CheckboxMenuItemPeer implementation
|
||||
|
||||
@Override
|
||||
public native void setState(boolean t);
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WCheckboxMenuItemPeer(CheckboxMenuItem target) {
|
||||
super(target, true);
|
||||
setState(target.getState());
|
||||
}
|
||||
|
||||
// native callbacks
|
||||
|
||||
public void handleAction(final boolean state) {
|
||||
final CheckboxMenuItem target = (CheckboxMenuItem)this.target;
|
||||
WToolkit.executeOnEventHandlerThread(target, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
target.setState(state);
|
||||
postEvent(new ItemEvent(target, ItemEvent.ITEM_STATE_CHANGED,
|
||||
target.getLabel(), (state)
|
||||
? ItemEvent.SELECTED
|
||||
: ItemEvent.DESELECTED));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
112
jdkSrc/jdk8/sun/awt/windows/WCheckboxPeer.java
Normal file
112
jdkSrc/jdk8/sun/awt/windows/WCheckboxPeer.java
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import java.awt.event.ItemEvent;
|
||||
|
||||
final class WCheckboxPeer extends WComponentPeer implements CheckboxPeer {
|
||||
|
||||
// CheckboxPeer implementation
|
||||
|
||||
@Override
|
||||
public native void setState(boolean state);
|
||||
@Override
|
||||
public native void setCheckboxGroup(CheckboxGroup g);
|
||||
@Override
|
||||
public native void setLabel(String label);
|
||||
|
||||
private static native int getCheckMarkSize();
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
String lbl = ((Checkbox)target).getLabel();
|
||||
int marksize = getCheckMarkSize();
|
||||
if (lbl == null) {
|
||||
lbl = "";
|
||||
}
|
||||
FontMetrics fm = getFontMetrics(((Checkbox)target).getFont());
|
||||
/*
|
||||
* Borders between check mark and text and between text and edge of
|
||||
* checkbox should both be equal to marksize/4, here's where marksize/2
|
||||
* goes from. Marksize is currently constant ( = 16 pixels) on win32.
|
||||
*/
|
||||
return new Dimension(fm.stringWidth(lbl) + marksize/2 + marksize,
|
||||
Math.max(fm.getHeight() + 8, marksize));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFocusable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WCheckboxPeer(Checkbox target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
native void create(WComponentPeer parent);
|
||||
|
||||
@Override
|
||||
void initialize() {
|
||||
Checkbox t = (Checkbox)target;
|
||||
setState(t.getState());
|
||||
setCheckboxGroup(t.getCheckboxGroup());
|
||||
|
||||
Color bg = ((Component)target).getBackground();
|
||||
if (bg != null) {
|
||||
setBackground(bg);
|
||||
}
|
||||
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldClearRectBeforePaint() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// native callbacks
|
||||
|
||||
void handleAction(final boolean state) {
|
||||
final Checkbox cb = (Checkbox)this.target;
|
||||
WToolkit.executeOnEventHandlerThread(cb, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CheckboxGroup chg = cb.getCheckboxGroup();
|
||||
if ((chg != null) && (cb == chg.getSelectedCheckbox()) && cb.getState()) {
|
||||
return;
|
||||
}
|
||||
cb.setState(state);
|
||||
postEvent(new ItemEvent(cb, ItemEvent.ITEM_STATE_CHANGED,
|
||||
cb.getLabel(),
|
||||
state? ItemEvent.SELECTED : ItemEvent.DESELECTED));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
169
jdkSrc/jdk8/sun/awt/windows/WChoicePeer.java
Normal file
169
jdkSrc/jdk8/sun/awt/windows/WChoicePeer.java
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
final class WChoicePeer extends WComponentPeer implements ChoicePeer {
|
||||
|
||||
// WComponentPeer overrides
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
FontMetrics fm = getFontMetrics(((Choice)target).getFont());
|
||||
Choice c = (Choice)target;
|
||||
int w = 0;
|
||||
for (int i = c.getItemCount() ; i-- > 0 ;) {
|
||||
w = Math.max(fm.stringWidth(c.getItem(i)), w);
|
||||
}
|
||||
return new Dimension(28 + w, Math.max(fm.getHeight() + 6, 15));
|
||||
}
|
||||
@Override
|
||||
public boolean isFocusable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ChoicePeer implementation
|
||||
|
||||
@Override
|
||||
public native void select(int index);
|
||||
|
||||
@Override
|
||||
public void add(String item, int index) {
|
||||
addItem(item, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldClearRectBeforePaint() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public native void removeAll();
|
||||
@Override
|
||||
public native void remove(int index);
|
||||
|
||||
/**
|
||||
* DEPRECATED, but for now, called by add(String, int).
|
||||
*/
|
||||
public void addItem(String item, int index) {
|
||||
addItems(new String[] {item}, index);
|
||||
}
|
||||
public native void addItems(String[] items, int index);
|
||||
|
||||
@Override
|
||||
public synchronized native void reshape(int x, int y, int width, int height);
|
||||
|
||||
private WindowListener windowListener;
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WChoicePeer(Choice target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
native void create(WComponentPeer parent);
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
void initialize() {
|
||||
Choice opt = (Choice)target;
|
||||
int itemCount = opt.getItemCount();
|
||||
if (itemCount > 0) {
|
||||
String[] items = new String[itemCount];
|
||||
for (int i=0; i < itemCount; i++) {
|
||||
items[i] = opt.getItem(i);
|
||||
}
|
||||
addItems(items, 0);
|
||||
if (opt.getSelectedIndex() >= 0) {
|
||||
select(opt.getSelectedIndex());
|
||||
}
|
||||
}
|
||||
|
||||
Window parentWindow = SunToolkit.getContainingWindow((Component)target);
|
||||
if (parentWindow != null) {
|
||||
WWindowPeer wpeer = (WWindowPeer)parentWindow.getPeer();
|
||||
if (wpeer != null) {
|
||||
windowListener = new WindowAdapter() {
|
||||
@Override
|
||||
public void windowIconified(WindowEvent e) {
|
||||
closeList();
|
||||
}
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
closeList();
|
||||
}
|
||||
};
|
||||
wpeer.addWindowListener(windowListener);
|
||||
}
|
||||
}
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void disposeImpl() {
|
||||
// TODO: we should somehow reset the listener when the choice
|
||||
// is moved to another toplevel without destroying its peer.
|
||||
Window parentWindow = SunToolkit.getContainingWindow((Component)target);
|
||||
if (parentWindow != null) {
|
||||
WWindowPeer wpeer = (WWindowPeer)parentWindow.getPeer();
|
||||
if (wpeer != null) {
|
||||
wpeer.removeWindowListener(windowListener);
|
||||
}
|
||||
}
|
||||
super.disposeImpl();
|
||||
}
|
||||
|
||||
// native callbacks
|
||||
|
||||
void handleAction(final int index) {
|
||||
final Choice c = (Choice)target;
|
||||
WToolkit.executeOnEventHandlerThread(c, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
c.select(index);
|
||||
postEvent(new ItemEvent(c, ItemEvent.ITEM_STATE_CHANGED,
|
||||
c.getItem(index), ItemEvent.SELECTED));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
int getDropDownHeight() {
|
||||
Choice c = (Choice)target;
|
||||
FontMetrics fm = getFontMetrics(c.getFont());
|
||||
int maxItems = Math.min(c.getItemCount(), 8);
|
||||
return fm.getHeight() * maxItems;
|
||||
}
|
||||
|
||||
native void closeList();
|
||||
}
|
||||
223
jdkSrc/jdk8/sun/awt/windows/WClipboard.java
Normal file
223
jdkSrc/jdk8/sun/awt/windows/WClipboard.java
Normal file
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import sun.awt.datatransfer.DataTransferer;
|
||||
import sun.awt.datatransfer.SunClipboard;
|
||||
|
||||
|
||||
/**
|
||||
* A class which interfaces with the Windows clipboard in order to support
|
||||
* data transfer via Clipboard operations. Most of the work is provided by
|
||||
* sun.awt.datatransfer.DataTransferer.
|
||||
*
|
||||
* @author Tom Ball
|
||||
* @author David Mendenhall
|
||||
* @author Danila Sinopalnikov
|
||||
* @author Alexander Gerasimov
|
||||
*
|
||||
* @since JDK1.1
|
||||
*/
|
||||
final class WClipboard extends SunClipboard {
|
||||
|
||||
private boolean isClipboardViewerRegistered;
|
||||
|
||||
WClipboard() {
|
||||
super("System");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getID() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setContentsNative(Transferable contents) {
|
||||
// Don't use delayed Clipboard rendering for the Transferable's data.
|
||||
// If we did that, we would call Transferable.getTransferData on
|
||||
// the Toolkit thread, which is a security hole.
|
||||
//
|
||||
// Get all of the target formats into which the Transferable can be
|
||||
// translated. Then, for each format, translate the data and post
|
||||
// it to the Clipboard.
|
||||
Map <Long, DataFlavor> formatMap = WDataTransferer.getInstance().
|
||||
getFormatsForTransferable(contents, getDefaultFlavorTable());
|
||||
|
||||
openClipboard(this);
|
||||
|
||||
try {
|
||||
for (Long format : formatMap.keySet()) {
|
||||
DataFlavor flavor = formatMap.get(format);
|
||||
|
||||
try {
|
||||
byte[] bytes = WDataTransferer.getInstance().
|
||||
translateTransferable(contents, flavor, format);
|
||||
publishClipboardData(format, bytes);
|
||||
} catch (IOException e) {
|
||||
// Fix 4696186: don't print exception if data with
|
||||
// javaJVMLocalObjectMimeType failed to serialize.
|
||||
// May remove this if-check when 5078787 is fixed.
|
||||
if (!(flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType) &&
|
||||
e instanceof java.io.NotSerializableException)) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
closeClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
private void lostSelectionOwnershipImpl() {
|
||||
lostOwnershipImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently delayed data rendering is not used for the Windows clipboard,
|
||||
* so there is no native context to clear.
|
||||
*/
|
||||
@Override
|
||||
protected void clearNativeContext() {}
|
||||
|
||||
/**
|
||||
* Call the Win32 OpenClipboard function. If newOwner is non-null,
|
||||
* we also call EmptyClipboard and take ownership.
|
||||
*
|
||||
* @throws IllegalStateException if the clipboard has not been opened
|
||||
*/
|
||||
@Override
|
||||
public native void openClipboard(SunClipboard newOwner) throws IllegalStateException;
|
||||
/**
|
||||
* Call the Win32 CloseClipboard function if we have clipboard ownership,
|
||||
* does nothing if we have not ownership.
|
||||
*/
|
||||
@Override
|
||||
public native void closeClipboard();
|
||||
/**
|
||||
* Call the Win32 SetClipboardData function.
|
||||
*/
|
||||
private native void publishClipboardData(long format, byte[] bytes);
|
||||
|
||||
private static native void init();
|
||||
static {
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected native long[] getClipboardFormats();
|
||||
@Override
|
||||
protected native byte[] getClipboardData(long format) throws IOException;
|
||||
|
||||
@Override
|
||||
protected void registerClipboardViewerChecked() {
|
||||
if (!isClipboardViewerRegistered) {
|
||||
registerClipboardViewer();
|
||||
isClipboardViewerRegistered = true;
|
||||
}
|
||||
}
|
||||
|
||||
private native void registerClipboardViewer();
|
||||
|
||||
/**
|
||||
* The clipboard viewer (it's the toolkit window) is not unregistered
|
||||
* until the toolkit window disposing since MSDN suggests removing
|
||||
* the window from the clipboard viewer chain just before it is destroyed.
|
||||
*/
|
||||
@Override
|
||||
protected void unregisterClipboardViewerChecked() {}
|
||||
|
||||
/**
|
||||
* Upcall from native code.
|
||||
*/
|
||||
private void handleContentsChanged() {
|
||||
if (!areFlavorListenersRegistered()) {
|
||||
return;
|
||||
}
|
||||
|
||||
long[] formats = null;
|
||||
try {
|
||||
openClipboard(null);
|
||||
formats = getClipboardFormats();
|
||||
} catch (IllegalStateException exc) {
|
||||
// do nothing to handle the exception, call checkChange(null)
|
||||
} finally {
|
||||
closeClipboard();
|
||||
}
|
||||
checkChange(formats);
|
||||
}
|
||||
|
||||
/**
|
||||
* The clipboard must be opened.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
@Override
|
||||
protected Transferable createLocaleTransferable(long[] formats) throws IOException {
|
||||
boolean found = false;
|
||||
for (int i = 0; i < formats.length; i++) {
|
||||
if (formats[i] == WDataTransferer.CF_LOCALE) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] localeData = null;
|
||||
try {
|
||||
localeData = getClipboardData(WDataTransferer.CF_LOCALE);
|
||||
} catch (IOException ioexc) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final byte[] localeDataFinal = localeData;
|
||||
|
||||
return new Transferable() {
|
||||
@Override
|
||||
public DataFlavor[] getTransferDataFlavors() {
|
||||
return new DataFlavor[] { DataTransferer.javaTextEncodingFlavor };
|
||||
}
|
||||
@Override
|
||||
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
||||
return flavor.equals(DataTransferer.javaTextEncodingFlavor);
|
||||
}
|
||||
@Override
|
||||
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
|
||||
if (isDataFlavorSupported(flavor)) {
|
||||
return localeDataFinal;
|
||||
}
|
||||
throw new UnsupportedFlavorException(flavor);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
45
jdkSrc/jdk8/sun/awt/windows/WColor.java
Normal file
45
jdkSrc/jdk8/sun/awt/windows/WColor.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
/*
|
||||
* This helper class maps Windows system colors to AWT Color objects.
|
||||
*/
|
||||
final class WColor {
|
||||
|
||||
static final int WINDOW_BKGND = 1; // COLOR_WINDOW
|
||||
static final int WINDOW_TEXT = 2; // COLOR_WINDOWTEXT
|
||||
static final int FRAME = 3; // COLOR_WINDOWFRAME
|
||||
static final int SCROLLBAR = 4; // COLOR_SCROLLBAR
|
||||
static final int MENU_BKGND = 5; // COLOR_MENU
|
||||
static final int MENU_TEXT = 6; // COLOR MENUTEXT
|
||||
static final int BUTTON_BKGND = 7; // COLOR_3DFACE or COLOR_BTNFACE
|
||||
static final int BUTTON_TEXT = 8; // COLOR_BTNTEXT
|
||||
static final int HIGHLIGHT = 9; // COLOR_HIGHLIGHT
|
||||
|
||||
static native Color getDefaultColor(int index);
|
||||
}
|
||||
1155
jdkSrc/jdk8/sun/awt/windows/WComponentPeer.java
Normal file
1155
jdkSrc/jdk8/sun/awt/windows/WComponentPeer.java
Normal file
File diff suppressed because it is too large
Load Diff
104
jdkSrc/jdk8/sun/awt/windows/WCustomCursor.java
Normal file
104
jdkSrc/jdk8/sun/awt/windows/WCustomCursor.java
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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 sun.awt.windows;
|
||||
|
||||
import sun.awt.CustomCursor;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import sun.awt.image.ImageRepresentation;
|
||||
import sun.awt.image.IntegerComponentRaster;
|
||||
import sun.awt.image.ToolkitImage;
|
||||
|
||||
/**
|
||||
* A class to encapsulate a custom image-based cursor.
|
||||
*
|
||||
* @see Component#setCursor
|
||||
* @author ThomasBall
|
||||
*/
|
||||
final class WCustomCursor extends CustomCursor {
|
||||
|
||||
WCustomCursor(Image cursor, Point hotSpot, String name)
|
||||
throws IndexOutOfBoundsException {
|
||||
super(cursor, hotSpot, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createNativeCursor(Image im, int[] pixels, int w, int h,
|
||||
int xHotSpot, int yHotSpot) {
|
||||
BufferedImage bimage = new BufferedImage(w, h,
|
||||
BufferedImage.TYPE_INT_RGB);
|
||||
Graphics g = bimage.getGraphics();
|
||||
try {
|
||||
if (im instanceof ToolkitImage) {
|
||||
ImageRepresentation ir = ((ToolkitImage)im).getImageRep();
|
||||
ir.reconstruct(ImageObserver.ALLBITS);
|
||||
}
|
||||
g.drawImage(im, 0, 0, w, h, null);
|
||||
} finally {
|
||||
g.dispose();
|
||||
}
|
||||
Raster raster = bimage.getRaster();
|
||||
DataBuffer buffer = raster.getDataBuffer();
|
||||
// REMIND: native code should use ScanStride _AND_ width
|
||||
int data[] = ((DataBufferInt)buffer).getData();
|
||||
|
||||
byte[] andMask = new byte[w * h / 8];
|
||||
int npixels = pixels.length;
|
||||
for (int i = 0; i < npixels; i++) {
|
||||
int ibyte = i / 8;
|
||||
int omask = 1 << (7 - (i % 8));
|
||||
if ((pixels[i] & 0xff000000) == 0) {
|
||||
// Transparent bit
|
||||
andMask[ibyte] |= omask;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int ficW = raster.getWidth();
|
||||
if( raster instanceof IntegerComponentRaster ) {
|
||||
ficW = ((IntegerComponentRaster)raster).getScanlineStride();
|
||||
}
|
||||
createCursorIndirect(
|
||||
((DataBufferInt)bimage.getRaster().getDataBuffer()).getData(),
|
||||
andMask, ficW, raster.getWidth(), raster.getHeight(),
|
||||
xHotSpot, yHotSpot);
|
||||
}
|
||||
}
|
||||
|
||||
private native void createCursorIndirect(int[] rData, byte[] andMask,
|
||||
int nScanStride, int width,
|
||||
int height, int xHotSpot,
|
||||
int yHotSpot);
|
||||
/**
|
||||
* Return the current value of SM_CXCURSOR.
|
||||
*/
|
||||
static native int getCursorWidth();
|
||||
|
||||
/**
|
||||
* Return the current value of SM_CYCURSOR.
|
||||
*/
|
||||
static native int getCursorHeight();
|
||||
}
|
||||
923
jdkSrc/jdk8/sun/awt/windows/WDataTransferer.java
Normal file
923
jdkSrc/jdk8/sun/awt/windows/WDataTransferer.java
Normal file
@@ -0,0 +1,923 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Transparency;
|
||||
|
||||
import java.awt.color.ColorSpace;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.FlavorTable;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.ComponentColorModel;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DataBufferByte;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.DirectColorModel;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.WritableRaster;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.File;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import sun.awt.Mutex;
|
||||
import sun.awt.datatransfer.DataTransferer;
|
||||
import sun.awt.datatransfer.ToolkitThreadBlockedHandler;
|
||||
|
||||
import sun.awt.image.ImageRepresentation;
|
||||
import sun.awt.image.ToolkitImage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
/**
|
||||
* Platform-specific support for the data transfer subsystem.
|
||||
*
|
||||
* @author David Mendenhall
|
||||
* @author Danila Sinopalnikov
|
||||
*
|
||||
* @since 1.3.1
|
||||
*/
|
||||
final class WDataTransferer extends DataTransferer {
|
||||
private static final String[] predefinedClipboardNames = {
|
||||
"",
|
||||
"TEXT",
|
||||
"BITMAP",
|
||||
"METAFILEPICT",
|
||||
"SYLK",
|
||||
"DIF",
|
||||
"TIFF",
|
||||
"OEM TEXT",
|
||||
"DIB",
|
||||
"PALETTE",
|
||||
"PENDATA",
|
||||
"RIFF",
|
||||
"WAVE",
|
||||
"UNICODE TEXT",
|
||||
"ENHMETAFILE",
|
||||
"HDROP",
|
||||
"LOCALE",
|
||||
"DIBV5"
|
||||
};
|
||||
|
||||
private static final Map <String, Long> predefinedClipboardNameMap;
|
||||
static {
|
||||
Map <String,Long> tempMap =
|
||||
new HashMap <> (predefinedClipboardNames.length, 1.0f);
|
||||
for (int i = 1; i < predefinedClipboardNames.length; i++) {
|
||||
tempMap.put(predefinedClipboardNames[i], Long.valueOf(i));
|
||||
}
|
||||
predefinedClipboardNameMap =
|
||||
Collections.synchronizedMap(tempMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* from winuser.h
|
||||
*/
|
||||
public static final int CF_TEXT = 1;
|
||||
public static final int CF_METAFILEPICT = 3;
|
||||
public static final int CF_DIB = 8;
|
||||
public static final int CF_ENHMETAFILE = 14;
|
||||
public static final int CF_HDROP = 15;
|
||||
public static final int CF_LOCALE = 16;
|
||||
|
||||
public static final long CF_HTML = registerClipboardFormat("HTML Format");
|
||||
public static final long CFSTR_INETURL = registerClipboardFormat("UniformResourceLocator");
|
||||
public static final long CF_PNG = registerClipboardFormat("PNG");
|
||||
public static final long CF_JFIF = registerClipboardFormat("JFIF");
|
||||
|
||||
public static final long CF_FILEGROUPDESCRIPTORW = registerClipboardFormat("FileGroupDescriptorW");
|
||||
public static final long CF_FILEGROUPDESCRIPTORA = registerClipboardFormat("FileGroupDescriptor");
|
||||
//CF_FILECONTENTS supported as mandatory associated clipboard
|
||||
|
||||
private static final Long L_CF_LOCALE =
|
||||
predefinedClipboardNameMap.get(predefinedClipboardNames[CF_LOCALE]);
|
||||
|
||||
private static final DirectColorModel directColorModel =
|
||||
new DirectColorModel(24,
|
||||
0x00FF0000, /* red mask */
|
||||
0x0000FF00, /* green mask */
|
||||
0x000000FF); /* blue mask */
|
||||
|
||||
private static final int[] bandmasks = new int[] {
|
||||
directColorModel.getRedMask(),
|
||||
directColorModel.getGreenMask(),
|
||||
directColorModel.getBlueMask() };
|
||||
|
||||
/**
|
||||
* Singleton constructor
|
||||
*/
|
||||
private WDataTransferer() {
|
||||
}
|
||||
|
||||
private static WDataTransferer transferer;
|
||||
|
||||
static synchronized WDataTransferer getInstanceImpl() {
|
||||
if (transferer == null) {
|
||||
transferer = new WDataTransferer();
|
||||
}
|
||||
return transferer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap <Long, DataFlavor> getFormatsForFlavors(
|
||||
DataFlavor[] flavors, FlavorTable map)
|
||||
{
|
||||
SortedMap <Long, DataFlavor> retval =
|
||||
super.getFormatsForFlavors(flavors, map);
|
||||
|
||||
// The Win32 native code does not support exporting LOCALE data, nor
|
||||
// should it.
|
||||
retval.remove(L_CF_LOCALE);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultUnicodeEncoding() {
|
||||
return "utf-16le";
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] translateTransferable(Transferable contents,
|
||||
DataFlavor flavor,
|
||||
long format) throws IOException
|
||||
{
|
||||
byte[] bytes = null;
|
||||
if (format == CF_HTML) {
|
||||
if (contents.isDataFlavorSupported(DataFlavor.selectionHtmlFlavor)) {
|
||||
// if a user provides data represented by
|
||||
// DataFlavor.selectionHtmlFlavor format, we use this
|
||||
// type to store the data in the native clipboard
|
||||
bytes = super.translateTransferable(contents,
|
||||
DataFlavor.selectionHtmlFlavor,
|
||||
format);
|
||||
} else if (contents.isDataFlavorSupported(DataFlavor.allHtmlFlavor)) {
|
||||
// if we cannot get data represented by the
|
||||
// DataFlavor.selectionHtmlFlavor format
|
||||
// but the DataFlavor.allHtmlFlavor format is avialable
|
||||
// we belive that the user knows how to represent
|
||||
// the data and how to mark up selection in a
|
||||
// system specific manner. Therefor, we use this data
|
||||
bytes = super.translateTransferable(contents,
|
||||
DataFlavor.allHtmlFlavor,
|
||||
format);
|
||||
} else {
|
||||
// handle other html flavor types, including custom and
|
||||
// fragment ones
|
||||
bytes = HTMLCodec.convertToHTMLFormat(super.translateTransferable(contents, flavor, format));
|
||||
}
|
||||
} else {
|
||||
// we handle non-html types basing on their
|
||||
// flavors
|
||||
bytes = super.translateTransferable(contents, flavor, format);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
// The stream is closed as a closable object
|
||||
@Override
|
||||
public Object translateStream(InputStream str,
|
||||
DataFlavor flavor, long format,
|
||||
Transferable localeTransferable)
|
||||
throws IOException
|
||||
{
|
||||
if (format == CF_HTML && flavor.isFlavorTextType()) {
|
||||
str = new HTMLCodec(str,
|
||||
EHTMLReadMode.getEHTMLReadMode(flavor));
|
||||
|
||||
}
|
||||
return super.translateStream(str, flavor, format,
|
||||
localeTransferable);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object translateBytes(byte[] bytes, DataFlavor flavor, long format,
|
||||
Transferable localeTransferable) throws IOException
|
||||
{
|
||||
|
||||
|
||||
if (format == CF_FILEGROUPDESCRIPTORA || format == CF_FILEGROUPDESCRIPTORW) {
|
||||
if (bytes == null || !DataFlavor.javaFileListFlavor.equals(flavor)) {
|
||||
throw new IOException("data translation failed");
|
||||
}
|
||||
String st = new String(bytes, 0, bytes.length, "UTF-16LE");
|
||||
String[] filenames = st.split("\0");
|
||||
if( 0 == filenames.length ){
|
||||
return null;
|
||||
}
|
||||
|
||||
// Convert the strings to File objects
|
||||
File[] files = new File[filenames.length];
|
||||
for (int i = 0; i < filenames.length; ++i) {
|
||||
files[i] = new File(filenames[i]);
|
||||
//They are temp-files from memory Stream, so they have to be removed on exit
|
||||
files[i].deleteOnExit();
|
||||
}
|
||||
// Turn the list of Files into a List and return
|
||||
return Arrays.asList(files);
|
||||
}
|
||||
|
||||
if (format == CFSTR_INETURL &&
|
||||
URL.class.equals(flavor.getRepresentationClass()))
|
||||
{
|
||||
String charset = getDefaultTextCharset();
|
||||
if (localeTransferable != null && localeTransferable.
|
||||
isDataFlavorSupported(javaTextEncodingFlavor))
|
||||
{
|
||||
try {
|
||||
charset = new String((byte[])localeTransferable.
|
||||
getTransferData(javaTextEncodingFlavor), "UTF-8");
|
||||
} catch (UnsupportedFlavorException cannotHappen) {
|
||||
}
|
||||
}
|
||||
return new URL(new String(bytes, charset));
|
||||
}
|
||||
|
||||
return super.translateBytes(bytes , flavor, format,
|
||||
localeTransferable);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocaleDependentTextFormat(long format) {
|
||||
return format == CF_TEXT || format == CFSTR_INETURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileFormat(long format) {
|
||||
return format == CF_HDROP || format == CF_FILEGROUPDESCRIPTORA || format == CF_FILEGROUPDESCRIPTORW;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long getFormatForNativeAsLong(String str) {
|
||||
Long format = predefinedClipboardNameMap.get(str);
|
||||
if (format == null) {
|
||||
format = Long.valueOf(registerClipboardFormat(str));
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNativeForFormat(long format) {
|
||||
return (format < predefinedClipboardNames.length)
|
||||
? predefinedClipboardNames[(int)format]
|
||||
: getClipboardFormatName(format);
|
||||
}
|
||||
|
||||
private final ToolkitThreadBlockedHandler handler =
|
||||
new WToolkitThreadBlockedHandler();
|
||||
|
||||
@Override
|
||||
public ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the Win32 RegisterClipboardFormat function to register
|
||||
* a non-standard format.
|
||||
*/
|
||||
private static native long registerClipboardFormat(String str);
|
||||
|
||||
/**
|
||||
* Calls the Win32 GetClipboardFormatName function which is
|
||||
* the reverse operation of RegisterClipboardFormat.
|
||||
*/
|
||||
private static native String getClipboardFormatName(long format);
|
||||
|
||||
@Override
|
||||
public boolean isImageFormat(long format) {
|
||||
return format == CF_DIB || format == CF_ENHMETAFILE ||
|
||||
format == CF_METAFILEPICT || format == CF_PNG ||
|
||||
format == CF_JFIF;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] imageToPlatformBytes(Image image, long format)
|
||||
throws IOException {
|
||||
String mimeType = null;
|
||||
if (format == CF_PNG) {
|
||||
mimeType = "image/png";
|
||||
} else if (format == CF_JFIF) {
|
||||
mimeType = "image/jpeg";
|
||||
}
|
||||
if (mimeType != null) {
|
||||
return imageToStandardBytes(image, mimeType);
|
||||
}
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
if (image instanceof ToolkitImage) {
|
||||
ImageRepresentation ir = ((ToolkitImage)image).getImageRep();
|
||||
ir.reconstruct(ImageObserver.ALLBITS);
|
||||
width = ir.getWidth();
|
||||
height = ir.getHeight();
|
||||
} else {
|
||||
width = image.getWidth(null);
|
||||
height = image.getHeight(null);
|
||||
}
|
||||
|
||||
// Fix for 4919639.
|
||||
// Some Windows native applications (e.g. clipbrd.exe) do not handle
|
||||
// 32-bpp DIBs correctly.
|
||||
// As a workaround we switched to 24-bpp DIBs.
|
||||
// MSDN prescribes that the bitmap array for a 24-bpp should consist of
|
||||
// 3-byte triplets representing blue, green and red components of a
|
||||
// pixel respectively. Additionally each scan line must be padded with
|
||||
// zeroes to end on a LONG data-type boundary. LONG is always 32-bit.
|
||||
// We render the given Image to a BufferedImage of type TYPE_3BYTE_BGR
|
||||
// with non-default scanline stride and pass the resulting data buffer
|
||||
// to the native code to fill the BITMAPINFO structure.
|
||||
int mod = (width * 3) % 4;
|
||||
int pad = mod > 0 ? 4 - mod : 0;
|
||||
|
||||
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
|
||||
int[] nBits = {8, 8, 8};
|
||||
int[] bOffs = {2, 1, 0};
|
||||
ColorModel colorModel =
|
||||
new ComponentColorModel(cs, nBits, false, false,
|
||||
Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
|
||||
WritableRaster raster =
|
||||
Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height,
|
||||
width * 3 + pad, 3, bOffs, null);
|
||||
|
||||
BufferedImage bimage = new BufferedImage(colorModel, raster, false, null);
|
||||
|
||||
// Some Windows native applications (e.g. clipbrd.exe) do not understand
|
||||
// top-down DIBs.
|
||||
// So we flip the image vertically and create a bottom-up DIB.
|
||||
AffineTransform imageFlipTransform =
|
||||
new AffineTransform(1, 0, 0, -1, 0, height);
|
||||
|
||||
Graphics2D g2d = bimage.createGraphics();
|
||||
|
||||
try {
|
||||
g2d.drawImage(image, imageFlipTransform, null);
|
||||
} finally {
|
||||
g2d.dispose();
|
||||
}
|
||||
|
||||
DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer();
|
||||
|
||||
byte[] imageData = buffer.getData();
|
||||
return imageDataToPlatformImageBytes(imageData, width, height, format);
|
||||
}
|
||||
|
||||
private static final byte [] UNICODE_NULL_TERMINATOR = new byte [] {0,0};
|
||||
|
||||
@Override
|
||||
protected ByteArrayOutputStream convertFileListToBytes(ArrayList<String> fileList)
|
||||
throws IOException
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
|
||||
if(fileList.isEmpty()) {
|
||||
//store empty unicode string (null terminator)
|
||||
bos.write(UNICODE_NULL_TERMINATOR);
|
||||
} else {
|
||||
for (int i = 0; i < fileList.size(); i++) {
|
||||
byte[] bytes = fileList.get(i).getBytes(getDefaultUnicodeEncoding());
|
||||
//store unicode string with null terminator
|
||||
bos.write(bytes, 0, bytes.length);
|
||||
bos.write(UNICODE_NULL_TERMINATOR);
|
||||
}
|
||||
}
|
||||
|
||||
// According to MSDN the byte array have to be double NULL-terminated.
|
||||
// The array contains Unicode characters, so each NULL-terminator is
|
||||
// a pair of bytes
|
||||
|
||||
bos.write(UNICODE_NULL_TERMINATOR);
|
||||
return bos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a byte array which contains data special for the given format
|
||||
* and for the given image data.
|
||||
*/
|
||||
private native byte[] imageDataToPlatformImageBytes(byte[] imageData,
|
||||
int width, int height,
|
||||
long format);
|
||||
|
||||
/**
|
||||
* Translates either a byte array or an input stream which contain
|
||||
* platform-specific image data in the given format into an Image.
|
||||
*/
|
||||
@Override
|
||||
protected Image platformImageBytesToImage(byte[] bytes, long format)
|
||||
throws IOException {
|
||||
String mimeType = null;
|
||||
if (format == CF_PNG) {
|
||||
mimeType = "image/png";
|
||||
} else if (format == CF_JFIF) {
|
||||
mimeType = "image/jpeg";
|
||||
}
|
||||
if (mimeType != null) {
|
||||
return standardImageBytesToImage(bytes, mimeType);
|
||||
}
|
||||
|
||||
int[] imageData = platformImageBytesToImageData(bytes, format);
|
||||
if (imageData == null) {
|
||||
throw new IOException("data translation failed");
|
||||
}
|
||||
|
||||
int len = imageData.length - 2;
|
||||
int width = imageData[len];
|
||||
int height = imageData[len + 1];
|
||||
|
||||
DataBufferInt buffer = new DataBufferInt(imageData, len);
|
||||
WritableRaster raster = Raster.createPackedRaster(buffer, width,
|
||||
height, width,
|
||||
bandmasks, null);
|
||||
|
||||
return new BufferedImage(directColorModel, raster, false, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a byte array which contains platform-specific image data in
|
||||
* the given format into an integer array which contains pixel values in
|
||||
* ARGB format. The two last elements in the array specify width and
|
||||
* height of the image respectively.
|
||||
*/
|
||||
private native int[] platformImageBytesToImageData(byte[] bytes,
|
||||
long format)
|
||||
throws IOException;
|
||||
|
||||
@Override
|
||||
protected native String[] dragQueryFile(byte[] bytes);
|
||||
}
|
||||
|
||||
final class WToolkitThreadBlockedHandler extends Mutex
|
||||
implements ToolkitThreadBlockedHandler {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
if (!isOwned()) {
|
||||
throw new IllegalMonitorStateException();
|
||||
}
|
||||
unlock();
|
||||
startSecondaryEventLoop();
|
||||
lock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exit() {
|
||||
if (!isOwned()) {
|
||||
throw new IllegalMonitorStateException();
|
||||
}
|
||||
WToolkit.quitSecondaryEventLoop();
|
||||
}
|
||||
|
||||
private native void startSecondaryEventLoop();
|
||||
}
|
||||
|
||||
enum EHTMLReadMode {
|
||||
HTML_READ_ALL,
|
||||
HTML_READ_FRAGMENT,
|
||||
HTML_READ_SELECTION;
|
||||
|
||||
public static EHTMLReadMode getEHTMLReadMode (DataFlavor df) {
|
||||
|
||||
EHTMLReadMode mode = HTML_READ_SELECTION;
|
||||
|
||||
String parameter = df.getParameter("document");
|
||||
|
||||
if ("all".equals(parameter)) {
|
||||
mode = HTML_READ_ALL;
|
||||
} else if ("fragment".equals(parameter)) {
|
||||
mode = HTML_READ_FRAGMENT;
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* on decode: This stream takes an InputStream which provides data in CF_HTML format,
|
||||
* strips off the description and context to extract the original HTML data.
|
||||
*
|
||||
* on encode: static convertToHTMLFormat is responsible for HTML clipboard header creation
|
||||
*/
|
||||
class HTMLCodec extends InputStream {
|
||||
//static section
|
||||
public static final String ENCODING = "UTF-8";
|
||||
|
||||
public static final String VERSION = "Version:";
|
||||
public static final String START_HTML = "StartHTML:";
|
||||
public static final String END_HTML = "EndHTML:";
|
||||
public static final String START_FRAGMENT = "StartFragment:";
|
||||
public static final String END_FRAGMENT = "EndFragment:";
|
||||
public static final String START_SELECTION = "StartSelection:"; //optional
|
||||
public static final String END_SELECTION = "EndSelection:"; //optional
|
||||
|
||||
public static final String START_FRAGMENT_CMT = "<!--StartFragment-->";
|
||||
public static final String END_FRAGMENT_CMT = "<!--EndFragment-->";
|
||||
public static final String SOURCE_URL = "SourceURL:";
|
||||
public static final String DEF_SOURCE_URL = "about:blank";
|
||||
|
||||
public static final String EOLN = "\r\n";
|
||||
|
||||
private static final String VERSION_NUM = "1.0";
|
||||
private static final int PADDED_WIDTH = 10;
|
||||
|
||||
private static String toPaddedString(int n, int width) {
|
||||
String string = "" + n;
|
||||
int len = string.length();
|
||||
if (n >= 0 && len < width) {
|
||||
char[] array = new char[width - len];
|
||||
Arrays.fill(array, '0');
|
||||
StringBuffer buffer = new StringBuffer(width);
|
||||
buffer.append(array);
|
||||
buffer.append(string);
|
||||
string = buffer.toString();
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
/**
|
||||
* convertToHTMLFormat adds the MS HTML clipboard header to byte array that
|
||||
* contains the parameters pairs.
|
||||
*
|
||||
* The consequence of parameters is fixed, but some or all of them could be
|
||||
* omitted. One parameter per one text line.
|
||||
* It looks like that:
|
||||
*
|
||||
* Version:1.0\r\n -- current supported version
|
||||
* StartHTML:000000192\r\n -- shift in array to the first byte after the header
|
||||
* EndHTML:000000757\r\n -- shift in array of last byte for HTML syntax analysis
|
||||
* StartFragment:000000396\r\n -- shift in array jast after <!--StartFragment-->
|
||||
* EndFragment:000000694\r\n -- shift in array before start <!--EndFragment-->
|
||||
* StartSelection:000000398\r\n -- shift in array of the first char in copied selection
|
||||
* EndSelection:000000692\r\n -- shift in array of the last char in copied selection
|
||||
* SourceURL:http://sun.com/\r\n -- base URL for related referenses
|
||||
* <HTML>...<BODY>...<!--StartFragment-->.....................<!--EndFragment-->...</BODY><HTML>
|
||||
* ^ ^ ^ ^^ ^
|
||||
* \ StartHTML | \-StartSelection | \EndFragment EndHTML/
|
||||
* \-StartFragment \EndSelection
|
||||
*
|
||||
*Combinations with tags sequence
|
||||
*<!--StartFragment--><HTML>...<BODY>...</BODY><HTML><!--EndFragment-->
|
||||
* or
|
||||
*<HTML>...<!--StartFragment-->...<BODY>...</BODY><!--EndFragment--><HTML>
|
||||
* are vailid too.
|
||||
*/
|
||||
public static byte[] convertToHTMLFormat(byte[] bytes) {
|
||||
// Calculate section offsets
|
||||
String htmlPrefix = "";
|
||||
String htmlSuffix = "";
|
||||
{
|
||||
//we have extend the fragment to full HTML document correctly
|
||||
//to avoid HTML and BODY tags doubling
|
||||
String stContext = new String(bytes);
|
||||
String stUpContext = stContext.toUpperCase();
|
||||
if( -1 == stUpContext.indexOf("<HTML") ) {
|
||||
htmlPrefix = "<HTML>";
|
||||
htmlSuffix = "</HTML>";
|
||||
if( -1 == stUpContext.indexOf("<BODY") ) {
|
||||
htmlPrefix = htmlPrefix +"<BODY>";
|
||||
htmlSuffix = "</BODY>" + htmlSuffix;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
String stBaseUrl = DEF_SOURCE_URL;
|
||||
int nStartHTML =
|
||||
VERSION.length() + VERSION_NUM.length() + EOLN.length()
|
||||
+ START_HTML.length() + PADDED_WIDTH + EOLN.length()
|
||||
+ END_HTML.length() + PADDED_WIDTH + EOLN.length()
|
||||
+ START_FRAGMENT.length() + PADDED_WIDTH + EOLN.length()
|
||||
+ END_FRAGMENT.length() + PADDED_WIDTH + EOLN.length()
|
||||
+ SOURCE_URL.length() + stBaseUrl.length() + EOLN.length()
|
||||
;
|
||||
int nStartFragment = nStartHTML + htmlPrefix.length();
|
||||
int nEndFragment = nStartFragment + bytes.length - 1;
|
||||
int nEndHTML = nEndFragment + htmlSuffix.length();
|
||||
|
||||
StringBuilder header = new StringBuilder(
|
||||
nStartFragment
|
||||
+ START_FRAGMENT_CMT.length()
|
||||
);
|
||||
//header
|
||||
header.append(VERSION);
|
||||
header.append(VERSION_NUM);
|
||||
header.append(EOLN);
|
||||
|
||||
header.append(START_HTML);
|
||||
header.append(toPaddedString(nStartHTML, PADDED_WIDTH));
|
||||
header.append(EOLN);
|
||||
|
||||
header.append(END_HTML);
|
||||
header.append(toPaddedString(nEndHTML, PADDED_WIDTH));
|
||||
header.append(EOLN);
|
||||
|
||||
header.append(START_FRAGMENT);
|
||||
header.append(toPaddedString(nStartFragment, PADDED_WIDTH));
|
||||
header.append(EOLN);
|
||||
|
||||
header.append(END_FRAGMENT);
|
||||
header.append(toPaddedString(nEndFragment, PADDED_WIDTH));
|
||||
header.append(EOLN);
|
||||
|
||||
header.append(SOURCE_URL);
|
||||
header.append(stBaseUrl);
|
||||
header.append(EOLN);
|
||||
|
||||
//HTML
|
||||
header.append(htmlPrefix);
|
||||
|
||||
byte[] headerBytes = null, trailerBytes = null;
|
||||
|
||||
try {
|
||||
headerBytes = header.toString().getBytes(ENCODING);
|
||||
trailerBytes = htmlSuffix.getBytes(ENCODING);
|
||||
} catch (UnsupportedEncodingException cannotHappen) {
|
||||
}
|
||||
|
||||
byte[] retval = new byte[headerBytes.length + bytes.length +
|
||||
trailerBytes.length];
|
||||
|
||||
System.arraycopy(headerBytes, 0, retval, 0, headerBytes.length);
|
||||
System.arraycopy(bytes, 0, retval, headerBytes.length,
|
||||
bytes.length - 1);
|
||||
System.arraycopy(trailerBytes, 0, retval,
|
||||
headerBytes.length + bytes.length - 1,
|
||||
trailerBytes.length);
|
||||
retval[retval.length-1] = 0;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
//decoder instance data and methods:
|
||||
|
||||
private final BufferedInputStream bufferedStream;
|
||||
private boolean descriptionParsed = false;
|
||||
private boolean closed = false;
|
||||
|
||||
// InputStreamReader uses an 8K buffer. The size is not customizable.
|
||||
public static final int BYTE_BUFFER_LEN = 8192;
|
||||
|
||||
// CharToByteUTF8.getMaxBytesPerChar returns 3, so we should not buffer
|
||||
// more chars than 3 times the number of bytes we can buffer.
|
||||
public static final int CHAR_BUFFER_LEN = BYTE_BUFFER_LEN / 3;
|
||||
|
||||
private static final String FAILURE_MSG =
|
||||
"Unable to parse HTML description: ";
|
||||
private static final String INVALID_MSG =
|
||||
" invalid";
|
||||
|
||||
//HTML header mapping:
|
||||
private long iHTMLStart,// StartHTML -- shift in array to the first byte after the header
|
||||
iHTMLEnd, // EndHTML -- shift in array of last byte for HTML syntax analysis
|
||||
iFragStart,// StartFragment -- shift in array jast after <!--StartFragment-->
|
||||
iFragEnd, // EndFragment -- shift in array before start <!--EndFragment-->
|
||||
iSelStart, // StartSelection -- shift in array of the first char in copied selection
|
||||
iSelEnd; // EndSelection -- shift in array of the last char in copied selection
|
||||
private String stBaseURL; // SourceURL -- base URL for related referenses
|
||||
private String stVersion; // Version -- current supported version
|
||||
|
||||
//Stream reader markers:
|
||||
private long iStartOffset,
|
||||
iEndOffset,
|
||||
iReadCount;
|
||||
|
||||
private EHTMLReadMode readMode;
|
||||
|
||||
public HTMLCodec(
|
||||
InputStream _bytestream,
|
||||
EHTMLReadMode _readMode) throws IOException
|
||||
{
|
||||
bufferedStream = new BufferedInputStream(_bytestream, BYTE_BUFFER_LEN);
|
||||
readMode = _readMode;
|
||||
}
|
||||
|
||||
public synchronized String getBaseURL() throws IOException
|
||||
{
|
||||
if( !descriptionParsed ) {
|
||||
parseDescription();
|
||||
}
|
||||
return stBaseURL;
|
||||
}
|
||||
public synchronized String getVersion() throws IOException
|
||||
{
|
||||
if( !descriptionParsed ) {
|
||||
parseDescription();
|
||||
}
|
||||
return stVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* parseDescription parsing HTML clipboard header as it described in
|
||||
* comment to convertToHTMLFormat
|
||||
*/
|
||||
private void parseDescription() throws IOException
|
||||
{
|
||||
stBaseURL = null;
|
||||
stVersion = null;
|
||||
|
||||
// initialization of array offset pointers
|
||||
// to the same "uninitialized" state.
|
||||
iHTMLEnd =
|
||||
iHTMLStart =
|
||||
iFragEnd =
|
||||
iFragStart =
|
||||
iSelEnd =
|
||||
iSelStart = -1;
|
||||
|
||||
bufferedStream.mark(BYTE_BUFFER_LEN);
|
||||
String astEntries[] = new String[] {
|
||||
//common
|
||||
VERSION,
|
||||
START_HTML,
|
||||
END_HTML,
|
||||
START_FRAGMENT,
|
||||
END_FRAGMENT,
|
||||
//ver 1.0
|
||||
START_SELECTION,
|
||||
END_SELECTION,
|
||||
SOURCE_URL
|
||||
};
|
||||
BufferedReader bufferedReader = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
bufferedStream,
|
||||
ENCODING
|
||||
),
|
||||
CHAR_BUFFER_LEN
|
||||
);
|
||||
long iHeadSize = 0;
|
||||
long iCRSize = EOLN.length();
|
||||
int iEntCount = astEntries.length;
|
||||
boolean bContinue = true;
|
||||
|
||||
for( int iEntry = 0; iEntry < iEntCount; ++iEntry ){
|
||||
String stLine = bufferedReader.readLine();
|
||||
if( null==stLine ) {
|
||||
break;
|
||||
}
|
||||
//some header entries are optional, but the order is fixed.
|
||||
for( ; iEntry < iEntCount; ++iEntry ){
|
||||
if( !stLine.startsWith(astEntries[iEntry]) ) {
|
||||
continue;
|
||||
}
|
||||
iHeadSize += stLine.length() + iCRSize;
|
||||
String stValue = stLine.substring(astEntries[iEntry].length()).trim();
|
||||
if( null!=stValue ) {
|
||||
try{
|
||||
switch( iEntry ){
|
||||
case 0:
|
||||
stVersion = stValue;
|
||||
break;
|
||||
case 1:
|
||||
iHTMLStart = Integer.parseInt(stValue);
|
||||
break;
|
||||
case 2:
|
||||
iHTMLEnd = Integer.parseInt(stValue);
|
||||
break;
|
||||
case 3:
|
||||
iFragStart = Integer.parseInt(stValue);
|
||||
break;
|
||||
case 4:
|
||||
iFragEnd = Integer.parseInt(stValue);
|
||||
break;
|
||||
case 5:
|
||||
iSelStart = Integer.parseInt(stValue);
|
||||
break;
|
||||
case 6:
|
||||
iSelEnd = Integer.parseInt(stValue);
|
||||
break;
|
||||
case 7:
|
||||
stBaseURL = stValue;
|
||||
break;
|
||||
};
|
||||
} catch ( NumberFormatException e ) {
|
||||
throw new IOException(FAILURE_MSG + astEntries[iEntry]+ " value " + e + INVALID_MSG);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
//some entries could absent in HTML header,
|
||||
//so we have find they by another way.
|
||||
if( -1 == iHTMLStart )
|
||||
iHTMLStart = iHeadSize;
|
||||
if( -1 == iFragStart )
|
||||
iFragStart = iHTMLStart;
|
||||
if( -1 == iFragEnd )
|
||||
iFragEnd = iHTMLEnd;
|
||||
if( -1 == iSelStart )
|
||||
iSelStart = iFragStart;
|
||||
if( -1 == iSelEnd )
|
||||
iSelEnd = iFragEnd;
|
||||
|
||||
//one of possible modes
|
||||
switch( readMode ){
|
||||
case HTML_READ_ALL:
|
||||
iStartOffset = iHTMLStart;
|
||||
iEndOffset = iHTMLEnd;
|
||||
break;
|
||||
case HTML_READ_FRAGMENT:
|
||||
iStartOffset = iFragStart;
|
||||
iEndOffset = iFragEnd;
|
||||
break;
|
||||
case HTML_READ_SELECTION:
|
||||
default:
|
||||
iStartOffset = iSelStart;
|
||||
iEndOffset = iSelEnd;
|
||||
break;
|
||||
}
|
||||
|
||||
bufferedStream.reset();
|
||||
if( -1 == iStartOffset ){
|
||||
throw new IOException(FAILURE_MSG + "invalid HTML format.");
|
||||
}
|
||||
|
||||
int curOffset = 0;
|
||||
while (curOffset < iStartOffset){
|
||||
curOffset += bufferedStream.skip(iStartOffset - curOffset);
|
||||
}
|
||||
|
||||
iReadCount = curOffset;
|
||||
|
||||
if( iStartOffset != iReadCount ){
|
||||
throw new IOException(FAILURE_MSG + "Byte stream ends in description.");
|
||||
}
|
||||
descriptionParsed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int read() throws IOException {
|
||||
if( closed ){
|
||||
throw new IOException("Stream closed");
|
||||
}
|
||||
|
||||
if( !descriptionParsed ){
|
||||
parseDescription();
|
||||
}
|
||||
if( -1 != iEndOffset && iReadCount >= iEndOffset ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int retval = bufferedStream.read();
|
||||
if( retval == -1 ) {
|
||||
return -1;
|
||||
}
|
||||
++iReadCount;
|
||||
return retval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() throws IOException {
|
||||
if( !closed ){
|
||||
closed = true;
|
||||
bufferedStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
62
jdkSrc/jdk8/sun/awt/windows/WDefaultFontCharset.java
Normal file
62
jdkSrc/jdk8/sun/awt/windows/WDefaultFontCharset.java
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.nio.charset.*;
|
||||
import sun.awt.AWTCharset;
|
||||
|
||||
final class WDefaultFontCharset extends AWTCharset
|
||||
{
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
// Name for Windows FontSet.
|
||||
private String fontName;
|
||||
|
||||
WDefaultFontCharset(String name){
|
||||
super("WDefaultFontCharset", Charset.forName("windows-1252"));
|
||||
fontName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder();
|
||||
}
|
||||
|
||||
private class Encoder extends AWTCharset.Encoder {
|
||||
@Override
|
||||
public boolean canEncode(char c){
|
||||
return canConvert(c);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized native boolean canConvert(char ch);
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method IDs
|
||||
*/
|
||||
private static native void initIDs();
|
||||
}
|
||||
97
jdkSrc/jdk8/sun/awt/windows/WDesktopPeer.java
Normal file
97
jdkSrc/jdk8/sun/awt/windows/WDesktopPeer.java
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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 sun.awt.windows;
|
||||
|
||||
|
||||
import java.awt.Desktop.Action;
|
||||
import java.awt.peer.DesktopPeer;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
|
||||
/**
|
||||
* Concrete implementation of the interface <code>DesktopPeer</code> for
|
||||
* the Windows platform.
|
||||
*
|
||||
* @see DesktopPeer
|
||||
*/
|
||||
final class WDesktopPeer implements DesktopPeer {
|
||||
/* Contants for the operation verbs */
|
||||
private static String ACTION_OPEN_VERB = "open";
|
||||
private static String ACTION_EDIT_VERB = "edit";
|
||||
private static String ACTION_PRINT_VERB = "print";
|
||||
|
||||
@Override
|
||||
public boolean isSupported(Action action) {
|
||||
// OPEN, EDIT, PRINT, MAIL, BROWSE all supported on windows.
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(File file) throws IOException {
|
||||
this.ShellExecute(file, ACTION_OPEN_VERB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(File file) throws IOException {
|
||||
this.ShellExecute(file, ACTION_EDIT_VERB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(File file) throws IOException {
|
||||
this.ShellExecute(file, ACTION_PRINT_VERB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mail(URI uri) throws IOException {
|
||||
this.ShellExecute(uri, ACTION_OPEN_VERB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void browse(URI uri) throws IOException {
|
||||
this.ShellExecute(uri, ACTION_OPEN_VERB);
|
||||
}
|
||||
|
||||
private void ShellExecute(File file, String verb) throws IOException {
|
||||
String errMsg = ShellExecute(file.getAbsolutePath(), verb);
|
||||
if (errMsg != null) {
|
||||
throw new IOException("Failed to " + verb + " " + file + ". Error message: " + errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShellExecute(URI uri, String verb) throws IOException {
|
||||
String errmsg = ShellExecute(uri.toString(), verb);
|
||||
|
||||
if (errmsg != null) {
|
||||
throw new IOException("Failed to " + verb + " " + uri
|
||||
+ ". Error message: " + errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
private static native String ShellExecute(String fileOrUri, String verb);
|
||||
|
||||
}
|
||||
316
jdkSrc/jdk8/sun/awt/windows/WDesktopProperties.java
Normal file
316
jdkSrc/jdk8/sun/awt/windows/WDesktopProperties.java
Normal file
@@ -0,0 +1,316 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import static java.awt.RenderingHints.*;
|
||||
import java.awt.RenderingHints;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
/*
|
||||
* Class encapsulating Windows desktop properties.;
|
||||
* This class exposes Windows user configuration values
|
||||
* for things like:
|
||||
* Window metrics
|
||||
* Accessibility, display settings
|
||||
* Animation effects
|
||||
* Colors
|
||||
* Etc, etc etc.
|
||||
*
|
||||
* It's primary use is so that Windows specific Java code;
|
||||
* like the Windows Pluggable Look-and-Feel can better adapt
|
||||
* itself when running on a Windows platform.
|
||||
*/
|
||||
final class WDesktopProperties {
|
||||
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WDesktopProperties");
|
||||
private static final String PREFIX = "win.";
|
||||
private static final String FILE_PREFIX = "awt.file.";
|
||||
private static final String PROP_NAMES = "win.propNames";
|
||||
|
||||
private long pData;
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
private WToolkit wToolkit;
|
||||
|
||||
private HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method IDs
|
||||
*/
|
||||
private static native void initIDs();
|
||||
|
||||
static boolean isWindowsProperty(String name) {
|
||||
return name.startsWith(PREFIX) || name.startsWith(FILE_PREFIX) ||
|
||||
name.equals(SunToolkit.DESKTOPFONTHINTS);
|
||||
}
|
||||
|
||||
WDesktopProperties(WToolkit wToolkit) {
|
||||
this.wToolkit = wToolkit;
|
||||
init();
|
||||
}
|
||||
|
||||
private native void init();
|
||||
|
||||
/*
|
||||
* Returns String[] containing available property names
|
||||
*/
|
||||
private String [] getKeyNames() {
|
||||
Object keys[] = map.keySet().toArray();
|
||||
String sortedKeys[] = new String[keys.length];
|
||||
|
||||
for ( int nkey = 0; nkey < keys.length; nkey++ ) {
|
||||
sortedKeys[nkey] = keys[nkey].toString();
|
||||
}
|
||||
Arrays.sort(sortedKeys);
|
||||
return sortedKeys;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reads Win32 configuration information and
|
||||
* updates hashmap values
|
||||
*/
|
||||
private native void getWindowsParameters();
|
||||
|
||||
/*
|
||||
* Called from native code to set a boolean property
|
||||
*/
|
||||
private synchronized void setBooleanProperty(String key, boolean value) {
|
||||
assert( key != null );
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine(key + "=" + String.valueOf(value));
|
||||
}
|
||||
map.put(key, Boolean.valueOf(value));
|
||||
}
|
||||
|
||||
/*
|
||||
* Called from native code to set an integer property
|
||||
*/
|
||||
private synchronized void setIntegerProperty(String key, int value) {
|
||||
assert( key != null );
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine(key + "=" + String.valueOf(value));
|
||||
}
|
||||
map.put(key, Integer.valueOf(value));
|
||||
}
|
||||
|
||||
/*
|
||||
* Called from native code to set a string property
|
||||
*/
|
||||
private synchronized void setStringProperty(String key, String value) {
|
||||
assert( key != null );
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine(key + "=" + value);
|
||||
}
|
||||
map.put(key, value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called from native code to set a color property
|
||||
*/
|
||||
private synchronized void setColorProperty(String key, int r, int g, int b) {
|
||||
assert( key != null && r <= 255 && g <=255 && b <= 255 );
|
||||
Color color = new Color(r, g, b);
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine(key + "=" + color);
|
||||
}
|
||||
map.put(key, color);
|
||||
}
|
||||
|
||||
/* Map of known windows font aliases to the preferred JDK name */
|
||||
static HashMap<String,String> fontNameMap;
|
||||
static {
|
||||
fontNameMap = new HashMap<String,String>();
|
||||
fontNameMap.put("Courier", Font.MONOSPACED);
|
||||
fontNameMap.put("MS Serif", "Microsoft Serif");
|
||||
fontNameMap.put("MS Sans Serif", "Microsoft Sans Serif");
|
||||
fontNameMap.put("Terminal", Font.DIALOG);
|
||||
fontNameMap.put("FixedSys", Font.MONOSPACED);
|
||||
fontNameMap.put("System", Font.DIALOG);
|
||||
}
|
||||
/*
|
||||
* Called from native code to set a font property
|
||||
*/
|
||||
private synchronized void setFontProperty(String key, String name, int style, int size) {
|
||||
assert( key != null && style <= (Font.BOLD|Font.ITALIC) && size >= 0 );
|
||||
|
||||
String mappedName = fontNameMap.get(name);
|
||||
if (mappedName != null) {
|
||||
name = mappedName;
|
||||
}
|
||||
Font font = new Font(name, style, size);
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine(key + "=" + font);
|
||||
}
|
||||
map.put(key, font);
|
||||
|
||||
String sizeKey = key + ".height";
|
||||
Integer iSize = Integer.valueOf(size);
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine(sizeKey + "=" + iSize);
|
||||
}
|
||||
map.put(sizeKey, iSize);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called from native code to set a sound event property
|
||||
*/
|
||||
private synchronized void setSoundProperty(String key, String winEventName) {
|
||||
assert( key != null && winEventName != null );
|
||||
|
||||
Runnable soundRunnable = new WinPlaySound(winEventName);
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine(key + "=" + soundRunnable);
|
||||
}
|
||||
map.put(key, soundRunnable);
|
||||
}
|
||||
|
||||
/*
|
||||
* Plays Windows sound event
|
||||
*/
|
||||
private native void playWindowsSound(String winEventName);
|
||||
|
||||
class WinPlaySound implements Runnable {
|
||||
String winEventName;
|
||||
|
||||
WinPlaySound(String winEventName) {
|
||||
this.winEventName = winEventName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
WDesktopProperties.this.playWindowsSound(winEventName);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "WinPlaySound("+winEventName+")";
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
return winEventName.equals(((WinPlaySound)o).winEventName);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return winEventName.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by WToolkit when Windows settings change-- we (re)load properties and
|
||||
* set new values.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
synchronized Map<String, Object> getProperties() {
|
||||
ThemeReader.flush();
|
||||
|
||||
// load the changed properties into a new hashmap
|
||||
map = new HashMap<String, Object>();
|
||||
getWindowsParameters();
|
||||
map.put(SunToolkit.DESKTOPFONTHINTS, SunToolkit.getDesktopFontHints());
|
||||
map.put(PROP_NAMES, getKeyNames());
|
||||
// DnD uses one value for x and y drag diff, but Windows provides
|
||||
// separate ones. For now, just use the x value - rnk
|
||||
map.put("DnD.Autoscroll.cursorHysteresis", map.get("win.drag.x"));
|
||||
|
||||
return (Map<String, Object>) map.clone();
|
||||
}
|
||||
|
||||
/*
|
||||
* This returns the value for the desktop property "awt.font.desktophints"
|
||||
* It builds this using the Windows desktop properties to return
|
||||
* them as platform independent hints.
|
||||
* This requires that the Windows properties have already been gathered
|
||||
* and placed in "map"
|
||||
*/
|
||||
synchronized RenderingHints getDesktopAAHints() {
|
||||
|
||||
/* Equate "DEFAULT" to "OFF", which it is in our implementation.
|
||||
* Doing this prevents unnecessary pipeline revalidation where
|
||||
* the value OFF is detected as a distinct value by SunGraphics2D
|
||||
*/
|
||||
Object fontSmoothingHint = VALUE_TEXT_ANTIALIAS_DEFAULT;
|
||||
Integer fontSmoothingContrast = null;
|
||||
|
||||
Boolean smoothingOn = (Boolean)map.get("win.text.fontSmoothingOn");
|
||||
|
||||
if (smoothingOn != null && smoothingOn.equals(Boolean.TRUE)) {
|
||||
Integer typeID = (Integer)map.get("win.text.fontSmoothingType");
|
||||
/* "1" is GASP/Standard but we'll also use that if the return
|
||||
* value is anything other than "2" for LCD.
|
||||
*/
|
||||
if (typeID == null || typeID.intValue() <= 1 ||
|
||||
typeID.intValue() > 2) {
|
||||
fontSmoothingHint = VALUE_TEXT_ANTIALIAS_GASP;
|
||||
} else {
|
||||
/* Recognise 0 as BGR and everything else as RGB - note
|
||||
* that 1 is the expected value for RGB.
|
||||
*/
|
||||
Integer orientID = (Integer)
|
||||
map.get("win.text.fontSmoothingOrientation");
|
||||
/* 0 is BGR, 1 is RGB. Other values, assume RGB */
|
||||
if (orientID == null || orientID.intValue() != 0) {
|
||||
fontSmoothingHint = VALUE_TEXT_ANTIALIAS_LCD_HRGB;
|
||||
} else {
|
||||
fontSmoothingHint = VALUE_TEXT_ANTIALIAS_LCD_HBGR;
|
||||
}
|
||||
|
||||
fontSmoothingContrast = (Integer)
|
||||
map.get("win.text.fontSmoothingContrast");
|
||||
if (fontSmoothingContrast == null) {
|
||||
fontSmoothingContrast = Integer.valueOf(140);
|
||||
} else {
|
||||
/* Windows values are scaled 10x those of Java 2D */
|
||||
fontSmoothingContrast =
|
||||
Integer.valueOf(fontSmoothingContrast.intValue()/10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RenderingHints hints = new RenderingHints(null);
|
||||
hints.put(KEY_TEXT_ANTIALIASING, fontSmoothingHint);
|
||||
if (fontSmoothingContrast != null) {
|
||||
hints.put(KEY_TEXT_LCD_CONTRAST, fontSmoothingContrast);
|
||||
}
|
||||
return hints;
|
||||
}
|
||||
}
|
||||
153
jdkSrc/jdk8/sun/awt/windows/WDialogPeer.java
Normal file
153
jdkSrc/jdk8/sun/awt/windows/WDialogPeer.java
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
|
||||
import sun.awt.*;
|
||||
import sun.awt.im.*;
|
||||
|
||||
final class WDialogPeer extends WWindowPeer implements DialogPeer {
|
||||
// Toolkit & peer internals
|
||||
|
||||
// Platform default background for dialogs. Gets set on target if
|
||||
// target has none explicitly specified.
|
||||
final static Color defaultBackground = SystemColor.control;
|
||||
|
||||
// If target doesn't have its background color set, we set its
|
||||
// background to platform default.
|
||||
boolean needDefaultBackground;
|
||||
|
||||
WDialogPeer(Dialog target) {
|
||||
super(target);
|
||||
|
||||
InputMethodManager imm = InputMethodManager.getInstance();
|
||||
String menuString = imm.getTriggerMenuString();
|
||||
if (menuString != null)
|
||||
{
|
||||
pSetIMMOption(menuString);
|
||||
}
|
||||
}
|
||||
|
||||
native void createAwtDialog(WComponentPeer parent);
|
||||
@Override
|
||||
void create(WComponentPeer parent) {
|
||||
preCreate(parent);
|
||||
createAwtDialog(parent);
|
||||
}
|
||||
|
||||
native void showModal();
|
||||
native void endModal();
|
||||
|
||||
@Override
|
||||
void initialize() {
|
||||
Dialog target = (Dialog)this.target;
|
||||
// Need to set target's background to default _before_ a call
|
||||
// to super.initialize.
|
||||
if (needDefaultBackground) {
|
||||
target.setBackground(defaultBackground);
|
||||
}
|
||||
|
||||
super.initialize();
|
||||
|
||||
if (target.getTitle() != null) {
|
||||
setTitle(target.getTitle());
|
||||
}
|
||||
setResizable(target.isResizable());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void realShow() {
|
||||
Dialog dlg = (Dialog)target;
|
||||
if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) {
|
||||
showModal();
|
||||
} else {
|
||||
super.realShow();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
void hide() {
|
||||
Dialog dlg = (Dialog)target;
|
||||
if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) {
|
||||
endModal();
|
||||
} else {
|
||||
super.hide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blockWindows(java.util.List<Window> toBlock) {
|
||||
for (Window w : toBlock) {
|
||||
WWindowPeer wp = (WWindowPeer)AWTAccessor.getComponentAccessor().getPeer(w);
|
||||
if (wp != null) {
|
||||
wp.setModalBlocked((Dialog)target, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
if (((Dialog)target).isUndecorated()) {
|
||||
return super.getMinimumSize();
|
||||
} else {
|
||||
return new Dimension(getSysMinWidth(), getSysMinHeight());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isTargetUndecorated() {
|
||||
return ((Dialog)target).isUndecorated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reshape(int x, int y, int width, int height) {
|
||||
if (((Dialog)target).isUndecorated()) {
|
||||
super.reshape(x, y, width, height);
|
||||
} else {
|
||||
reshapeFrame(x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
/* Native create() peeks at target's background and if it's null
|
||||
* calls this method to arrage for default background to be set on
|
||||
* target. Can't make the check in Java, since getBackground will
|
||||
* return owner's background if target has none set.
|
||||
*/
|
||||
private void setDefaultColor() {
|
||||
// Can't call target.setBackground directly, since we are
|
||||
// called on toolkit thread. Can't schedule a Runnable on the
|
||||
// EventHandlerThread because of the race condition. So just
|
||||
// set a flag and call target.setBackground in initialize.
|
||||
needDefaultBackground = true;
|
||||
}
|
||||
|
||||
native void pSetIMMOption(String option);
|
||||
void notifyIMMOptionChange(){
|
||||
InputMethodManager.getInstance().notifyChangeRequest((Component)target);
|
||||
}
|
||||
}
|
||||
171
jdkSrc/jdk8/sun/awt/windows/WDragSourceContextPeer.java
Normal file
171
jdkSrc/jdk8/sun/awt/windows/WDragSourceContextPeer.java
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2009, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
|
||||
import java.awt.datatransfer.Transferable;
|
||||
|
||||
import java.awt.dnd.DragGestureEvent;
|
||||
import java.awt.dnd.InvalidDnDOperationException;
|
||||
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import sun.awt.dnd.SunDragSourceContextPeer;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* TBC
|
||||
* </p>
|
||||
*
|
||||
* @since JDK1.2
|
||||
*
|
||||
*/
|
||||
|
||||
final class WDragSourceContextPeer extends SunDragSourceContextPeer {
|
||||
public void startSecondaryEventLoop(){
|
||||
WToolkit.startSecondaryEventLoop();
|
||||
}
|
||||
public void quitSecondaryEventLoop(){
|
||||
WToolkit.quitSecondaryEventLoop();
|
||||
}
|
||||
|
||||
private static final WDragSourceContextPeer theInstance =
|
||||
new WDragSourceContextPeer(null);
|
||||
|
||||
/**
|
||||
* construct a new WDragSourceContextPeer. package private
|
||||
*/
|
||||
|
||||
private WDragSourceContextPeer(DragGestureEvent dge) {
|
||||
super(dge);
|
||||
}
|
||||
|
||||
static WDragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
|
||||
theInstance.setTrigger(dge);
|
||||
return theInstance;
|
||||
}
|
||||
|
||||
protected void startDrag(Transferable trans,
|
||||
long[] formats, Map formatMap) {
|
||||
|
||||
long nativeCtxtLocal = 0;
|
||||
|
||||
nativeCtxtLocal = createDragSource(getTrigger().getComponent(),
|
||||
trans,
|
||||
getTrigger().getTriggerEvent(),
|
||||
getTrigger().getSourceAsDragGestureRecognizer().getSourceActions(),
|
||||
formats,
|
||||
formatMap);
|
||||
|
||||
if (nativeCtxtLocal == 0) {
|
||||
throw new InvalidDnDOperationException("failed to create native peer");
|
||||
}
|
||||
|
||||
int[] imageData = null;
|
||||
Point op = null;
|
||||
|
||||
Image im = getDragImage();
|
||||
int imageWidth = -1;
|
||||
int imageHeight = -1;
|
||||
if (im != null) {
|
||||
//image is ready (partial images are ok)
|
||||
try{
|
||||
imageWidth = im.getWidth(null);
|
||||
imageHeight = im.getHeight(null);
|
||||
if (imageWidth < 0 || imageHeight < 0) {
|
||||
throw new InvalidDnDOperationException("drag image is not ready");
|
||||
}
|
||||
//We could get an exception from user code here.
|
||||
//"im" and "dragImageOffset" are user-defined objects
|
||||
op = getDragImageOffset(); //op could not be null here
|
||||
BufferedImage bi = new BufferedImage(
|
||||
imageWidth,
|
||||
imageHeight,
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
bi.getGraphics().drawImage(im, 0, 0, null);
|
||||
|
||||
//we can get out-of-memory here
|
||||
imageData = ((DataBufferInt)bi.getData().getDataBuffer()).getData();
|
||||
} catch (Throwable ex) {
|
||||
throw new InvalidDnDOperationException("drag image creation problem: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//We shouldn't have user-level exceptions since now.
|
||||
//Any exception leads to corrupted D'n'D state.
|
||||
setNativeContext(nativeCtxtLocal);
|
||||
WDropTargetContextPeer.setCurrentJVMLocalSourceTransferable(trans);
|
||||
|
||||
if (imageData != null) {
|
||||
doDragDrop(
|
||||
getNativeContext(),
|
||||
getCursor(),
|
||||
imageData,
|
||||
imageWidth, imageHeight,
|
||||
op.x, op.y);
|
||||
} else {
|
||||
doDragDrop(
|
||||
getNativeContext(),
|
||||
getCursor(),
|
||||
null,
|
||||
-1, -1,
|
||||
0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* downcall into native code
|
||||
*/
|
||||
|
||||
native long createDragSource(Component component,
|
||||
Transferable transferable,
|
||||
InputEvent nativeTrigger,
|
||||
int actions,
|
||||
long[] formats,
|
||||
Map formatMap);
|
||||
|
||||
/**
|
||||
* downcall into native code
|
||||
*/
|
||||
|
||||
native void doDragDrop(
|
||||
long nativeCtxt,
|
||||
Cursor cursor,
|
||||
int[] imageData,
|
||||
int imgWidth, int imgHight,
|
||||
int offsetX, int offsetY);
|
||||
|
||||
protected native void setNativeCursor(long nativeCtxt, Cursor c, int cType);
|
||||
|
||||
}
|
||||
245
jdkSrc/jdk8/sun/awt/windows/WDropTargetContextPeer.java
Normal file
245
jdkSrc/jdk8/sun/awt/windows/WDropTargetContextPeer.java
Normal file
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* 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 sun.awt.windows;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
import sun.awt.PeerEvent;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.dnd.SunDropTargetContextPeer;
|
||||
import sun.awt.dnd.SunDropTargetEvent;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The WDropTargetContextPeer class is the class responsible for handling
|
||||
* the interaction between the win32 DnD system and Java.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
final class WDropTargetContextPeer extends SunDropTargetContextPeer {
|
||||
/**
|
||||
* create the peer typically upcall from C++
|
||||
*/
|
||||
|
||||
static WDropTargetContextPeer getWDropTargetContextPeer() {
|
||||
return new WDropTargetContextPeer();
|
||||
}
|
||||
|
||||
/**
|
||||
* create the peer
|
||||
*/
|
||||
|
||||
private WDropTargetContextPeer() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* upcall to encapsulate file transfer
|
||||
*/
|
||||
|
||||
private static FileInputStream getFileStream(String file, long stgmedium)
|
||||
throws IOException
|
||||
{
|
||||
return new WDropTargetContextPeerFileStream(file, stgmedium);
|
||||
}
|
||||
|
||||
/**
|
||||
* upcall to encapsulate IStream buffer transfer
|
||||
*/
|
||||
|
||||
private static Object getIStream(long istream) throws IOException {
|
||||
return new WDropTargetContextPeerIStream(istream);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getNativeData(long format) {
|
||||
return getData(getNativeDragContext(), format);
|
||||
}
|
||||
|
||||
/**
|
||||
* signal drop complete
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected void doDropDone(boolean success, int dropAction,
|
||||
boolean isLocal) {
|
||||
dropDone(getNativeDragContext(), success, dropAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void eventPosted(final SunDropTargetEvent e) {
|
||||
if (e.getID() != SunDropTargetEvent.MOUSE_DROPPED) {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
e.getDispatcher().unregisterAllEvents();
|
||||
}
|
||||
};
|
||||
// NOTE: this PeerEvent must be a NORM_PRIORITY event to be
|
||||
// dispatched after this SunDropTargetEvent, but before the next
|
||||
// one, so we should pass zero flags.
|
||||
PeerEvent peerEvent = new PeerEvent(e.getSource(), runnable, 0);
|
||||
SunToolkit.executeOnEventHandlerThread(peerEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* downcall to bind transfer data.
|
||||
*/
|
||||
|
||||
private native Object getData(long nativeContext, long format);
|
||||
|
||||
/**
|
||||
* downcall to notify that drop is complete
|
||||
*/
|
||||
|
||||
private native void dropDone(long nativeContext, boolean success, int action);
|
||||
}
|
||||
|
||||
/**
|
||||
* package private class to handle file transfers
|
||||
*/
|
||||
|
||||
final class WDropTargetContextPeerFileStream extends FileInputStream {
|
||||
|
||||
/**
|
||||
* construct file input stream
|
||||
*/
|
||||
|
||||
WDropTargetContextPeerFileStream(String name, long stgmedium)
|
||||
throws FileNotFoundException
|
||||
{
|
||||
super(name);
|
||||
|
||||
this.stgmedium = stgmedium;
|
||||
}
|
||||
|
||||
/**
|
||||
* close
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (stgmedium != 0) {
|
||||
super.close();
|
||||
freeStgMedium(stgmedium);
|
||||
stgmedium = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* free underlying windows data structure
|
||||
*/
|
||||
|
||||
private native void freeStgMedium(long stgmedium);
|
||||
|
||||
/*
|
||||
* fields
|
||||
*/
|
||||
|
||||
private long stgmedium;
|
||||
}
|
||||
|
||||
/**
|
||||
* Package private class to access IStream objects
|
||||
*/
|
||||
|
||||
final class WDropTargetContextPeerIStream extends InputStream {
|
||||
|
||||
/**
|
||||
* construct a WDropTargetContextPeerIStream wrapper
|
||||
*/
|
||||
|
||||
WDropTargetContextPeerIStream(long istream) throws IOException {
|
||||
super();
|
||||
|
||||
if (istream == 0) throw new IOException("No IStream");
|
||||
|
||||
this.istream = istream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bytes available
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
if (istream == 0) throw new IOException("No IStream");
|
||||
return Available(istream);
|
||||
}
|
||||
|
||||
private native int Available(long istream);
|
||||
|
||||
/**
|
||||
* read
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (istream == 0) throw new IOException("No IStream");
|
||||
return Read(istream);
|
||||
}
|
||||
|
||||
private native int Read(long istream) throws IOException;
|
||||
|
||||
/**
|
||||
* read into buffer
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
if (istream == 0) throw new IOException("No IStream");
|
||||
return ReadBytes(istream, b, off, len);
|
||||
}
|
||||
|
||||
private native int ReadBytes(long istream, byte[] b, int off, int len) throws IOException;
|
||||
|
||||
/**
|
||||
* close
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (istream != 0) {
|
||||
super.close();
|
||||
Close(istream);
|
||||
istream = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private native void Close(long istream);
|
||||
|
||||
/*
|
||||
* fields
|
||||
*/
|
||||
|
||||
private long istream;
|
||||
}
|
||||
277
jdkSrc/jdk8/sun/awt/windows/WEmbeddedFrame.java
Normal file
277
jdkSrc/jdk8/sun/awt/windows/WEmbeddedFrame.java
Normal file
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import sun.awt.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InvocationEvent;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.image.*;
|
||||
import sun.awt.image.ByteInterleavedRaster;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.AccessController;
|
||||
|
||||
public class WEmbeddedFrame extends EmbeddedFrame {
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
private long handle;
|
||||
|
||||
private int bandWidth = 0;
|
||||
private int bandHeight = 0;
|
||||
private int imgWid = 0;
|
||||
private int imgHgt = 0;
|
||||
|
||||
private static int pScale = 0;
|
||||
private static final int MAX_BAND_SIZE = (1024*30);
|
||||
|
||||
/**
|
||||
* This flag is set to {@code true} if this embedded frame is hosted by Internet Explorer.
|
||||
*/
|
||||
private boolean isEmbeddedInIE = false;
|
||||
|
||||
private static String printScale = AccessController.doPrivileged(
|
||||
new GetPropertyAction("sun.java2d.print.pluginscalefactor"));
|
||||
|
||||
public WEmbeddedFrame() {
|
||||
this((long)0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This constructor will be removed in 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
public WEmbeddedFrame(int handle) {
|
||||
this((long)handle);
|
||||
}
|
||||
|
||||
public WEmbeddedFrame(long handle) {
|
||||
this.handle = handle;
|
||||
if (handle != 0) {
|
||||
addNotify();
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void addNotify() {
|
||||
if (getPeer() == null) {
|
||||
WToolkit toolkit = (WToolkit)Toolkit.getDefaultToolkit();
|
||||
setPeer(toolkit.createEmbeddedFrame(this));
|
||||
}
|
||||
super.addNotify();
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the native handle
|
||||
*/
|
||||
public long getEmbedderHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the embedded frame and its children using the specified HDC.
|
||||
*/
|
||||
|
||||
void print(long hdc) {
|
||||
BufferedImage bandImage = null;
|
||||
|
||||
int xscale = 1;
|
||||
int yscale = 1;
|
||||
|
||||
/* Is this is either a printer DC or an enhanced meta file DC ?
|
||||
* Mozilla passes in a printer DC, IE passes plug-in a DC for an
|
||||
* enhanced meta file. Its possible we may be passed to a memory
|
||||
* DC. If we here create a larger image, draw in to it and have
|
||||
* that memory DC then lose the image resolution only to scale it
|
||||
* back up again when sending to a printer it will look really bad.
|
||||
* So, is this is either a printer DC or an enhanced meta file DC ?
|
||||
* Scale only if it is. Use a 4x scale factor, partly since for
|
||||
* an enhanced meta file we don't know anything about the
|
||||
* real resolution of the destination.
|
||||
*
|
||||
* For a printer DC we could probably derive the scale factor to use
|
||||
* by querying LOGPIXELSX/Y, and dividing that by the screen
|
||||
* resolution (typically 96 dpi or 120 dpi) but that would typically
|
||||
* make for even bigger output for marginal extra quality.
|
||||
* But for enhanced meta file we don't know anything about the
|
||||
* real resolution of the destination so
|
||||
*/
|
||||
if (isPrinterDC(hdc)) {
|
||||
xscale = yscale = getPrintScaleFactor();
|
||||
}
|
||||
|
||||
int frameHeight = getHeight();
|
||||
if (bandImage == null) {
|
||||
bandWidth = getWidth();
|
||||
if (bandWidth % 4 != 0) {
|
||||
bandWidth += (4 - (bandWidth % 4));
|
||||
}
|
||||
if (bandWidth <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
bandHeight = Math.min(MAX_BAND_SIZE/bandWidth, frameHeight);
|
||||
|
||||
imgWid = bandWidth * xscale;
|
||||
imgHgt = bandHeight * yscale;
|
||||
bandImage = new BufferedImage(imgWid, imgHgt,
|
||||
BufferedImage.TYPE_3BYTE_BGR);
|
||||
}
|
||||
|
||||
Graphics clearGraphics = bandImage.getGraphics();
|
||||
clearGraphics.setColor(Color.white);
|
||||
Graphics2D g2d = (Graphics2D)bandImage.getGraphics();
|
||||
g2d.translate(0, imgHgt);
|
||||
g2d.scale(xscale, -yscale);
|
||||
|
||||
ByteInterleavedRaster ras = (ByteInterleavedRaster)bandImage.getRaster();
|
||||
byte[] data = ras.getDataStorage();
|
||||
|
||||
for (int bandTop = 0; bandTop < frameHeight; bandTop += bandHeight) {
|
||||
clearGraphics.fillRect(0, 0, bandWidth, bandHeight);
|
||||
|
||||
printComponents(g2d);
|
||||
int imageOffset =0;
|
||||
int currBandHeight = bandHeight;
|
||||
int currImgHeight = imgHgt;
|
||||
if ((bandTop+bandHeight) > frameHeight) {
|
||||
// last band
|
||||
currBandHeight = frameHeight - bandTop;
|
||||
currImgHeight = currBandHeight*yscale;
|
||||
|
||||
// multiply by 3 because the image is a 3 byte BGR
|
||||
imageOffset = imgWid*(imgHgt-currImgHeight)*3;
|
||||
}
|
||||
|
||||
printBand(hdc, data, imageOffset,
|
||||
0, 0, imgWid, currImgHeight,
|
||||
0, bandTop, bandWidth, currBandHeight);
|
||||
g2d.translate(0, -bandHeight);
|
||||
}
|
||||
}
|
||||
|
||||
protected static int getPrintScaleFactor() {
|
||||
// check if value is already cached
|
||||
if (pScale != 0)
|
||||
return pScale;
|
||||
if (printScale == null) {
|
||||
// if no system property is specified,
|
||||
// check for environment setting
|
||||
printScale = AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
public String run() {
|
||||
return System.getenv("JAVA2D_PLUGIN_PRINT_SCALE");
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
int default_printDC_scale = 4;
|
||||
int scale = default_printDC_scale;
|
||||
if (printScale != null) {
|
||||
try {
|
||||
scale = Integer.parseInt(printScale);
|
||||
if (scale > 8 || scale < 1) {
|
||||
scale = default_printDC_scale;
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
}
|
||||
pScale = scale;
|
||||
return pScale;
|
||||
}
|
||||
|
||||
|
||||
private native boolean isPrinterDC(long hdc);
|
||||
|
||||
private native void printBand(long hdc, byte[] data, int offset, int sx,
|
||||
int sy, int swidth, int sheight, int dx,
|
||||
int dy, int dwidth, int dheight);
|
||||
|
||||
/**
|
||||
* Initialize JNI field IDs
|
||||
*/
|
||||
private static native void initIDs();
|
||||
|
||||
/**
|
||||
* This method is called from the native code when this embedded
|
||||
* frame should be activated. It is expected to be overridden in
|
||||
* subclasses, for example, in plugin to activate the browser
|
||||
* window that contains this embedded frame.
|
||||
*
|
||||
* NOTE: This method may be called by privileged threads.
|
||||
* DO NOT INVOKE CLIENT CODE ON THIS THREAD!
|
||||
*/
|
||||
public void activateEmbeddingTopLevel() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void synthesizeWindowActivation(final boolean activate) {
|
||||
if (!activate || EventQueue.isDispatchThread()) {
|
||||
((WFramePeer)getPeer()).emulateActivation(activate);
|
||||
} else {
|
||||
// To avoid focus concurrence b/w IE and EmbeddedFrame
|
||||
// activation is postponed by means of posting it to EDT.
|
||||
Runnable r = new Runnable() {
|
||||
public void run() {
|
||||
((WFramePeer)getPeer()).emulateActivation(true);
|
||||
}
|
||||
};
|
||||
WToolkit.postEvent(WToolkit.targetToAppContext(this),
|
||||
new InvocationEvent(this, r));
|
||||
}
|
||||
}
|
||||
|
||||
public void registerAccelerator(AWTKeyStroke stroke) {}
|
||||
public void unregisterAccelerator(AWTKeyStroke stroke) {}
|
||||
|
||||
/**
|
||||
* Should be overridden in subclasses. Call to
|
||||
* super.notifyModalBlocked(blocker, blocked) must be present
|
||||
* when overriding.
|
||||
* It may occur that embedded frame is not put into its
|
||||
* container at the moment when it is blocked, for example,
|
||||
* when running an applet in IE. Then the call to this method
|
||||
* should be delayed until embedded frame is reparented.
|
||||
*
|
||||
* NOTE: This method may be called by privileged threads.
|
||||
* DO NOT INVOKE CLIENT CODE ON THIS THREAD!
|
||||
*/
|
||||
public void notifyModalBlocked(Dialog blocker, boolean blocked) {
|
||||
try {
|
||||
ComponentPeer thisPeer = (ComponentPeer)WToolkit.targetToPeer(this);
|
||||
ComponentPeer blockerPeer = (ComponentPeer)WToolkit.targetToPeer(blocker);
|
||||
notifyModalBlockedImpl((WEmbeddedFramePeer)thisPeer,
|
||||
(WWindowPeer)blockerPeer, blocked);
|
||||
} catch (Exception z) {
|
||||
z.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
native void notifyModalBlockedImpl(WEmbeddedFramePeer peer, WWindowPeer blockerPeer, boolean blocked);
|
||||
}
|
||||
82
jdkSrc/jdk8/sun/awt/windows/WEmbeddedFramePeer.java
Normal file
82
jdkSrc/jdk8/sun/awt/windows/WEmbeddedFramePeer.java
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import sun.awt.EmbeddedFrame;
|
||||
import sun.awt.Win32GraphicsEnvironment;
|
||||
|
||||
public class WEmbeddedFramePeer extends WFramePeer {
|
||||
|
||||
public WEmbeddedFramePeer(EmbeddedFrame target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
native void create(WComponentPeer parent);
|
||||
|
||||
// suppress printing of an embedded frame.
|
||||
@Override
|
||||
public void print(Graphics g) {}
|
||||
|
||||
// supress calling native setMinSize()
|
||||
@Override
|
||||
public void updateMinimumSize() {}
|
||||
|
||||
@Override
|
||||
public void modalDisable(Dialog blocker, long blockerHWnd)
|
||||
{
|
||||
super.modalDisable(blocker, blockerHWnd);
|
||||
((EmbeddedFrame)target).notifyModalBlocked(blocker, true);
|
||||
}
|
||||
@Override
|
||||
public void modalEnable(Dialog blocker)
|
||||
{
|
||||
super.modalEnable(blocker);
|
||||
((EmbeddedFrame)target).notifyModalBlocked(blocker, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoundsPrivate(int x, int y, int width, int height) {
|
||||
setBounds(x, y, width, height, SET_BOUNDS | NO_EMBEDDED_CHECK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public native Rectangle getBoundsPrivate();
|
||||
|
||||
@Override
|
||||
public boolean isAccelCapable() {
|
||||
// REMIND: Temp workaround for issues with using HW acceleration
|
||||
// in the browser on Vista when DWM is enabled
|
||||
// Note: isDWMCompositionEnabled is only relevant on Vista, returns
|
||||
// false on other systems.
|
||||
return !Win32GraphicsEnvironment.isDWMCompositionEnabled();
|
||||
}
|
||||
|
||||
}
|
||||
336
jdkSrc/jdk8/sun/awt/windows/WFileDialogPeer.java
Normal file
336
jdkSrc/jdk8/sun/awt/windows/WFileDialogPeer.java
Normal file
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.peer.*;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Vector;
|
||||
import sun.awt.CausedFocusEvent;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
final class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
private WComponentPeer parent;
|
||||
private FilenameFilter fileFilter;
|
||||
|
||||
private Vector<WWindowPeer> blockedWindows = new Vector<>();
|
||||
|
||||
//Needed to fix 4152317
|
||||
private static native void setFilterString(String allFilter);
|
||||
|
||||
@Override
|
||||
public void setFilenameFilter(FilenameFilter filter) {
|
||||
this.fileFilter = filter;
|
||||
}
|
||||
|
||||
boolean checkFilenameFilter(String filename) {
|
||||
FileDialog fileDialog = (FileDialog)target;
|
||||
if (fileFilter == null) {
|
||||
return true;
|
||||
}
|
||||
File file = new File(filename);
|
||||
return fileFilter.accept(new File(file.getParent()), file.getName());
|
||||
}
|
||||
|
||||
// Toolkit & peer internals
|
||||
WFileDialogPeer(FileDialog target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
void create(WComponentPeer parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
// don't use checkCreation() from WComponentPeer to avoid hwnd check
|
||||
@Override
|
||||
protected void checkCreation() {
|
||||
}
|
||||
|
||||
@Override
|
||||
void initialize() {
|
||||
setFilenameFilter(((FileDialog) target).getFilenameFilter());
|
||||
}
|
||||
|
||||
private native void _dispose();
|
||||
@Override
|
||||
protected void disposeImpl() {
|
||||
WToolkit.targetDisposedPeer(target, this);
|
||||
_dispose();
|
||||
}
|
||||
|
||||
private native void _show();
|
||||
private native void _hide();
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
_show();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
void hide() {
|
||||
_hide();
|
||||
}
|
||||
|
||||
// called from native code when the dialog is shown or hidden
|
||||
void setHWnd(long hwnd) {
|
||||
if (this.hwnd == hwnd) {
|
||||
return;
|
||||
}
|
||||
this.hwnd = hwnd;
|
||||
for (WWindowPeer window : blockedWindows) {
|
||||
if (hwnd != 0) {
|
||||
window.modalDisable((Dialog)target, hwnd);
|
||||
} else {
|
||||
window.modalEnable((Dialog)target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The function converts the file names (the buffer parameter)
|
||||
* in the Windows format into the Java format and saves the results
|
||||
* into the FileDialog instance.
|
||||
*
|
||||
* If it's the multi-select mode, the buffer contains the current
|
||||
* directory followed by the short names of the files.
|
||||
* The directory and file name strings are NULL separated.
|
||||
* If it's the single-select mode, the buffer doesn't have the NULL
|
||||
* separator between the path and the file name.
|
||||
*
|
||||
* NOTE: This method is called by privileged threads.
|
||||
* DO NOT INVOKE CLIENT CODE ON THIS THREAD!
|
||||
*/
|
||||
void handleSelected(final char[] buffer)
|
||||
{
|
||||
String[] wFiles = (new String(buffer)).split("\0"); // NULL is the delimiter
|
||||
boolean multiple = (wFiles.length > 1);
|
||||
|
||||
String jDirectory = null;
|
||||
String jFile = null;
|
||||
File[] jFiles = null;
|
||||
|
||||
if (multiple) {
|
||||
jDirectory = wFiles[0];
|
||||
int filesNumber = wFiles.length - 1;
|
||||
jFiles = new File[filesNumber];
|
||||
for (int i = 0; i < filesNumber; i++) {
|
||||
jFiles[i] = new File(jDirectory, wFiles[i + 1]);
|
||||
}
|
||||
jFile = wFiles[1]; // choose any file
|
||||
} else {
|
||||
int index = wFiles[0].lastIndexOf(java.io.File.separatorChar);
|
||||
if (index == -1) {
|
||||
jDirectory = "."+java.io.File.separator;
|
||||
jFile = wFiles[0];
|
||||
} else {
|
||||
jDirectory = wFiles[0].substring(0, index + 1);
|
||||
jFile = wFiles[0].substring(index + 1);
|
||||
}
|
||||
jFiles = new File[] { new File(jDirectory, jFile) };
|
||||
}
|
||||
|
||||
final FileDialog fileDialog = (FileDialog)target;
|
||||
AWTAccessor.FileDialogAccessor fileDialogAccessor = AWTAccessor.getFileDialogAccessor();
|
||||
|
||||
fileDialogAccessor.setDirectory(fileDialog, jDirectory);
|
||||
fileDialogAccessor.setFile(fileDialog, jFile);
|
||||
fileDialogAccessor.setFiles(fileDialog, jFiles);
|
||||
|
||||
WToolkit.executeOnEventHandlerThread(fileDialog, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fileDialog.setVisible(false);
|
||||
}
|
||||
});
|
||||
} // handleSelected()
|
||||
|
||||
// NOTE: This method is called by privileged threads.
|
||||
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
|
||||
void handleCancel() {
|
||||
final FileDialog fileDialog = (FileDialog)target;
|
||||
|
||||
AWTAccessor.getFileDialogAccessor().setFile(fileDialog, null);
|
||||
AWTAccessor.getFileDialogAccessor().setFiles(fileDialog, null);
|
||||
AWTAccessor.getFileDialogAccessor().setDirectory(fileDialog, null);
|
||||
|
||||
WToolkit.executeOnEventHandlerThread(fileDialog, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fileDialog.setVisible(false);
|
||||
}
|
||||
});
|
||||
} // handleCancel()
|
||||
|
||||
//This whole static block is a part of 4152317 fix
|
||||
static {
|
||||
String filterString = AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
@Override
|
||||
public String run() {
|
||||
try {
|
||||
ResourceBundle rb = ResourceBundle.getBundle("sun.awt.windows.awtLocalization");
|
||||
return rb.getString("allFiles");
|
||||
} catch (MissingResourceException e) {
|
||||
return "All Files";
|
||||
}
|
||||
}
|
||||
});
|
||||
setFilterString(filterString);
|
||||
}
|
||||
|
||||
void blockWindow(WWindowPeer window) {
|
||||
blockedWindows.add(window);
|
||||
// if this dialog hasn't got an HWND, notification is
|
||||
// postponed until setHWnd() is called
|
||||
if (hwnd != 0) {
|
||||
window.modalDisable((Dialog)target, hwnd);
|
||||
}
|
||||
}
|
||||
void unblockWindow(WWindowPeer window) {
|
||||
blockedWindows.remove(window);
|
||||
// if this dialog hasn't got an HWND or has been already
|
||||
// closed, don't send notification
|
||||
if (hwnd != 0) {
|
||||
window.modalEnable((Dialog)target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blockWindows(java.util.List<Window> toBlock) {
|
||||
for (Window w : toBlock) {
|
||||
WWindowPeer wp = (WWindowPeer)AWTAccessor.getComponentAccessor().getPeer(w);
|
||||
if (wp != null) {
|
||||
blockWindow(wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public native void toFront();
|
||||
@Override
|
||||
public native void toBack();
|
||||
|
||||
// unused methods. Overridden to disable this functionality as
|
||||
// it requires HWND which is not available for FileDialog
|
||||
@Override
|
||||
public void updateAlwaysOnTopState() {}
|
||||
@Override
|
||||
public void setDirectory(String dir) {}
|
||||
@Override
|
||||
public void setFile(String file) {}
|
||||
@Override
|
||||
public void setTitle(String title) {}
|
||||
|
||||
@Override
|
||||
public void setResizable(boolean resizable) {}
|
||||
@Override
|
||||
void enable() {}
|
||||
@Override
|
||||
void disable() {}
|
||||
@Override
|
||||
public void reshape(int x, int y, int width, int height) {}
|
||||
public boolean handleEvent(Event e) { return false; }
|
||||
@Override
|
||||
public void setForeground(Color c) {}
|
||||
@Override
|
||||
public void setBackground(Color c) {}
|
||||
@Override
|
||||
public void setFont(Font f) {}
|
||||
@Override
|
||||
public void updateMinimumSize() {}
|
||||
@Override
|
||||
public void updateIconImages() {}
|
||||
public boolean requestFocus(boolean temporary,
|
||||
boolean focusedWindowChangeAllowed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestFocus
|
||||
(Component lightweightChild, boolean temporary,
|
||||
boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
void start() {}
|
||||
@Override
|
||||
public void beginValidate() {}
|
||||
@Override
|
||||
public void endValidate() {}
|
||||
void invalidate(int x, int y, int width, int height) {}
|
||||
@Override
|
||||
public void addDropTarget(DropTarget dt) {}
|
||||
@Override
|
||||
public void removeDropTarget(DropTarget dt) {}
|
||||
@Override
|
||||
public void updateFocusableWindowState() {}
|
||||
@Override
|
||||
public void setZOrder(ComponentPeer above) {}
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method ids
|
||||
*/
|
||||
private static native void initIDs();
|
||||
|
||||
// The effects are not supported for system dialogs.
|
||||
@Override
|
||||
public void applyShape(sun.java2d.pipe.Region shape) {}
|
||||
@Override
|
||||
public void setOpacity(float opacity) {}
|
||||
@Override
|
||||
public void setOpaque(boolean isOpaque) {}
|
||||
public void updateWindow(java.awt.image.BufferedImage backBuffer) {}
|
||||
|
||||
// the file/print dialogs are native dialogs and
|
||||
// the native system does their own rendering
|
||||
@Override
|
||||
public void createScreenSurface(boolean isResize) {}
|
||||
@Override
|
||||
public void replaceSurfaceData() {}
|
||||
|
||||
public boolean isMultipleMode() {
|
||||
FileDialog fileDialog = (FileDialog)target;
|
||||
return AWTAccessor.getFileDialogAccessor().isMultipleMode(fileDialog);
|
||||
}
|
||||
}
|
||||
252
jdkSrc/jdk8/sun/awt/windows/WFontConfiguration.java
Normal file
252
jdkSrc/jdk8/sun/awt/windows/WFontConfiguration.java
Normal file
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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 sun.awt.windows;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import sun.awt.FontDescriptor;
|
||||
import sun.awt.FontConfiguration;
|
||||
import sun.font.SunFontManager;
|
||||
import java.nio.charset.*;
|
||||
|
||||
public final class WFontConfiguration extends FontConfiguration {
|
||||
|
||||
// whether compatibility fallbacks for TimesRoman and Co. are used
|
||||
private boolean useCompatibilityFallbacks;
|
||||
|
||||
public WFontConfiguration(SunFontManager fm) {
|
||||
super(fm);
|
||||
useCompatibilityFallbacks = "windows-1252".equals(encoding);
|
||||
initTables(encoding);
|
||||
}
|
||||
|
||||
public WFontConfiguration(SunFontManager fm,
|
||||
boolean preferLocaleFonts,
|
||||
boolean preferPropFonts) {
|
||||
super(fm, preferLocaleFonts, preferPropFonts);
|
||||
useCompatibilityFallbacks = "windows-1252".equals(encoding);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initReorderMap() {
|
||||
if (encoding.equalsIgnoreCase("windows-31j")) {
|
||||
localeMap = new Hashtable();
|
||||
/* Substitute Mincho for Gothic in this one case.
|
||||
* Note the windows fontconfig files already contain the mapping:
|
||||
* filename.MS_Mincho=MSMINCHO.TTC
|
||||
* which isn't essential to this usage but avoids a call
|
||||
* to loadfonts in the event MSMINCHO.TTC has not otherwise
|
||||
* been opened and its fonts loaded.
|
||||
* Also note this usage is only enabled if a private flag is set.
|
||||
*/
|
||||
localeMap.put("dialoginput.plain.japanese", "MS Mincho");
|
||||
localeMap.put("dialoginput.bold.japanese", "MS Mincho");
|
||||
localeMap.put("dialoginput.italic.japanese", "MS Mincho");
|
||||
localeMap.put("dialoginput.bolditalic.japanese", "MS Mincho");
|
||||
}
|
||||
reorderMap = new HashMap();
|
||||
reorderMap.put("UTF-8.hi", "devanagari");
|
||||
reorderMap.put("windows-1255", "hebrew");
|
||||
reorderMap.put("x-windows-874", "thai");
|
||||
reorderMap.put("windows-31j", "japanese");
|
||||
reorderMap.put("x-windows-949", "korean");
|
||||
reorderMap.put("GBK", "chinese-ms936");
|
||||
reorderMap.put("GB18030", "chinese-gb18030");
|
||||
reorderMap.put("x-windows-950", "chinese-ms950");
|
||||
reorderMap.put("x-MS950-HKSCS", split("chinese-ms950,chinese-hkscs"));
|
||||
// reorderMap.put("windows-1252", "alphabetic");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setOsNameAndVersion(){
|
||||
super.setOsNameAndVersion();
|
||||
if (osName.startsWith("Windows")){
|
||||
int p, q;
|
||||
p = osName.indexOf(' ');
|
||||
if (p == -1){
|
||||
osName = null;
|
||||
}
|
||||
else{
|
||||
q = osName.indexOf(' ', p + 1);
|
||||
if (q == -1){
|
||||
osName = osName.substring(p + 1);
|
||||
}
|
||||
else{
|
||||
osName = osName.substring(p + 1, q);
|
||||
}
|
||||
}
|
||||
osVersion = null;
|
||||
}
|
||||
}
|
||||
|
||||
// overrides FontConfiguration.getFallbackFamilyName
|
||||
@Override
|
||||
public String getFallbackFamilyName(String fontName, String defaultFallback) {
|
||||
// maintain compatibility with old font.properties files, where
|
||||
// default file had aliases for timesroman & Co, while others didn't.
|
||||
if (useCompatibilityFallbacks) {
|
||||
String compatibilityName = getCompatibilityFamilyName(fontName);
|
||||
if (compatibilityName != null) {
|
||||
return compatibilityName;
|
||||
}
|
||||
}
|
||||
return defaultFallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String makeAWTFontName(String platformFontName, String characterSubsetName) {
|
||||
String windowsCharset = (String) subsetCharsetMap.get(characterSubsetName);
|
||||
if (windowsCharset == null) {
|
||||
windowsCharset = "DEFAULT_CHARSET";
|
||||
}
|
||||
return platformFontName + "," + windowsCharset;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getEncoding(String awtFontName, String characterSubsetName) {
|
||||
String encoding = (String) subsetEncodingMap.get(characterSubsetName);
|
||||
if (encoding == null) {
|
||||
encoding = "default";
|
||||
}
|
||||
return encoding;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Charset getDefaultFontCharset(String fontName) {
|
||||
return new WDefaultFontCharset(fontName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFaceNameFromComponentFontName(String componentFontName) {
|
||||
// for Windows, the platform name is the face name
|
||||
return componentFontName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getFileNameFromComponentFontName(String componentFontName) {
|
||||
return getFileNameFromPlatformName(componentFontName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the component font name (face name plus charset) of the
|
||||
* font that should be used for AWT text components. May return null.
|
||||
*/
|
||||
public String getTextComponentFontName(String familyName, int style) {
|
||||
FontDescriptor[] fontDescriptors = getFontDescriptors(familyName, style);
|
||||
String fontName = findFontWithCharset(fontDescriptors, textInputCharset);
|
||||
if (fontName == null) {
|
||||
fontName = findFontWithCharset(fontDescriptors, "DEFAULT_CHARSET");
|
||||
}
|
||||
return fontName;
|
||||
}
|
||||
|
||||
private String findFontWithCharset(FontDescriptor[] fontDescriptors, String charset) {
|
||||
String fontName = null;
|
||||
for (int i = 0; i < fontDescriptors.length; i++) {
|
||||
String componentFontName = fontDescriptors[i].getNativeName();
|
||||
if (componentFontName.endsWith(charset)) {
|
||||
fontName = componentFontName;
|
||||
}
|
||||
}
|
||||
return fontName;
|
||||
}
|
||||
|
||||
private static HashMap subsetCharsetMap = new HashMap();
|
||||
private static HashMap subsetEncodingMap = new HashMap();
|
||||
private static String textInputCharset;
|
||||
|
||||
private void initTables(String defaultEncoding) {
|
||||
subsetCharsetMap.put("alphabetic", "ANSI_CHARSET");
|
||||
subsetCharsetMap.put("alphabetic/1252", "ANSI_CHARSET");
|
||||
subsetCharsetMap.put("alphabetic/default", "DEFAULT_CHARSET");
|
||||
subsetCharsetMap.put("arabic", "ARABIC_CHARSET");
|
||||
subsetCharsetMap.put("chinese-ms936", "GB2312_CHARSET");
|
||||
subsetCharsetMap.put("chinese-gb18030", "GB2312_CHARSET");
|
||||
subsetCharsetMap.put("chinese-ms950", "CHINESEBIG5_CHARSET");
|
||||
subsetCharsetMap.put("chinese-hkscs", "CHINESEBIG5_CHARSET");
|
||||
subsetCharsetMap.put("cyrillic", "RUSSIAN_CHARSET");
|
||||
subsetCharsetMap.put("devanagari", "DEFAULT_CHARSET");
|
||||
subsetCharsetMap.put("dingbats", "SYMBOL_CHARSET");
|
||||
subsetCharsetMap.put("greek", "GREEK_CHARSET");
|
||||
subsetCharsetMap.put("hebrew", "HEBREW_CHARSET");
|
||||
subsetCharsetMap.put("japanese", "SHIFTJIS_CHARSET");
|
||||
subsetCharsetMap.put("korean", "HANGEUL_CHARSET");
|
||||
subsetCharsetMap.put("latin", "ANSI_CHARSET");
|
||||
subsetCharsetMap.put("symbol", "SYMBOL_CHARSET");
|
||||
subsetCharsetMap.put("thai", "THAI_CHARSET");
|
||||
|
||||
subsetEncodingMap.put("alphabetic", "default");
|
||||
subsetEncodingMap.put("alphabetic/1252", "windows-1252");
|
||||
subsetEncodingMap.put("alphabetic/default", defaultEncoding);
|
||||
subsetEncodingMap.put("arabic", "windows-1256");
|
||||
subsetEncodingMap.put("chinese-ms936", "GBK");
|
||||
subsetEncodingMap.put("chinese-gb18030", "GB18030");
|
||||
if ("x-MS950-HKSCS".equals(defaultEncoding)) {
|
||||
subsetEncodingMap.put("chinese-ms950", "x-MS950-HKSCS");
|
||||
} else {
|
||||
subsetEncodingMap.put("chinese-ms950", "x-windows-950"); //MS950
|
||||
}
|
||||
subsetEncodingMap.put("chinese-hkscs", "sun.awt.HKSCS");
|
||||
subsetEncodingMap.put("cyrillic", "windows-1251");
|
||||
subsetEncodingMap.put("devanagari", "UTF-16LE");
|
||||
subsetEncodingMap.put("dingbats", "sun.awt.windows.WingDings");
|
||||
subsetEncodingMap.put("greek", "windows-1253");
|
||||
subsetEncodingMap.put("hebrew", "windows-1255");
|
||||
subsetEncodingMap.put("japanese", "windows-31j");
|
||||
subsetEncodingMap.put("korean", "x-windows-949");
|
||||
subsetEncodingMap.put("latin", "windows-1252");
|
||||
subsetEncodingMap.put("symbol", "sun.awt.Symbol");
|
||||
subsetEncodingMap.put("thai", "x-windows-874");
|
||||
|
||||
if ("windows-1256".equals(defaultEncoding)) {
|
||||
textInputCharset = "ARABIC_CHARSET";
|
||||
} else if ("GBK".equals(defaultEncoding)) {
|
||||
textInputCharset = "GB2312_CHARSET";
|
||||
} else if ("GB18030".equals(defaultEncoding)) {
|
||||
textInputCharset = "GB2312_CHARSET";
|
||||
} else if ("x-windows-950".equals(defaultEncoding)) {
|
||||
textInputCharset = "CHINESEBIG5_CHARSET";
|
||||
} else if ("x-MS950-HKSCS".equals(defaultEncoding)) {
|
||||
textInputCharset = "CHINESEBIG5_CHARSET";
|
||||
} else if ("windows-1251".equals(defaultEncoding)) {
|
||||
textInputCharset = "RUSSIAN_CHARSET";
|
||||
} else if ("UTF-8".equals(defaultEncoding)) {
|
||||
textInputCharset = "DEFAULT_CHARSET";
|
||||
} else if ("windows-1253".equals(defaultEncoding)) {
|
||||
textInputCharset = "GREEK_CHARSET";
|
||||
} else if ("windows-1255".equals(defaultEncoding)) {
|
||||
textInputCharset = "HEBREW_CHARSET";
|
||||
} else if ("windows-31j".equals(defaultEncoding)) {
|
||||
textInputCharset = "SHIFTJIS_CHARSET";
|
||||
} else if ("x-windows-949".equals(defaultEncoding)) {
|
||||
textInputCharset = "HANGEUL_CHARSET";
|
||||
} else if ("x-windows-874".equals(defaultEncoding)) {
|
||||
textInputCharset = "THAI_CHARSET";
|
||||
} else {
|
||||
textInputCharset = "DEFAULT_CHARSET";
|
||||
}
|
||||
}
|
||||
}
|
||||
215
jdkSrc/jdk8/sun/awt/windows/WFontMetrics.java
Normal file
215
jdkSrc/jdk8/sun/awt/windows/WFontMetrics.java
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* A font metrics object for a WServer font.
|
||||
*
|
||||
* @author Jim Graham
|
||||
*/
|
||||
final class WFontMetrics extends FontMetrics {
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
/**
|
||||
* The widths of the first 256 characters.
|
||||
*/
|
||||
int widths[];
|
||||
|
||||
/**
|
||||
* The standard ascent of the font. This is the logical height
|
||||
* above the baseline for the Alphanumeric characters and should
|
||||
* be used for determining line spacing. Note, however, that some
|
||||
* characters in the font may extend above this height.
|
||||
*/
|
||||
int ascent;
|
||||
|
||||
/**
|
||||
* The standard descent of the font. This is the logical height
|
||||
* below the baseline for the Alphanumeric characters and should
|
||||
* be used for determining line spacing. Note, however, that some
|
||||
* characters in the font may extend below this height.
|
||||
*/
|
||||
int descent;
|
||||
|
||||
/**
|
||||
* The standard leading for the font. This is the logical amount
|
||||
* of space to be reserved between the descent of one line of text
|
||||
* and the ascent of the next line. The height metric is calculated
|
||||
* to include this extra space.
|
||||
*/
|
||||
int leading;
|
||||
|
||||
/**
|
||||
* The standard height of a line of text in this font. This is
|
||||
* the distance between the baseline of adjacent lines of text.
|
||||
* It is the sum of the ascent+descent+leading. There is no
|
||||
* guarantee that lines of text spaced at this distance will be
|
||||
* disjoint; such lines may overlap if some characters overshoot
|
||||
* the standard ascent and descent metrics.
|
||||
*/
|
||||
int height;
|
||||
|
||||
/**
|
||||
* The maximum ascent for all characters in this font. No character
|
||||
* will extend further above the baseline than this metric.
|
||||
*/
|
||||
int maxAscent;
|
||||
|
||||
/**
|
||||
* The maximum descent for all characters in this font. No character
|
||||
* will descend further below the baseline than this metric.
|
||||
*/
|
||||
int maxDescent;
|
||||
|
||||
/**
|
||||
* The maximum possible height of a line of text in this font.
|
||||
* Adjacent lines of text spaced this distance apart will be
|
||||
* guaranteed not to overlap. Note, however, that many paragraphs
|
||||
* that contain ordinary alphanumeric text may look too widely
|
||||
* spaced if this metric is used to determine line spacing. The
|
||||
* height field should be preferred unless the text in a given
|
||||
* line contains particularly tall characters.
|
||||
*/
|
||||
int maxHeight;
|
||||
|
||||
/**
|
||||
* The maximum advance width of any character in this font.
|
||||
*/
|
||||
int maxAdvance;
|
||||
|
||||
/**
|
||||
* Calculate the metrics from the given WServer and font.
|
||||
*/
|
||||
public WFontMetrics(Font font) {
|
||||
super(font);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get leading
|
||||
*/
|
||||
@Override
|
||||
public int getLeading() {
|
||||
return leading;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ascent.
|
||||
*/
|
||||
@Override
|
||||
public int getAscent() {
|
||||
return ascent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get descent
|
||||
*/
|
||||
@Override
|
||||
public int getDescent() {
|
||||
return descent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get height
|
||||
*/
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get maxAscent
|
||||
*/
|
||||
@Override
|
||||
public int getMaxAscent() {
|
||||
return maxAscent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get maxDescent
|
||||
*/
|
||||
@Override
|
||||
public int getMaxDescent() {
|
||||
return maxDescent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get maxAdvance
|
||||
*/
|
||||
@Override
|
||||
public int getMaxAdvance() {
|
||||
return maxAdvance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the width of the specified string in this Font.
|
||||
*/
|
||||
@Override
|
||||
public native int stringWidth(String str);
|
||||
|
||||
/**
|
||||
* Return the width of the specified char[] in this Font.
|
||||
*/
|
||||
@Override
|
||||
public native int charsWidth(char data[], int off, int len);
|
||||
|
||||
/**
|
||||
* Return the width of the specified byte[] in this Font.
|
||||
*/
|
||||
@Override
|
||||
public native int bytesWidth(byte data[], int off, int len);
|
||||
|
||||
/**
|
||||
* Get the widths of the first 256 characters in the font.
|
||||
*/
|
||||
@Override
|
||||
public int[] getWidths() {
|
||||
return widths;
|
||||
}
|
||||
|
||||
native void init();
|
||||
|
||||
static Hashtable table = new Hashtable();
|
||||
|
||||
static FontMetrics getFontMetrics(Font font) {
|
||||
FontMetrics fm = (FontMetrics)table.get(font);
|
||||
if (fm == null) {
|
||||
table.put(font, fm = new WFontMetrics(font));
|
||||
}
|
||||
return fm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method IDs
|
||||
*/
|
||||
private static native void initIDs();
|
||||
}
|
||||
55
jdkSrc/jdk8/sun/awt/windows/WFontPeer.java
Normal file
55
jdkSrc/jdk8/sun/awt/windows/WFontPeer.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import sun.awt.PlatformFont;
|
||||
|
||||
final class WFontPeer extends PlatformFont {
|
||||
|
||||
private String textComponentFontName;
|
||||
|
||||
public WFontPeer(String name, int style){
|
||||
super(name, style);
|
||||
if (fontConfig != null) {
|
||||
textComponentFontName = ((WFontConfiguration) fontConfig).getTextComponentFontName(familyName, style);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected char getMissingGlyphCharacter() {
|
||||
return '\u2751';
|
||||
}
|
||||
|
||||
static {
|
||||
/* NB Headless printing uses AWT Fonts */
|
||||
initIDs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method IDs
|
||||
*/
|
||||
private static native void initIDs();
|
||||
}
|
||||
234
jdkSrc/jdk8/sun/awt/windows/WFramePeer.java
Normal file
234
jdkSrc/jdk8/sun/awt/windows/WFramePeer.java
Normal file
@@ -0,0 +1,234 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2016, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.im.InputMethodManager;
|
||||
import java.security.AccessController;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
class WFramePeer extends WWindowPeer implements FramePeer {
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
// initialize JNI field and method IDs
|
||||
private static native void initIDs();
|
||||
|
||||
// FramePeer implementation
|
||||
@Override
|
||||
public native void setState(int state);
|
||||
@Override
|
||||
public native int getState();
|
||||
|
||||
// sync target and peer
|
||||
public void setExtendedState(int state) {
|
||||
AWTAccessor.getFrameAccessor().setExtendedState((Frame)target, state);
|
||||
}
|
||||
public int getExtendedState() {
|
||||
return AWTAccessor.getFrameAccessor().getExtendedState((Frame)target);
|
||||
}
|
||||
|
||||
// Convenience methods to save us from trouble of extracting
|
||||
// Rectangle fields in native code.
|
||||
private native void setMaximizedBounds(int x, int y, int w, int h);
|
||||
private native void clearMaximizedBounds();
|
||||
|
||||
private static final boolean keepOnMinimize = "true".equals(
|
||||
AccessController.doPrivileged(
|
||||
new GetPropertyAction(
|
||||
"sun.awt.keepWorkingSetOnMinimize")));
|
||||
|
||||
@Override
|
||||
public void setMaximizedBounds(Rectangle b) {
|
||||
if (b == null) {
|
||||
clearMaximizedBounds();
|
||||
} else {
|
||||
Rectangle adjBounds = (Rectangle)b.clone();
|
||||
adjustMaximizedBounds(adjBounds);
|
||||
setMaximizedBounds(adjBounds.x, adjBounds.y, adjBounds.width, adjBounds.height);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The incoming bounds describe the maximized size and position of the
|
||||
* window on the monitor that displays the window. But the window manager
|
||||
* expects that the bounds are based on the size and position of the
|
||||
* primary monitor, even if the window ultimately maximizes onto a
|
||||
* secondary monitor. And the window manager adjusts these values to
|
||||
* compensate for differences between the primary monitor and the monitor
|
||||
* that displays the window.
|
||||
* The method translates the incoming bounds to the values acceptable
|
||||
* by the window manager. For more details, please refer to 6699851.
|
||||
*/
|
||||
private void adjustMaximizedBounds(Rectangle b) {
|
||||
GraphicsConfiguration currentDevGC = getGraphicsConfiguration();
|
||||
|
||||
GraphicsDevice primaryDev = GraphicsEnvironment
|
||||
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
||||
GraphicsConfiguration primaryDevGC = primaryDev.getDefaultConfiguration();
|
||||
|
||||
if (currentDevGC != null && currentDevGC != primaryDevGC) {
|
||||
Rectangle currentDevBounds = currentDevGC.getBounds();
|
||||
Rectangle primaryDevBounds = primaryDevGC.getBounds();
|
||||
|
||||
boolean isCurrentDevLarger =
|
||||
((currentDevBounds.width - primaryDevBounds.width > 0) ||
|
||||
(currentDevBounds.height - primaryDevBounds.height > 0));
|
||||
|
||||
// the window manager doesn't seem to compensate for differences when
|
||||
// the primary monitor is larger than the monitor that display the window
|
||||
if (isCurrentDevLarger) {
|
||||
b.width -= (currentDevBounds.width - primaryDevBounds.width);
|
||||
b.height -= (currentDevBounds.height - primaryDevBounds.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateGraphicsData(GraphicsConfiguration gc) {
|
||||
boolean result = super.updateGraphicsData(gc);
|
||||
Rectangle bounds = AWTAccessor.getFrameAccessor().
|
||||
getMaximizedBounds((Frame)target);
|
||||
if (bounds != null) {
|
||||
setMaximizedBounds(bounds);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isTargetUndecorated() {
|
||||
return ((Frame)target).isUndecorated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reshape(int x, int y, int width, int height) {
|
||||
if (((Frame)target).isUndecorated()) {
|
||||
super.reshape(x, y, width, height);
|
||||
} else {
|
||||
reshapeFrame(x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
Dimension d = new Dimension();
|
||||
if (!((Frame)target).isUndecorated()) {
|
||||
d.setSize(getSysMinWidth(), getSysMinHeight());
|
||||
}
|
||||
if (((Frame)target).getMenuBar() != null) {
|
||||
d.height += getSysMenuHeight();
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
// Note: Because this method calls resize(), which may be overridden
|
||||
// by client code, this method must not be executed on the toolkit
|
||||
// thread.
|
||||
@Override
|
||||
public void setMenuBar(MenuBar mb) {
|
||||
WMenuBarPeer mbPeer = (WMenuBarPeer) WToolkit.targetToPeer(mb);
|
||||
if (mbPeer != null) {
|
||||
if (mbPeer.framePeer != this) {
|
||||
mb.removeNotify();
|
||||
mb.addNotify();
|
||||
mbPeer = (WMenuBarPeer) WToolkit.targetToPeer(mb);
|
||||
if (mbPeer != null && mbPeer.framePeer != this) {
|
||||
throw new IllegalStateException("Wrong parent peer");
|
||||
}
|
||||
}
|
||||
if (mbPeer != null) {
|
||||
addChildPeer(mbPeer);
|
||||
}
|
||||
}
|
||||
setMenuBar0(mbPeer);
|
||||
updateInsets(insets_);
|
||||
}
|
||||
|
||||
// Note: Because this method calls resize(), which may be overridden
|
||||
// by client code, this method must not be executed on the toolkit
|
||||
// thread.
|
||||
private native void setMenuBar0(WMenuBarPeer mbPeer);
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WFramePeer(Frame target) {
|
||||
super(target);
|
||||
|
||||
InputMethodManager imm = InputMethodManager.getInstance();
|
||||
String menuString = imm.getTriggerMenuString();
|
||||
if (menuString != null)
|
||||
{
|
||||
pSetIMMOption(menuString);
|
||||
}
|
||||
}
|
||||
|
||||
native void createAwtFrame(WComponentPeer parent);
|
||||
@Override
|
||||
void create(WComponentPeer parent) {
|
||||
preCreate(parent);
|
||||
createAwtFrame(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
void initialize() {
|
||||
super.initialize();
|
||||
|
||||
Frame target = (Frame)this.target;
|
||||
|
||||
if (target.getTitle() != null) {
|
||||
setTitle(target.getTitle());
|
||||
}
|
||||
setResizable(target.isResizable());
|
||||
setState(target.getExtendedState());
|
||||
}
|
||||
|
||||
private native static int getSysMenuHeight();
|
||||
|
||||
native void pSetIMMOption(String option);
|
||||
void notifyIMMOptionChange(){
|
||||
InputMethodManager.getInstance().notifyChangeRequest((Component)target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoundsPrivate(int x, int y, int width, int height) {
|
||||
setBounds(x, y, width, height, SET_BOUNDS);
|
||||
}
|
||||
@Override
|
||||
public Rectangle getBoundsPrivate() {
|
||||
return getBounds();
|
||||
}
|
||||
|
||||
// TODO: implement it in peers. WLightweightFramePeer may implement lw version.
|
||||
@Override
|
||||
public void emulateActivation(boolean activate) {
|
||||
synthesizeWmActivate(activate);
|
||||
}
|
||||
|
||||
private native void synthesizeWmActivate(boolean activate);
|
||||
}
|
||||
61
jdkSrc/jdk8/sun/awt/windows/WGlobalCursorManager.java
Normal file
61
jdkSrc/jdk8/sun/awt/windows/WGlobalCursorManager.java
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import sun.awt.GlobalCursorManager;
|
||||
|
||||
final class WGlobalCursorManager extends GlobalCursorManager {
|
||||
private static WGlobalCursorManager manager;
|
||||
|
||||
public static GlobalCursorManager getCursorManager() {
|
||||
if (manager == null) {
|
||||
manager = new WGlobalCursorManager();
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called in response to a native mouse enter or native mouse
|
||||
* button released message. Should not be called during a mouse drag.
|
||||
*/
|
||||
public static void nativeUpdateCursor(Component heavy) {
|
||||
WGlobalCursorManager.getCursorManager().updateCursorLater(heavy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected native void setCursor(Component comp, Cursor cursor, boolean u);
|
||||
@Override
|
||||
protected native void getCursorPos(Point p);
|
||||
/*
|
||||
* two native methods to call corresponding methods in Container and
|
||||
* Component
|
||||
*/
|
||||
@Override
|
||||
protected native Component findHeavyweightUnderCursor(boolean useCache);
|
||||
@Override
|
||||
protected native Point getLocationOnScreen(Component com);
|
||||
}
|
||||
647
jdkSrc/jdk8/sun/awt/windows/WInputMethod.java
Normal file
647
jdkSrc/jdk8/sun/awt/windows/WInputMethod.java
Normal file
@@ -0,0 +1,647 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2017, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.im.*;
|
||||
import java.awt.im.spi.InputMethodContext;
|
||||
import java.awt.font.*;
|
||||
import java.text.*;
|
||||
import java.text.AttributedCharacterIterator.Attribute;
|
||||
import java.lang.Character.Subset;
|
||||
import java.lang.Character.UnicodeBlock;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import sun.awt.im.InputMethodAdapter;
|
||||
|
||||
final class WInputMethod extends InputMethodAdapter
|
||||
{
|
||||
/**
|
||||
* The input method context, which is used to dispatch input method
|
||||
* events to the client component and to request information from
|
||||
* the client component.
|
||||
*/
|
||||
private InputMethodContext inputContext;
|
||||
|
||||
private Component awtFocussedComponent;
|
||||
private WComponentPeer awtFocussedComponentPeer = null;
|
||||
private WComponentPeer lastFocussedComponentPeer = null;
|
||||
private boolean isLastFocussedActiveClient = false;
|
||||
private boolean isActive;
|
||||
private int context;
|
||||
private boolean open; //default open status;
|
||||
private int cmode; //default conversion mode;
|
||||
private Locale currentLocale;
|
||||
// indicate whether status window is hidden or not.
|
||||
private boolean statusWindowHidden = false;
|
||||
|
||||
// attribute definition in Win32 (in IMM.H)
|
||||
public final static byte ATTR_INPUT = 0x00;
|
||||
public final static byte ATTR_TARGET_CONVERTED = 0x01;
|
||||
public final static byte ATTR_CONVERTED = 0x02;
|
||||
public final static byte ATTR_TARGET_NOTCONVERTED = 0x03;
|
||||
public final static byte ATTR_INPUT_ERROR = 0x04;
|
||||
// cmode definition in Win32 (in IMM.H)
|
||||
public final static int IME_CMODE_ALPHANUMERIC = 0x0000;
|
||||
public final static int IME_CMODE_NATIVE = 0x0001;
|
||||
public final static int IME_CMODE_KATAKANA = 0x0002;
|
||||
public final static int IME_CMODE_LANGUAGE = 0x0003;
|
||||
public final static int IME_CMODE_FULLSHAPE = 0x0008;
|
||||
public final static int IME_CMODE_HANJACONVERT = 0x0040;
|
||||
public final static int IME_CMODE_ROMAN = 0x0010;
|
||||
|
||||
// flag values for endCompositionNative() behavior
|
||||
private final static boolean COMMIT_INPUT = true;
|
||||
private final static boolean DISCARD_INPUT = false;
|
||||
|
||||
private static Map<TextAttribute,Object> [] highlightStyles;
|
||||
|
||||
// Initialize highlight mapping table
|
||||
static {
|
||||
Map<TextAttribute,Object> styles[] = new Map[4];
|
||||
HashMap<TextAttribute,Object> map;
|
||||
|
||||
// UNSELECTED_RAW_TEXT_HIGHLIGHT
|
||||
map = new HashMap(1);
|
||||
map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_DOTTED);
|
||||
styles[0] = Collections.unmodifiableMap(map);
|
||||
|
||||
// SELECTED_RAW_TEXT_HIGHLIGHT
|
||||
map = new HashMap(1);
|
||||
map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_GRAY);
|
||||
styles[1] = Collections.unmodifiableMap(map);
|
||||
|
||||
// UNSELECTED_CONVERTED_TEXT_HIGHLIGHT
|
||||
map = new HashMap(1);
|
||||
map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_DOTTED);
|
||||
styles[2] = Collections.unmodifiableMap(map);
|
||||
|
||||
// SELECTED_CONVERTED_TEXT_HIGHLIGHT
|
||||
map = new HashMap(4);
|
||||
Color navyBlue = new Color(0, 0, 128);
|
||||
map.put(TextAttribute.FOREGROUND, navyBlue);
|
||||
map.put(TextAttribute.BACKGROUND, Color.white);
|
||||
map.put(TextAttribute.SWAP_COLORS, TextAttribute.SWAP_COLORS_ON);
|
||||
map.put(TextAttribute.INPUT_METHOD_UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
|
||||
styles[3] = Collections.unmodifiableMap(map);
|
||||
|
||||
highlightStyles = styles;
|
||||
}
|
||||
|
||||
public WInputMethod()
|
||||
{
|
||||
context = createNativeContext();
|
||||
cmode = getConversionStatus(context);
|
||||
open = getOpenStatus(context);
|
||||
currentLocale = getNativeLocale();
|
||||
if (currentLocale == null) {
|
||||
currentLocale = Locale.getDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
// Release the resources used by the native input context.
|
||||
if (context!=0) {
|
||||
destroyNativeContext(context);
|
||||
context=0;
|
||||
}
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setInputMethodContext(InputMethodContext context) {
|
||||
inputContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void dispose() {
|
||||
// Due to a memory management problem in Windows 98, we should retain
|
||||
// the native input context until this object is finalized. So do
|
||||
// nothing here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null.
|
||||
*
|
||||
* @see java.awt.im.spi.InputMethod#getControlObject
|
||||
*/
|
||||
@Override
|
||||
public Object getControlObject() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setLocale(Locale lang) {
|
||||
return setLocale(lang, false);
|
||||
}
|
||||
|
||||
private boolean setLocale(Locale lang, boolean onActivate) {
|
||||
Locale[] available = WInputMethodDescriptor.getAvailableLocalesInternal();
|
||||
for (int i = 0; i < available.length; i++) {
|
||||
Locale locale = available[i];
|
||||
if (lang.equals(locale) ||
|
||||
// special compatibility rule for Japanese and Korean
|
||||
locale.equals(Locale.JAPAN) && lang.equals(Locale.JAPANESE) ||
|
||||
locale.equals(Locale.KOREA) && lang.equals(Locale.KOREAN)) {
|
||||
if (isActive) {
|
||||
setNativeLocale(locale.toLanguageTag(), onActivate);
|
||||
}
|
||||
currentLocale = locale;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
if (isActive) {
|
||||
currentLocale = getNativeLocale();
|
||||
if (currentLocale == null) {
|
||||
currentLocale = Locale.getDefault();
|
||||
}
|
||||
}
|
||||
return currentLocale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements InputMethod.setCharacterSubsets for Windows.
|
||||
*
|
||||
* @see java.awt.im.spi.InputMethod#setCharacterSubsets
|
||||
*/
|
||||
@Override
|
||||
public void setCharacterSubsets(Subset[] subsets) {
|
||||
if (subsets == null){
|
||||
setConversionStatus(context, cmode);
|
||||
setOpenStatus(context, open);
|
||||
return;
|
||||
}
|
||||
|
||||
// Use first subset only. Other subsets in array is ignored.
|
||||
// This is restriction of Win32 implementation.
|
||||
Subset subset1 = subsets[0];
|
||||
|
||||
Locale locale = getNativeLocale();
|
||||
int newmode;
|
||||
|
||||
if (locale == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (locale.getLanguage().equals(Locale.JAPANESE.getLanguage())) {
|
||||
if (subset1 == UnicodeBlock.BASIC_LATIN || subset1 == InputSubset.LATIN_DIGITS) {
|
||||
setOpenStatus(context, false);
|
||||
} else {
|
||||
if (subset1 == UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|
||||
|| subset1 == InputSubset.KANJI
|
||||
|| subset1 == UnicodeBlock.HIRAGANA)
|
||||
newmode = IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE;
|
||||
else if (subset1 == UnicodeBlock.KATAKANA)
|
||||
newmode = IME_CMODE_NATIVE | IME_CMODE_KATAKANA| IME_CMODE_FULLSHAPE;
|
||||
else if (subset1 == InputSubset.HALFWIDTH_KATAKANA)
|
||||
newmode = IME_CMODE_NATIVE | IME_CMODE_KATAKANA;
|
||||
else if (subset1 == InputSubset.FULLWIDTH_LATIN)
|
||||
newmode = IME_CMODE_FULLSHAPE;
|
||||
else
|
||||
return;
|
||||
setOpenStatus(context, true);
|
||||
newmode |= (getConversionStatus(context)&IME_CMODE_ROMAN); // reserve ROMAN input mode
|
||||
setConversionStatus(context, newmode);
|
||||
}
|
||||
} else if (locale.getLanguage().equals(Locale.KOREAN.getLanguage())) {
|
||||
if (subset1 == UnicodeBlock.BASIC_LATIN || subset1 == InputSubset.LATIN_DIGITS) {
|
||||
setOpenStatus(context, false);
|
||||
} else {
|
||||
if (subset1 == UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|
||||
|| subset1 == InputSubset.HANJA
|
||||
|| subset1 == UnicodeBlock.HANGUL_SYLLABLES
|
||||
|| subset1 == UnicodeBlock.HANGUL_JAMO
|
||||
|| subset1 == UnicodeBlock.HANGUL_COMPATIBILITY_JAMO)
|
||||
newmode = IME_CMODE_NATIVE;
|
||||
else if (subset1 == InputSubset.FULLWIDTH_LATIN)
|
||||
newmode = IME_CMODE_FULLSHAPE;
|
||||
else
|
||||
return;
|
||||
setOpenStatus(context, true);
|
||||
setConversionStatus(context, newmode);
|
||||
}
|
||||
} else if (locale.getLanguage().equals(Locale.CHINESE.getLanguage())) {
|
||||
if (subset1 == UnicodeBlock.BASIC_LATIN || subset1 == InputSubset.LATIN_DIGITS) {
|
||||
setOpenStatus(context, false);
|
||||
} else {
|
||||
if (subset1 == UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|
||||
|| subset1 == InputSubset.TRADITIONAL_HANZI
|
||||
|| subset1 == InputSubset.SIMPLIFIED_HANZI)
|
||||
newmode = IME_CMODE_NATIVE;
|
||||
else if (subset1 == InputSubset.FULLWIDTH_LATIN)
|
||||
newmode = IME_CMODE_FULLSHAPE;
|
||||
else
|
||||
return;
|
||||
setOpenStatus(context, true);
|
||||
setConversionStatus(context, newmode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchEvent(AWTEvent e) {
|
||||
if (e instanceof ComponentEvent) {
|
||||
Component comp = ((ComponentEvent) e).getComponent();
|
||||
if (comp == awtFocussedComponent) {
|
||||
if (awtFocussedComponentPeer == null ||
|
||||
awtFocussedComponentPeer.isDisposed()) {
|
||||
awtFocussedComponentPeer = getNearestNativePeer(comp);
|
||||
}
|
||||
if (awtFocussedComponentPeer != null) {
|
||||
handleNativeIMEEvent(awtFocussedComponentPeer, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate() {
|
||||
boolean isAc = haveActiveClient();
|
||||
|
||||
// When the last focussed component peer is different from the
|
||||
// current focussed component or if they are different client
|
||||
// (active or passive), disable native IME for the old focussed
|
||||
// component and enable for the new one.
|
||||
if (lastFocussedComponentPeer != awtFocussedComponentPeer ||
|
||||
isLastFocussedActiveClient != isAc) {
|
||||
if (lastFocussedComponentPeer != null) {
|
||||
disableNativeIME(lastFocussedComponentPeer);
|
||||
}
|
||||
if (awtFocussedComponentPeer != null) {
|
||||
enableNativeIME(awtFocussedComponentPeer, context, !isAc);
|
||||
}
|
||||
lastFocussedComponentPeer = awtFocussedComponentPeer;
|
||||
isLastFocussedActiveClient = isAc;
|
||||
}
|
||||
isActive = true;
|
||||
if (currentLocale != null) {
|
||||
setLocale(currentLocale, true);
|
||||
}
|
||||
|
||||
/* If the status window or Windows language bar is turned off due to
|
||||
native input method was switched to java input method, we
|
||||
have to turn it on otherwise it is gone for good until next time
|
||||
the user turns it on through Windows Control Panel. See details
|
||||
from bug 6252674.
|
||||
*/
|
||||
if (statusWindowHidden) {
|
||||
setStatusWindowVisible(awtFocussedComponentPeer, true);
|
||||
statusWindowHidden = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate(boolean isTemporary)
|
||||
{
|
||||
// Sync currentLocale with the Windows keyboard layout which might be changed
|
||||
// by hot key
|
||||
getLocale();
|
||||
|
||||
// Delay calling disableNativeIME until activate is called and the newly
|
||||
// focussed component has a different peer as the last focussed component.
|
||||
if (awtFocussedComponentPeer != null) {
|
||||
lastFocussedComponentPeer = awtFocussedComponentPeer;
|
||||
isLastFocussedActiveClient = haveActiveClient();
|
||||
}
|
||||
isActive = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explicitly disable the native IME. Native IME is not disabled when
|
||||
* deactivate is called.
|
||||
*/
|
||||
@Override
|
||||
public void disableInputMethod() {
|
||||
if (lastFocussedComponentPeer != null) {
|
||||
disableNativeIME(lastFocussedComponentPeer);
|
||||
lastFocussedComponentPeer = null;
|
||||
isLastFocussedActiveClient = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string with information about the windows input method,
|
||||
* or null.
|
||||
*/
|
||||
@Override
|
||||
public String getNativeInputMethodInfo() {
|
||||
return getNativeIMMDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see sun.awt.im.InputMethodAdapter#stopListening
|
||||
* This method is called when the input method is swapped out.
|
||||
* Calling stopListening to give other input method the keybaord input
|
||||
* focus.
|
||||
*/
|
||||
@Override
|
||||
protected void stopListening() {
|
||||
// Since the native input method is not disabled when deactivate is
|
||||
// called, we need to call disableInputMethod to explicitly turn off the
|
||||
// native IME.
|
||||
disableInputMethod();
|
||||
}
|
||||
|
||||
// implements sun.awt.im.InputMethodAdapter.setAWTFocussedComponent
|
||||
@Override
|
||||
protected void setAWTFocussedComponent(Component component) {
|
||||
if (component == null) {
|
||||
return;
|
||||
}
|
||||
WComponentPeer peer = getNearestNativePeer(component);
|
||||
if (isActive) {
|
||||
// deactivate/activate are being suppressed during a focus change -
|
||||
// this may happen when an input method window is made visible
|
||||
if (awtFocussedComponentPeer != null) {
|
||||
disableNativeIME(awtFocussedComponentPeer);
|
||||
}
|
||||
if (peer != null) {
|
||||
enableNativeIME(peer, context, !haveActiveClient());
|
||||
}
|
||||
}
|
||||
awtFocussedComponent = component;
|
||||
awtFocussedComponentPeer = peer;
|
||||
}
|
||||
|
||||
// implements java.awt.im.spi.InputMethod.hideWindows
|
||||
@Override
|
||||
public void hideWindows() {
|
||||
if (awtFocussedComponentPeer != null) {
|
||||
/* Hide the native status window including the Windows language
|
||||
bar if it is on. One typical senario this method
|
||||
gets called is when the native input method is
|
||||
switched to java input method, for example.
|
||||
*/
|
||||
setStatusWindowVisible(awtFocussedComponentPeer, false);
|
||||
statusWindowHidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.im.spi.InputMethod#removeNotify
|
||||
*/
|
||||
@Override
|
||||
public void removeNotify() {
|
||||
endCompositionNative(context, DISCARD_INPUT);
|
||||
awtFocussedComponent = null;
|
||||
awtFocussedComponentPeer = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.Toolkit#mapInputMethodHighlight
|
||||
*/
|
||||
static Map<TextAttribute,?> mapInputMethodHighlight(InputMethodHighlight highlight) {
|
||||
int index;
|
||||
int state = highlight.getState();
|
||||
if (state == InputMethodHighlight.RAW_TEXT) {
|
||||
index = 0;
|
||||
} else if (state == InputMethodHighlight.CONVERTED_TEXT) {
|
||||
index = 2;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (highlight.isSelected()) {
|
||||
index += 1;
|
||||
}
|
||||
return highlightStyles[index];
|
||||
}
|
||||
|
||||
// see sun.awt.im.InputMethodAdapter.supportsBelowTheSpot
|
||||
@Override
|
||||
protected boolean supportsBelowTheSpot() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endComposition()
|
||||
{
|
||||
//right now the native endCompositionNative() just cancel
|
||||
//the composition string, maybe a commtting is desired
|
||||
endCompositionNative(context,
|
||||
(haveActiveClient() ? COMMIT_INPUT : DISCARD_INPUT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.im.spi.InputMethod#setCompositionEnabled(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setCompositionEnabled(boolean enable) {
|
||||
setOpenStatus(context, enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.im.spi.InputMethod#isCompositionEnabled
|
||||
*/
|
||||
@Override
|
||||
public boolean isCompositionEnabled() {
|
||||
return getOpenStatus(context);
|
||||
}
|
||||
|
||||
public void sendInputMethodEvent(int id, long when, String text,
|
||||
int[] clauseBoundary, String[] clauseReading,
|
||||
int[] attributeBoundary, byte[] attributeValue,
|
||||
int commitedTextLength, int caretPos, int visiblePos)
|
||||
{
|
||||
|
||||
AttributedCharacterIterator iterator = null;
|
||||
|
||||
if (text!=null) {
|
||||
|
||||
// construct AttributedString
|
||||
AttributedString attrStr = new AttributedString(text);
|
||||
|
||||
// set Language Information
|
||||
attrStr.addAttribute(Attribute.LANGUAGE,
|
||||
Locale.getDefault(), 0, text.length());
|
||||
|
||||
// set Clause and Reading Information
|
||||
if (clauseBoundary!=null && clauseReading!=null &&
|
||||
clauseReading.length!=0 && clauseBoundary.length==clauseReading.length+1 &&
|
||||
clauseBoundary[0]==0 && clauseBoundary[clauseReading.length]<=text.length() )
|
||||
{
|
||||
for (int i=0; i<clauseBoundary.length-1; i++) {
|
||||
attrStr.addAttribute(Attribute.INPUT_METHOD_SEGMENT,
|
||||
new Annotation(null), clauseBoundary[i], clauseBoundary[i+1]);
|
||||
attrStr.addAttribute(Attribute.READING,
|
||||
new Annotation(clauseReading[i]), clauseBoundary[i], clauseBoundary[i+1]);
|
||||
}
|
||||
} else {
|
||||
// if (clauseBoundary != null)
|
||||
// System.out.println("Invalid clause information!");
|
||||
|
||||
attrStr.addAttribute(Attribute.INPUT_METHOD_SEGMENT,
|
||||
new Annotation(null), 0, text.length());
|
||||
attrStr.addAttribute(Attribute.READING,
|
||||
new Annotation(""), 0, text.length());
|
||||
}
|
||||
|
||||
// set Hilight Information
|
||||
if (attributeBoundary!=null && attributeValue!=null &&
|
||||
attributeValue.length!=0 && attributeBoundary.length==attributeValue.length+1 &&
|
||||
attributeBoundary[0]==0 && attributeBoundary[attributeValue.length]==text.length() )
|
||||
{
|
||||
for (int i=0; i<attributeBoundary.length-1; i++) {
|
||||
InputMethodHighlight highlight;
|
||||
switch (attributeValue[i]) {
|
||||
case ATTR_TARGET_CONVERTED:
|
||||
highlight = InputMethodHighlight.SELECTED_CONVERTED_TEXT_HIGHLIGHT;
|
||||
break;
|
||||
case ATTR_CONVERTED:
|
||||
highlight = InputMethodHighlight.UNSELECTED_CONVERTED_TEXT_HIGHLIGHT;
|
||||
break;
|
||||
case ATTR_TARGET_NOTCONVERTED:
|
||||
highlight = InputMethodHighlight.SELECTED_RAW_TEXT_HIGHLIGHT;
|
||||
break;
|
||||
case ATTR_INPUT:
|
||||
case ATTR_INPUT_ERROR:
|
||||
default:
|
||||
highlight = InputMethodHighlight.UNSELECTED_RAW_TEXT_HIGHLIGHT;
|
||||
break;
|
||||
}
|
||||
attrStr.addAttribute(TextAttribute.INPUT_METHOD_HIGHLIGHT,
|
||||
highlight,
|
||||
attributeBoundary[i], attributeBoundary[i+1]);
|
||||
}
|
||||
} else {
|
||||
// if (attributeBoundary != null)
|
||||
// System.out.println("Invalid attribute information!");
|
||||
|
||||
attrStr.addAttribute(TextAttribute.INPUT_METHOD_HIGHLIGHT,
|
||||
InputMethodHighlight.UNSELECTED_CONVERTED_TEXT_HIGHLIGHT,
|
||||
0, text.length());
|
||||
}
|
||||
|
||||
// get iterator
|
||||
iterator = attrStr.getIterator();
|
||||
|
||||
}
|
||||
|
||||
Component source = getClientComponent();
|
||||
if (source == null)
|
||||
return;
|
||||
|
||||
InputMethodEvent event = new InputMethodEvent(source,
|
||||
id,
|
||||
when,
|
||||
iterator,
|
||||
commitedTextLength,
|
||||
TextHitInfo.leading(caretPos),
|
||||
TextHitInfo.leading(visiblePos));
|
||||
WToolkit.postEvent(WToolkit.targetToAppContext(source), event);
|
||||
}
|
||||
|
||||
public void inquireCandidatePosition()
|
||||
{
|
||||
Component source = getClientComponent();
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
// This call should return immediately just to cause
|
||||
// InputMethodRequests.getTextLocation be called within
|
||||
// AWT Event thread. Otherwise, a potential deadlock
|
||||
// could happen.
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
Component client = getClientComponent();
|
||||
|
||||
if (client != null) {
|
||||
if (!client.isShowing()) {
|
||||
return;
|
||||
}
|
||||
if (haveActiveClient()) {
|
||||
Rectangle rc = inputContext.getTextLocation(TextHitInfo.leading(0));
|
||||
x = rc.x;
|
||||
y = rc.y + rc.height;
|
||||
} else {
|
||||
Point pt = client.getLocationOnScreen();
|
||||
Dimension size = client.getSize();
|
||||
x = pt.x;
|
||||
y = pt.y + size.height;
|
||||
}
|
||||
}
|
||||
|
||||
openCandidateWindow(awtFocussedComponentPeer, x, y);
|
||||
}
|
||||
};
|
||||
WToolkit.postEvent(WToolkit.targetToAppContext(source),
|
||||
new InvocationEvent(source, r));
|
||||
}
|
||||
|
||||
// java.awt.Toolkit#getNativeContainer() is not available
|
||||
// from this package
|
||||
private WComponentPeer getNearestNativePeer(Component comp)
|
||||
{
|
||||
if (comp==null) return null;
|
||||
|
||||
ComponentPeer peer = comp.getPeer();
|
||||
if (peer==null) return null;
|
||||
|
||||
while (peer instanceof java.awt.peer.LightweightPeer) {
|
||||
comp = comp.getParent();
|
||||
if (comp==null) return null;
|
||||
peer = comp.getPeer();
|
||||
if (peer==null) return null;
|
||||
}
|
||||
|
||||
if (peer instanceof WComponentPeer)
|
||||
return (WComponentPeer)peer;
|
||||
else
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private native int createNativeContext();
|
||||
private native void destroyNativeContext(int context);
|
||||
private native void enableNativeIME(WComponentPeer peer, int context, boolean useNativeCompWindow);
|
||||
private native void disableNativeIME(WComponentPeer peer);
|
||||
private native void handleNativeIMEEvent(WComponentPeer peer, AWTEvent e);
|
||||
private native void endCompositionNative(int context, boolean flag);
|
||||
private native void setConversionStatus(int context, int cmode);
|
||||
private native int getConversionStatus(int context);
|
||||
private native void setOpenStatus(int context, boolean flag);
|
||||
private native boolean getOpenStatus(int context);
|
||||
private native void setStatusWindowVisible(WComponentPeer peer, boolean visible);
|
||||
private native String getNativeIMMDescription();
|
||||
static native Locale getNativeLocale();
|
||||
static native boolean setNativeLocale(String localeName, boolean onActivate);
|
||||
private native void openCandidateWindow(WComponentPeer peer, int x, int y);
|
||||
}
|
||||
101
jdkSrc/jdk8/sun/awt/windows/WInputMethodDescriptor.java
Normal file
101
jdkSrc/jdk8/sun/awt/windows/WInputMethodDescriptor.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.im.spi.InputMethod;
|
||||
import java.awt.im.spi.InputMethodDescriptor;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Provides sufficient information about an input method
|
||||
* to enable selection and loading of that input method.
|
||||
* The input method itself is only loaded when it is actually used.
|
||||
*
|
||||
* @since JDK1.3
|
||||
*/
|
||||
|
||||
final class WInputMethodDescriptor implements InputMethodDescriptor {
|
||||
|
||||
/**
|
||||
* @see java.awt.im.spi.InputMethodDescriptor#getAvailableLocales
|
||||
*/
|
||||
@Override
|
||||
public Locale[] getAvailableLocales() {
|
||||
// returns a copy of internal list for public API
|
||||
Locale[] locales = getAvailableLocalesInternal();
|
||||
Locale[] tmp = new Locale[locales.length];
|
||||
System.arraycopy(locales, 0, tmp, 0, locales.length);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static Locale[] getAvailableLocalesInternal() {
|
||||
return getNativeAvailableLocales();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.im.spi.InputMethodDescriptor#hasDynamicLocaleList
|
||||
*/
|
||||
@Override
|
||||
public boolean hasDynamicLocaleList() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.im.spi.InputMethodDescriptor#getInputMethodDisplayName
|
||||
*/
|
||||
@Override
|
||||
public synchronized String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage) {
|
||||
// We ignore the input locale.
|
||||
// When displaying for the default locale, rely on the localized AWT properties;
|
||||
// for any other locale, fall back to English.
|
||||
String name = "System Input Methods";
|
||||
if (Locale.getDefault().equals(displayLanguage)) {
|
||||
name = Toolkit.getProperty("AWT.HostInputMethodDisplayName", name);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.im.spi.InputMethodDescriptor#getInputMethodIcon
|
||||
*/
|
||||
@Override
|
||||
public Image getInputMethodIcon(Locale inputLocale) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.awt.im.spi.InputMethodDescriptor#createInputMethod
|
||||
*/
|
||||
@Override
|
||||
public InputMethod createInputMethod() throws Exception {
|
||||
return new WInputMethod();
|
||||
}
|
||||
|
||||
private static native Locale[] getNativeAvailableLocales();
|
||||
}
|
||||
85
jdkSrc/jdk8/sun/awt/windows/WKeyboardFocusManagerPeer.java
Normal file
85
jdkSrc/jdk8/sun/awt/windows/WKeyboardFocusManagerPeer.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Window;
|
||||
import java.awt.Component;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import sun.awt.KeyboardFocusManagerPeerImpl;
|
||||
import sun.awt.CausedFocusEvent;
|
||||
|
||||
final class WKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
|
||||
static native void setNativeFocusOwner(ComponentPeer peer);
|
||||
static native Component getNativeFocusOwner();
|
||||
static native Window getNativeFocusedWindow();
|
||||
|
||||
private static final WKeyboardFocusManagerPeer inst = new WKeyboardFocusManagerPeer();
|
||||
|
||||
public static WKeyboardFocusManagerPeer getInstance() {
|
||||
return inst;
|
||||
}
|
||||
|
||||
private WKeyboardFocusManagerPeer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentFocusOwner(Component comp) {
|
||||
setNativeFocusOwner(comp != null ? comp.getPeer() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getCurrentFocusOwner() {
|
||||
return getNativeFocusOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentFocusedWindow(Window win) {
|
||||
// Not used on Windows
|
||||
throw new RuntimeException("not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Window getCurrentFocusedWindow() {
|
||||
return getNativeFocusedWindow();
|
||||
}
|
||||
|
||||
public static boolean deliverFocus(Component lightweightChild,
|
||||
Component target,
|
||||
boolean temporary,
|
||||
boolean focusedWindowChangeAllowed,
|
||||
long time,
|
||||
CausedFocusEvent.Cause cause)
|
||||
{
|
||||
// TODO: do something to eliminate this forwarding
|
||||
return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
|
||||
target,
|
||||
temporary,
|
||||
focusedWindowChangeAllowed,
|
||||
time,
|
||||
cause,
|
||||
getNativeFocusOwner());
|
||||
}
|
||||
}
|
||||
85
jdkSrc/jdk8/sun/awt/windows/WLabelPeer.java
Normal file
85
jdkSrc/jdk8/sun/awt/windows/WLabelPeer.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
|
||||
final class WLabelPeer extends WComponentPeer implements LabelPeer {
|
||||
|
||||
// ComponentPeer overrides
|
||||
|
||||
public Dimension getMinimumSize() {
|
||||
FontMetrics fm = getFontMetrics(((Label)target).getFont());
|
||||
String label = ((Label)target).getText();
|
||||
if (label == null)
|
||||
label = "";
|
||||
return new Dimension(fm.stringWidth(label) + 14, fm.getHeight() + 8);
|
||||
}
|
||||
|
||||
native void lazyPaint();
|
||||
synchronized void start() {
|
||||
super.start();
|
||||
// if need then paint label
|
||||
lazyPaint();
|
||||
}
|
||||
// LabelPeer implementation
|
||||
|
||||
public boolean shouldClearRectBeforePaint() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public native void setText(String label);
|
||||
public native void setAlignment(int alignment);
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WLabelPeer(Label target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
native void create(WComponentPeer parent);
|
||||
|
||||
void initialize() {
|
||||
Label l = (Label)target;
|
||||
|
||||
String txt = l.getText();
|
||||
if (txt != null) {
|
||||
setText(txt);
|
||||
}
|
||||
|
||||
int align = l.getAlignment();
|
||||
if (align != Label.LEFT) {
|
||||
setAlignment(align);
|
||||
}
|
||||
|
||||
Color bg = ((Component)target).getBackground();
|
||||
if (bg != null) {
|
||||
setBackground(bg);
|
||||
}
|
||||
|
||||
super.initialize();
|
||||
}
|
||||
}
|
||||
116
jdkSrc/jdk8/sun/awt/windows/WLightweightFramePeer.java
Normal file
116
jdkSrc/jdk8/sun/awt/windows/WLightweightFramePeer.java
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import sun.awt.LightweightFrame;
|
||||
import sun.awt.OverrideNativeWindowHandle;
|
||||
import sun.swing.JLightweightFrame;
|
||||
import sun.swing.SwingAccessor;
|
||||
|
||||
public class WLightweightFramePeer extends WFramePeer implements OverrideNativeWindowHandle {
|
||||
|
||||
public WLightweightFramePeer(LightweightFrame target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
private LightweightFrame getLwTarget() {
|
||||
return (LightweightFrame)target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Graphics getGraphics() {
|
||||
return getLwTarget().getGraphics();
|
||||
}
|
||||
|
||||
private native void overrideNativeHandle(long hwnd);
|
||||
|
||||
@Override
|
||||
public void overrideWindowHandle(final long handle) {
|
||||
overrideNativeHandle(handle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
postEvent(new ComponentEvent((Component)getTarget(), ComponentEvent.COMPONENT_SHOWN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
super.hide();
|
||||
postEvent(new ComponentEvent((Component)getTarget(), ComponentEvent.COMPONENT_HIDDEN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reshape(int x, int y, int width, int height) {
|
||||
super.reshape(x, y, width, height);
|
||||
postEvent(new ComponentEvent((Component) getTarget(), ComponentEvent.COMPONENT_MOVED));
|
||||
postEvent(new ComponentEvent((Component) getTarget(), ComponentEvent.COMPONENT_RESIZED));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEvent(java.awt.AWTEvent e) {
|
||||
if (e.getID() == MouseEvent.MOUSE_PRESSED) {
|
||||
emulateActivation(true);
|
||||
}
|
||||
super.handleEvent(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void grab() {
|
||||
getLwTarget().grabFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ungrab() {
|
||||
getLwTarget().ungrabFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCursorImmediately() {
|
||||
SwingAccessor.getJLightweightFrameAccessor().updateCursor((JLightweightFrame)getLwTarget());
|
||||
}
|
||||
|
||||
public boolean isLightweightFramePeer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDropTarget(DropTarget dt) {
|
||||
getLwTarget().addDropTarget(dt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDropTarget(DropTarget dt) {
|
||||
getLwTarget().removeDropTarget(dt);
|
||||
}
|
||||
}
|
||||
230
jdkSrc/jdk8/sun/awt/windows/WListPeer.java
Normal file
230
jdkSrc/jdk8/sun/awt/windows/WListPeer.java
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ItemEvent;
|
||||
|
||||
final class WListPeer extends WComponentPeer implements ListPeer {
|
||||
|
||||
@Override
|
||||
public boolean isFocusable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ListPeer implementation
|
||||
|
||||
@Override
|
||||
public int[] getSelectedIndexes() {
|
||||
List l = (List)target;
|
||||
int len = l.countItems();
|
||||
int sel[] = new int[len];
|
||||
int nsel = 0;
|
||||
for (int i = 0 ; i < len ; i++) {
|
||||
if (isSelected(i)) {
|
||||
sel[nsel++] = i;
|
||||
}
|
||||
}
|
||||
int selected[] = new int[nsel];
|
||||
System.arraycopy(sel, 0, selected, 0, nsel);
|
||||
return selected;
|
||||
}
|
||||
|
||||
/* New method name for 1.1 */
|
||||
@Override
|
||||
public void add(String item, int index) {
|
||||
addItem(item, index);
|
||||
}
|
||||
|
||||
/* New method name for 1.1 */
|
||||
@Override
|
||||
public void removeAll() {
|
||||
clear();
|
||||
}
|
||||
|
||||
/* New method name for 1.1 */
|
||||
@Override
|
||||
public void setMultipleMode (boolean b) {
|
||||
setMultipleSelections(b);
|
||||
}
|
||||
|
||||
/* New method name for 1.1 */
|
||||
@Override
|
||||
public Dimension getPreferredSize(int rows) {
|
||||
return preferredSize(rows);
|
||||
}
|
||||
|
||||
/* New method name for 1.1 */
|
||||
@Override
|
||||
public Dimension getMinimumSize(int rows) {
|
||||
return minimumSize(rows);
|
||||
}
|
||||
|
||||
private FontMetrics fm;
|
||||
public void addItem(String item, int index) {
|
||||
addItems(new String[] {item}, index, fm.stringWidth(item));
|
||||
}
|
||||
native void addItems(String[] items, int index, int width);
|
||||
|
||||
@Override
|
||||
public native void delItems(int start, int end);
|
||||
public void clear() {
|
||||
List l = (List)target;
|
||||
delItems(0, l.countItems());
|
||||
}
|
||||
@Override
|
||||
public native void select(int index);
|
||||
@Override
|
||||
public native void deselect(int index);
|
||||
@Override
|
||||
public native void makeVisible(int index);
|
||||
public native void setMultipleSelections(boolean v);
|
||||
public native int getMaxWidth();
|
||||
|
||||
public Dimension preferredSize(int v) {
|
||||
if ( fm == null ) {
|
||||
List li = (List)target;
|
||||
fm = getFontMetrics( li.getFont() );
|
||||
}
|
||||
Dimension d = minimumSize(v);
|
||||
d.width = Math.max(d.width, getMaxWidth() + 20);
|
||||
return d;
|
||||
}
|
||||
public Dimension minimumSize(int v) {
|
||||
return new Dimension(20 + fm.stringWidth("0123456789abcde"),
|
||||
(fm.getHeight() * v) + 4); // include borders
|
||||
}
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WListPeer(List target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
native void create(WComponentPeer parent);
|
||||
|
||||
@Override
|
||||
void initialize() {
|
||||
List li = (List)target;
|
||||
|
||||
fm = getFontMetrics( li.getFont() );
|
||||
|
||||
// Fixed 6336384: setFont should be done before addItems
|
||||
Font f = li.getFont();
|
||||
if (f != null) {
|
||||
setFont(f);
|
||||
}
|
||||
|
||||
// add any items that were already inserted in the target.
|
||||
int nitems = li.countItems();
|
||||
if (nitems > 0) {
|
||||
String[] items = new String[nitems];
|
||||
int maxWidth = 0;
|
||||
int width = 0;
|
||||
for (int i = 0; i < nitems; i++) {
|
||||
items[i] = li.getItem(i);
|
||||
width = fm.stringWidth(items[i]);
|
||||
if (width > maxWidth) {
|
||||
maxWidth = width;
|
||||
}
|
||||
}
|
||||
addItems(items, 0, maxWidth);
|
||||
}
|
||||
|
||||
// set whether this list should allow multiple selections.
|
||||
setMultipleSelections(li.allowsMultipleSelections());
|
||||
|
||||
// select the item if necessary.
|
||||
int sel[] = li.getSelectedIndexes();
|
||||
for (int i = 0 ; i < sel.length ; i++) {
|
||||
select(sel[i]);
|
||||
}
|
||||
|
||||
// make the visible position visible.
|
||||
// fix for 4676536 by kdm@sparc.spb.su
|
||||
// we should call makeVisible() after we call select()
|
||||
// because of a bug in Windows which is manifested by
|
||||
// incorrect scrolling of the selected item if the list
|
||||
// height is less than an item height of the list.
|
||||
int index = li.getVisibleIndex();
|
||||
if (index < 0 && sel.length > 0) {
|
||||
index = sel[0];
|
||||
}
|
||||
if (index >= 0) {
|
||||
makeVisible(index);
|
||||
}
|
||||
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldClearRectBeforePaint() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private native void updateMaxItemWidth();
|
||||
|
||||
/*public*/ native boolean isSelected(int index);
|
||||
|
||||
// update the fontmetrics when the font changes
|
||||
@Override
|
||||
synchronized void _setFont(Font f)
|
||||
{
|
||||
super._setFont( f );
|
||||
fm = getFontMetrics( ((List)target).getFont() );
|
||||
updateMaxItemWidth();
|
||||
}
|
||||
|
||||
// native callbacks
|
||||
|
||||
void handleAction(final int index, final long when, final int modifiers) {
|
||||
final List l = (List)target;
|
||||
WToolkit.executeOnEventHandlerThread(l, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
l.select(index);
|
||||
postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
|
||||
l.getItem(index), when, modifiers));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void handleListChanged(final int index) {
|
||||
final List l = (List)target;
|
||||
WToolkit.executeOnEventHandlerThread(l, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
postEvent(new ItemEvent(l, ItemEvent.ITEM_STATE_CHANGED,
|
||||
Integer.valueOf(index),
|
||||
isSelected(index)? ItemEvent.SELECTED :
|
||||
ItemEvent.DESELECTED));
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
59
jdkSrc/jdk8/sun/awt/windows/WMenuBarPeer.java
Normal file
59
jdkSrc/jdk8/sun/awt/windows/WMenuBarPeer.java
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2016, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
|
||||
final class WMenuBarPeer extends WMenuPeer implements MenuBarPeer {
|
||||
|
||||
// MenuBarPeer implementation
|
||||
|
||||
final WFramePeer framePeer;
|
||||
|
||||
@Override
|
||||
public native void addMenu(Menu m);
|
||||
@Override
|
||||
public native void delMenu(int index);
|
||||
|
||||
@Override
|
||||
public void addHelpMenu(Menu m) {
|
||||
addMenu(m);
|
||||
}
|
||||
|
||||
// Toolkit & peer internals
|
||||
WMenuBarPeer(MenuBar target) {
|
||||
this.target = target;
|
||||
framePeer = (WFramePeer)
|
||||
WToolkit.targetToPeer(target.getParent());
|
||||
if (framePeer != null) {
|
||||
framePeer.addChildPeer(this);
|
||||
}
|
||||
create(framePeer);
|
||||
// fix for 5088782: check if menu object is created successfully
|
||||
checkMenuCreation();
|
||||
}
|
||||
native void create(WFramePeer f);
|
||||
}
|
||||
192
jdkSrc/jdk8/sun/awt/windows/WMenuItemPeer.java
Normal file
192
jdkSrc/jdk8/sun/awt/windows/WMenuItemPeer.java
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2016, 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 sun.awt.windows;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.MissingResourceException;
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
class WMenuItemPeer extends WObjectPeer implements MenuItemPeer {
|
||||
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.WMenuItemPeer");
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
String shortcutLabel;
|
||||
//WMenuBarPeer extends WMenuPeer
|
||||
//so parent is always instanceof WMenuPeer
|
||||
protected WMenuPeer parent;
|
||||
|
||||
// MenuItemPeer implementation
|
||||
|
||||
private synchronized native void _dispose();
|
||||
protected void disposeImpl() {
|
||||
WToolkit.targetDisposedPeer(target, this);
|
||||
_dispose();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean b) {
|
||||
enable(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setEnabled(boolean).
|
||||
*/
|
||||
public void enable() {
|
||||
enable(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by setEnabled(boolean).
|
||||
*/
|
||||
public void disable() {
|
||||
enable(false);
|
||||
}
|
||||
|
||||
private void readShortcutLabel() {
|
||||
//Fix for 6288578: PIT. Windows: Shortcuts displayed for the menuitems in a popup menu
|
||||
WMenuPeer ancestor = parent;
|
||||
while (ancestor != null && !(ancestor instanceof WMenuBarPeer)) {
|
||||
ancestor = ancestor.parent;
|
||||
}
|
||||
if (ancestor instanceof WMenuBarPeer) {
|
||||
MenuShortcut sc = ((MenuItem)target).getShortcut();
|
||||
shortcutLabel = (sc != null) ? sc.toString() : null;
|
||||
} else {
|
||||
shortcutLabel = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
//Fix for 6288578: PIT. Windows: Shortcuts displayed for the menuitems in a popup menu
|
||||
readShortcutLabel();
|
||||
_setLabel(label);
|
||||
}
|
||||
public native void _setLabel(String label);
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
private final boolean isCheckbox;
|
||||
|
||||
protected WMenuItemPeer() {
|
||||
isCheckbox = false;
|
||||
}
|
||||
WMenuItemPeer(MenuItem target) {
|
||||
this(target, false);
|
||||
}
|
||||
|
||||
WMenuItemPeer(MenuItem target, boolean isCheckbox) {
|
||||
this.target = target;
|
||||
this.parent = (WMenuPeer) WToolkit.targetToPeer(target.getParent());
|
||||
this.isCheckbox = isCheckbox;
|
||||
parent.addChildPeer(this);
|
||||
create(parent);
|
||||
// fix for 5088782: check if menu object is created successfully
|
||||
checkMenuCreation();
|
||||
//Fix for 6288578: PIT. Windows: Shortcuts displayed for the menuitems in a popup menu
|
||||
readShortcutLabel();
|
||||
}
|
||||
|
||||
void checkMenuCreation()
|
||||
{
|
||||
// fix for 5088782: check if menu peer is created successfully
|
||||
if (pData == 0)
|
||||
{
|
||||
if (createError != null)
|
||||
{
|
||||
throw createError;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InternalError("couldn't create menu peer");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Post an event. Queue it for execution by the callback thread.
|
||||
*/
|
||||
void postEvent(AWTEvent event) {
|
||||
WToolkit.postEvent(WToolkit.targetToAppContext(target), event);
|
||||
}
|
||||
|
||||
native void create(WMenuPeer parent);
|
||||
|
||||
native void enable(boolean e);
|
||||
|
||||
// native callbacks
|
||||
|
||||
void handleAction(final long when, final int modifiers) {
|
||||
WToolkit.executeOnEventHandlerThread(target, new Runnable() {
|
||||
public void run() {
|
||||
postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
|
||||
((MenuItem)target).
|
||||
getActionCommand(), when,
|
||||
modifiers));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static Font defaultMenuFont;
|
||||
|
||||
static {
|
||||
defaultMenuFont = AccessController.doPrivileged(
|
||||
new PrivilegedAction <Font> () {
|
||||
public Font run() {
|
||||
try {
|
||||
ResourceBundle rb = ResourceBundle.getBundle("sun.awt.windows.awtLocalization");
|
||||
return Font.decode(rb.getString("menuFont"));
|
||||
} catch (MissingResourceException e) {
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine("WMenuItemPeer: " + e.getMessage()+". Using default MenuItem font.", e);
|
||||
}
|
||||
return new Font("SanSerif", Font.PLAIN, 11);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static Font getDefaultFont() {
|
||||
return defaultMenuFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method IDs
|
||||
*/
|
||||
private static native void initIDs();
|
||||
|
||||
private native void _setFont(Font f);
|
||||
|
||||
public void setFont(final Font f) {
|
||||
_setFont(f);
|
||||
}
|
||||
}
|
||||
71
jdkSrc/jdk8/sun/awt/windows/WMenuPeer.java
Normal file
71
jdkSrc/jdk8/sun/awt/windows/WMenuPeer.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2016, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
|
||||
class WMenuPeer extends WMenuItemPeer implements MenuPeer {
|
||||
|
||||
// MenuPeer implementation
|
||||
|
||||
@Override
|
||||
public native void addSeparator();
|
||||
@Override
|
||||
public void addItem(MenuItem item) {
|
||||
WMenuItemPeer itemPeer = (WMenuItemPeer) WToolkit.targetToPeer(item);
|
||||
}
|
||||
@Override
|
||||
public native void delItem(int index);
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WMenuPeer() {} // used by subclasses.
|
||||
|
||||
WMenuPeer(Menu target) {
|
||||
this.target = target;
|
||||
MenuContainer parent = target.getParent();
|
||||
|
||||
if (parent instanceof MenuBar) {
|
||||
WMenuBarPeer mbPeer = (WMenuBarPeer) WToolkit.targetToPeer(parent);
|
||||
this.parent = mbPeer;
|
||||
mbPeer.addChildPeer(this);
|
||||
createMenu(mbPeer);
|
||||
}
|
||||
else if (parent instanceof Menu) {
|
||||
this.parent = (WMenuPeer) WToolkit.targetToPeer(parent);
|
||||
this.parent.addChildPeer(this);
|
||||
createSubMenu(this.parent);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("unknown menu container class");
|
||||
}
|
||||
// fix for 5088782: check if menu object is created successfully
|
||||
checkMenuCreation();
|
||||
}
|
||||
|
||||
native void createMenu(WMenuBarPeer parent);
|
||||
native void createSubMenu(WMenuPeer parent);
|
||||
}
|
||||
233
jdkSrc/jdk8/sun/awt/windows/WMouseDragGestureRecognizer.java
Normal file
233
jdkSrc/jdk8/sun/awt/windows/WMouseDragGestureRecognizer.java
Normal file
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.dnd.DragGestureListener;
|
||||
import java.awt.dnd.DragSource;
|
||||
import java.awt.dnd.MouseDragGestureRecognizer;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import sun.awt.dnd.SunDragSourceContextPeer;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This subclass of MouseDragGestureRecognizer defines a DragGestureRecognizer
|
||||
* for Mouse based gestures on Win32.
|
||||
* </p>
|
||||
*
|
||||
* @author Laurence P. G. Cable
|
||||
*
|
||||
* @see java.awt.dnd.DragGestureListener
|
||||
* @see java.awt.dnd.DragGestureEvent
|
||||
* @see java.awt.dnd.DragSource
|
||||
*/
|
||||
|
||||
final class WMouseDragGestureRecognizer extends MouseDragGestureRecognizer {
|
||||
|
||||
private static final long serialVersionUID = -3527844310018033570L;
|
||||
|
||||
/*
|
||||
* constant for number of pixels hysterisis before drag is determined
|
||||
* to have started
|
||||
*/
|
||||
|
||||
protected static int motionThreshold;
|
||||
|
||||
protected static final int ButtonMask = InputEvent.BUTTON1_DOWN_MASK |
|
||||
InputEvent.BUTTON2_DOWN_MASK |
|
||||
InputEvent.BUTTON3_DOWN_MASK;
|
||||
|
||||
/**
|
||||
* construct a new WMouseDragGestureRecognizer
|
||||
*
|
||||
* @param ds The DragSource for the Component c
|
||||
* @param c The Component to observe
|
||||
* @param act The actions permitted for this Drag
|
||||
* @param dgl The DragGestureRecognizer to notify when a gesture is detected
|
||||
*
|
||||
*/
|
||||
|
||||
protected WMouseDragGestureRecognizer(DragSource ds, Component c, int act, DragGestureListener dgl) {
|
||||
super(ds, c, act, dgl);
|
||||
}
|
||||
|
||||
/**
|
||||
* construct a new WMouseDragGestureRecognizer
|
||||
*
|
||||
* @param ds The DragSource for the Component c
|
||||
* @param c The Component to observe
|
||||
* @param act The actions permitted for this Drag
|
||||
*/
|
||||
|
||||
protected WMouseDragGestureRecognizer(DragSource ds, Component c, int act) {
|
||||
this(ds, c, act, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* construct a new WMouseDragGestureRecognizer
|
||||
*
|
||||
* @param ds The DragSource for the Component c
|
||||
* @param c The Component to observe
|
||||
*/
|
||||
|
||||
protected WMouseDragGestureRecognizer(DragSource ds, Component c) {
|
||||
this(ds, c, DnDConstants.ACTION_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* construct a new WMouseDragGestureRecognizer
|
||||
*
|
||||
* @param ds The DragSource for the Component c
|
||||
*/
|
||||
|
||||
protected WMouseDragGestureRecognizer(DragSource ds) {
|
||||
this(ds, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* determine the drop action from the event
|
||||
*/
|
||||
|
||||
protected int mapDragOperationFromModifiers(MouseEvent e) {
|
||||
int mods = e.getModifiersEx();
|
||||
int btns = mods & ButtonMask;
|
||||
|
||||
// Prohibit multi-button drags.
|
||||
if (!(btns == InputEvent.BUTTON1_DOWN_MASK ||
|
||||
btns == InputEvent.BUTTON2_DOWN_MASK ||
|
||||
btns == InputEvent.BUTTON3_DOWN_MASK)) {
|
||||
return DnDConstants.ACTION_NONE;
|
||||
}
|
||||
|
||||
return
|
||||
SunDragSourceContextPeer.convertModifiersToDropAction(mods,
|
||||
getSourceActions());
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the mouse has been clicked on a component.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when a mouse button has been pressed on a component.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
events.clear();
|
||||
|
||||
if (mapDragOperationFromModifiers(e) != DnDConstants.ACTION_NONE) {
|
||||
try {
|
||||
motionThreshold = DragSource.getDragThreshold();
|
||||
} catch (Exception exc) {
|
||||
motionThreshold = 5;
|
||||
}
|
||||
appendEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when a mouse button has been released on a component.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
events.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the mouse enters a component.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
events.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the mouse exits a component.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
|
||||
if (!events.isEmpty()) { // gesture pending
|
||||
int dragAction = mapDragOperationFromModifiers(e);
|
||||
|
||||
if (dragAction == DnDConstants.ACTION_NONE) {
|
||||
events.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when a mouse button is pressed on a component.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
if (!events.isEmpty()) { // gesture pending
|
||||
int dop = mapDragOperationFromModifiers(e);
|
||||
|
||||
if (dop == DnDConstants.ACTION_NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
MouseEvent trigger = (MouseEvent)events.get(0);
|
||||
|
||||
|
||||
Point origin = trigger.getPoint();
|
||||
Point current = e.getPoint();
|
||||
|
||||
int dx = Math.abs(origin.x - current.x);
|
||||
int dy = Math.abs(origin.y - current.y);
|
||||
|
||||
if (dx > motionThreshold || dy > motionThreshold) {
|
||||
fireDragGestureRecognized(dop, ((MouseEvent)getTriggerEvent()).getPoint());
|
||||
} else
|
||||
appendEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when the mouse button has been moved on a component
|
||||
* (with no buttons no down).
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
128
jdkSrc/jdk8/sun/awt/windows/WObjectPeer.java
Normal file
128
jdkSrc/jdk8/sun/awt/windows/WObjectPeer.java
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
abstract class WObjectPeer {
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
// The Windows handle for the native widget.
|
||||
volatile long pData;
|
||||
// if the native peer has been destroyed
|
||||
private volatile boolean destroyed;
|
||||
// The associated AWT object.
|
||||
volatile Object target;
|
||||
|
||||
private volatile boolean disposed;
|
||||
|
||||
// set from JNI if any errors in creating the peer occur
|
||||
volatile Error createError = null;
|
||||
|
||||
// used to synchronize the state of this peer
|
||||
private final Object stateLock = new Object();
|
||||
|
||||
private volatile Map<WObjectPeer, WObjectPeer> childPeers;
|
||||
|
||||
public static WObjectPeer getPeerForTarget(Object t) {
|
||||
WObjectPeer peer = (WObjectPeer) WToolkit.targetToPeer(t);
|
||||
return peer;
|
||||
}
|
||||
|
||||
public long getData() {
|
||||
return pData;
|
||||
}
|
||||
|
||||
public Object getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public final Object getStateLock() {
|
||||
return stateLock;
|
||||
}
|
||||
|
||||
/*
|
||||
* Subclasses should override disposeImpl() instead of dispose(). Client
|
||||
* code should always invoke dispose(), never disposeImpl().
|
||||
*/
|
||||
abstract protected void disposeImpl();
|
||||
public final void dispose() {
|
||||
boolean call_disposeImpl = false;
|
||||
|
||||
synchronized (this) {
|
||||
if (!disposed) {
|
||||
disposed = call_disposeImpl = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (call_disposeImpl) {
|
||||
if (childPeers != null) {
|
||||
disposeChildPeers();
|
||||
}
|
||||
disposeImpl();
|
||||
}
|
||||
}
|
||||
protected final boolean isDisposed() {
|
||||
return disposed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method IDs
|
||||
*/
|
||||
private static native void initIDs();
|
||||
|
||||
// if a child peer existence depends on this peer, add it to this collection
|
||||
final void addChildPeer(WObjectPeer child) {
|
||||
synchronized (getStateLock()) {
|
||||
if (childPeers == null) {
|
||||
childPeers = new WeakHashMap<>();
|
||||
}
|
||||
if (isDisposed()) {
|
||||
throw new IllegalStateException("Parent peer is disposed");
|
||||
}
|
||||
childPeers.put(child, this);
|
||||
}
|
||||
}
|
||||
|
||||
// called to dispose dependent child peers
|
||||
private void disposeChildPeers() {
|
||||
synchronized (getStateLock()) {
|
||||
for (WObjectPeer child : childPeers.keySet()) {
|
||||
if (child != null) {
|
||||
try {
|
||||
child.dispose();
|
||||
}
|
||||
catch (Exception e) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
80
jdkSrc/jdk8/sun/awt/windows/WPageDialog.java
Normal file
80
jdkSrc/jdk8/sun/awt/windows/WPageDialog.java
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Container;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.print.PrinterJob;
|
||||
import java.awt.print.PageFormat;
|
||||
import java.awt.print.Printable;
|
||||
|
||||
final class WPageDialog extends WPrintDialog {
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
PageFormat page;
|
||||
Printable painter;
|
||||
|
||||
WPageDialog(Frame parent, PrinterJob control, PageFormat page, Printable painter) {
|
||||
super(parent, control);
|
||||
this.page = page;
|
||||
this.painter = painter;
|
||||
}
|
||||
|
||||
|
||||
WPageDialog(Dialog parent, PrinterJob control, PageFormat page, Printable painter) {
|
||||
super(parent, control);
|
||||
this.page = page;
|
||||
this.painter = painter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void addNotify() {
|
||||
synchronized(getTreeLock()) {
|
||||
Container parent = getParent();
|
||||
if (parent != null && parent.getPeer() == null) {
|
||||
parent.addNotify();
|
||||
}
|
||||
|
||||
if (getPeer() == null) {
|
||||
ComponentPeer peer = ((WToolkit)Toolkit.getDefaultToolkit()).
|
||||
createWPageDialog(this);
|
||||
setPeer(peer);
|
||||
}
|
||||
super.addNotify();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method ids
|
||||
*/
|
||||
private static native void initIDs();
|
||||
}
|
||||
58
jdkSrc/jdk8/sun/awt/windows/WPageDialogPeer.java
Normal file
58
jdkSrc/jdk8/sun/awt/windows/WPageDialogPeer.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 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 sun.awt.windows;
|
||||
|
||||
final class WPageDialogPeer extends WPrintDialogPeer {
|
||||
|
||||
WPageDialogPeer(WPageDialog target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the page setup dialog placing the user's
|
||||
* settings into target's 'page'.
|
||||
*/
|
||||
private native boolean _show();
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Call pageSetup even with no printer installed, this
|
||||
// will display Windows error dialog and return false.
|
||||
try {
|
||||
((WPrintDialog)target).setRetVal(_show());
|
||||
} catch (Exception e) {
|
||||
// No exception should be thrown by native dialog code,
|
||||
// but if it is we need to trap it so the thread does
|
||||
// not hide is called and the thread doesn't hang.
|
||||
}
|
||||
((WPrintDialog)target).setVisible(false);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
102
jdkSrc/jdk8/sun/awt/windows/WPanelPeer.java
Normal file
102
jdkSrc/jdk8/sun/awt/windows/WPanelPeer.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
|
||||
import sun.awt.SunGraphicsCallback;
|
||||
|
||||
class WPanelPeer extends WCanvasPeer implements PanelPeer {
|
||||
|
||||
// ComponentPeer overrides
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
SunGraphicsCallback.PaintHeavyweightComponentsCallback.getInstance().
|
||||
runComponents(((Container)target).getComponents(), g,
|
||||
SunGraphicsCallback.LIGHTWEIGHTS |
|
||||
SunGraphicsCallback.HEAVYWEIGHTS);
|
||||
}
|
||||
@Override
|
||||
public void print(Graphics g) {
|
||||
super.print(g);
|
||||
SunGraphicsCallback.PrintHeavyweightComponentsCallback.getInstance().
|
||||
runComponents(((Container)target).getComponents(), g,
|
||||
SunGraphicsCallback.LIGHTWEIGHTS |
|
||||
SunGraphicsCallback.HEAVYWEIGHTS);
|
||||
}
|
||||
|
||||
// ContainerPeer (via PanelPeer) implementation
|
||||
|
||||
@Override
|
||||
public Insets getInsets() {
|
||||
return insets_;
|
||||
}
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
Insets insets_;
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize JNI field IDs
|
||||
*/
|
||||
private static native void initIDs();
|
||||
|
||||
WPanelPeer(Component target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
void initialize() {
|
||||
super.initialize();
|
||||
insets_ = new Insets(0,0,0,0);
|
||||
|
||||
Color c = ((Component)target).getBackground();
|
||||
if (c == null) {
|
||||
c = WColor.getDefaultColor(WColor.WINDOW_BKGND);
|
||||
((Component)target).setBackground(c);
|
||||
setBackground(c);
|
||||
}
|
||||
c = ((Component)target).getForeground();
|
||||
if (c == null) {
|
||||
c = WColor.getDefaultColor(WColor.WINDOW_TEXT);
|
||||
((Component)target).setForeground(c);
|
||||
setForeground(c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED: Replaced by getInsets().
|
||||
*/
|
||||
public Insets insets() {
|
||||
return getInsets();
|
||||
}
|
||||
}
|
||||
1791
jdkSrc/jdk8/sun/awt/windows/WPathGraphics.java
Normal file
1791
jdkSrc/jdk8/sun/awt/windows/WPathGraphics.java
Normal file
File diff suppressed because it is too large
Load Diff
111
jdkSrc/jdk8/sun/awt/windows/WPopupMenuPeer.java
Normal file
111
jdkSrc/jdk8/sun/awt/windows/WPopupMenuPeer.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2016, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
final class WPopupMenuPeer extends WMenuPeer implements PopupMenuPeer {
|
||||
// We can't use target.getParent() for TrayIcon popup
|
||||
// because this method should return null for the TrayIcon
|
||||
// popup regardless of that whether it has parent or not.
|
||||
|
||||
WPopupMenuPeer(PopupMenu target) {
|
||||
this.target = target;
|
||||
MenuContainer parent = null;
|
||||
|
||||
// We can't use target.getParent() for TrayIcon popup
|
||||
// because this method should return null for the TrayIcon
|
||||
// popup regardless of that whether it has parent or not.
|
||||
boolean isTrayIconPopup = AWTAccessor.getPopupMenuAccessor().isTrayIconPopup(target);
|
||||
if (isTrayIconPopup) {
|
||||
parent = AWTAccessor.getMenuComponentAccessor().getParent(target);
|
||||
} else {
|
||||
parent = target.getParent();
|
||||
}
|
||||
|
||||
if (parent instanceof Component) {
|
||||
WComponentPeer parentPeer = (WComponentPeer) WToolkit.targetToPeer(parent);
|
||||
if (parentPeer == null) {
|
||||
// because the menu isn't a component (sigh) we first have to wait
|
||||
// for a failure to map the peer which should only happen for a
|
||||
// lightweight container, then find the actual native parent from
|
||||
// that component.
|
||||
parent = WToolkit.getNativeContainer((Component)parent);
|
||||
parentPeer = (WComponentPeer) WToolkit.targetToPeer(parent);
|
||||
}
|
||||
parentPeer.addChildPeer(this);
|
||||
createMenu(parentPeer);
|
||||
// fix for 5088782: check if menu object is created successfully
|
||||
checkMenuCreation();
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"illegal popup menu container class");
|
||||
}
|
||||
}
|
||||
|
||||
private native void createMenu(WComponentPeer parent);
|
||||
|
||||
public void show(Event e) {
|
||||
Component origin = (Component)e.target;
|
||||
WComponentPeer peer = (WComponentPeer) WToolkit.targetToPeer(origin);
|
||||
if (peer == null) {
|
||||
// A failure to map the peer should only happen for a
|
||||
// lightweight component, then find the actual native parent from
|
||||
// that component. The event coorinates are going to have to be
|
||||
// remapped as well.
|
||||
Component nativeOrigin = WToolkit.getNativeContainer(origin);
|
||||
e.target = nativeOrigin;
|
||||
|
||||
// remove the event coordinates
|
||||
for (Component c = origin; c != nativeOrigin; c = c.getParent()) {
|
||||
Point p = c.getLocation();
|
||||
e.x += p.x;
|
||||
e.y += p.y;
|
||||
}
|
||||
}
|
||||
_show(e);
|
||||
}
|
||||
|
||||
/*
|
||||
* This overloaded method is for TrayIcon.
|
||||
* Its popup has special parent.
|
||||
*/
|
||||
void show(Component origin, Point p) {
|
||||
WComponentPeer peer = (WComponentPeer) WToolkit.targetToPeer(origin);
|
||||
Event e = new Event(origin, 0, Event.MOUSE_DOWN, p.x, p.y, 0, 0);
|
||||
if (peer == null) {
|
||||
Component nativeOrigin = WToolkit.getNativeContainer(origin);
|
||||
e.target = nativeOrigin;
|
||||
}
|
||||
e.x = p.x;
|
||||
e.y = p.y;
|
||||
_show(e);
|
||||
}
|
||||
|
||||
private native void _show(Event e);
|
||||
}
|
||||
91
jdkSrc/jdk8/sun/awt/windows/WPrintDialog.java
Normal file
91
jdkSrc/jdk8/sun/awt/windows/WPrintDialog.java
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
|
||||
import java.awt.print.PrinterJob;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
class WPrintDialog extends Dialog {
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
protected PrintJob job;
|
||||
protected PrinterJob pjob;
|
||||
|
||||
WPrintDialog(Frame parent, PrinterJob control) {
|
||||
super(parent, true);
|
||||
this.pjob = control;
|
||||
setLayout(null);
|
||||
}
|
||||
|
||||
WPrintDialog(Dialog parent, PrinterJob control) {
|
||||
super(parent, "", true);
|
||||
this.pjob = control;
|
||||
setLayout(null);
|
||||
}
|
||||
|
||||
final void setPeer(final ComponentPeer p){
|
||||
AWTAccessor.getComponentAccessor().setPeer(this, p);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void addNotify() {
|
||||
synchronized(getTreeLock()) {
|
||||
Container parent = getParent();
|
||||
if (parent != null && parent.getPeer() == null) {
|
||||
parent.addNotify();
|
||||
}
|
||||
|
||||
if (getPeer() == null) {
|
||||
ComponentPeer peer = ((WToolkit)Toolkit.getDefaultToolkit()).
|
||||
createWPrintDialog(this);
|
||||
setPeer(peer);
|
||||
}
|
||||
super.addNotify();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean retval = false;
|
||||
|
||||
final void setRetVal(boolean ret) {
|
||||
retval = ret;
|
||||
}
|
||||
|
||||
final boolean getRetVal() {
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method ids
|
||||
*/
|
||||
private static native void initIDs();
|
||||
}
|
||||
200
jdkSrc/jdk8/sun/awt/windows/WPrintDialogPeer.java
Normal file
200
jdkSrc/jdk8/sun/awt/windows/WPrintDialogPeer.java
Normal file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.DialogPeer;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.util.Vector;
|
||||
import sun.awt.CausedFocusEvent;
|
||||
import sun.awt.AWTAccessor;
|
||||
|
||||
class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
private WComponentPeer parent;
|
||||
|
||||
private Vector<WWindowPeer> blockedWindows = new Vector<>();
|
||||
|
||||
WPrintDialogPeer(WPrintDialog target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
void create(WComponentPeer parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
// fix for CR 6178323:
|
||||
// don't use checkCreation() from WComponentPeer to avoid hwnd check
|
||||
@Override
|
||||
protected void checkCreation() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disposeImpl() {
|
||||
WToolkit.targetDisposedPeer(target, this);
|
||||
}
|
||||
|
||||
private native boolean _show();
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
((WPrintDialog)target).setRetVal(_show());
|
||||
} catch (Exception e) {
|
||||
// No exception should be thrown by native dialog code,
|
||||
// but if it is we need to trap it so the thread does
|
||||
// not hide is called and the thread doesn't hang.
|
||||
}
|
||||
((WPrintDialog)target).setVisible(false);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
synchronized void setHWnd(long hwnd) {
|
||||
this.hwnd = hwnd;
|
||||
for (WWindowPeer window : blockedWindows) {
|
||||
if (hwnd != 0) {
|
||||
window.modalDisable((Dialog)target, hwnd);
|
||||
} else {
|
||||
window.modalEnable((Dialog)target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
synchronized void blockWindow(WWindowPeer window) {
|
||||
blockedWindows.add(window);
|
||||
if (hwnd != 0) {
|
||||
window.modalDisable((Dialog)target, hwnd);
|
||||
}
|
||||
}
|
||||
synchronized void unblockWindow(WWindowPeer window) {
|
||||
blockedWindows.remove(window);
|
||||
if (hwnd != 0) {
|
||||
window.modalEnable((Dialog)target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blockWindows(java.util.List<Window> toBlock) {
|
||||
for (Window w : toBlock) {
|
||||
WWindowPeer wp = (WWindowPeer)AWTAccessor.getComponentAccessor().getPeer(w);
|
||||
if (wp != null) {
|
||||
blockWindow(wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public native void toFront();
|
||||
@Override
|
||||
public native void toBack();
|
||||
|
||||
// unused methods. Overridden to disable this functionality as
|
||||
// it requires HWND which is not available for FileDialog
|
||||
@Override
|
||||
void initialize() {}
|
||||
@Override
|
||||
public void updateAlwaysOnTopState() {}
|
||||
@Override
|
||||
public void setResizable(boolean resizable) {}
|
||||
@Override
|
||||
void hide() {}
|
||||
@Override
|
||||
void enable() {}
|
||||
@Override
|
||||
void disable() {}
|
||||
@Override
|
||||
public void reshape(int x, int y, int width, int height) {}
|
||||
public boolean handleEvent(Event e) { return false; }
|
||||
@Override
|
||||
public void setForeground(Color c) {}
|
||||
@Override
|
||||
public void setBackground(Color c) {}
|
||||
@Override
|
||||
public void setFont(Font f) {}
|
||||
@Override
|
||||
public void updateMinimumSize() {}
|
||||
@Override
|
||||
public void updateIconImages() {}
|
||||
public boolean requestFocus(boolean temporary, boolean focusedWindowChangeAllowed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestFocus
|
||||
(Component lightweightChild, boolean temporary,
|
||||
boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFocusableWindowState() {}
|
||||
@Override
|
||||
void start() {}
|
||||
@Override
|
||||
public void beginValidate() {}
|
||||
@Override
|
||||
public void endValidate() {}
|
||||
void invalidate(int x, int y, int width, int height) {}
|
||||
@Override
|
||||
public void addDropTarget(DropTarget dt) {}
|
||||
@Override
|
||||
public void removeDropTarget(DropTarget dt) {}
|
||||
@Override
|
||||
public void setZOrder(ComponentPeer above) {}
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method ids
|
||||
*/
|
||||
private static native void initIDs();
|
||||
|
||||
// The effects are not supported for system dialogs.
|
||||
@Override
|
||||
public void applyShape(sun.java2d.pipe.Region shape) {}
|
||||
@Override
|
||||
public void setOpacity(float opacity) {}
|
||||
@Override
|
||||
public void setOpaque(boolean isOpaque) {}
|
||||
public void updateWindow(java.awt.image.BufferedImage backBuffer) {}
|
||||
|
||||
// the file/print dialogs are native dialogs and
|
||||
// the native system does their own rendering
|
||||
@Override
|
||||
public void createScreenSurface(boolean isResize) {}
|
||||
@Override
|
||||
public void replaceSurfaceData() {}
|
||||
}
|
||||
2242
jdkSrc/jdk8/sun/awt/windows/WPrinterJob.java
Normal file
2242
jdkSrc/jdk8/sun/awt/windows/WPrinterJob.java
Normal file
File diff suppressed because it is too large
Load Diff
79
jdkSrc/jdk8/sun/awt/windows/WRobotPeer.java
Normal file
79
jdkSrc/jdk8/sun/awt/windows/WRobotPeer.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.RobotPeer;
|
||||
|
||||
final class WRobotPeer extends WObjectPeer implements RobotPeer
|
||||
{
|
||||
WRobotPeer() {
|
||||
create();
|
||||
}
|
||||
WRobotPeer(GraphicsDevice screen) {
|
||||
create();
|
||||
}
|
||||
|
||||
private synchronized native void _dispose();
|
||||
|
||||
@Override
|
||||
protected void disposeImpl() {
|
||||
_dispose();
|
||||
}
|
||||
|
||||
public native void create();
|
||||
public native void mouseMoveImpl(int x, int y);
|
||||
@Override
|
||||
public void mouseMove(int x, int y) {
|
||||
mouseMoveImpl(x, y);
|
||||
}
|
||||
@Override
|
||||
public native void mousePress(int buttons);
|
||||
@Override
|
||||
public native void mouseRelease(int buttons);
|
||||
@Override
|
||||
public native void mouseWheel(int wheelAmt);
|
||||
|
||||
@Override
|
||||
public native void keyPress( int keycode );
|
||||
@Override
|
||||
public native void keyRelease( int keycode );
|
||||
|
||||
@Override
|
||||
public int getRGBPixel(int x, int y) {
|
||||
// See 7002846: that's ineffective, but works correctly with non-opaque windows
|
||||
return getRGBPixels(new Rectangle(x, y, 1, 1))[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int [] getRGBPixels(Rectangle bounds) {
|
||||
int pixelArray[] = new int[bounds.width*bounds.height];
|
||||
getRGBPixels(bounds.x, bounds.y, bounds.width, bounds.height, pixelArray);
|
||||
return pixelArray;
|
||||
}
|
||||
|
||||
private native void getRGBPixels(int x, int y, int width, int height, int pixelArray[]);
|
||||
}
|
||||
284
jdkSrc/jdk8/sun/awt/windows/WScrollPanePeer.java
Normal file
284
jdkSrc/jdk8/sun/awt/windows/WScrollPanePeer.java
Normal file
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.AdjustmentEvent;
|
||||
import java.awt.peer.ScrollPanePeer;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.PeerEvent;
|
||||
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
final class WScrollPanePeer extends WPanelPeer implements ScrollPanePeer {
|
||||
|
||||
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WScrollPanePeer");
|
||||
|
||||
int scrollbarWidth;
|
||||
int scrollbarHeight;
|
||||
int prevx;
|
||||
int prevy;
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
static native void initIDs();
|
||||
@Override
|
||||
native void create(WComponentPeer parent);
|
||||
native int getOffset(int orient);
|
||||
|
||||
WScrollPanePeer(Component target) {
|
||||
super(target);
|
||||
scrollbarWidth = _getVScrollbarWidth();
|
||||
scrollbarHeight = _getHScrollbarHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
void initialize() {
|
||||
super.initialize();
|
||||
setInsets();
|
||||
Insets i = getInsets();
|
||||
setScrollPosition(-i.left,-i.top);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnitIncrement(Adjustable adj, int p) {
|
||||
// The unitIncrement is grabbed from the target as needed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets insets() {
|
||||
return getInsets();
|
||||
}
|
||||
private native void setInsets();
|
||||
|
||||
@Override
|
||||
public native synchronized void setScrollPosition(int x, int y);
|
||||
|
||||
@Override
|
||||
public int getHScrollbarHeight() {
|
||||
return scrollbarHeight;
|
||||
}
|
||||
private native int _getHScrollbarHeight();
|
||||
|
||||
@Override
|
||||
public int getVScrollbarWidth() {
|
||||
return scrollbarWidth;
|
||||
}
|
||||
private native int _getVScrollbarWidth();
|
||||
|
||||
public Point getScrollOffset() {
|
||||
int x = getOffset(Adjustable.HORIZONTAL);
|
||||
int y = getOffset(Adjustable.VERTICAL);
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* The child component has been resized. The scrollbars must be
|
||||
* updated with the new sizes. At the native level the sizes of
|
||||
* the actual windows may not have changed yet, so the size
|
||||
* information from the java-level is passed down and used.
|
||||
*/
|
||||
@Override
|
||||
public void childResized(int width, int height) {
|
||||
ScrollPane sp = (ScrollPane)target;
|
||||
Dimension vs = sp.getSize();
|
||||
setSpans(vs.width, vs.height, width, height);
|
||||
setInsets();
|
||||
}
|
||||
|
||||
native synchronized void setSpans(int viewWidth, int viewHeight,
|
||||
int childWidth, int childHeight);
|
||||
|
||||
/**
|
||||
* Called by ScrollPane's internal observer of the scrollpane's adjustables.
|
||||
* This is called whenever a scroll position is changed in one
|
||||
* of adjustables, whether it was modified externally or from the
|
||||
* native scrollbars themselves.
|
||||
*/
|
||||
@Override
|
||||
public void setValue(Adjustable adj, int v) {
|
||||
Component c = getScrollChild();
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Point p = c.getLocation();
|
||||
switch(adj.getOrientation()) {
|
||||
case Adjustable.VERTICAL:
|
||||
setScrollPosition(-(p.x), v);
|
||||
break;
|
||||
case Adjustable.HORIZONTAL:
|
||||
setScrollPosition(v, -(p.y));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Component getScrollChild() {
|
||||
ScrollPane sp = (ScrollPane)target;
|
||||
Component child = null;
|
||||
try {
|
||||
child = sp.getComponent(0);
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
// do nothing. in this case we return null
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called from Windows in response to WM_VSCROLL/WM_HSCROLL message
|
||||
*/
|
||||
private void postScrollEvent(int orient, int type,
|
||||
int pos, boolean isAdjusting)
|
||||
{
|
||||
Runnable adjustor = new Adjustor(orient, type, pos, isAdjusting);
|
||||
WToolkit.executeOnEventHandlerThread(new ScrollEvent(target, adjustor));
|
||||
}
|
||||
|
||||
/*
|
||||
* Event that executes on the Java dispatch thread to move the
|
||||
* scroll bar thumbs and paint the exposed area in one synchronous
|
||||
* operation.
|
||||
*/
|
||||
class ScrollEvent extends PeerEvent {
|
||||
ScrollEvent(Object source, Runnable runnable) {
|
||||
super(source, runnable, 0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PeerEvent coalesceEvents(PeerEvent newEvent) {
|
||||
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
|
||||
log.finest("ScrollEvent coalesced: " + newEvent);
|
||||
}
|
||||
if (newEvent instanceof ScrollEvent) {
|
||||
return newEvent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Runnable for the ScrollEvent that performs the adjustment.
|
||||
*/
|
||||
class Adjustor implements Runnable {
|
||||
int orient; // selects scrollbar
|
||||
int type; // adjustment type
|
||||
int pos; // new position (only used for absolute)
|
||||
boolean isAdjusting; // isAdjusting status
|
||||
|
||||
Adjustor(int orient, int type, int pos, boolean isAdjusting) {
|
||||
this.orient = orient;
|
||||
this.type = type;
|
||||
this.pos = pos;
|
||||
this.isAdjusting = isAdjusting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (getScrollChild() == null) {
|
||||
return;
|
||||
}
|
||||
ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
|
||||
ScrollPaneAdjustable adj = null;
|
||||
|
||||
// ScrollPaneAdjustable made public in 1.4, but
|
||||
// get[HV]Adjustable can't be declared to return
|
||||
// ScrollPaneAdjustable because it would break backward
|
||||
// compatibility -- hence the cast
|
||||
|
||||
if (orient == Adjustable.VERTICAL) {
|
||||
adj = (ScrollPaneAdjustable)sp.getVAdjustable();
|
||||
} else if (orient == Adjustable.HORIZONTAL) {
|
||||
adj = (ScrollPaneAdjustable)sp.getHAdjustable();
|
||||
} else {
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine("Assertion failed: unknown orient");
|
||||
}
|
||||
}
|
||||
|
||||
if (adj == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int newpos = adj.getValue();
|
||||
switch (type) {
|
||||
case AdjustmentEvent.UNIT_DECREMENT:
|
||||
newpos -= adj.getUnitIncrement();
|
||||
break;
|
||||
case AdjustmentEvent.UNIT_INCREMENT:
|
||||
newpos += adj.getUnitIncrement();
|
||||
break;
|
||||
case AdjustmentEvent.BLOCK_DECREMENT:
|
||||
newpos -= adj.getBlockIncrement();
|
||||
break;
|
||||
case AdjustmentEvent.BLOCK_INCREMENT:
|
||||
newpos += adj.getBlockIncrement();
|
||||
break;
|
||||
case AdjustmentEvent.TRACK:
|
||||
newpos = this.pos;
|
||||
break;
|
||||
default:
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine("Assertion failed: unknown type");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// keep scroll position in acceptable range
|
||||
newpos = Math.max(adj.getMinimum(), newpos);
|
||||
newpos = Math.min(adj.getMaximum(), newpos);
|
||||
|
||||
// set value, this will synchronously fire an AdjustmentEvent
|
||||
adj.setValueIsAdjusting(isAdjusting);
|
||||
|
||||
// Fix for 4075484 - consider type information when creating AdjustmentEvent
|
||||
// We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
|
||||
// Instead, we call private method setTypedValue of ScrollPaneAdjustable.
|
||||
AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
|
||||
newpos,
|
||||
type);
|
||||
|
||||
// Paint the exposed area right away. To do this - find
|
||||
// the heavyweight ancestor of the scroll child.
|
||||
Component hwAncestor = getScrollChild();
|
||||
while (hwAncestor != null
|
||||
&& !(hwAncestor.getPeer() instanceof WComponentPeer))
|
||||
{
|
||||
hwAncestor = hwAncestor.getParent();
|
||||
}
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
if (hwAncestor == null) {
|
||||
log.fine("Assertion (hwAncestor != null) failed, " +
|
||||
"couldn't find heavyweight ancestor of scroll pane child");
|
||||
}
|
||||
}
|
||||
WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
|
||||
hwPeer.paintDamagedAreaImmediately();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
142
jdkSrc/jdk8/sun/awt/windows/WScrollbarPeer.java
Normal file
142
jdkSrc/jdk8/sun/awt/windows/WScrollbarPeer.java
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import java.awt.event.AdjustmentEvent;
|
||||
|
||||
final class WScrollbarPeer extends WComponentPeer implements ScrollbarPeer {
|
||||
|
||||
// Returns width for vertial scrollbar as SM_CXHSCROLL,
|
||||
// height for horizontal scrollbar as SM_CYVSCROLL
|
||||
static native int getScrollbarSize(int orientation);
|
||||
|
||||
// ComponentPeer overrides
|
||||
public Dimension getMinimumSize() {
|
||||
if (((Scrollbar)target).getOrientation() == Scrollbar.VERTICAL) {
|
||||
return new Dimension(getScrollbarSize(Scrollbar.VERTICAL), 50);
|
||||
}
|
||||
else {
|
||||
return new Dimension(50, getScrollbarSize(Scrollbar.HORIZONTAL));
|
||||
}
|
||||
}
|
||||
|
||||
// ScrollbarPeer implementation
|
||||
|
||||
public native void setValues(int value, int visible,
|
||||
int minimum, int maximum);
|
||||
public native void setLineIncrement(int l);
|
||||
public native void setPageIncrement(int l);
|
||||
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WScrollbarPeer(Scrollbar target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
native void create(WComponentPeer parent);
|
||||
|
||||
void initialize() {
|
||||
Scrollbar sb = (Scrollbar)target;
|
||||
setValues(sb.getValue(), sb.getVisibleAmount(),
|
||||
sb.getMinimum(), sb.getMaximum());
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
|
||||
// NOTE: Callback methods are called by privileged threads.
|
||||
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
|
||||
|
||||
private void postAdjustmentEvent(final int type, final int value,
|
||||
final boolean isAdjusting)
|
||||
{
|
||||
final Scrollbar sb = (Scrollbar)target;
|
||||
WToolkit.executeOnEventHandlerThread(sb, new Runnable() {
|
||||
public void run() {
|
||||
sb.setValueIsAdjusting(isAdjusting);
|
||||
sb.setValue(value);
|
||||
postEvent(new AdjustmentEvent(sb,
|
||||
AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
|
||||
type, value, isAdjusting));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void lineUp(int value) {
|
||||
postAdjustmentEvent(AdjustmentEvent.UNIT_DECREMENT, value, false);
|
||||
}
|
||||
|
||||
void lineDown(int value) {
|
||||
postAdjustmentEvent(AdjustmentEvent.UNIT_INCREMENT, value, false);
|
||||
}
|
||||
|
||||
void pageUp(int value) {
|
||||
postAdjustmentEvent(AdjustmentEvent.BLOCK_DECREMENT, value, false);
|
||||
}
|
||||
|
||||
void pageDown(int value) {
|
||||
postAdjustmentEvent(AdjustmentEvent.BLOCK_INCREMENT, value, false);
|
||||
}
|
||||
|
||||
// SB_TOP/BOTTOM are mapped to tracking
|
||||
void warp(int value) {
|
||||
postAdjustmentEvent(AdjustmentEvent.TRACK, value, false);
|
||||
}
|
||||
|
||||
private boolean dragInProgress = false;
|
||||
|
||||
void drag(final int value) {
|
||||
if (!dragInProgress) {
|
||||
dragInProgress = true;
|
||||
}
|
||||
postAdjustmentEvent(AdjustmentEvent.TRACK, value, true);
|
||||
}
|
||||
|
||||
void dragEnd(final int value) {
|
||||
final Scrollbar sb = (Scrollbar)target;
|
||||
|
||||
if (!dragInProgress) {
|
||||
return;
|
||||
}
|
||||
|
||||
dragInProgress = false;
|
||||
WToolkit.executeOnEventHandlerThread(sb, new Runnable() {
|
||||
public void run() {
|
||||
// NB: notification only, no sb.setValue()
|
||||
// last TRACK event will have done it already
|
||||
sb.setValueIsAdjusting(false);
|
||||
postEvent(new AdjustmentEvent(sb,
|
||||
AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
|
||||
AdjustmentEvent.TRACK, value, false));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean shouldClearRectBeforePaint() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
50
jdkSrc/jdk8/sun/awt/windows/WSystemTrayPeer.java
Normal file
50
jdkSrc/jdk8/sun/awt/windows/WSystemTrayPeer.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.SystemTray;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.peer.SystemTrayPeer;
|
||||
|
||||
final class WSystemTrayPeer extends WObjectPeer implements SystemTrayPeer {
|
||||
WSystemTrayPeer(SystemTray target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getTrayIconSize() {
|
||||
return new Dimension(WTrayIconPeer.TRAY_ICON_WIDTH, WTrayIconPeer.TRAY_ICON_HEIGHT);
|
||||
}
|
||||
|
||||
public boolean isSupported() {
|
||||
return ((WToolkit)Toolkit.getDefaultToolkit()).isTraySupported();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disposeImpl() {
|
||||
}
|
||||
}
|
||||
76
jdkSrc/jdk8/sun/awt/windows/WTextAreaPeer.java
Normal file
76
jdkSrc/jdk8/sun/awt/windows/WTextAreaPeer.java
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import java.awt.im.InputMethodRequests;
|
||||
|
||||
|
||||
final class WTextAreaPeer extends WTextComponentPeer implements TextAreaPeer {
|
||||
|
||||
// WComponentPeer overrides
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return getMinimumSize(10, 60);
|
||||
}
|
||||
|
||||
// TextAreaPeer implementation
|
||||
|
||||
@Override
|
||||
public void insert(String text, int pos) {
|
||||
replaceRange(text, pos, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public native void replaceRange(String text, int start, int end);
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize(int rows, int cols) {
|
||||
return getMinimumSize(rows, cols);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize(int rows, int cols) {
|
||||
FontMetrics fm = getFontMetrics(((TextArea)target).getFont());
|
||||
return new Dimension(fm.charWidth('0') * cols + 20, fm.getHeight() * rows + 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputMethodRequests getInputMethodRequests() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WTextAreaPeer(TextArea target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
native void create(WComponentPeer parent);
|
||||
}
|
||||
119
jdkSrc/jdk8/sun/awt/windows/WTextComponentPeer.java
Normal file
119
jdkSrc/jdk8/sun/awt/windows/WTextComponentPeer.java
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import java.awt.event.TextEvent;
|
||||
|
||||
abstract
|
||||
class WTextComponentPeer extends WComponentPeer implements TextComponentPeer {
|
||||
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
// TextComponentPeer implementation
|
||||
|
||||
@Override
|
||||
public void setEditable(boolean editable) {
|
||||
enableEditing(editable);
|
||||
setBackground(((TextComponent)target).getBackground());
|
||||
}
|
||||
@Override
|
||||
public native String getText();
|
||||
@Override
|
||||
public native void setText(String text);
|
||||
@Override
|
||||
public native int getSelectionStart();
|
||||
@Override
|
||||
public native int getSelectionEnd();
|
||||
@Override
|
||||
public native void select(int selStart, int selEnd);
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WTextComponentPeer(TextComponent target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
void initialize() {
|
||||
TextComponent tc = (TextComponent)target;
|
||||
String text = tc.getText();
|
||||
|
||||
if (text != null) {
|
||||
setText(text);
|
||||
}
|
||||
select(tc.getSelectionStart(), tc.getSelectionEnd());
|
||||
setEditable(tc.isEditable());
|
||||
|
||||
super.initialize();
|
||||
}
|
||||
|
||||
native void enableEditing(boolean e);
|
||||
|
||||
@Override
|
||||
public boolean isFocusable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the caret position by doing an empty selection. This
|
||||
* unfortunately resets the selection, but seems to be the
|
||||
* only way to get this to work.
|
||||
*/
|
||||
@Override
|
||||
public void setCaretPosition(int pos) {
|
||||
select(pos,pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the caret position by looking up the end of the current
|
||||
* selection.
|
||||
*/
|
||||
@Override
|
||||
public int getCaretPosition() {
|
||||
return getSelectionStart();
|
||||
}
|
||||
|
||||
/*
|
||||
* Post a new TextEvent when the value of a text component changes.
|
||||
*/
|
||||
public void valueChanged() {
|
||||
postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method IDs
|
||||
*/
|
||||
private static native void initIDs();
|
||||
|
||||
@Override
|
||||
public boolean shouldClearRectBeforePaint() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
97
jdkSrc/jdk8/sun/awt/windows/WTextFieldPeer.java
Normal file
97
jdkSrc/jdk8/sun/awt/windows/WTextFieldPeer.java
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.peer.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.im.InputMethodRequests;
|
||||
|
||||
final class WTextFieldPeer extends WTextComponentPeer implements TextFieldPeer {
|
||||
|
||||
// WComponentPeer overrides
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
FontMetrics fm = getFontMetrics(((TextField)target).getFont());
|
||||
return new Dimension(fm.stringWidth(getText()) + 24,
|
||||
fm.getHeight() + 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleJavaKeyEvent(KeyEvent e) {
|
||||
switch (e.getID()) {
|
||||
case KeyEvent.KEY_TYPED:
|
||||
if ((e.getKeyChar() == '\n') && !e.isAltDown() && !e.isControlDown()) {
|
||||
postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
|
||||
getText(), e.getWhen(), e.getModifiers()));
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// TextFieldPeer implementation
|
||||
|
||||
@Override
|
||||
public native void setEchoChar(char echoChar);
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize(int cols) {
|
||||
return getMinimumSize(cols);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize(int cols) {
|
||||
FontMetrics fm = getFontMetrics(((TextField)target).getFont());
|
||||
return new Dimension(fm.charWidth('0') * cols + 24, fm.getHeight() + 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputMethodRequests getInputMethodRequests() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WTextFieldPeer(TextField target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
native void create(WComponentPeer parent);
|
||||
|
||||
@Override
|
||||
void initialize() {
|
||||
TextField tf = (TextField)target;
|
||||
if (tf.echoCharIsSet()) {
|
||||
setEchoChar(tf.getEchoChar());
|
||||
}
|
||||
super.initialize();
|
||||
}
|
||||
}
|
||||
1253
jdkSrc/jdk8/sun/awt/windows/WToolkit.java
Normal file
1253
jdkSrc/jdk8/sun/awt/windows/WToolkit.java
Normal file
File diff suppressed because it is too large
Load Diff
208
jdkSrc/jdk8/sun/awt/windows/WTrayIconPeer.java
Normal file
208
jdkSrc/jdk8/sun/awt/windows/WTrayIconPeer.java
Normal file
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Frame;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.Point;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.Image;
|
||||
import java.awt.peer.TrayIconPeer;
|
||||
import java.awt.image.*;
|
||||
import sun.awt.SunToolkit;
|
||||
import sun.awt.image.IntegerComponentRaster;
|
||||
|
||||
final class WTrayIconPeer extends WObjectPeer implements TrayIconPeer {
|
||||
final static int TRAY_ICON_WIDTH = 16;
|
||||
final static int TRAY_ICON_HEIGHT = 16;
|
||||
final static int TRAY_ICON_MASK_SIZE = (TRAY_ICON_WIDTH * TRAY_ICON_HEIGHT) / 8;
|
||||
|
||||
IconObserver observer = new IconObserver();
|
||||
boolean firstUpdate = true;
|
||||
Frame popupParent = new Frame("PopupMessageWindow");
|
||||
PopupMenu popup;
|
||||
|
||||
@Override
|
||||
protected void disposeImpl() {
|
||||
if (popupParent != null) {
|
||||
popupParent.dispose();
|
||||
}
|
||||
popupParent.dispose();
|
||||
_dispose();
|
||||
WToolkit.targetDisposedPeer(target, this);
|
||||
}
|
||||
|
||||
WTrayIconPeer(TrayIcon target) {
|
||||
this.target = target;
|
||||
popupParent.addNotify();
|
||||
create();
|
||||
updateImage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateImage() {
|
||||
Image image = ((TrayIcon)target).getImage();
|
||||
if (image != null) {
|
||||
updateNativeImage(image);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public native void setToolTip(String tooltip);
|
||||
|
||||
@Override
|
||||
public synchronized void showPopupMenu(final int x, final int y) {
|
||||
if (isDisposed())
|
||||
return;
|
||||
|
||||
SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PopupMenu newPopup = ((TrayIcon)target).getPopupMenu();
|
||||
if (popup != newPopup) {
|
||||
if (popup != null) {
|
||||
popupParent.remove(popup);
|
||||
}
|
||||
if (newPopup != null) {
|
||||
popupParent.add(newPopup);
|
||||
}
|
||||
popup = newPopup;
|
||||
}
|
||||
if (popup != null) {
|
||||
((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayMessage(String caption, String text, String messageType) {
|
||||
// The situation when both caption and text are null is processed in the shared code.
|
||||
if (caption == null) {
|
||||
caption = "";
|
||||
}
|
||||
if (text == null) {
|
||||
text = "";
|
||||
}
|
||||
_displayMessage(caption, text, messageType);
|
||||
}
|
||||
|
||||
|
||||
// ***********************************************
|
||||
// ***********************************************
|
||||
|
||||
|
||||
synchronized void updateNativeImage(Image image) {
|
||||
if (isDisposed())
|
||||
return;
|
||||
|
||||
boolean autosize = ((TrayIcon)target).isImageAutoSize();
|
||||
|
||||
BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT,
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D gr = bufImage.createGraphics();
|
||||
if (gr != null) {
|
||||
try {
|
||||
gr.setPaintMode();
|
||||
|
||||
gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)),
|
||||
(autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer);
|
||||
|
||||
createNativeImage(bufImage);
|
||||
|
||||
updateNativeIcon(!firstUpdate);
|
||||
if (firstUpdate) firstUpdate = false;
|
||||
|
||||
} finally {
|
||||
gr.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void createNativeImage(BufferedImage bimage) {
|
||||
Raster raster = bimage.getRaster();
|
||||
byte[] andMask = new byte[TRAY_ICON_MASK_SIZE];
|
||||
int pixels[] = ((DataBufferInt)raster.getDataBuffer()).getData();
|
||||
int npixels = pixels.length;
|
||||
int ficW = raster.getWidth();
|
||||
|
||||
for (int i = 0; i < npixels; i++) {
|
||||
int ibyte = i / 8;
|
||||
int omask = 1 << (7 - (i % 8));
|
||||
|
||||
if ((pixels[i] & 0xff000000) == 0) {
|
||||
// Transparent bit
|
||||
if (ibyte < andMask.length) {
|
||||
andMask[ibyte] |= omask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (raster instanceof IntegerComponentRaster) {
|
||||
ficW = ((IntegerComponentRaster)raster).getScanlineStride();
|
||||
}
|
||||
setNativeIcon(((DataBufferInt)bimage.getRaster().getDataBuffer()).getData(),
|
||||
andMask, ficW, raster.getWidth(), raster.getHeight());
|
||||
}
|
||||
|
||||
void postEvent(AWTEvent event) {
|
||||
WToolkit.postEvent(WToolkit.targetToAppContext(target), event);
|
||||
}
|
||||
|
||||
native void create();
|
||||
synchronized native void _dispose();
|
||||
|
||||
/*
|
||||
* Updates/adds the icon in/to the system tray.
|
||||
* @param doUpdate if <code>true</code>, updates the icon,
|
||||
* otherwise, adds the icon
|
||||
*/
|
||||
native void updateNativeIcon(boolean doUpdate);
|
||||
|
||||
native void setNativeIcon(int[] rData, byte[] andMask, int nScanStride,
|
||||
int width, int height);
|
||||
|
||||
native void _displayMessage(String caption, String text, String messageType);
|
||||
|
||||
class IconObserver implements ImageObserver {
|
||||
@Override
|
||||
public boolean imageUpdate(Image image, int flags, int x, int y, int width, int height) {
|
||||
if (image != ((TrayIcon)target).getImage() || // if the image has been changed
|
||||
isDisposed())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((flags & (ImageObserver.FRAMEBITS | ImageObserver.ALLBITS |
|
||||
ImageObserver.WIDTH | ImageObserver.HEIGHT)) != 0)
|
||||
{
|
||||
updateNativeImage(image);
|
||||
}
|
||||
return (flags & ImageObserver.ALLBITS) == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
869
jdkSrc/jdk8/sun/awt/windows/WWindowPeer.java
Normal file
869
jdkSrc/jdk8/sun/awt/windows/WWindowPeer.java
Normal file
@@ -0,0 +1,869 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2020, 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 sun.awt.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.peer.*;
|
||||
|
||||
import java.beans.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import sun.awt.*;
|
||||
|
||||
import sun.java2d.pipe.Region;
|
||||
|
||||
public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
DisplayChangedListener
|
||||
{
|
||||
|
||||
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WWindowPeer");
|
||||
private static final PlatformLogger screenLog = PlatformLogger.getLogger("sun.awt.windows.screen.WWindowPeer");
|
||||
|
||||
// we can't use WDialogPeer as blocker may be an instance of WPrintDialogPeer that
|
||||
// extends WWindowPeer, not WDialogPeer
|
||||
private WWindowPeer modalBlocker = null;
|
||||
|
||||
private boolean isOpaque;
|
||||
|
||||
private TranslucentWindowPainter painter;
|
||||
|
||||
/*
|
||||
* A key used for storing a list of active windows in AppContext. The value
|
||||
* is a list of windows, sorted by the time of activation: later a window is
|
||||
* activated, greater its index is in the list.
|
||||
*/
|
||||
private final static StringBuffer ACTIVE_WINDOWS_KEY =
|
||||
new StringBuffer("active_windows_list");
|
||||
|
||||
/*
|
||||
* Listener for 'activeWindow' KFM property changes. It is added to each
|
||||
* AppContext KFM. See ActiveWindowListener inner class below.
|
||||
*/
|
||||
private static PropertyChangeListener activeWindowListener =
|
||||
new ActiveWindowListener();
|
||||
|
||||
/*
|
||||
* The object is a listener for the AppContext.GUI_DISPOSED property.
|
||||
*/
|
||||
private final static PropertyChangeListener guiDisposedListener =
|
||||
new GuiDisposedListener();
|
||||
|
||||
/*
|
||||
* Called (on the Toolkit thread) before the appropriate
|
||||
* WindowStateEvent is posted to the EventQueue.
|
||||
*/
|
||||
private WindowListener windowListener;
|
||||
|
||||
/**
|
||||
* Initialize JNI field IDs
|
||||
*/
|
||||
private static native void initIDs();
|
||||
static {
|
||||
initIDs();
|
||||
}
|
||||
|
||||
// WComponentPeer overrides
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void disposeImpl() {
|
||||
AppContext appContext = SunToolkit.targetToAppContext(target);
|
||||
synchronized (appContext) {
|
||||
List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY);
|
||||
if (l != null) {
|
||||
l.remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove ourself from the Map of DisplayChangeListeners
|
||||
GraphicsConfiguration gc = getGraphicsConfiguration();
|
||||
((Win32GraphicsDevice)gc.getDevice()).removeDisplayChangedListener(this);
|
||||
|
||||
synchronized (getStateLock()) {
|
||||
TranslucentWindowPainter currentPainter = painter;
|
||||
if (currentPainter != null) {
|
||||
currentPainter.flush();
|
||||
// don't set the current one to null here; reduces the chances of
|
||||
// MT issues (like NPEs)
|
||||
}
|
||||
}
|
||||
|
||||
super.disposeImpl();
|
||||
}
|
||||
|
||||
// WindowPeer implementation
|
||||
|
||||
@Override
|
||||
public void toFront() {
|
||||
updateFocusableWindowState();
|
||||
_toFront();
|
||||
}
|
||||
private native void _toFront();
|
||||
|
||||
@Override
|
||||
public native void toBack();
|
||||
|
||||
private native void setAlwaysOnTopNative(boolean value);
|
||||
|
||||
public void setAlwaysOnTop(boolean value) {
|
||||
if ((value && ((Window)target).isVisible()) || !value) {
|
||||
setAlwaysOnTopNative(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAlwaysOnTopState() {
|
||||
setAlwaysOnTop(((Window)target).isAlwaysOnTop());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFocusableWindowState() {
|
||||
setFocusableWindow(((Window)target).isFocusableWindow());
|
||||
}
|
||||
native void setFocusableWindow(boolean value);
|
||||
|
||||
// FramePeer & DialogPeer partial shared implementation
|
||||
|
||||
public void setTitle(String title) {
|
||||
// allow a null title to pass as an empty string.
|
||||
if (title == null) {
|
||||
title = "";
|
||||
}
|
||||
_setTitle(title);
|
||||
}
|
||||
private native void _setTitle(String title);
|
||||
|
||||
public void setResizable(boolean resizable) {
|
||||
_setResizable(resizable);
|
||||
}
|
||||
|
||||
private native void _setResizable(boolean resizable);
|
||||
|
||||
// Toolkit & peer internals
|
||||
|
||||
WWindowPeer(Window target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
void initialize() {
|
||||
super.initialize();
|
||||
|
||||
updateInsets(insets_);
|
||||
|
||||
Font f = ((Window)target).getFont();
|
||||
if (f == null) {
|
||||
f = defaultFont;
|
||||
((Window)target).setFont(f);
|
||||
setFont(f);
|
||||
}
|
||||
// Express our interest in display changes
|
||||
GraphicsConfiguration gc = getGraphicsConfiguration();
|
||||
((Win32GraphicsDevice)gc.getDevice()).addDisplayChangedListener(this);
|
||||
|
||||
initActiveWindowsTracking((Window)target);
|
||||
|
||||
updateIconImages();
|
||||
|
||||
Shape shape = ((Window)target).getShape();
|
||||
if (shape != null) {
|
||||
applyShape(Region.getInstance(shape, null));
|
||||
}
|
||||
|
||||
float opacity = ((Window)target).getOpacity();
|
||||
if (opacity < 1.0f) {
|
||||
setOpacity(opacity);
|
||||
}
|
||||
|
||||
synchronized (getStateLock()) {
|
||||
// default value of a boolean field is 'false', so set isOpaque to
|
||||
// true here explicitly
|
||||
this.isOpaque = true;
|
||||
setOpaque(((Window)target).isOpaque());
|
||||
}
|
||||
}
|
||||
|
||||
native void createAwtWindow(WComponentPeer parent);
|
||||
|
||||
private volatile Window.Type windowType = Window.Type.NORMAL;
|
||||
|
||||
// This method must be called for Window, Dialog, and Frame before creating
|
||||
// the hwnd
|
||||
void preCreate(WComponentPeer parent) {
|
||||
windowType = ((Window)target).getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
void create(WComponentPeer parent) {
|
||||
preCreate(parent);
|
||||
createAwtWindow(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
final WComponentPeer getNativeParent() {
|
||||
final Container owner = ((Window) target).getOwner();
|
||||
return (WComponentPeer) WToolkit.targetToPeer(owner);
|
||||
}
|
||||
|
||||
// should be overriden in WDialogPeer
|
||||
protected void realShow() {
|
||||
super.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
updateFocusableWindowState();
|
||||
|
||||
boolean alwaysOnTop = ((Window)target).isAlwaysOnTop();
|
||||
|
||||
// Fix for 4868278.
|
||||
// If we create a window with a specific GraphicsConfig, and then move it with
|
||||
// setLocation() or setBounds() to another one before its peer has been created,
|
||||
// then calling Window.getGraphicsConfig() returns wrong config. That may lead
|
||||
// to some problems like wrong-placed tooltips. It is caused by calling
|
||||
// super.displayChanged() in WWindowPeer.displayChanged() regardless of whether
|
||||
// GraphicsDevice was really changed, or not. So we need to track it here.
|
||||
updateGC();
|
||||
|
||||
realShow();
|
||||
updateMinimumSize();
|
||||
|
||||
if (((Window)target).isAlwaysOnTopSupported() && alwaysOnTop) {
|
||||
setAlwaysOnTop(alwaysOnTop);
|
||||
}
|
||||
|
||||
synchronized (getStateLock()) {
|
||||
if (!isOpaque) {
|
||||
updateWindow(true);
|
||||
}
|
||||
}
|
||||
|
||||
// See https://javafx-jira.kenai.com/browse/RT-32570
|
||||
WComponentPeer owner = getNativeParent();
|
||||
if (owner != null && owner.isLightweightFramePeer()) {
|
||||
Rectangle b = getBounds();
|
||||
handleExpose(0, 0, b.width, b.height);
|
||||
}
|
||||
}
|
||||
|
||||
// Synchronize the insets members (here & in helper) with actual window
|
||||
// state.
|
||||
native void updateInsets(Insets i);
|
||||
|
||||
static native int getSysMinWidth();
|
||||
static native int getSysMinHeight();
|
||||
static native int getSysIconWidth();
|
||||
static native int getSysIconHeight();
|
||||
static native int getSysSmIconWidth();
|
||||
static native int getSysSmIconHeight();
|
||||
/**windows/classes/sun/awt/windows/
|
||||
* Creates native icon from specified raster data and updates
|
||||
* icon for window and all descendant windows that inherit icon.
|
||||
* Raster data should be passed in the ARGB form.
|
||||
* Note that raster data format was changed to provide support
|
||||
* for XP icons with alpha-channel
|
||||
*/
|
||||
native void setIconImagesData(int[] iconRaster, int w, int h,
|
||||
int[] smallIconRaster, int smw, int smh);
|
||||
|
||||
synchronized native void reshapeFrame(int x, int y, int width, int height);
|
||||
|
||||
public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
|
||||
if (!focusAllowedFor()) {
|
||||
return false;
|
||||
}
|
||||
return requestWindowFocus(cause == CausedFocusEvent.Cause.MOUSE_EVENT);
|
||||
}
|
||||
private native boolean requestWindowFocus(boolean isMouseEventCause);
|
||||
|
||||
public boolean focusAllowedFor() {
|
||||
Window window = (Window)this.target;
|
||||
if (!window.isVisible() ||
|
||||
!window.isEnabled() ||
|
||||
!window.isFocusableWindow())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (isModalBlocked()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
void hide() {
|
||||
WindowListener listener = windowListener;
|
||||
if (listener != null) {
|
||||
// We're not getting WINDOW_CLOSING from the native code when hiding
|
||||
// the window programmatically. So, create it and notify the listener.
|
||||
listener.windowClosing(new WindowEvent((Window)target, WindowEvent.WINDOW_CLOSING));
|
||||
}
|
||||
super.hide();
|
||||
}
|
||||
|
||||
// WARNING: it's called on the Toolkit thread!
|
||||
@Override
|
||||
void preprocessPostEvent(AWTEvent event) {
|
||||
if (event instanceof WindowEvent) {
|
||||
WindowListener listener = windowListener;
|
||||
if (listener != null) {
|
||||
switch(event.getID()) {
|
||||
case WindowEvent.WINDOW_CLOSING:
|
||||
listener.windowClosing((WindowEvent)event);
|
||||
break;
|
||||
case WindowEvent.WINDOW_ICONIFIED:
|
||||
listener.windowIconified((WindowEvent)event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyWindowStateChanged(int oldState, int newState) {
|
||||
int changed = oldState ^ newState;
|
||||
if (changed == 0) {
|
||||
return;
|
||||
}
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine("Reporting state change %x -> %x", oldState, newState);
|
||||
}
|
||||
|
||||
if (target instanceof Frame) {
|
||||
// Sync target with peer.
|
||||
AWTAccessor.getFrameAccessor().setExtendedState((Frame) target,
|
||||
newState);
|
||||
}
|
||||
|
||||
// Report (de)iconification to old clients.
|
||||
if ((changed & Frame.ICONIFIED) > 0) {
|
||||
if ((newState & Frame.ICONIFIED) > 0) {
|
||||
postEvent(new TimedWindowEvent((Window) target,
|
||||
WindowEvent.WINDOW_ICONIFIED, null, 0, 0,
|
||||
System.currentTimeMillis()));
|
||||
} else {
|
||||
postEvent(new TimedWindowEvent((Window) target,
|
||||
WindowEvent.WINDOW_DEICONIFIED, null, 0, 0,
|
||||
System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
|
||||
// New (since 1.4) state change event.
|
||||
postEvent(new TimedWindowEvent((Window) target,
|
||||
WindowEvent.WINDOW_STATE_CHANGED, null, oldState, newState,
|
||||
System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
synchronized void addWindowListener(WindowListener l) {
|
||||
windowListener = AWTEventMulticaster.add(windowListener, l);
|
||||
}
|
||||
|
||||
synchronized void removeWindowListener(WindowListener l) {
|
||||
windowListener = AWTEventMulticaster.remove(windowListener, l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMinimumSize() {
|
||||
Dimension minimumSize = null;
|
||||
if (((Component)target).isMinimumSizeSet()) {
|
||||
minimumSize = ((Component)target).getMinimumSize();
|
||||
}
|
||||
if (minimumSize != null) {
|
||||
int msw = getSysMinWidth();
|
||||
int msh = getSysMinHeight();
|
||||
int w = (minimumSize.width >= msw) ? minimumSize.width : msw;
|
||||
int h = (minimumSize.height >= msh) ? minimumSize.height : msh;
|
||||
setMinSize(w, h);
|
||||
} else {
|
||||
setMinSize(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateIconImages() {
|
||||
java.util.List<Image> imageList = ((Window)target).getIconImages();
|
||||
if (imageList == null || imageList.size() == 0) {
|
||||
setIconImagesData(null, 0, 0, null, 0, 0);
|
||||
} else {
|
||||
int w = getSysIconWidth();
|
||||
int h = getSysIconHeight();
|
||||
int smw = getSysSmIconWidth();
|
||||
int smh = getSysSmIconHeight();
|
||||
DataBufferInt iconData = SunToolkit.getScaledIconData(imageList,
|
||||
w, h);
|
||||
DataBufferInt iconSmData = SunToolkit.getScaledIconData(imageList,
|
||||
smw, smh);
|
||||
if (iconData != null && iconSmData != null) {
|
||||
setIconImagesData(iconData.getData(), w, h,
|
||||
iconSmData.getData(), smw, smh);
|
||||
} else {
|
||||
setIconImagesData(null, 0, 0, null, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
native void setMinSize(int width, int height);
|
||||
|
||||
/*
|
||||
* ---- MODALITY SUPPORT ----
|
||||
*/
|
||||
|
||||
/**
|
||||
* Some modality-related code here because WFileDialogPeer, WPrintDialogPeer and
|
||||
* WPageDialogPeer are descendants of WWindowPeer, not WDialogPeer
|
||||
*/
|
||||
|
||||
public boolean isModalBlocked() {
|
||||
return modalBlocker != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setModalBlocked(Dialog dialog, boolean blocked) {
|
||||
synchronized (((Component)getTarget()).getTreeLock()) // State lock should always be after awtLock
|
||||
{
|
||||
// use WWindowPeer instead of WDialogPeer because of FileDialogs and PrintDialogs
|
||||
WWindowPeer blockerPeer = (WWindowPeer)dialog.getPeer();
|
||||
if (blocked)
|
||||
{
|
||||
modalBlocker = blockerPeer;
|
||||
// handle native dialogs separately, as they may have not
|
||||
// got HWND yet; modalEnable/modalDisable is called from
|
||||
// their setHWnd() methods
|
||||
if (blockerPeer instanceof WFileDialogPeer) {
|
||||
((WFileDialogPeer)blockerPeer).blockWindow(this);
|
||||
} else if (blockerPeer instanceof WPrintDialogPeer) {
|
||||
((WPrintDialogPeer)blockerPeer).blockWindow(this);
|
||||
} else {
|
||||
modalDisable(dialog, blockerPeer.getHWnd());
|
||||
}
|
||||
} else {
|
||||
modalBlocker = null;
|
||||
if (blockerPeer instanceof WFileDialogPeer) {
|
||||
((WFileDialogPeer)blockerPeer).unblockWindow(this);
|
||||
} else if (blockerPeer instanceof WPrintDialogPeer) {
|
||||
((WPrintDialogPeer)blockerPeer).unblockWindow(this);
|
||||
} else {
|
||||
modalEnable(dialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
native void modalDisable(Dialog blocker, long blockerHWnd);
|
||||
native void modalEnable(Dialog blocker);
|
||||
|
||||
/*
|
||||
* Returns all the ever active windows from the current AppContext.
|
||||
* The list is sorted by the time of activation, so the latest
|
||||
* active window is always at the end.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static long[] getActiveWindowHandles(Component target) {
|
||||
AppContext appContext = SunToolkit.targetToAppContext(target);
|
||||
if (appContext == null) return null;
|
||||
synchronized (appContext) {
|
||||
List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY);
|
||||
if (l == null) {
|
||||
return null;
|
||||
}
|
||||
long[] result = new long[l.size()];
|
||||
for (int j = 0; j < l.size(); j++) {
|
||||
result[j] = l.get(j).getHWnd();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ----DISPLAY CHANGE SUPPORT----
|
||||
*/
|
||||
|
||||
/*
|
||||
* Called from native code when we have been dragged onto another screen.
|
||||
*/
|
||||
void draggedToNewScreen() {
|
||||
displayChanged();
|
||||
}
|
||||
|
||||
public void updateGC() {
|
||||
int scrn = getScreenImOn();
|
||||
if (screenLog.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
log.finer("Screen number: " + scrn);
|
||||
}
|
||||
|
||||
// get current GD
|
||||
Win32GraphicsDevice oldDev = (Win32GraphicsDevice)winGraphicsConfig
|
||||
.getDevice();
|
||||
|
||||
Win32GraphicsDevice newDev;
|
||||
GraphicsDevice devs[] = GraphicsEnvironment
|
||||
.getLocalGraphicsEnvironment()
|
||||
.getScreenDevices();
|
||||
// Occasionally during device addition/removal getScreenImOn can return
|
||||
// a non-existing screen number. Use the default device in this case.
|
||||
if (scrn >= devs.length) {
|
||||
newDev = (Win32GraphicsDevice)GraphicsEnvironment
|
||||
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
||||
} else {
|
||||
newDev = (Win32GraphicsDevice)devs[scrn];
|
||||
}
|
||||
|
||||
// Set winGraphicsConfig to the default GC for the monitor this Window
|
||||
// is now mostly on.
|
||||
winGraphicsConfig = (Win32GraphicsConfig)newDev
|
||||
.getDefaultConfiguration();
|
||||
if (screenLog.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
if (winGraphicsConfig == null) {
|
||||
screenLog.fine("Assertion (winGraphicsConfig != null) failed");
|
||||
}
|
||||
}
|
||||
|
||||
// if on a different display, take off old GD and put on new GD
|
||||
if (oldDev != newDev) {
|
||||
oldDev.removeDisplayChangedListener(this);
|
||||
newDev.addDisplayChangedListener(this);
|
||||
}
|
||||
|
||||
AWTAccessor.getComponentAccessor().
|
||||
setGraphicsConfiguration((Component)target, winGraphicsConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* From the DisplayChangedListener interface.
|
||||
*
|
||||
* This method handles a display change - either when the display settings
|
||||
* are changed, or when the window has been dragged onto a different
|
||||
* display.
|
||||
* Called after a change in the display mode. This event
|
||||
* triggers replacing the surfaceData object (since that object
|
||||
* reflects the current display depth information, which has
|
||||
* just changed).
|
||||
*/
|
||||
@Override
|
||||
public void displayChanged() {
|
||||
SunToolkit.executeOnEventHandlerThread(target, this::updateGC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Part of the DisplayChangedListener interface: components
|
||||
* do not need to react to this event
|
||||
*/
|
||||
@Override
|
||||
public void paletteChanged() {
|
||||
}
|
||||
|
||||
private native int getScreenImOn();
|
||||
|
||||
// Used in Win32GraphicsDevice.
|
||||
public final native void setFullScreenExclusiveModeState(boolean state);
|
||||
|
||||
/*
|
||||
* ----END DISPLAY CHANGE SUPPORT----
|
||||
*/
|
||||
|
||||
public void grab() {
|
||||
nativeGrab();
|
||||
}
|
||||
|
||||
public void ungrab() {
|
||||
nativeUngrab();
|
||||
}
|
||||
private native void nativeGrab();
|
||||
private native void nativeUngrab();
|
||||
|
||||
private final boolean hasWarningWindow() {
|
||||
return ((Window)target).getWarningString() != null;
|
||||
}
|
||||
|
||||
boolean isTargetUndecorated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// These are the peer bounds. They get updated at:
|
||||
// 1. the WWindowPeer.setBounds() method.
|
||||
// 2. the native code (on WM_SIZE/WM_MOVE)
|
||||
private volatile int sysX = 0;
|
||||
private volatile int sysY = 0;
|
||||
private volatile int sysW = 0;
|
||||
private volatile int sysH = 0;
|
||||
|
||||
@Override
|
||||
public native void repositionSecurityWarning();
|
||||
|
||||
@Override
|
||||
public void setBounds(int x, int y, int width, int height, int op) {
|
||||
sysX = x;
|
||||
sysY = y;
|
||||
sysW = width;
|
||||
sysH = height;
|
||||
|
||||
super.setBounds(x, y, width, height, op);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(Graphics g) {
|
||||
// We assume we print the whole frame,
|
||||
// so we expect no clip was set previously
|
||||
Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target);
|
||||
if (shape != null) {
|
||||
g.setClip(shape);
|
||||
}
|
||||
super.print(g);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void replaceSurfaceDataRecursively(Component c) {
|
||||
if (c instanceof Container) {
|
||||
for (Component child : ((Container)c).getComponents()) {
|
||||
replaceSurfaceDataRecursively(child);
|
||||
}
|
||||
}
|
||||
ComponentPeer cp = c.getPeer();
|
||||
if (cp instanceof WComponentPeer) {
|
||||
((WComponentPeer)cp).replaceSurfaceDataLater();
|
||||
}
|
||||
}
|
||||
|
||||
public final Graphics getTranslucentGraphics() {
|
||||
synchronized (getStateLock()) {
|
||||
return isOpaque ? null : painter.getBackBuffer(false).getGraphics();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackground(Color c) {
|
||||
super.setBackground(c);
|
||||
synchronized (getStateLock()) {
|
||||
if (!isOpaque && ((Window)target).isVisible()) {
|
||||
updateWindow(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private native void setOpacity(int iOpacity);
|
||||
private float opacity = 1.0f;
|
||||
|
||||
@Override
|
||||
public void setOpacity(float opacity) {
|
||||
if (!((SunToolkit)((Window)target).getToolkit()).
|
||||
isWindowOpacitySupported())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (opacity < 0.0f || opacity > 1.0f) {
|
||||
throw new IllegalArgumentException(
|
||||
"The value of opacity should be in the range [0.0f .. 1.0f].");
|
||||
}
|
||||
|
||||
if (((this.opacity == 1.0f && opacity < 1.0f) ||
|
||||
(this.opacity < 1.0f && opacity == 1.0f)) &&
|
||||
!Win32GraphicsEnvironment.isVistaOS())
|
||||
{
|
||||
// non-Vista OS: only replace the surface data if opacity status
|
||||
// changed (see WComponentPeer.isAccelCapable() for more)
|
||||
replaceSurfaceDataRecursively((Component)getTarget());
|
||||
}
|
||||
|
||||
this.opacity = opacity;
|
||||
|
||||
final int maxOpacity = 0xff;
|
||||
int iOpacity = (int)(opacity * maxOpacity);
|
||||
if (iOpacity < 0) {
|
||||
iOpacity = 0;
|
||||
}
|
||||
if (iOpacity > maxOpacity) {
|
||||
iOpacity = maxOpacity;
|
||||
}
|
||||
|
||||
setOpacity(iOpacity);
|
||||
|
||||
synchronized (getStateLock()) {
|
||||
if (!isOpaque && ((Window)target).isVisible()) {
|
||||
updateWindow(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private native void setOpaqueImpl(boolean isOpaque);
|
||||
|
||||
@Override
|
||||
public void setOpaque(boolean isOpaque) {
|
||||
synchronized (getStateLock()) {
|
||||
if (this.isOpaque == isOpaque) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Window target = (Window)getTarget();
|
||||
|
||||
if (!isOpaque) {
|
||||
SunToolkit sunToolkit = (SunToolkit)target.getToolkit();
|
||||
if (!sunToolkit.isWindowTranslucencySupported() ||
|
||||
!sunToolkit.isTranslucencyCapable(target.getGraphicsConfiguration()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isVistaOS = Win32GraphicsEnvironment.isVistaOS();
|
||||
|
||||
if (this.isOpaque != isOpaque && !isVistaOS) {
|
||||
// non-Vista OS: only replace the surface data if the opacity
|
||||
// status changed (see WComponentPeer.isAccelCapable() for more)
|
||||
replaceSurfaceDataRecursively(target);
|
||||
}
|
||||
|
||||
synchronized (getStateLock()) {
|
||||
this.isOpaque = isOpaque;
|
||||
setOpaqueImpl(isOpaque);
|
||||
if (isOpaque) {
|
||||
TranslucentWindowPainter currentPainter = painter;
|
||||
if (currentPainter != null) {
|
||||
currentPainter.flush();
|
||||
painter = null;
|
||||
}
|
||||
} else {
|
||||
painter = TranslucentWindowPainter.createInstance(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (isVistaOS) {
|
||||
// On Vista: setting the window non-opaque makes the window look
|
||||
// rectangular, though still catching the mouse clicks within
|
||||
// its shape only. To restore the correct visual appearance
|
||||
// of the window (i.e. w/ the correct shape) we have to reset
|
||||
// the shape.
|
||||
Shape shape = target.getShape();
|
||||
if (shape != null) {
|
||||
target.setShape(shape);
|
||||
}
|
||||
}
|
||||
|
||||
if (target.isVisible()) {
|
||||
updateWindow(true);
|
||||
}
|
||||
}
|
||||
|
||||
native void updateWindowImpl(int[] data, int width, int height);
|
||||
|
||||
@Override
|
||||
public void updateWindow() {
|
||||
updateWindow(false);
|
||||
}
|
||||
|
||||
private void updateWindow(boolean repaint) {
|
||||
Window w = (Window)target;
|
||||
synchronized (getStateLock()) {
|
||||
if (isOpaque || !w.isVisible() ||
|
||||
(w.getWidth() <= 0) || (w.getHeight() <= 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
TranslucentWindowPainter currentPainter = painter;
|
||||
if (currentPainter != null) {
|
||||
currentPainter.updateWindow(repaint);
|
||||
} else if (log.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
log.finer("Translucent window painter is null in updateWindow");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The method maps the list of the active windows to the window's AppContext,
|
||||
* then the method registers ActiveWindowListener, GuiDisposedListener listeners;
|
||||
* it executes the initilialization only once per AppContext.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void initActiveWindowsTracking(Window w) {
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
synchronized (appContext) {
|
||||
List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY);
|
||||
if (l == null) {
|
||||
l = new LinkedList<WWindowPeer>();
|
||||
appContext.put(ACTIVE_WINDOWS_KEY, l);
|
||||
appContext.addPropertyChangeListener(AppContext.GUI_DISPOSED, guiDisposedListener);
|
||||
|
||||
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
kfm.addPropertyChangeListener("activeWindow", activeWindowListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The GuiDisposedListener class listens for the AppContext.GUI_DISPOSED property,
|
||||
* it removes the list of the active windows from the disposed AppContext and
|
||||
* unregisters ActiveWindowListener listener.
|
||||
*/
|
||||
private static class GuiDisposedListener implements PropertyChangeListener {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
boolean isDisposed = (Boolean)e.getNewValue();
|
||||
if (isDisposed != true) {
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine(" Assertion (newValue != true) failed for AppContext.GUI_DISPOSED ");
|
||||
}
|
||||
}
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
synchronized (appContext) {
|
||||
appContext.remove(ACTIVE_WINDOWS_KEY);
|
||||
appContext.removePropertyChangeListener(AppContext.GUI_DISPOSED, this);
|
||||
|
||||
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
kfm.removePropertyChangeListener("activeWindow", activeWindowListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Static inner class, listens for 'activeWindow' KFM property changes and
|
||||
* updates the list of active windows per AppContext, so the latest active
|
||||
* window is always at the end of the list. The list is stored in AppContext.
|
||||
*/
|
||||
@SuppressWarnings( value = {"deprecation", "unchecked"})
|
||||
private static class ActiveWindowListener implements PropertyChangeListener {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
Window w = (Window)e.getNewValue();
|
||||
if (w == null) {
|
||||
return;
|
||||
}
|
||||
AppContext appContext = SunToolkit.targetToAppContext(w);
|
||||
synchronized (appContext) {
|
||||
WWindowPeer wp = (WWindowPeer)w.getPeer();
|
||||
// add/move wp to the end of the list
|
||||
List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY);
|
||||
if (l != null) {
|
||||
l.remove(wp);
|
||||
l.add(wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
169
jdkSrc/jdk8/sun/awt/windows/WingDings.java
Normal file
169
jdkSrc/jdk8/sun/awt/windows/WingDings.java
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 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 sun.awt.windows;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.*;
|
||||
|
||||
public final class WingDings extends Charset {
|
||||
public WingDings () {
|
||||
super("WingDings", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new Encoder(this);
|
||||
}
|
||||
|
||||
/* Seems like supporting a decoder is required, but we aren't going
|
||||
* to be publically exposing this class, so no need to waste work
|
||||
*/
|
||||
@Override
|
||||
public CharsetDecoder newDecoder() {
|
||||
throw new Error("Decoder isn't implemented for WingDings Charset");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Charset cs) {
|
||||
return cs instanceof WingDings;
|
||||
}
|
||||
|
||||
private static class Encoder extends CharsetEncoder {
|
||||
public Encoder(Charset cs) {
|
||||
super(cs, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEncode(char c) {
|
||||
if(c >= 0x2701 && c <= 0x27be){
|
||||
if (table[c - 0x2700] != 0x00)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CoderResult encodeLoop(CharBuffer src, ByteBuffer dst) {
|
||||
char[] sa = src.array();
|
||||
int sp = src.arrayOffset() + src.position();
|
||||
int sl = src.arrayOffset() + src.limit();
|
||||
assert (sp <= sl);
|
||||
sp = (sp <= sl ? sp : sl);
|
||||
byte[] da = dst.array();
|
||||
int dp = dst.arrayOffset() + dst.position();
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
assert (dp <= dl);
|
||||
dp = (dp <= dl ? dp : dl);
|
||||
|
||||
try {
|
||||
while (sp < sl) {
|
||||
char c = sa[sp];
|
||||
if (dl - dp < 1)
|
||||
return CoderResult.OVERFLOW;
|
||||
if (!canEncode(c))
|
||||
return CoderResult.unmappableForLength(1);
|
||||
sp++;
|
||||
da[dp++] = table[c - 0x2700];
|
||||
}
|
||||
return CoderResult.UNDERFLOW;
|
||||
} finally {
|
||||
src.position(sp - src.arrayOffset());
|
||||
dst.position(dp - dst.arrayOffset());
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] table = {
|
||||
(byte)0x00, (byte)0x23, (byte)0x22, (byte)0x00, // 0x2700
|
||||
(byte)0x00, (byte)0x00, (byte)0x29, (byte)0x3e, // 0x2704
|
||||
(byte)0x51, (byte)0x2a, (byte)0x00, (byte)0x00, // 0x2708
|
||||
(byte)0x41, (byte)0x3f, (byte)0x00, (byte)0x00, // 0x270c
|
||||
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0xfc, // 0x2710
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0xfb, // 0x2714
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2718
|
||||
(byte)0x00, (byte)0x00, (byte)0x56, (byte)0x00, // 0x271c
|
||||
|
||||
(byte)0x58, (byte)0x59, (byte)0x00, (byte)0x00, // 0x2720
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2724
|
||||
(byte)0x00, (byte)0x00, (byte)0xb5, (byte)0x00, // 0x2728
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x272c
|
||||
|
||||
(byte)0xb6, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2730
|
||||
(byte)0xad, (byte)0xaf, (byte)0xac, (byte)0x00, // 0x2734
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2738
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x7c, // 0x273c
|
||||
|
||||
(byte)0x7b, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2740
|
||||
(byte)0x54, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2744
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2748
|
||||
(byte)0x00, (byte)0xa6, (byte)0x00, (byte)0x00, // 0x274c
|
||||
|
||||
(byte)0x00, (byte)0x71, (byte)0x72, (byte)0x00, // 0x2750
|
||||
(byte)0x00, (byte)0x00, (byte)0x75, (byte)0x00, // 0x2754
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2758
|
||||
(byte)0x00, (byte)0x7d, (byte)0x7e, (byte)0x00, // 0x275c
|
||||
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2760
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2764
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2768
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x276c
|
||||
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2770
|
||||
(byte)0x00, (byte)0x00, (byte)0x8c, (byte)0x8d, // 0x2774
|
||||
(byte)0x8e, (byte)0x8f, (byte)0x90, (byte)0x91, // 0x2778
|
||||
(byte)0x92, (byte)0x93, (byte)0x94, (byte)0x95, // 0x277c
|
||||
|
||||
(byte)0x81, (byte)0x82, (byte)0x83, (byte)0x84, // 0x2780
|
||||
(byte)0x85, (byte)0x86, (byte)0x87, (byte)0x88, // 0x2784
|
||||
(byte)0x89, (byte)0x8a, (byte)0x8c, (byte)0x8d, // 0x2788
|
||||
(byte)0x8e, (byte)0x8f, (byte)0x90, (byte)0x91, // 0x278c
|
||||
|
||||
(byte)0x92, (byte)0x93, (byte)0x94, (byte)0x95, // 0x2790
|
||||
(byte)0xe8, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2794
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x2798
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x279c
|
||||
|
||||
(byte)0x00, (byte)0xe8, (byte)0xd8, (byte)0x00, // 0x27a0
|
||||
(byte)0x00, (byte)0xc4, (byte)0xc6, (byte)0x00, // 0x27a4
|
||||
(byte)0x00, (byte)0xf0, (byte)0x00, (byte)0x00, // 0x27a8
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x27ac
|
||||
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0xdc, // 0x27b0
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x27b4
|
||||
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, // 0x27b8
|
||||
(byte)0x00, (byte)0x00, (byte)0x00 // 0x27bc
|
||||
};
|
||||
|
||||
/* The default implementation creates a decoder and we don't have one */
|
||||
@Override
|
||||
public boolean isLegalReplacement(byte[] repl) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization.java
Normal file
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class awtLocalization extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "allFiles", "All Files" },
|
||||
{ "menuFont", "SansSerif-plain-11" },
|
||||
};
|
||||
}
|
||||
}
|
||||
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_de.java
Normal file
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_de.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class awtLocalization_de extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "allFiles", "Alle Dateien" },
|
||||
{ "menuFont", "SansSerif-plain-11" },
|
||||
};
|
||||
}
|
||||
}
|
||||
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_es.java
Normal file
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_es.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class awtLocalization_es extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "allFiles", "Todos los Archivos" },
|
||||
{ "menuFont", "SansSerif-plain-11" },
|
||||
};
|
||||
}
|
||||
}
|
||||
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_fr.java
Normal file
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_fr.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class awtLocalization_fr extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "allFiles", "Tous les fichiers" },
|
||||
{ "menuFont", "SansSerif-plain-11" },
|
||||
};
|
||||
}
|
||||
}
|
||||
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_it.java
Normal file
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_it.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class awtLocalization_it extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "allFiles", "Tutti i file" },
|
||||
{ "menuFont", "SansSerif-plain-11" },
|
||||
};
|
||||
}
|
||||
}
|
||||
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_ja.java
Normal file
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_ja.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class awtLocalization_ja extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "allFiles", "\u3059\u3079\u3066\u306E\u30D5\u30A1\u30A4\u30EB" },
|
||||
{ "menuFont", "SansSerif-plain-11" },
|
||||
};
|
||||
}
|
||||
}
|
||||
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_ko.java
Normal file
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_ko.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class awtLocalization_ko extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "allFiles", "\uBAA8\uB4E0 \uD30C\uC77C" },
|
||||
{ "menuFont", "SansSerif-plain-11" },
|
||||
};
|
||||
}
|
||||
}
|
||||
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_pt_BR.java
Normal file
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_pt_BR.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class awtLocalization_pt_BR extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "allFiles", "Todos os Arquivos" },
|
||||
{ "menuFont", "SansSerif-plain-11" },
|
||||
};
|
||||
}
|
||||
}
|
||||
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_sv.java
Normal file
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_sv.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class awtLocalization_sv extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "allFiles", "Alla filer" },
|
||||
{ "menuFont", "SansSerif-plain-11" },
|
||||
};
|
||||
}
|
||||
}
|
||||
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_zh_CN.java
Normal file
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_zh_CN.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class awtLocalization_zh_CN extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "allFiles", "\u6240\u6709\u6587\u4EF6" },
|
||||
{ "menuFont", "SansSerif-plain-11" },
|
||||
};
|
||||
}
|
||||
}
|
||||
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_zh_HK.java
Normal file
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_zh_HK.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class awtLocalization_zh_HK extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "allFiles", "\u6240\u6709\u6A94\u6848" },
|
||||
{ "menuFont", "SansSerif-plain-12" },
|
||||
};
|
||||
}
|
||||
}
|
||||
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_zh_TW.java
Normal file
12
jdkSrc/jdk8/sun/awt/windows/awtLocalization_zh_TW.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class awtLocalization_zh_TW extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "allFiles", "\u6240\u6709\u6A94\u6848" },
|
||||
{ "menuFont", "SansSerif-plain-12" },
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user