Ejemplo n.º 1
0
 public void setImage(Image image) {
   checkWidget();
   if ((style & SWT.SEPARATOR) != 0) return;
   if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
   super.setImage(image);
   updateImages(getEnabled() && parent.getEnabled());
 }
Ejemplo n.º 2
0
 /**
  * Returns a point describing the receiver's size.
  *
  * @return the receiver's size
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public Point getSize() {
   checkWidget();
   if (image != null) {
     Rectangle rect = image.getBounds();
     return new Point(rect.width, rect.height);
   }
   return new Point(width, height);
 }
Ejemplo n.º 3
0
 /**
  * Returns a rectangle describing the receiver's size and location relative to its parent (or its
  * display if its parent is null).
  *
  * @return the receiver's bounding rectangle
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public Rectangle getBounds() {
   checkWidget();
   if (image != null) {
     Rectangle rect = image.getBounds();
     return new Rectangle(x, y, rect.width, rect.height);
   }
   return new Rectangle(x, y, width, height);
 }
Ejemplo n.º 4
0
 void resize(int width, int height) {
   if (image != null) {
     Rectangle rect = image.getBounds();
     width = rect.width;
     height = rect.height;
   }
   if (width == 0) width = 1;
   OS.FrameworkElement_Width(handle, width);
   OS.FrameworkElement_Height(handle, height);
 }
Ejemplo n.º 5
0
 /**
  * Sets the image that the receiver will use to paint the caret to the image specified by the
  * argument, or to the default which is a filled rectangle if the argument is null
  *
  * @param image the new image (or null)
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_INVALID_ARGUMENT - if the image has been disposed
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setImage(Image image) {
   checkWidget();
   if (image != null && image.isDisposed()) {
     error(SWT.ERROR_INVALID_ARGUMENT);
   }
   this.image = image;
   if (image != null) {
     OS.Image_Source(imageHandle, image.handle);
     OS.UIElement_Visibility(imageHandle, OS.Visibility_Visible);
   } else {
     OS.Image_Source(imageHandle, 0);
     OS.UIElement_Visibility(imageHandle, OS.Visibility_Collapsed);
   }
   resize(width, height);
 }
Ejemplo n.º 6
0
 /**
  * Sets the receiver's image to the argument, which may be <code>null</code> indicating that no
  * image should be displayed.
  *
  * <p>Note that a Button can display an image and text simultaneously on Windows (starting with
  * XP), GTK+ and OSX. On other platforms, a Button that has an image and text set into it will
  * display the image or text that was set most recently.
  *
  * @param image the image to display on the receiver (may be <code>null</code>)
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_INVALID_ARGUMENT - if the image has been disposed
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setImage(Image image) {
   checkWidget();
   if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
   if ((style & SWT.ARROW) != 0) return;
   this.image = image;
   OS.Image_Source(imageHandle, image != null ? image.handle : 0);
   OS.UIElement_Visibility(
       imageHandle, image != null ? OS.Visibility_Visible : OS.Visibility_Collapsed);
   OS.UIElement_Visibility(
       textHandle,
       image != null && text.length() == 0 ? OS.Visibility_Collapsed : OS.Visibility_Visible);
   int spacing = image != null && text.length() != 0 ? 3 : 0;
   int margin = OS.gcnew_Thickness(0, 0, spacing, 0);
   if (margin == 0) error(SWT.ERROR_NO_HANDLES);
   OS.FrameworkElement_Margin(imageHandle, margin);
   OS.GCHandle_Free(margin);
 }