< prev index next >

src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java

Print this page


   1 /*
   2  * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  30 import java.awt.im.InputMethodHighlight;
  31 import java.awt.im.spi.InputMethodDescriptor;
  32 import java.awt.image.*;
  33 import java.awt.peer.*;
  34 import java.awt.event.FocusEvent;
  35 import java.awt.event.KeyEvent;
  36 import java.awt.event.MouseEvent;
  37 import java.awt.datatransfer.Clipboard;
  38 import java.awt.TextComponent;
  39 import java.awt.TrayIcon;
  40 import java.beans.PropertyChangeListener;
  41 import java.security.AccessController;
  42 import java.security.PrivilegedAction;
  43 import javax.swing.text.JTextComponent;
  44 
  45 import sun.awt.AWTAccessor;
  46 import sun.awt.AppContext;
  47 import sun.awt.AWTAutoShutdown;
  48 import sun.awt.AWTPermissions;
  49 import sun.awt.AppContext;

  50 import sun.awt.LightweightFrame;
  51 import sun.awt.SunToolkit;
  52 import sun.awt.util.ThreadGroupUtils;
  53 import sun.awt.Win32GraphicsDevice;
  54 import sun.awt.Win32GraphicsEnvironment;
  55 import sun.awt.datatransfer.DataTransferer;
  56 import sun.java2d.d3d.D3DRenderQueue;
  57 import sun.java2d.opengl.OGLRenderQueue;
  58 
  59 import sun.print.PrintJob2D;
  60 
  61 import java.awt.dnd.DragSource;
  62 import java.awt.dnd.DragGestureListener;
  63 import java.awt.dnd.DragGestureEvent;
  64 import java.awt.dnd.DragGestureRecognizer;
  65 import java.awt.dnd.MouseDragGestureRecognizer;
  66 import java.awt.dnd.InvalidDnDOperationException;
  67 import java.awt.dnd.peer.DragSourceContextPeer;
  68 
  69 import java.util.Hashtable;


 785      */
 786     @Override
 787     public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
 788         throws IndexOutOfBoundsException {
 789         return new WCustomCursor(cursor, hotSpot, name);
 790     }
 791 
 792     /**
 793      * Returns the supported cursor size (Win32 only has one).
 794      */
 795     @Override
 796     public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
 797         return new Dimension(WCustomCursor.getCursorWidth(),
 798                              WCustomCursor.getCursorHeight());
 799     }
 800 
 801     @Override
 802     public native int getMaximumCursorColors();
 803 
 804     static void paletteChanged() {
 805         ((Win32GraphicsEnvironment)GraphicsEnvironment
 806         .getLocalGraphicsEnvironment())
 807         .paletteChanged();

 808     }
 809 
 810     /*
 811      * Called from Toolkit native code when a WM_DISPLAYCHANGE occurs.
 812      * Have Win32GraphicsEnvironment execute the display change code on the
 813      * Event thread.
 814      */
 815     public static void displayChanged() {
 816         EventQueue.invokeLater(new Runnable() {
 817             @Override
 818             public void run() {
 819                 ((Win32GraphicsEnvironment)GraphicsEnvironment
 820                 .getLocalGraphicsEnvironment())
 821                 .displayChanged();

 822             }
 823         });
 824     }
 825 
 826     /**
 827      * create the peer for a DragSourceContext
 828      */
 829 
 830     @Override
 831     public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
 832         final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
 833         if (f != null) {
 834             return f.createDragSourceContextPeer(dge);
 835         }
 836 
 837         return WDragSourceContextPeer.createDragSourceContextPeer(dge);
 838     }
 839 
 840     @Override
 841     @SuppressWarnings("unchecked")


   1 /*
   2  * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  30 import java.awt.im.InputMethodHighlight;
  31 import java.awt.im.spi.InputMethodDescriptor;
  32 import java.awt.image.*;
  33 import java.awt.peer.*;
  34 import java.awt.event.FocusEvent;
  35 import java.awt.event.KeyEvent;
  36 import java.awt.event.MouseEvent;
  37 import java.awt.datatransfer.Clipboard;
  38 import java.awt.TextComponent;
  39 import java.awt.TrayIcon;
  40 import java.beans.PropertyChangeListener;
  41 import java.security.AccessController;
  42 import java.security.PrivilegedAction;
  43 import javax.swing.text.JTextComponent;
  44 
  45 import sun.awt.AWTAccessor;
  46 import sun.awt.AppContext;
  47 import sun.awt.AWTAutoShutdown;
  48 import sun.awt.AWTPermissions;
  49 import sun.awt.AppContext;
  50 import sun.awt.DisplayChangedListener;
  51 import sun.awt.LightweightFrame;
  52 import sun.awt.SunToolkit;
  53 import sun.awt.util.ThreadGroupUtils;
  54 import sun.awt.Win32GraphicsDevice;
  55 import sun.awt.Win32GraphicsEnvironment;
  56 import sun.awt.datatransfer.DataTransferer;
  57 import sun.java2d.d3d.D3DRenderQueue;
  58 import sun.java2d.opengl.OGLRenderQueue;
  59 
  60 import sun.print.PrintJob2D;
  61 
  62 import java.awt.dnd.DragSource;
  63 import java.awt.dnd.DragGestureListener;
  64 import java.awt.dnd.DragGestureEvent;
  65 import java.awt.dnd.DragGestureRecognizer;
  66 import java.awt.dnd.MouseDragGestureRecognizer;
  67 import java.awt.dnd.InvalidDnDOperationException;
  68 import java.awt.dnd.peer.DragSourceContextPeer;
  69 
  70 import java.util.Hashtable;


 786      */
 787     @Override
 788     public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
 789         throws IndexOutOfBoundsException {
 790         return new WCustomCursor(cursor, hotSpot, name);
 791     }
 792 
 793     /**
 794      * Returns the supported cursor size (Win32 only has one).
 795      */
 796     @Override
 797     public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
 798         return new Dimension(WCustomCursor.getCursorWidth(),
 799                              WCustomCursor.getCursorHeight());
 800     }
 801 
 802     @Override
 803     public native int getMaximumCursorColors();
 804 
 805     static void paletteChanged() {
 806         Object lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 807         if (lge instanceof DisplayChangedListener) {
 808             ((DisplayChangedListener) lge).paletteChanged();
 809         }
 810     }
 811 
 812     /*
 813      * Called from Toolkit native code when a WM_DISPLAYCHANGE occurs.
 814      * Have Win32GraphicsEnvironment execute the display change code on the
 815      * Event thread.
 816      */
 817     public static void displayChanged() {
 818         EventQueue.invokeLater(new Runnable() {
 819             @Override
 820             public void run() {
 821                 Object lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 822                 if (lge instanceof DisplayChangedListener) {
 823                     ((DisplayChangedListener) lge).displayChanged();
 824                 }
 825             }
 826         });
 827     }
 828 
 829     /**
 830      * create the peer for a DragSourceContext
 831      */
 832 
 833     @Override
 834     public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
 835         final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
 836         if (f != null) {
 837             return f.createDragSourceContextPeer(dge);
 838         }
 839 
 840         return WDragSourceContextPeer.createDragSourceContextPeer(dge);
 841     }
 842 
 843     @Override
 844     @SuppressWarnings("unchecked")


< prev index next >