src/windows/classes/sun/awt/windows/WComponentPeer.java

Print this page




 343                 // Fallthrough to next statement
 344             case PaintEvent.UPDATE:
 345                 // Skip all painting while layouting and all UPDATEs
 346                 // while waiting for native paint
 347                 if (!isLayouting && ! paintPending) {
 348                     paintArea.paint(target,shouldClearRectBeforePaint());
 349                 }
 350                 return;
 351             case FocusEvent.FOCUS_LOST:
 352             case FocusEvent.FOCUS_GAINED:
 353                 handleJavaFocusEvent((FocusEvent)e);
 354             default:
 355             break;
 356         }
 357 
 358         // Call the native code
 359         nativeHandleEvent(e);
 360     }
 361 
 362     void handleJavaFocusEvent(FocusEvent fe) {
 363         if (focusLog.isLoggable(PlatformLogger.FINER)) focusLog.finer(fe.toString());


 364         setFocus(fe.getID() == FocusEvent.FOCUS_GAINED);
 365     }
 366 
 367     native void setFocus(boolean doSetFocus);
 368 
 369     public Dimension getMinimumSize() {
 370         return ((Component)target).getSize();
 371     }
 372 
 373     public Dimension getPreferredSize() {
 374         return getMinimumSize();
 375     }
 376 
 377     // Do nothing for heavyweight implementation
 378     public void layout() {}
 379 
 380     public Rectangle getBounds() {
 381         return ((Component)target).getBounds();
 382     }
 383 


 676                                             temporary, focusedWindowChangeAllowed,
 677                                             time, cause);
 678 
 679         switch (result) {
 680           case WKeyboardFocusManagerPeer.SNFH_FAILURE:
 681               return false;
 682           case WKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
 683               if (focusLog.isLoggable(PlatformLogger.FINER)) {
 684                   focusLog.finer("Proceeding with request to " + lightweightChild + " in " + target);
 685               }
 686               Window parentWindow = SunToolkit.getContainingWindow((Component)target);
 687               if (parentWindow == null) {
 688                   return rejectFocusRequestHelper("WARNING: Parent window is null");
 689               }
 690               WWindowPeer wpeer = (WWindowPeer)parentWindow.getPeer();
 691               if (wpeer == null) {
 692                   return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
 693               }
 694               boolean res = wpeer.requestWindowFocus(cause);
 695 
 696               if (focusLog.isLoggable(PlatformLogger.FINER)) focusLog.finer("Requested window focus: " + res);


 697               // If parent window can be made focused and has been made focused(synchronously)
 698               // then we can proceed with children, otherwise we retreat.
 699               if (!(res && parentWindow.isFocused())) {
 700                   return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
 701               }
 702               return WKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
 703                                                             (Component)target,
 704                                                             temporary,
 705                                                             focusedWindowChangeAllowed,
 706                                                             time, cause);
 707 
 708           case WKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
 709               // Either lightweight or excessive request - all events are generated.
 710               return true;
 711         }
 712         return false;
 713     }
 714 
 715     private boolean rejectFocusRequestHelper(String logMsg) {
 716         if (focusLog.isLoggable(PlatformLogger.FINER)) focusLog.finer(logMsg);


 717         WKeyboardFocusManagerPeer.removeLastFocusRequest((Component)target);
 718         return false;
 719     }
 720 
 721     public Image createImage(ImageProducer producer) {
 722         return new ToolkitImage(producer);
 723     }
 724 
 725     public Image createImage(int width, int height) {
 726         Win32GraphicsConfig gc =
 727             (Win32GraphicsConfig)getGraphicsConfiguration();
 728         return gc.createAcceleratedImage((Component)target, width, height);
 729     }
 730 
 731     public VolatileImage createVolatileImage(int width, int height) {
 732         return new SunVolatileImage((Component)target, width, height);
 733     }
 734 
 735     public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
 736         return getToolkit().prepareImage(img, w, h, o);


1063     // @return true if the toplevel container is not an EmbeddedFrame or
1064     // if this EmbeddedFrame is acceleration capable, false otherwise
1065     @SuppressWarnings("deprecation")
1066     private static final boolean isContainingTopLevelAccelCapable(Component c) {
1067         while (c != null && !(c instanceof WEmbeddedFrame)) {
1068             c = c.getParent();
1069         }
1070         if (c == null) {
1071             return true;
1072         }
1073         return ((WEmbeddedFramePeer)c.getPeer()).isAccelCapable();
1074     }
1075 
1076     /**
1077      * Applies the shape to the native component window.
1078      * @since 1.7
1079      */
1080     @SuppressWarnings("deprecation")
1081     public void applyShape(Region shape) {
1082         if (shapeLog.isLoggable(PlatformLogger.FINER)) {
1083             shapeLog.finer(
1084                     "*** INFO: Setting shape: PEER: " + this
1085                     + "; TARGET: " + target
1086                     + "; SHAPE: " + shape);
1087         }
1088 
1089         if (shape != null) {
1090             setRectangularShape(shape.getLoX(), shape.getLoY(), shape.getHiX(), shape.getHiY(),
1091                     (shape.isRectangular() ? null : shape));
1092         } else {
1093             setRectangularShape(0, 0, 0, 0, null);
1094         }
1095     }
1096 
1097     /**
1098      * Lowers this component at the bottom of the above component. If the above parameter
1099      * is null then the method places this component at the top of the Z-order.
1100      */
1101     public void setZOrder(ComponentPeer above) {
1102         long aboveHWND = (above != null) ? ((WComponentPeer)above).getHWnd() : 0;
1103 
1104         setZOrder(aboveHWND);


 343                 // Fallthrough to next statement
 344             case PaintEvent.UPDATE:
 345                 // Skip all painting while layouting and all UPDATEs
 346                 // while waiting for native paint
 347                 if (!isLayouting && ! paintPending) {
 348                     paintArea.paint(target,shouldClearRectBeforePaint());
 349                 }
 350                 return;
 351             case FocusEvent.FOCUS_LOST:
 352             case FocusEvent.FOCUS_GAINED:
 353                 handleJavaFocusEvent((FocusEvent)e);
 354             default:
 355             break;
 356         }
 357 
 358         // Call the native code
 359         nativeHandleEvent(e);
 360     }
 361 
 362     void handleJavaFocusEvent(FocusEvent fe) {
 363         if (focusLog.isLoggable(PlatformLogger.FINER)) {
 364             focusLog.finer(fe.toString());
 365         }
 366         setFocus(fe.getID() == FocusEvent.FOCUS_GAINED);
 367     }
 368 
 369     native void setFocus(boolean doSetFocus);
 370 
 371     public Dimension getMinimumSize() {
 372         return ((Component)target).getSize();
 373     }
 374 
 375     public Dimension getPreferredSize() {
 376         return getMinimumSize();
 377     }
 378 
 379     // Do nothing for heavyweight implementation
 380     public void layout() {}
 381 
 382     public Rectangle getBounds() {
 383         return ((Component)target).getBounds();
 384     }
 385 


 678                                             temporary, focusedWindowChangeAllowed,
 679                                             time, cause);
 680 
 681         switch (result) {
 682           case WKeyboardFocusManagerPeer.SNFH_FAILURE:
 683               return false;
 684           case WKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
 685               if (focusLog.isLoggable(PlatformLogger.FINER)) {
 686                   focusLog.finer("Proceeding with request to " + lightweightChild + " in " + target);
 687               }
 688               Window parentWindow = SunToolkit.getContainingWindow((Component)target);
 689               if (parentWindow == null) {
 690                   return rejectFocusRequestHelper("WARNING: Parent window is null");
 691               }
 692               WWindowPeer wpeer = (WWindowPeer)parentWindow.getPeer();
 693               if (wpeer == null) {
 694                   return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
 695               }
 696               boolean res = wpeer.requestWindowFocus(cause);
 697 
 698               if (focusLog.isLoggable(PlatformLogger.FINER)) {
 699                   focusLog.finer("Requested window focus: " + res);
 700               }
 701               // If parent window can be made focused and has been made focused(synchronously)
 702               // then we can proceed with children, otherwise we retreat.
 703               if (!(res && parentWindow.isFocused())) {
 704                   return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
 705               }
 706               return WKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
 707                                                             (Component)target,
 708                                                             temporary,
 709                                                             focusedWindowChangeAllowed,
 710                                                             time, cause);
 711 
 712           case WKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
 713               // Either lightweight or excessive request - all events are generated.
 714               return true;
 715         }
 716         return false;
 717     }
 718 
 719     private boolean rejectFocusRequestHelper(String logMsg) {
 720         if (focusLog.isLoggable(PlatformLogger.FINER)) {
 721             focusLog.finer(logMsg);
 722         }
 723         WKeyboardFocusManagerPeer.removeLastFocusRequest((Component)target);
 724         return false;
 725     }
 726 
 727     public Image createImage(ImageProducer producer) {
 728         return new ToolkitImage(producer);
 729     }
 730 
 731     public Image createImage(int width, int height) {
 732         Win32GraphicsConfig gc =
 733             (Win32GraphicsConfig)getGraphicsConfiguration();
 734         return gc.createAcceleratedImage((Component)target, width, height);
 735     }
 736 
 737     public VolatileImage createVolatileImage(int width, int height) {
 738         return new SunVolatileImage((Component)target, width, height);
 739     }
 740 
 741     public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
 742         return getToolkit().prepareImage(img, w, h, o);


1069     // @return true if the toplevel container is not an EmbeddedFrame or
1070     // if this EmbeddedFrame is acceleration capable, false otherwise
1071     @SuppressWarnings("deprecation")
1072     private static final boolean isContainingTopLevelAccelCapable(Component c) {
1073         while (c != null && !(c instanceof WEmbeddedFrame)) {
1074             c = c.getParent();
1075         }
1076         if (c == null) {
1077             return true;
1078         }
1079         return ((WEmbeddedFramePeer)c.getPeer()).isAccelCapable();
1080     }
1081 
1082     /**
1083      * Applies the shape to the native component window.
1084      * @since 1.7
1085      */
1086     @SuppressWarnings("deprecation")
1087     public void applyShape(Region shape) {
1088         if (shapeLog.isLoggable(PlatformLogger.FINER)) {
1089             shapeLog.finer("*** INFO: Setting shape: PEER: " + this

1090                             + "; TARGET: " + target
1091                             + "; SHAPE: " + shape);
1092         }
1093 
1094         if (shape != null) {
1095             setRectangularShape(shape.getLoX(), shape.getLoY(), shape.getHiX(), shape.getHiY(),
1096                     (shape.isRectangular() ? null : shape));
1097         } else {
1098             setRectangularShape(0, 0, 0, 0, null);
1099         }
1100     }
1101 
1102     /**
1103      * Lowers this component at the bottom of the above component. If the above parameter
1104      * is null then the method places this component at the top of the Z-order.
1105      */
1106     public void setZOrder(ComponentPeer above) {
1107         long aboveHWND = (above != null) ? ((WComponentPeer)above).getHWnd() : 0;
1108 
1109         setZOrder(aboveHWND);