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

Print this page




 281         // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable
 282         {
 283             final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
 284             styleBits = SET(styleBits, RESIZABLE, resizable);
 285             if (!resizable) {
 286                 styleBits = SET(styleBits, RESIZABLE, false);
 287                 styleBits = SET(styleBits, ZOOMABLE, false);
 288             }
 289         }
 290 
 291         if (target.isAlwaysOnTop()) {
 292             styleBits = SET(styleBits, ALWAYS_ON_TOP, true);
 293         }
 294 
 295         if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
 296             styleBits = SET(styleBits, MODAL_EXCLUDED, true);
 297         }
 298 
 299         // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look.
 300         if (isPopup) {
 301             styleBits = SET(styleBits, TEXTURED, true);
 302             // Popups in applets don't activate applet's process
 303             styleBits = SET(styleBits, NONACTIVATING, true);
 304         }
 305 
 306         if (Window.Type.UTILITY.equals(target.getType())) {
 307             styleBits = SET(styleBits, UTILITY, true);
 308         }
 309 
 310         if (target instanceof javax.swing.RootPaneContainer) {
 311             javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane();
 312             Object prop = null;
 313 
 314             prop = rootpane.getClientProperty(WINDOW_BRUSH_METAL_LOOK);
 315             if (prop != null) {
 316                 styleBits = SET(styleBits, TEXTURED, Boolean.parseBoolean(prop.toString()));
 317             }
 318 
 319             if (isDialog && ((Dialog)target).getModalityType() == ModalityType.DOCUMENT_MODAL) {
 320                 prop = rootpane.getClientProperty(WINDOW_DOC_MODAL_SHEET);
 321                 if (prop != null) {


 355             if (prop != null) {
 356                 styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString()));
 357             }
 358 
 359             prop = rootpane.getClientProperty(WINDOW_FULLSCREENABLE);
 360             if (prop != null) {
 361                 styleBits = SET(styleBits, FULLSCREENABLE, Boolean.parseBoolean(prop.toString()));
 362             }
 363 
 364             prop = rootpane.getClientProperty(WINDOW_SHADOW);
 365             if (prop != null) {
 366                 styleBits = SET(styleBits, HAS_SHADOW, Boolean.parseBoolean(prop.toString()));
 367             }
 368 
 369             prop = rootpane.getClientProperty(WINDOW_DRAGGABLE_BACKGROUND);
 370             if (prop != null) {
 371                 styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString()));
 372             }
 373         }
 374 


 375         return styleBits;
 376     }
 377 
 378     // this is the counter-point to -[CWindow _nativeSetStyleBit:]
 379     protected void setStyleBits(final int mask, final boolean value) {
 380         nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0);
 381     }
 382 
 383     private native void _toggleFullScreenMode(final long model);
 384 
 385     public void toggleFullScreen() {
 386         _toggleFullScreenMode(getNSWindowPtr());
 387     }
 388 
 389     @Override // PlatformWindow
 390     public void setMenuBar(MenuBar mb) {
 391         final long nsWindowPtr = getNSWindowPtr();
 392         CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb);
 393         if (mbPeer != null) {
 394             nativeSetNSWindowMenuBar(nsWindowPtr, mbPeer.getModel());


 716 
 717     @Override
 718     public Graphics transformGraphics(Graphics g) {
 719         // is this where we can inject a transform for HiDPI?
 720         return g;
 721     }
 722 
 723     @Override
 724     public void setAlwaysOnTop(boolean isAlwaysOnTop) {
 725         setStyleBits(ALWAYS_ON_TOP, isAlwaysOnTop);
 726     }
 727 
 728     @Override
 729     public void setOpacity(float opacity) {
 730         CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity);
 731     }
 732 
 733     @Override
 734     public void setOpaque(boolean isOpaque) {
 735         CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque);
 736         if (!isOpaque) {
 737             long clearColor = CWrapper.NSColor.clearColor();
 738             CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), clearColor);
 739         }
 740 
 741         //This is a temporary workaround. Looks like after 7124236 will be fixed
 742         //the correct place for invalidateShadow() is CGLayer.drawInCGLContext.
 743         SwingUtilities.invokeLater(new Runnable() {
 744             @Override
 745             public void run() {
 746                 invalidateShadow();
 747             }
 748         });
 749     }
 750 
 751     @Override
 752     public void enterFullScreenMode() {
 753         isFullScreenMode = true;
 754         contentView.enterFullScreenMode(getNSWindowPtr());
 755     }
 756 




 281         // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable
 282         {
 283             final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
 284             styleBits = SET(styleBits, RESIZABLE, resizable);
 285             if (!resizable) {
 286                 styleBits = SET(styleBits, RESIZABLE, false);
 287                 styleBits = SET(styleBits, ZOOMABLE, false);
 288             }
 289         }
 290 
 291         if (target.isAlwaysOnTop()) {
 292             styleBits = SET(styleBits, ALWAYS_ON_TOP, true);
 293         }
 294 
 295         if (target.getModalExclusionType() == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
 296             styleBits = SET(styleBits, MODAL_EXCLUDED, true);
 297         }
 298 
 299         // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look.
 300         if (isPopup) {
 301             styleBits = SET(styleBits, TEXTURED, false);
 302             // Popups in applets don't activate applet's process
 303             styleBits = SET(styleBits, NONACTIVATING, true);
 304         }
 305 
 306         if (Window.Type.UTILITY.equals(target.getType())) {
 307             styleBits = SET(styleBits, UTILITY, true);
 308         }
 309 
 310         if (target instanceof javax.swing.RootPaneContainer) {
 311             javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane();
 312             Object prop = null;
 313 
 314             prop = rootpane.getClientProperty(WINDOW_BRUSH_METAL_LOOK);
 315             if (prop != null) {
 316                 styleBits = SET(styleBits, TEXTURED, Boolean.parseBoolean(prop.toString()));
 317             }
 318 
 319             if (isDialog && ((Dialog)target).getModalityType() == ModalityType.DOCUMENT_MODAL) {
 320                 prop = rootpane.getClientProperty(WINDOW_DOC_MODAL_SHEET);
 321                 if (prop != null) {


 355             if (prop != null) {
 356                 styleBits = SET(styleBits, ZOOMABLE, Boolean.parseBoolean(prop.toString()));
 357             }
 358 
 359             prop = rootpane.getClientProperty(WINDOW_FULLSCREENABLE);
 360             if (prop != null) {
 361                 styleBits = SET(styleBits, FULLSCREENABLE, Boolean.parseBoolean(prop.toString()));
 362             }
 363 
 364             prop = rootpane.getClientProperty(WINDOW_SHADOW);
 365             if (prop != null) {
 366                 styleBits = SET(styleBits, HAS_SHADOW, Boolean.parseBoolean(prop.toString()));
 367             }
 368 
 369             prop = rootpane.getClientProperty(WINDOW_DRAGGABLE_BACKGROUND);
 370             if (prop != null) {
 371                 styleBits = SET(styleBits, DRAGGABLE_BACKGROUND, Boolean.parseBoolean(prop.toString()));
 372             }
 373         }
 374 
 375         peer.setTextured(IS(TEXTURED, styleBits));
 376 
 377         return styleBits;
 378     }
 379 
 380     // this is the counter-point to -[CWindow _nativeSetStyleBit:]
 381     protected void setStyleBits(final int mask, final boolean value) {
 382         nativeSetNSWindowStyleBits(getNSWindowPtr(), mask, value ? mask : 0);
 383     }
 384 
 385     private native void _toggleFullScreenMode(final long model);
 386 
 387     public void toggleFullScreen() {
 388         _toggleFullScreenMode(getNSWindowPtr());
 389     }
 390 
 391     @Override // PlatformWindow
 392     public void setMenuBar(MenuBar mb) {
 393         final long nsWindowPtr = getNSWindowPtr();
 394         CMenuBar mbPeer = (CMenuBar)LWToolkit.targetToPeer(mb);
 395         if (mbPeer != null) {
 396             nativeSetNSWindowMenuBar(nsWindowPtr, mbPeer.getModel());


 718 
 719     @Override
 720     public Graphics transformGraphics(Graphics g) {
 721         // is this where we can inject a transform for HiDPI?
 722         return g;
 723     }
 724 
 725     @Override
 726     public void setAlwaysOnTop(boolean isAlwaysOnTop) {
 727         setStyleBits(ALWAYS_ON_TOP, isAlwaysOnTop);
 728     }
 729 
 730     @Override
 731     public void setOpacity(float opacity) {
 732         CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity);
 733     }
 734 
 735     @Override
 736     public void setOpaque(boolean isOpaque) {
 737         CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque);
 738         if (!isOpaque && !peer.isTextured()) {
 739             long clearColor = CWrapper.NSColor.clearColor();
 740             CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), clearColor);
 741         }
 742 
 743         //This is a temporary workaround. Looks like after 7124236 will be fixed
 744         //the correct place for invalidateShadow() is CGLayer.drawInCGLContext.
 745         SwingUtilities.invokeLater(new Runnable() {
 746             @Override
 747             public void run() {
 748                 invalidateShadow();
 749             }
 750         });
 751     }
 752 
 753     @Override
 754     public void enterFullScreenMode() {
 755         isFullScreenMode = true;
 756         contentView.enterFullScreenMode(getNSWindowPtr());
 757     }
 758