src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java

Print this page




  44 
  45 import com.apple.laf.*;
  46 import com.apple.laf.ClientPropertyApplicator.Property;
  47 import com.sun.awt.AWTUtilities;
  48 
  49 public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
  50     private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h);
  51     private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
  52     private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
  53     private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
  54     private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h);
  55     private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH);
  56     private static native void nativePushNSWindowToBack(long nsWindowPtr);
  57     private static native void nativePushNSWindowToFront(long nsWindowPtr);
  58     private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title);
  59     private static native void nativeSetNSWindowAlpha(long nsWindowPtr, float alpha);
  60     private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr);
  61     private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage);
  62     private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
  63     private static native void nativeSetNSWindowSecurityWarningPositioning(long nsWindowPtr, double x, double y, float biasX, float biasY);


  64 
  65     private static native int nativeGetScreenNSWindowIsOn_AppKitThread(long nsWindowPtr);
  66 
  67     // Loger to report issues happened during execution but that do not affect functionality
  68     private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
  69     private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow");
  70 
  71     // for client properties
  72     public static final String WINDOW_BRUSH_METAL_LOOK = "apple.awt.brushMetalLook";
  73     public static final String WINDOW_DRAGGABLE_BACKGROUND = "apple.awt.draggableWindowBackground";
  74 
  75     public static final String WINDOW_ALPHA = "Window.alpha";
  76     public static final String WINDOW_SHADOW = "Window.shadow";
  77 
  78     public static final String WINDOW_STYLE = "Window.style";
  79     public static final String WINDOW_SHADOW_REVALIDATE_NOW = "apple.awt.windowShadow.revalidateNow";
  80 
  81     public static final String WINDOW_DOCUMENT_MODIFIED = "Window.documentModified";
  82     public static final String WINDOW_DOCUMENT_FILE = "Window.documentFile";
  83 


 778                     CWrapper.NSWindow.deminiaturize(nsWindowPtr);
 779                 }
 780                 zoom();
 781                 break;
 782             case Frame.NORMAL:
 783                 if (prevWindowState == Frame.ICONIFIED) {
 784                     CWrapper.NSWindow.deminiaturize(nsWindowPtr);
 785                 } else if (prevWindowState == Frame.MAXIMIZED_BOTH) {
 786                     // the zoom call toggles between the normal and the max states
 787                     zoom();
 788                 }
 789                 break;
 790             default:
 791                 throw new RuntimeException("Unknown window state: " + windowState);
 792         }
 793 
 794         // NOTE: the SWP.windowState field gets updated to the newWindowState
 795         //       value when the native notification comes to us
 796     }
 797 










 798     // ----------------------------------------------------------------------
 799     //                          UTILITY METHODS
 800     // ----------------------------------------------------------------------
 801 
 802     /*
 803      * Find image to install into Title or into Application icon.
 804      * First try icons installed for toplevel. If there is no icon
 805      * use default Duke image.
 806      * This method shouldn't return null.
 807      */
 808     private CImage getImageForTarget() {
 809         List<Image> icons = target.getIconImages();
 810         if (icons == null || icons.size() == 0) {
 811             return null;
 812         }
 813         return CImage.getCreator().createFromImages(icons);
 814     }
 815 
 816     /*
 817      * Returns LWWindowPeer associated with this delegate.




  44 
  45 import com.apple.laf.*;
  46 import com.apple.laf.ClientPropertyApplicator.Property;
  47 import com.sun.awt.AWTUtilities;
  48 
  49 public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
  50     private native long nativeCreateNSWindow(long nsViewPtr, long styleBits, double x, double y, double w, double h);
  51     private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
  52     private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
  53     private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
  54     private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h);
  55     private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH);
  56     private static native void nativePushNSWindowToBack(long nsWindowPtr);
  57     private static native void nativePushNSWindowToFront(long nsWindowPtr);
  58     private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title);
  59     private static native void nativeSetNSWindowAlpha(long nsWindowPtr, float alpha);
  60     private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr);
  61     private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage);
  62     private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename);
  63     private static native void nativeSetNSWindowSecurityWarningPositioning(long nsWindowPtr, double x, double y, float biasX, float biasY);
  64     private static native void nativeModallyBlocked(long nsWindowPtr);
  65     private static native void nativeModallyUnblocked(long nsWindowPtr);
  66 
  67     private static native int nativeGetScreenNSWindowIsOn_AppKitThread(long nsWindowPtr);
  68 
  69     // Loger to report issues happened during execution but that do not affect functionality
  70     private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
  71     private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformWindow");
  72 
  73     // for client properties
  74     public static final String WINDOW_BRUSH_METAL_LOOK = "apple.awt.brushMetalLook";
  75     public static final String WINDOW_DRAGGABLE_BACKGROUND = "apple.awt.draggableWindowBackground";
  76 
  77     public static final String WINDOW_ALPHA = "Window.alpha";
  78     public static final String WINDOW_SHADOW = "Window.shadow";
  79 
  80     public static final String WINDOW_STYLE = "Window.style";
  81     public static final String WINDOW_SHADOW_REVALIDATE_NOW = "apple.awt.windowShadow.revalidateNow";
  82 
  83     public static final String WINDOW_DOCUMENT_MODIFIED = "Window.documentModified";
  84     public static final String WINDOW_DOCUMENT_FILE = "Window.documentFile";
  85 


 780                     CWrapper.NSWindow.deminiaturize(nsWindowPtr);
 781                 }
 782                 zoom();
 783                 break;
 784             case Frame.NORMAL:
 785                 if (prevWindowState == Frame.ICONIFIED) {
 786                     CWrapper.NSWindow.deminiaturize(nsWindowPtr);
 787                 } else if (prevWindowState == Frame.MAXIMIZED_BOTH) {
 788                     // the zoom call toggles between the normal and the max states
 789                     zoom();
 790                 }
 791                 break;
 792             default:
 793                 throw new RuntimeException("Unknown window state: " + windowState);
 794         }
 795 
 796         // NOTE: the SWP.windowState field gets updated to the newWindowState
 797         //       value when the native notification comes to us
 798     }
 799 
 800     @Override
 801     public void modallyBlocked() {
 802         nativeModallyBlocked(getNSWindowPtr());
 803     }
 804 
 805     @Override
 806     public void modallyUnblocked() {
 807         nativeModallyUnblocked(getNSWindowPtr());
 808     }
 809 
 810     // ----------------------------------------------------------------------
 811     //                          UTILITY METHODS
 812     // ----------------------------------------------------------------------
 813 
 814     /*
 815      * Find image to install into Title or into Application icon.
 816      * First try icons installed for toplevel. If there is no icon
 817      * use default Duke image.
 818      * This method shouldn't return null.
 819      */
 820     private CImage getImageForTarget() {
 821         List<Image> icons = target.getIconImages();
 822         if (icons == null || icons.size() == 0) {
 823             return null;
 824         }
 825         return CImage.getCreator().createFromImages(icons);
 826     }
 827 
 828     /*
 829      * Returns LWWindowPeer associated with this delegate.