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
 public void setImage(Image image) {
   super.setImage(image);
   if (imageList != null) imageList.dispose();
   imageList = null;
   if (image != null) {
     if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
     imageList = new ImageList();
     int imageIndex = imageList.add(image);
     long /*int*/ pixbuf = imageList.getPixbuf(imageIndex);
     OS.gtk_image_set_from_pixbuf(imageHandle, pixbuf);
     if (text.length() == 0) OS.gtk_widget_hide(labelHandle);
     OS.gtk_widget_show(imageHandle);
   } else {
     OS.gtk_image_set_from_pixbuf(imageHandle, 0);
     OS.gtk_widget_show(labelHandle);
     OS.gtk_widget_hide(imageHandle);
   }
 }
Example #3
0
 long /*int*/ gtk_enter_notify_event(long /*int*/ widget, long /*int*/ event) {
   parent.gtk_enter_notify_event(widget, event);
   drawHotImage = (parent.style & SWT.FLAT) != 0 && hotImage != null;
   if (drawHotImage) {
     ImageList imageList = parent.imageList;
     if (imageList != null) {
       int index = imageList.indexOf(hotImage);
       if (index != -1 && imageHandle != 0) {
         long /*int*/ pixbuf = imageList.getPixbuf(index);
         OS.gtk_image_set_from_pixbuf(imageHandle, pixbuf);
       }
     }
   }
   return 0;
 }
Example #4
0
 long /*int*/ gtk_leave_notify_event(long /*int*/ widget, long /*int*/ event) {
   parent.gtk_leave_notify_event(widget, event);
   if (drawHotImage) {
     drawHotImage = false;
     if (image != null) {
       ImageList imageList = parent.imageList;
       if (imageList != null) {
         int index = imageList.indexOf(image);
         if (index != -1 && imageHandle != 0) {
           long /*int*/ pixbuf = imageList.getPixbuf(index);
           OS.gtk_image_set_from_pixbuf(imageHandle, pixbuf);
         }
       }
     }
   }
   return 0;
 }