526 @Override
527 public void setMenuBar(MenuBar mb) {
528 platformWindow.setMenuBar(mb);
529 }
530
531 @Override // FramePeer and DialogPeer
532 public void setResizable(boolean resizable) {
533 platformWindow.setResizable(resizable);
534 }
535
536 @Override
537 public void setState(int state) {
538 platformWindow.setWindowState(state);
539 }
540
541 @Override
542 public int getState() {
543 return windowState;
544 }
545
546 @Override
547 public void setMaximizedBounds(Rectangle bounds) {
548 // TODO: not implemented
549 }
550
551 @Override
552 public void setBoundsPrivate(int x, int y, int width, int height) {
553 setBounds(x, y, width, height, SET_BOUNDS | NO_EMBEDDED_CHECK);
554 }
555
556 @Override
557 public Rectangle getBoundsPrivate() {
558 throw new RuntimeException("not implemented");
559 }
560
561 // ---- DIALOG PEER METHODS ---- //
562
563 @Override
564 public void blockWindows(List<Window> windows) {
565 //TODO: LWX will probably need some collectJavaToplevels to speed this up
566 for (Window w : windows) {
567 WindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(w);
568 if (wp != null) {
618 * user or window insets are changed. There's no notifyReshape() in
619 * LWComponentPeer as the only components which could be resized by user are
620 * top-level windows.
621 */
622 @Override
623 public void notifyReshape(int x, int y, int w, int h) {
624 Rectangle oldBounds = getBounds();
625 final boolean invalid = updateInsets(platformWindow.getInsets());
626 final boolean moved = (x != oldBounds.x) || (y != oldBounds.y);
627 final boolean resized = (w != oldBounds.width) || (h != oldBounds.height);
628
629 // Check if anything changed
630 if (!moved && !resized && !invalid) {
631 return;
632 }
633 // First, update peer's bounds
634 setBounds(x, y, w, h, SET_BOUNDS, false, false);
635
636 // Second, update the graphics config and surface data
637 final boolean isNewDevice = updateGraphicsDevice();
638 if (resized || isNewDevice) {
639 replaceSurfaceData();
640 updateMinimumSize();
641 }
642
643 // Third, COMPONENT_MOVED/COMPONENT_RESIZED/PAINT events
644 if (moved || invalid) {
645 handleMove(x, y, true);
646 }
647 if (resized || invalid || isNewDevice) {
648 handleResize(w, h, true);
649 repaintPeer();
650 }
651
652 repositionSecurityWarning();
653 }
654
655 private void clearBackground(final int w, final int h) {
656 final Graphics g = getOnscreenGraphics(getForeground(), getBackground(),
657 getFont());
1041 graphicsDevice = newGraphicsDevice;
1042 }
1043
1044 final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration();
1045
1046 if (!setGraphicsConfig(newGC)) return false;
1047
1048 SunToolkit.executeOnEventHandlerThread(getTarget(), new Runnable() {
1049 public void run() {
1050 AWTAccessor.getComponentAccessor().setGraphicsConfiguration(getTarget(), newGC);
1051 }
1052 });
1053 return true;
1054 }
1055
1056 @Override
1057 public final void displayChanged() {
1058 if (updateGraphicsDevice()) {
1059 updateMinimumSize();
1060 }
1061 // Replace surface unconditionally, because internal state of the
1062 // GraphicsDevice could be changed.
1063 replaceSurfaceData();
1064 repaintPeer();
1065 }
1066
1067 @Override
1068 public final void paletteChanged() {
1069 // components do not need to react to this event.
1070 }
1071
1072 /*
1073 * May be called by delegate to provide SD to Java2D code.
1074 */
1075 public SurfaceData getSurfaceData() {
1076 synchronized (surfaceDataLock) {
1077 return surfaceData;
1078 }
1079 }
1080
|
526 @Override
527 public void setMenuBar(MenuBar mb) {
528 platformWindow.setMenuBar(mb);
529 }
530
531 @Override // FramePeer and DialogPeer
532 public void setResizable(boolean resizable) {
533 platformWindow.setResizable(resizable);
534 }
535
536 @Override
537 public void setState(int state) {
538 platformWindow.setWindowState(state);
539 }
540
541 @Override
542 public int getState() {
543 return windowState;
544 }
545
546 public Rectangle getMaximizedBounds() {
547 Object target = getTarget();
548 return (target instanceof Frame)
549 ? ((Frame) target).getMaximizedBounds() : null;
550 }
551
552 public Rectangle getDefaultMaximizedBounds() {
553 GraphicsConfiguration config = getGraphicsConfiguration();
554 Insets insets = ((CGraphicsDevice) config.getDevice()).getScreenInsets();
555 Rectangle toBounds = config.getBounds();
556 return new Rectangle(
557 toBounds.x + insets.left,
558 toBounds.y + insets.top,
559 toBounds.width - insets.left - insets.right,
560 toBounds.height - insets.top - insets.bottom);
561 }
562
563 @Override
564 public void setMaximizedBounds(Rectangle bounds) {
565
566 bounds = (bounds == null)
567 ? getDefaultMaximizedBounds()
568 : constrainBounds(bounds);
569 platformWindow.setMaximizedBounds(
570 bounds.x, bounds.y, bounds.width, bounds.height);
571 }
572
573 private void updateMaximizedBounds() {
574 Rectangle maximizedBounds = getMaximizedBounds();
575 if (maximizedBounds == null) {
576 setMaximizedBounds(getDefaultMaximizedBounds());
577 }
578 }
579
580 @Override
581 public void setBoundsPrivate(int x, int y, int width, int height) {
582 setBounds(x, y, width, height, SET_BOUNDS | NO_EMBEDDED_CHECK);
583 }
584
585 @Override
586 public Rectangle getBoundsPrivate() {
587 throw new RuntimeException("not implemented");
588 }
589
590 // ---- DIALOG PEER METHODS ---- //
591
592 @Override
593 public void blockWindows(List<Window> windows) {
594 //TODO: LWX will probably need some collectJavaToplevels to speed this up
595 for (Window w : windows) {
596 WindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(w);
597 if (wp != null) {
647 * user or window insets are changed. There's no notifyReshape() in
648 * LWComponentPeer as the only components which could be resized by user are
649 * top-level windows.
650 */
651 @Override
652 public void notifyReshape(int x, int y, int w, int h) {
653 Rectangle oldBounds = getBounds();
654 final boolean invalid = updateInsets(platformWindow.getInsets());
655 final boolean moved = (x != oldBounds.x) || (y != oldBounds.y);
656 final boolean resized = (w != oldBounds.width) || (h != oldBounds.height);
657
658 // Check if anything changed
659 if (!moved && !resized && !invalid) {
660 return;
661 }
662 // First, update peer's bounds
663 setBounds(x, y, w, h, SET_BOUNDS, false, false);
664
665 // Second, update the graphics config and surface data
666 final boolean isNewDevice = updateGraphicsDevice();
667 if (isNewDevice) {
668 updateMaximizedBounds();
669 }
670
671 if (resized || isNewDevice) {
672 replaceSurfaceData();
673 updateMinimumSize();
674 }
675
676 // Third, COMPONENT_MOVED/COMPONENT_RESIZED/PAINT events
677 if (moved || invalid) {
678 handleMove(x, y, true);
679 }
680 if (resized || invalid || isNewDevice) {
681 handleResize(w, h, true);
682 repaintPeer();
683 }
684
685 repositionSecurityWarning();
686 }
687
688 private void clearBackground(final int w, final int h) {
689 final Graphics g = getOnscreenGraphics(getForeground(), getBackground(),
690 getFont());
1074 graphicsDevice = newGraphicsDevice;
1075 }
1076
1077 final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration();
1078
1079 if (!setGraphicsConfig(newGC)) return false;
1080
1081 SunToolkit.executeOnEventHandlerThread(getTarget(), new Runnable() {
1082 public void run() {
1083 AWTAccessor.getComponentAccessor().setGraphicsConfiguration(getTarget(), newGC);
1084 }
1085 });
1086 return true;
1087 }
1088
1089 @Override
1090 public final void displayChanged() {
1091 if (updateGraphicsDevice()) {
1092 updateMinimumSize();
1093 }
1094
1095 updateMaximizedBounds();
1096
1097 // Replace surface unconditionally, because internal state of the
1098 // GraphicsDevice could be changed.
1099 replaceSurfaceData();
1100 repaintPeer();
1101 }
1102
1103 @Override
1104 public final void paletteChanged() {
1105 // components do not need to react to this event.
1106 }
1107
1108 /*
1109 * May be called by delegate to provide SD to Java2D code.
1110 */
1111 public SurfaceData getSurfaceData() {
1112 synchronized (surfaceDataLock) {
1113 return surfaceData;
1114 }
1115 }
1116
|