Beispiel #1
0
 /**
  * Sets the width of the receiver, for <code>SEPARATOR</code> ToolItems.
  *
  * @param width the new width
  * @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 setWidth(int width) {
   checkWidget();
   if ((style & SWT.SEPARATOR) == 0) return;
   if (width < 0 || this.width == width) return;
   this.width = width;
   parent.relayout();
 }
Beispiel #2
0
 /**
  * Sets the receiver's text. The string may include the mnemonic character.
  *
  * <p>Mnemonics are indicated by an '&amp;' that causes the next character to be the mnemonic.
  * When the user presses a key sequence that matches the mnemonic, a selection event occurs. On
  * most platforms, the mnemonic appears underlined but may be emphasised in a platform specific
  * manner. The mnemonic indicator character '&amp;' can be escaped by doubling it in the string,
  * causing a single '&amp;' to be displayed.
  *
  * @param string the new text
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the text is null
  *     </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 setText(String string) {
   checkWidget();
   if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
   if ((style & SWT.SEPARATOR) != 0) return;
   if (string.equals(this.text)) return;
   super.setText(string);
   if (labelHandle == 0) return;
   char[] chars = fixMnemonic(string);
   byte[] buffer = Converter.wcsToMbcs(null, chars, true);
   OS.gtk_label_set_text_with_mnemonic(labelHandle, buffer);
   if ((style & SWT.DROP_DOWN) != 0 && OS.GTK_VERSION < OS.VERSION(2, 6, 0)) {
     if (string.length() != 0) {
       OS.gtk_widget_show(labelHandle);
     } else {
       OS.gtk_widget_hide(labelHandle);
     }
   }
   /*
    * 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();
 }
Beispiel #3
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();
 }
Beispiel #4
0
 /**
  * Sets the receiver's text. The string may include the mnemonic character.
  *
  * <p>Mnemonics are indicated by an '&amp;' that causes the next character to be the mnemonic.
  * When the user presses a key sequence that matches the mnemonic, a selection event occurs. On
  * most platforms, the mnemonic appears underlined but may be emphasised in a platform specific
  * manner. The mnemonic indicator character '&amp;' can be escaped by doubling it in the string,
  * causing a single '&amp;' to be displayed.
  *
  * @param string the new text
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the text is null
  *     </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 setText(String string) {
   checkWidget();
   if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
   if ((style & SWT.SEPARATOR) != 0) return;
   super.setText(string);
   parent.relayout();
   redraw();
 }
Beispiel #5
0
 public void setImage(Image image) {
   checkWidget();
   if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
   if ((style & SWT.SEPARATOR) != 0) return;
   super.setImage(image);
   parent.relayout();
   redraw();
 }
Beispiel #6
0
 /**
  * Sets the width of the receiver, for <code>SEPARATOR</code> ToolItems.
  *
  * @param width the new width. If the new value is <code>SWT.DEFAULT</code>, the width is a
  *     fixed-width area whose amount is determined by the platform. If the new value is 0 a
  *     vertical or horizontal line will be drawn, depending on the setting of the corresponding
  *     style bit (<code>SWT.VERTICAL</code> or <code>SWT.HORIZONTAL</code>). If the new value is
  *     <code>SWT.SEPARATOR_FILL</code> a variable-width space is inserted that acts as a spring
  *     between the two adjoining items which will push them out to the extent of the containing
  *     ToolBar.
  * @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 setWidth(int width) {
   checkWidget();
   if ((style & SWT.SEPARATOR) == 0) return;
   if (width < 0) return;
   boolean isVertical = (parent.style & SWT.VERTICAL) != 0;
   OS.gtk_widget_set_size_request(handle, width, isVertical ? 6 : 15);
   parent.relayout();
 }
Beispiel #7
0
 /**
  * Sets the control that is used to fill the bounds of the item when the item is a <code>SEPARATOR
  * </code>.
  *
  * @param control the new control
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_INVALID_ARGUMENT - if the control has been disposed
  *       <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree
  *     </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 setControl(Control control) {
   checkWidget();
   if (control != null) {
     if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
     if (control.parent != parent) error(SWT.ERROR_INVALID_PARENT);
   }
   if ((style & SWT.SEPARATOR) == 0) return;
   if (this.control == control) return;
   this.control = control;
   parent.relayout();
 }
Beispiel #8
0
 /**
  * Sets the control that is used to fill the bounds of the item when the item is a <code>SEPARATOR
  * </code>.
  *
  * @param control the new control
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_INVALID_ARGUMENT - if the control has been disposed
  *       <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree
  *     </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 setControl(Control control) {
   checkWidget();
   if (control != null) {
     if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
     if (control.parent != parent) error(SWT.ERROR_INVALID_PARENT);
   }
   if ((style & SWT.SEPARATOR) == 0) return;
   if (this.control == control) return;
   this.control = control;
   int[] argList = {
     OS.XmNseparatorType,
     control == null
         ? ((parent.style & SWT.FLAT) != 0 ? OS.XmSHADOW_ETCHED_IN : OS.XmSHADOW_ETCHED_OUT)
         : OS.XmNO_LINE,
   };
   OS.XtSetValues(handle, argList, argList.length / 2);
   if (control != null && !control.isDisposed()) {
     /*
      * It is possible that the control was created with a
      * z-order below that of the current tool item. In this
      * case, the control is not visible because it is
      * obscured by the tool item. The fix is to move the
      * control above this tool item in the z-order.
      * The code below is similar to the code found in
      * setZOrder.
      */
     int xDisplay = OS.XtDisplay(handle);
     if (xDisplay == 0) return;
     if (!OS.XtIsRealized(handle)) {
       Shell shell = parent.getShell();
       shell.realizeWidget();
     }
     int topHandle1 = control.topHandle();
     int window1 = OS.XtWindow(topHandle1);
     if (window1 == 0) return;
     int topHandle2 = this.topHandle();
     int window2 = OS.XtWindow(topHandle2);
     if (window2 == 0) return;
     XWindowChanges struct = new XWindowChanges();
     struct.sibling = window2;
     struct.stack_mode = OS.Above;
     int screen = OS.XDefaultScreen(xDisplay);
     int flags = OS.CWStackMode | OS.CWSibling;
     OS.XReconfigureWMWindow(xDisplay, window1, screen, flags, struct);
   }
   parent.relayout();
 }
Beispiel #9
0
 public void dispose() {
   if (isDisposed()) return;
   ToolBar parent = this.parent;
   super.dispose();
   parent.relayout();
 }
Beispiel #10
0
 void createWidget(int index) {
   super.createWidget(index);
   showWidget(index);
   parent.relayout();
 }