javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/GraphicsContext.java
changeset 78 71ad690e91f5
parent 35 85266cc22c7f
equal deleted inserted replaced
72:1f0034e370aa 78:71ad690e91f5
   338      * @throws java.lang.IllegalArgumentException if given target cannot be bound
   338      * @throws java.lang.IllegalArgumentException if given target cannot be bound
   339      * @throws java.lang.IllegalArgumentException if given target is already disposed
   339      * @throws java.lang.IllegalArgumentException if given target is already disposed
   340      */
   340      */
   341     public void bindTarget(org.eclipse.swt.widgets.Control target) {
   341     public void bindTarget(org.eclipse.swt.widgets.Control target) {
   342         if(target == null) {
   342         if(target == null) {
   343         	throw new NullPointerException("target is null");
   343             throw new NullPointerException("target is null");
   344         }
   344         }
   345         if(target.isDisposed())
   345         if(target.isDisposed())
   346             throw new IllegalArgumentException("Target already disposed");
   346             throw new IllegalArgumentException("Target already disposed");
   347         bindTarget(target, TARGET_WIDGET, handle(target), 0);
   347         bindTarget(target, TARGET_WIDGET, handle(target), 0);
   348     }
   348     }
   359      * @throws java.lang.IllegalArgumentException if given target cannot be bound
   359      * @throws java.lang.IllegalArgumentException if given target cannot be bound
   360      * @throws java.lang.IllegalArgumentException if given target is already disposed
   360      * @throws java.lang.IllegalArgumentException if given target is already disposed
   361      */
   361      */
   362     public void bindTarget(org.eclipse.swt.widgets.Display target) {
   362     public void bindTarget(org.eclipse.swt.widgets.Display target) {
   363         if(target == null) {
   363         if(target == null) {
   364         	throw new NullPointerException("target is null");
   364             throw new NullPointerException("target is null");
   365         }
   365         }
   366         if(target.isDisposed())
   366         if(target.isDisposed())
   367             throw new IllegalArgumentException("Target already disposed");
   367             throw new IllegalArgumentException("Target already disposed");
   368         int handle = org.eclipse.swt.internal.qt.OS.QApplication_desktop();
   368         int handle = org.eclipse.swt.internal.qt.OS.QApplication_desktop();
   369         bindTarget(target, TARGET_WIDGET, handle, 0);
   369         bindTarget(target, TARGET_WIDGET, handle, 0);
   381      * @throws java.lang.IllegalArgumentException if given target cannot be bound
   381      * @throws java.lang.IllegalArgumentException if given target cannot be bound
   382      * @throws java.lang.IllegalArgumentException if given target is already disposed
   382      * @throws java.lang.IllegalArgumentException if given target is already disposed
   383      */
   383      */
   384     public void bindTarget(org.eclipse.swt.internal.qt.graphics.Image target) {
   384     public void bindTarget(org.eclipse.swt.internal.qt.graphics.Image target) {
   385         if(target == null) {
   385         if(target == null) {
   386         	throw new NullPointerException("target is null");
   386             throw new NullPointerException("target is null");
   387         }
   387         }
   388         if(target.isDisposed())
   388         if(target.isDisposed())
   389             throw new IllegalArgumentException("Target already disposed");
   389             throw new IllegalArgumentException("Target already disposed");
   390         bindTarget(target, TARGET_IMAGE, target.handle, 0);
   390         bindTarget(target, TARGET_IMAGE, target.handle, 0);
   391     }
   391     }
   404      * @throws java.lang.IllegalArgumentException if given target cannot be bound
   404      * @throws java.lang.IllegalArgumentException if given target cannot be bound
   405      * @throws java.lang.IllegalArgumentException if given target is already disposed
   405      * @throws java.lang.IllegalArgumentException if given target is already disposed
   406      */
   406      */
   407     public void bindTarget(org.eclipse.swt.internal.qt.graphics.NativeCommandBuffer target, org.eclipse.swt.widgets.Control flushTarget) {
   407     public void bindTarget(org.eclipse.swt.internal.qt.graphics.NativeCommandBuffer target, org.eclipse.swt.widgets.Control flushTarget) {
   408         if(target == null) {
   408         if(target == null) {
   409         	throw new NullPointerException("target is null");
   409             throw new NullPointerException("target is null");
   410         }
   410         }
   411         if(flushTarget == null) {
   411         if(flushTarget == null) {
   412         	throw new NullPointerException("flushTarget is null");
   412             throw new NullPointerException("flushTarget is null");
   413         }
   413         }
   414         if(target.isDisposed())
   414         if(target.isDisposed())
   415             throw new IllegalArgumentException("Target already disposed");
   415             throw new IllegalArgumentException("Target already disposed");
   416         if(flushTarget.isDisposed())
   416         if(flushTarget.isDisposed())
   417             throw new IllegalArgumentException("Buffer flush target already disposed");
   417             throw new IllegalArgumentException("Buffer flush target already disposed");
   442      * @deprecated Buffer flush target must be given be given when binding to a buffer. 
   442      * @deprecated Buffer flush target must be given be given when binding to a buffer. 
   443      * @see bindTarget(org.eclipse.swt.internal.qt.graphics.Buffer target, org.eclipse.swt.widgets.Control flushTarget)
   443      * @see bindTarget(org.eclipse.swt.internal.qt.graphics.Buffer target, org.eclipse.swt.widgets.Control flushTarget)
   444      */
   444      */
   445     public void bindTarget(org.eclipse.swt.internal.qt.graphics.NativeCommandBuffer target) {
   445     public void bindTarget(org.eclipse.swt.internal.qt.graphics.NativeCommandBuffer target) {
   446         if(target == null) {
   446         if(target == null) {
   447         	throw new NullPointerException("Target is null");
   447             throw new NullPointerException("Target is null");
   448         }
   448         }
   449         if(target.isDisposed()) {
   449         if(target.isDisposed()) {
   450             throw new IllegalArgumentException("target already disposed");
   450             throw new IllegalArgumentException("target already disposed");
   451         }
   451         }
   452         bindTarget(target, TARGET_NATIVE_COMMAND_BUFFER, target.handle, 0);
   452         bindTarget(target, TARGET_NATIVE_COMMAND_BUFFER, target.handle, 0);
   462      * @throws java.lang.NullPointerException if given target is null
   462      * @throws java.lang.NullPointerException if given target is null
   463      * @throws java.lang.IllegalArgumentException if given target is already disposed
   463      * @throws java.lang.IllegalArgumentException if given target is already disposed
   464      */
   464      */
   465     public void bindTarget(org.eclipse.swt.internal.qt.graphics.WindowSurface target) {
   465     public void bindTarget(org.eclipse.swt.internal.qt.graphics.WindowSurface target) {
   466         if(target == null) {
   466         if(target == null) {
   467         	throw new NullPointerException("target is null");
   467             throw new NullPointerException("target is null");
   468         }
   468         }
   469     	if(target.isDisposed()) {
   469         if(target.isDisposed()) {
   470             throw new IllegalArgumentException("target already disposed");
   470             throw new IllegalArgumentException("target already disposed");
   471         }
   471         }
   472     	bindTarget(target, TARGET_WINDOWSURFACE, target.handle, 0); 
   472         bindTarget(target, TARGET_WINDOWSURFACE, target.handle, 0); 
   473     }
   473     }
   474     
   474     
   475     /**
   475     /**
   476      * Get target to which current GraphicsContext is bound to
   476      * Get target to which current GraphicsContext is bound to
   477      *
   477      *
   558         if(buffer == null) {
   558         if(buffer == null) {
   559             throw new NullPointerException("buffer is null");
   559             throw new NullPointerException("buffer is null");
   560         }
   560         }
   561         // if buffer does not contain data do nothing
   561         // if buffer does not contain data do nothing
   562         if(buffer.containsData()) {
   562         if(buffer.containsData()) {
       
   563             // Notify the image that it will get modified. This affects any existing shallow copies of it. 
       
   564             if(targetData.type == GraphicsContext.TARGET_IMAGE) {
       
   565                 ((Image)targetData.target).pixelDataModified();
       
   566             }
   563             processBuffer(buffer);
   567             processBuffer(buffer);
   564         }
   568         }
   565     }
   569     }
   566     
   570     
   567     /**
   571     /**
  1147      * @param width The width of the source area to draw
  1151      * @param width The width of the source area to draw
  1148      * @param height The height of the source area to draw
  1152      * @param height The height of the source area to draw
  1149      * @throws NullPointerException if surface is null
  1153      * @throws NullPointerException if surface is null
  1150      */
  1154      */
  1151     public void drawWindowSurface(WindowSurface surface, int x, int y, int width, int height) {
  1155     public void drawWindowSurface(WindowSurface surface, int x, int y, int width, int height) {
  1152     	if(surface == null) 
  1156         if(surface == null) 
  1153     	{
  1157         {
  1154     	    throw new NullPointerException("surface is null");
  1158             throw new NullPointerException("surface is null");
  1155     	}
  1159         }
  1156     	OS.graphicsContext_drawWindowSurface(handle, surface.handle, x, y, width, height);
  1160         OS.graphicsContext_drawWindowSurface(handle, surface.handle, x, y, width, height);
  1157     }
  1161     }
  1158     
  1162     
  1159     
  1163     
  1160     /**
  1164     /**
  1161      * Fill interior of circular or elliptical arc within specified rectangular area, using background color.
  1165      * Fill interior of circular or elliptical arc within specified rectangular area, using background color.
  2092                                                         intParams[i++]);
  2096                                                         intParams[i++]);
  2093                             break;
  2097                             break;
  2094                         }
  2098                         }
  2095                         case JavaCommandBuffer.OP_DRAWIMAGE1:
  2099                         case JavaCommandBuffer.OP_DRAWIMAGE1:
  2096                         {
  2100                         {
  2097                             Image img = (Image)images.elementAt(imageCount++);
  2101                             Image img = (Image)images.elementAt(imageCount);
       
  2102                             images.setElementAt(null, imageCount++);
  2098                             OS.graphicsContext_drawImage(handle, 
  2103                             OS.graphicsContext_drawImage(handle, 
  2099                                                          img.handle, 
  2104                                                          img.handle, 
  2100                                                          intParams[i++], 
  2105                                                          intParams[i++], 
  2101                                                          intParams[i++]);
  2106                                                          intParams[i++]);
  2102                             // As we made a shallow copy of the image in buffer
  2107                             // As we made a shallow copy of the image in buffer
  2103                             // its safe to delete that here
  2108                             // its safe to delete that here
  2104                             img.dispose(); 
  2109                             img.freeCommandBufferCopy();
  2105                             break;
  2110                             break;
  2106                         }
  2111                         }
  2107                         case JavaCommandBuffer.OP_DRAWIMAGE2:
  2112                         case JavaCommandBuffer.OP_DRAWIMAGE2:
  2108                         {
  2113                         {
  2109                             Image img = (Image)images.elementAt(imageCount++);  
  2114                             Image img = (Image)images.elementAt(imageCount);
       
  2115                             images.setElementAt(null, imageCount++);
  2110                             OS.graphicsContext_drawImage(handle, 
  2116                             OS.graphicsContext_drawImage(handle, 
  2111                                                          img.handle, 
  2117                                                          img.handle, 
  2112                                                          intParams[i++], 
  2118                                                          intParams[i++], 
  2113                                                          intParams[i++], 
  2119                                                          intParams[i++], 
  2114                                                          intParams[i++], 
  2120                                                          intParams[i++], 
  2118                                                          intParams[i++], 
  2124                                                          intParams[i++], 
  2119                                                          intParams[i++],
  2125                                                          intParams[i++],
  2120                                                          intParams[i++]);
  2126                                                          intParams[i++]);
  2121                             // As we made a shallow copy of the image in buffer
  2127                             // As we made a shallow copy of the image in buffer
  2122                             // its safe to delete that here
  2128                             // its safe to delete that here
  2123                             img.dispose(); 
  2129                             img.freeCommandBufferCopy();
  2124                             break;
  2130                             break;
  2125                         }
  2131                         }
  2126                         case JavaCommandBuffer.OP_DRAWFOCUS:
  2132                         case JavaCommandBuffer.OP_DRAWFOCUS:
  2127                         {
  2133                         {
  2128                             OS.graphicsContext_drawFocus(handle, 
  2134                             OS.graphicsContext_drawFocus(handle, 
  2225                             rgbs.setElementAt(null, index);
  2231                             rgbs.setElementAt(null, index);
  2226                             break;
  2232                             break;
  2227                         }
  2233                         }
  2228                         case JavaCommandBuffer.OP_DRAWROUNDRECT:
  2234                         case JavaCommandBuffer.OP_DRAWROUNDRECT:
  2229                         {
  2235                         {
  2230                             OS.graphicsContext_fillRoundRect(handle, 
  2236                             OS.graphicsContext_drawRoundRect(handle, 
  2231                                                              intParams[i++], 
  2237                                                              intParams[i++], 
  2232                                                              intParams[i++], 
  2238                                                              intParams[i++], 
  2233                                                              intParams[i++], 
  2239                                                              intParams[i++], 
  2234                                                              intParams[i++], 
  2240                                                              intParams[i++], 
  2235                                                              intParams[i++], 
  2241                                                              intParams[i++],