< prev index next >

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

Print this page




  55 import sun.awt.Win32GraphicsDevice;
  56 import sun.awt.Win32GraphicsEnvironment;
  57 import sun.awt.datatransfer.DataTransferer;
  58 import sun.java2d.d3d.D3DRenderQueue;
  59 import sun.java2d.opengl.OGLRenderQueue;
  60 
  61 import sun.print.PrintJob2D;
  62 
  63 import java.awt.dnd.DragSource;
  64 import java.awt.dnd.DragGestureListener;
  65 import java.awt.dnd.DragGestureEvent;
  66 import java.awt.dnd.DragGestureRecognizer;
  67 import java.awt.dnd.MouseDragGestureRecognizer;
  68 import java.awt.dnd.InvalidDnDOperationException;
  69 import java.awt.dnd.peer.DragSourceContextPeer;
  70 
  71 import java.util.Hashtable;
  72 import java.util.Locale;
  73 import java.util.Map;
  74 import java.util.Properties;


  75 
  76 import sun.awt.util.PerformanceLogger;
  77 import sun.font.FontManager;
  78 import sun.font.FontManagerFactory;
  79 import sun.font.SunFontManager;
  80 import sun.util.logging.PlatformLogger;
  81 
  82 public final class WToolkit extends SunToolkit implements Runnable {
  83 
  84     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit");
  85 
  86     // Desktop property which specifies whether XP visual styles are in effect
  87     public static final String XPSTYLE_THEME_ACTIVE = "win.xpstyle.themeActive";
  88 
  89     // System clipboard.
  90     WClipboard clipboard;
  91 
  92     // cache of font peers
  93     private Hashtable<String,FontPeer> cacheFontPeer;
  94 


 793 
 794     /**
 795      * Returns the supported cursor size (Win32 only has one).
 796      */
 797     @Override
 798     public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
 799         return new Dimension(WCustomCursor.getCursorWidth(),
 800                              WCustomCursor.getCursorHeight());
 801     }
 802 
 803     @Override
 804     public native int getMaximumCursorColors();
 805 
 806     static void paletteChanged() {
 807         Object lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 808         if (lge instanceof DisplayChangedListener) {
 809             ((DisplayChangedListener) lge).paletteChanged();
 810         }
 811     }
 812 


 813     /*
 814      * Called from Toolkit native code when a WM_DISPLAYCHANGE occurs.
 815      * Have Win32GraphicsEnvironment execute the display change code on the
 816      * Event thread.
 817      */
 818     public static void displayChanged() {
 819         EventQueue.invokeLater(new Runnable() {
 820             @Override
 821             public void run() {
 822                 Object lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 823                 if (lge instanceof DisplayChangedListener) {
 824                     ((DisplayChangedListener) lge).displayChanged();
 825                 }
 826             }










 827         });
 828     }



 829 
 830     /**
 831      * create the peer for a DragSourceContext
 832      */
 833 
 834     @Override
 835     public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
 836         final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
 837         if (f != null) {
 838             return f.createDragSourceContextPeer(dge);
 839         }
 840 
 841         return WDragSourceContextPeer.createDragSourceContextPeer(dge);
 842     }
 843 
 844     @Override
 845     @SuppressWarnings("unchecked")
 846     public <T extends DragGestureRecognizer> T
 847         createDragGestureRecognizer(Class<T> abstractRecognizerClass,
 848                                     DragSource ds, Component c, int srcActions,




  55 import sun.awt.Win32GraphicsDevice;
  56 import sun.awt.Win32GraphicsEnvironment;
  57 import sun.awt.datatransfer.DataTransferer;
  58 import sun.java2d.d3d.D3DRenderQueue;
  59 import sun.java2d.opengl.OGLRenderQueue;
  60 
  61 import sun.print.PrintJob2D;
  62 
  63 import java.awt.dnd.DragSource;
  64 import java.awt.dnd.DragGestureListener;
  65 import java.awt.dnd.DragGestureEvent;
  66 import java.awt.dnd.DragGestureRecognizer;
  67 import java.awt.dnd.MouseDragGestureRecognizer;
  68 import java.awt.dnd.InvalidDnDOperationException;
  69 import java.awt.dnd.peer.DragSourceContextPeer;
  70 
  71 import java.util.Hashtable;
  72 import java.util.Locale;
  73 import java.util.Map;
  74 import java.util.Properties;
  75 import java.util.concurrent.ExecutorService;
  76 import java.util.concurrent.Executors;
  77 
  78 import sun.awt.util.PerformanceLogger;
  79 import sun.font.FontManager;
  80 import sun.font.FontManagerFactory;
  81 import sun.font.SunFontManager;
  82 import sun.util.logging.PlatformLogger;
  83 
  84 public final class WToolkit extends SunToolkit implements Runnable {
  85 
  86     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WToolkit");
  87 
  88     // Desktop property which specifies whether XP visual styles are in effect
  89     public static final String XPSTYLE_THEME_ACTIVE = "win.xpstyle.themeActive";
  90 
  91     // System clipboard.
  92     WClipboard clipboard;
  93 
  94     // cache of font peers
  95     private Hashtable<String,FontPeer> cacheFontPeer;
  96 


 795 
 796     /**
 797      * Returns the supported cursor size (Win32 only has one).
 798      */
 799     @Override
 800     public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
 801         return new Dimension(WCustomCursor.getCursorWidth(),
 802                              WCustomCursor.getCursorHeight());
 803     }
 804 
 805     @Override
 806     public native int getMaximumCursorColors();
 807 
 808     static void paletteChanged() {
 809         Object lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 810         if (lge instanceof DisplayChangedListener) {
 811             ((DisplayChangedListener) lge).paletteChanged();
 812         }
 813     }
 814 
 815     private static ExecutorService displayChangeExecutor;
 816 
 817     /*
 818      * Called from Toolkit native code when a WM_DISPLAYCHANGE occurs.
 819      * Have Win32GraphicsEnvironment execute the display change code on the
 820      * Event thread.
 821      */
 822     public static void displayChanged() {
 823         final Runnable runnable = () -> {


 824             Object lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 825             if (lge instanceof DisplayChangedListener) {
 826                 ((DisplayChangedListener) lge).displayChanged();
 827             }
 828         };
 829         if (AppContext.getAppContext() != null) {
 830             // Common case, standalone application
 831             EventQueue.invokeLater(runnable);
 832         } else {
 833             if (displayChangeExecutor == null) {
 834                 // No synchronization, called on the Toolkit thread only
 835                 displayChangeExecutor = Executors.newFixedThreadPool(1, r -> {
 836                     Thread t = Executors.defaultThreadFactory().newThread(r);
 837                     t.setDaemon(true);
 838                     return t;
 839                 });
 840             }
 841             displayChangeExecutor.submit(runnable);
 842         }
 843     }
 844 
 845     /**
 846      * create the peer for a DragSourceContext
 847      */
 848 
 849     @Override
 850     public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
 851         final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
 852         if (f != null) {
 853             return f.createDragSourceContextPeer(dge);
 854         }
 855 
 856         return WDragSourceContextPeer.createDragSourceContextPeer(dge);
 857     }
 858 
 859     @Override
 860     @SuppressWarnings("unchecked")
 861     public <T extends DragGestureRecognizer> T
 862         createDragGestureRecognizer(Class<T> abstractRecognizerClass,
 863                                     DragSource ds, Component c, int srcActions,


< prev index next >