193 return (CPlatformWindow)((LWWindowPeer)root.getPeer()).getPlatformWindow(); 194 } 195 }; 196 197 // Bounds of the native widget but in the Java coordinate system. 198 // In order to keep it up-to-date we will update them on 199 // 1) setting native bounds via nativeSetBounds() call 200 // 2) getting notification from the native level via deliverMoveResizeEvent() 201 private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0); 202 private volatile boolean isFullScreenMode; 203 private boolean isFullScreenAnimationOn; 204 205 private Window target; 206 private LWWindowPeer peer; 207 protected CPlatformView contentView; 208 protected CPlatformWindow owner; 209 protected boolean visible = false; // visibility status from native perspective 210 private boolean undecorated; // initialized in getInitialStyleBits() 211 private Rectangle normalBounds = null; // not-null only for undecorated maximized windows 212 private CPlatformResponder responder; 213 private volatile boolean zoomed = false; // from native perspective 214 215 public CPlatformWindow() { 216 super(0, true); 217 } 218 219 /* 220 * Delegate initialization (create native window and all the 221 * related resources). 222 */ 223 @Override // PlatformWindow 224 public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) { 225 initializeBase(_target, _peer, _owner, new CPlatformView()); 226 227 final int styleBits = getInitialStyleBits(); 228 229 responder = createPlatformResponder(); 230 contentView = createContentView(); 231 contentView.initialize(peer, responder); 232 233 final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L; 234 final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(), ownerPtr, styleBits, 0, 0, 0, 0); 235 setPtr(nativeWindowPtr); 236 237 if (target instanceof javax.swing.RootPaneContainer) { 238 final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane(); 239 if (rootpane != null) rootpane.addPropertyChangeListener("ancestor", new PropertyChangeListener() { 240 public void propertyChange(final PropertyChangeEvent evt) { 241 CLIENT_PROPERTY_APPLICATOR.attachAndApplyClientProperties(rootpane); 242 rootpane.removePropertyChangeListener("ancestor", this); 243 } 244 }); 245 } 246 247 validateSurface(); 248 } 249 250 protected void initializeBase(Window target, LWWindowPeer peer, PlatformWindow owner, CPlatformView view) { 251 this.peer = peer; 252 this.target = target; 253 if (owner instanceof CPlatformWindow) { 254 this.owner = (CPlatformWindow)owner; 449 } 450 451 @Override // PlatformWindow 452 public SurfaceData getScreenSurface() { 453 // TODO: not implemented 454 return null; 455 } 456 457 @Override // PlatformWindow 458 public SurfaceData replaceSurfaceData() { 459 return contentView.replaceSurfaceData(); 460 } 461 462 @Override // PlatformWindow 463 public void setBounds(int x, int y, int w, int h) { 464 // assert CThreading.assertEventQueue(); 465 nativeSetNSWindowBounds(getNSWindowPtr(), x, y, w, h); 466 } 467 468 private boolean isMaximized() { 469 return undecorated ? this.normalBounds != null : zoomed; 470 } 471 472 private void maximize() { 473 if (peer == null || isMaximized()) { 474 return; 475 } 476 if (!undecorated) { 477 zoomed = true; 478 CWrapper.NSWindow.zoom(getNSWindowPtr()); 479 } else { 480 deliverZoom(true); 481 482 this.normalBounds = peer.getBounds(); 483 484 GraphicsConfiguration config = getPeer().getGraphicsConfiguration(); 485 Insets i = ((CGraphicsDevice)config.getDevice()).getScreenInsets(); 486 Rectangle toBounds = config.getBounds(); 487 setBounds(toBounds.x + i.left, 488 toBounds.y + i.top, 489 toBounds.width - i.left - i.right, 490 toBounds.height - i.top - i.bottom); 491 } 492 } 493 494 private void unmaximize() { 495 if (!isMaximized()) { 496 return; 497 } 498 if (!undecorated) { 499 zoomed = false; 500 CWrapper.NSWindow.zoom(getNSWindowPtr()); 501 } else { 502 deliverZoom(false); 503 504 Rectangle toBounds = this.normalBounds; 505 this.normalBounds = null; 506 setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height); 507 } 508 } 509 510 public boolean isVisible() { 511 return this.visible; 512 } 513 514 @Override // PlatformWindow 515 public void setVisible(boolean visible) { 516 final long nsWindowPtr = getNSWindowPtr(); 517 518 // Process parent-child relationship when hiding 519 if (!visible) { | 193 return (CPlatformWindow)((LWWindowPeer)root.getPeer()).getPlatformWindow(); 194 } 195 }; 196 197 // Bounds of the native widget but in the Java coordinate system. 198 // In order to keep it up-to-date we will update them on 199 // 1) setting native bounds via nativeSetBounds() call 200 // 2) getting notification from the native level via deliverMoveResizeEvent() 201 private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0); 202 private volatile boolean isFullScreenMode; 203 private boolean isFullScreenAnimationOn; 204 205 private Window target; 206 private LWWindowPeer peer; 207 protected CPlatformView contentView; 208 protected CPlatformWindow owner; 209 protected boolean visible = false; // visibility status from native perspective 210 private boolean undecorated; // initialized in getInitialStyleBits() 211 private Rectangle normalBounds = null; // not-null only for undecorated maximized windows 212 private CPlatformResponder responder; 213 214 public CPlatformWindow() { 215 super(0, true); 216 } 217 218 /* 219 * Delegate initialization (create native window and all the 220 * related resources). 221 */ 222 @Override // PlatformWindow 223 public void initialize(Window _target, LWWindowPeer _peer, PlatformWindow _owner) { 224 initializeBase(_target, _peer, _owner, new CPlatformView()); 225 226 final int styleBits = getInitialStyleBits(); 227 228 responder = createPlatformResponder(); 229 contentView = createContentView(); 230 contentView.initialize(peer, responder); 231 232 final long ownerPtr = owner != null ? owner.getNSWindowPtr() : 0L; 233 Rectangle bounds = _target.getBounds(); 234 final long nativeWindowPtr = nativeCreateNSWindow(contentView.getAWTView(), 235 ownerPtr, styleBits, bounds.x, bounds.y, bounds.width, bounds.height); 236 setPtr(nativeWindowPtr); 237 238 if (target instanceof javax.swing.RootPaneContainer) { 239 final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane(); 240 if (rootpane != null) rootpane.addPropertyChangeListener("ancestor", new PropertyChangeListener() { 241 public void propertyChange(final PropertyChangeEvent evt) { 242 CLIENT_PROPERTY_APPLICATOR.attachAndApplyClientProperties(rootpane); 243 rootpane.removePropertyChangeListener("ancestor", this); 244 } 245 }); 246 } 247 248 validateSurface(); 249 } 250 251 protected void initializeBase(Window target, LWWindowPeer peer, PlatformWindow owner, CPlatformView view) { 252 this.peer = peer; 253 this.target = target; 254 if (owner instanceof CPlatformWindow) { 255 this.owner = (CPlatformWindow)owner; 450 } 451 452 @Override // PlatformWindow 453 public SurfaceData getScreenSurface() { 454 // TODO: not implemented 455 return null; 456 } 457 458 @Override // PlatformWindow 459 public SurfaceData replaceSurfaceData() { 460 return contentView.replaceSurfaceData(); 461 } 462 463 @Override // PlatformWindow 464 public void setBounds(int x, int y, int w, int h) { 465 // assert CThreading.assertEventQueue(); 466 nativeSetNSWindowBounds(getNSWindowPtr(), x, y, w, h); 467 } 468 469 private boolean isMaximized() { 470 return undecorated ? this.normalBounds != null 471 : CWrapper.NSWindow.isZoomed(getNSWindowPtr()); 472 } 473 474 private void maximize() { 475 if (peer == null || isMaximized()) { 476 return; 477 } 478 if (!undecorated) { 479 CWrapper.NSWindow.zoom(getNSWindowPtr()); 480 } else { 481 deliverZoom(true); 482 483 this.normalBounds = peer.getBounds(); 484 485 GraphicsConfiguration config = getPeer().getGraphicsConfiguration(); 486 Insets i = ((CGraphicsDevice)config.getDevice()).getScreenInsets(); 487 Rectangle toBounds = config.getBounds(); 488 setBounds(toBounds.x + i.left, 489 toBounds.y + i.top, 490 toBounds.width - i.left - i.right, 491 toBounds.height - i.top - i.bottom); 492 } 493 } 494 495 private void unmaximize() { 496 if (!isMaximized()) { 497 return; 498 } 499 if (!undecorated) { 500 CWrapper.NSWindow.zoom(getNSWindowPtr()); 501 } else { 502 deliverZoom(false); 503 504 Rectangle toBounds = this.normalBounds; 505 this.normalBounds = null; 506 setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height); 507 } 508 } 509 510 public boolean isVisible() { 511 return this.visible; 512 } 513 514 @Override // PlatformWindow 515 public void setVisible(boolean visible) { 516 final long nsWindowPtr = getNSWindowPtr(); 517 518 // Process parent-child relationship when hiding 519 if (!visible) { |