Example #1
0
 public void setImage(Image image) {
   checkWidget();
   if ((style & SWT.SEPARATOR) != 0) return;
   super.setImage(image);
   if (image != null) {
     ImageList imageList = parent.imageList;
     if (imageList == null) imageList = parent.imageList = new ImageList();
     int imageIndex = imageList.indexOf(image);
     if (imageIndex == -1) {
       imageIndex = imageList.add(image);
     } else {
       imageList.put(imageIndex, image);
     }
     long /*int*/ pixbuf = imageList.getPixbuf(imageIndex);
     OS.gtk_image_set_from_pixbuf(imageHandle, pixbuf);
   } else {
     OS.gtk_image_set_from_pixbuf(imageHandle, 0);
   }
   /*
    * If Text/Image of a tool-item changes, then it is
    * required to reset the proxy menu. Otherwise, the
    * old menuItem appears in the overflow menu.
    */
   if ((style & SWT.DROP_DOWN) != 0) {
     proxyMenuItem = 0;
     proxyMenuItem = OS.gtk_tool_item_retrieve_proxy_menu_item(handle);
     OS.g_signal_connect(
         proxyMenuItem, OS.activate, ToolBar.menuItemSelectedFunc.getAddress(), handle);
   }
   parent.relayout();
 }
Example #2
0
 /**
  * Sets the receiver's hot image to the argument, which may be null indicating that no hot image
  * should be displayed.
  *
  * <p>The hot image is displayed when the mouse enters the receiver.
  *
  * @param image the hot image to display on the receiver (may be 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 setHotImage(Image image) {
   checkWidget();
   if ((style & SWT.SEPARATOR) != 0) return;
   hotImage = image;
   if (image != null) {
     ImageList imageList = parent.imageList;
     if (imageList == null) imageList = parent.imageList = new ImageList();
     int imageIndex = imageList.indexOf(image);
     if (imageIndex == -1) {
       imageIndex = imageList.add(image);
     } else {
       imageList.put(imageIndex, image);
     }
   }
 }