void releaseChildren(boolean destroy) {
   if (menu != null) {
     menu.release(false);
     menu = null;
   }
   super.releaseChildren(destroy);
 }
示例#2
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());
 }
示例#3
0
 void hookEvents() {
   super.hookEvents();
   if ((style & SWT.SEPARATOR) != 0) return;
   if ((style & (SWT.RADIO | SWT.CHECK)) != 0) {
     int handler = OS.gcnew_RoutedEventHandler(jniRef, "HandleChecked");
     if (handler == 0) error(SWT.ERROR_NO_HANDLES);
     OS.ToggleButton_Checked(handle, handler);
     OS.GCHandle_Free(handler);
     handler = OS.gcnew_RoutedEventHandler(jniRef, "HandleUnchecked");
     if (handler == 0) error(SWT.ERROR_NO_HANDLES);
     OS.ToggleButton_Unchecked(handle, handler);
     OS.GCHandle_Free(handler);
   } else {
     int handler = OS.gcnew_RoutedEventHandler(jniRef, "HandleClick");
     if (handler == 0) error(SWT.ERROR_NO_HANDLES);
     OS.ButtonBase_Click(handle, handler);
     OS.GCHandle_Free(handler);
   }
   int handler = OS.gcnew_MouseEventHandler(jniRef, "HandleMouseEnter");
   if (handler == 0) error(SWT.ERROR_NO_HANDLES);
   OS.UIElement_MouseEnter(handle, handler);
   OS.GCHandle_Free(handler);
   handler = OS.gcnew_MouseEventHandler(jniRef, "HandleMouseLeave");
   if (handler == 0) error(SWT.ERROR_NO_HANDLES);
   OS.UIElement_MouseLeave(handle, handler);
   OS.GCHandle_Free(handler);
 }
示例#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;
   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();
 }
示例#5
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();
 }
示例#6
0
 void releaseWidget() {
   super.releaseWidget();
   if (imageList != null) imageList.dispose();
   if (parent.lastFocus == this) parent.lastFocus = null;
   imageList = null;
   control = null;
 }
示例#7
0
 void register() {
   super.register();
   display.addWidget(clientHandle, this);
   display.addWidget(boxHandle, this);
   display.addWidget(labelHandle, this);
   display.addWidget(imageHandle, this);
 }
 /**
  * Sets the image the receiver will display to the argument.
  *
  * <p>Note: This operation is a hint and is not supported on platforms that do not have this
  * concept (for example, Windows NT). Furthermore, some platforms (such as GTK), cannot display
  * both a check box and an image at the same time. Instead, they hide the image and display the
  * check box.
  *
  * @param image the image to display
  * @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 ((style & SWT.SEPARATOR) != 0) return;
   super.setImage(image);
   if (OS.IsWinCE) {
     if ((OS.IsPPC || OS.IsSP) && parent.hwndCB != 0) {
       long /*int*/ hwndCB = parent.hwndCB;
       TBBUTTONINFO info = new TBBUTTONINFO();
       info.cbSize = TBBUTTONINFO.sizeof;
       info.dwMask = OS.TBIF_IMAGE;
       info.iImage = parent.imageIndex(image);
       OS.SendMessage(hwndCB, OS.TB_SETBUTTONINFO, id, info);
     }
     return;
   }
   if (OS.WIN32_VERSION < OS.VERSION(4, 10)) return;
   MENUITEMINFO info = new MENUITEMINFO();
   info.cbSize = MENUITEMINFO.sizeof;
   info.fMask = OS.MIIM_BITMAP;
   if (parent.foreground != -1) {
     info.hbmpItem = OS.HBMMENU_CALLBACK;
   } else {
     if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION(6, 0) && OS.IsAppThemed()) {
       if (hBitmap != 0) OS.DeleteObject(hBitmap);
       info.hbmpItem = hBitmap = image != null ? Display.create32bitDIB(image) : 0;
     } else {
       info.hbmpItem = image != null ? OS.HBMMENU_CALLBACK : 0;
     }
   }
   long /*int*/ hMenu = parent.handle;
   OS.SetMenuItemInfo(hMenu, id, false, info);
   parent.redraw();
 }
示例#9
0
 void deregister() {
   super.deregister();
   display.removeWidget(clientHandle);
   display.removeWidget(boxHandle);
   display.removeWidget(labelHandle);
   display.removeWidget(imageHandle);
 }
示例#10
0
 void setOrientation(boolean create) {
   super.setOrientation(create);
   if ((parent.style & SWT.RIGHT_TO_LEFT) != 0 || !create) {
     int dir = (parent.style & SWT.RIGHT_TO_LEFT) != 0 ? OS.GTK_TEXT_DIR_RTL : OS.GTK_TEXT_DIR_LTR;
     OS.gtk_widget_set_direction(handle, dir);
     OS.gtk_container_forall(handle, display.setDirectionProc, dir);
   }
 }
示例#11
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();
 }
示例#12
0
 void releaseWidget() {
   super.releaseWidget();
   if (parent.currentFocusItem == this) parent.currentFocusItem = null;
   parent = null;
   control = null;
   hotImage = disabledImage = null;
   toolTipText = null;
 }
示例#13
0
 void releaseWidget() {
   super.releaseWidget();
   display.releaseToolTipHandle(handle);
   if (parent.lastFocus == this) parent.lastFocus = null;
   control = null;
   toolTipText = null;
   image = disabledImage = hotImage = null;
 }
示例#14
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();
 }
 void releaseHandle() {
   super.releaseHandle();
   if (nsColumn != null) {
     nsColumn.headerCell().release();
     nsColumn.release();
   }
   nsColumn = null;
   parent = null;
 }
示例#16
0
 void releaseWidget() {
   super.releaseWidget();
   releaseImages();
   control = null;
   toolTipText = null;
   disabledImage = hotImage = null;
   if (disabledImage2 != null) disabledImage2.dispose();
   disabledImage2 = null;
 }
示例#17
0
 void releaseWidget() {
   super.releaseWidget();
   if (hBitmap != 0) OS.DeleteObject(hBitmap);
   hBitmap = 0;
   if (accelerator != 0) {
     parent.destroyAccelerators();
   }
   accelerator = 0;
   display.removeMenuItem(this);
 }
示例#18
0
 void createWidget(int index) {
   super.createWidget(index);
   int topHandle = topHandle();
   if (OS.XtIsRealized(topHandle)) {
     /*
      * Make sure that the widget has been properly realized
      * because the widget was created after the parent
      * has been realized.
      */
     realizeChildren();
   }
 }
 public void setImage(Image image) {
   checkWidget();
   if (image != null && image.isDisposed()) {
     error(SWT.ERROR_INVALID_ARGUMENT);
   }
   super.setImage(image);
   NSTableHeaderView headerView = ((NSOutlineView) parent.view).headerView();
   if (headerView == null) return;
   int index = parent.indexOf(nsColumn);
   NSRect rect = headerView.headerRectOfColumn(index);
   headerView.setNeedsDisplayInRect(rect);
 }
示例#20
0
 void hookEvents() {
   super.hookEvents();
   if ((style & SWT.SEPARATOR) != 0) return;
   int windowProc = display.windowProc;
   OS.XtAddEventHandler(handle, OS.KeyPressMask, false, windowProc, KEY_PRESS);
   OS.XtAddEventHandler(handle, OS.KeyReleaseMask, false, windowProc, KEY_RELEASE);
   OS.XtAddEventHandler(handle, OS.ButtonPressMask, false, windowProc, BUTTON_PRESS);
   OS.XtAddEventHandler(handle, OS.ButtonReleaseMask, false, windowProc, BUTTON_RELEASE);
   OS.XtAddEventHandler(handle, OS.PointerMotionMask, false, windowProc, POINTER_MOTION);
   OS.XtAddEventHandler(handle, OS.EnterWindowMask, false, windowProc, ENTER_WINDOW);
   OS.XtAddEventHandler(handle, OS.LeaveWindowMask, false, windowProc, LEAVE_WINDOW);
   OS.XtAddCallback(handle, OS.XmNexposeCallback, windowProc, EXPOSURE_CALLBACK);
   OS.XtInsertEventHandler(
       handle, OS.FocusChangeMask, false, windowProc, FOCUS_CHANGE, OS.XtListTail);
 }
 public void setText(String string) {
   checkWidget();
   if (string == null) error(SWT.ERROR_NULL_ARGUMENT);
   super.setText(string);
   char[] buffer = new char[text.length()];
   text.getChars(0, buffer.length, buffer, 0);
   int length = fixMnemonic(buffer);
   displayText = new String(buffer, 0, length);
   NSString title = NSString.stringWith(displayText);
   nsColumn.headerCell().setTitle(title);
   NSTableHeaderView headerView = ((NSOutlineView) parent.view).headerView();
   if (headerView == null) return;
   int index = parent.indexOf(nsColumn);
   NSRect rect = headerView.headerRectOfColumn(index);
   headerView.setNeedsDisplayInRect(rect);
 }
示例#22
0
 void releaseHandle() {
   super.releaseHandle();
   if (handle != 0) OS.GCHandle_Free(handle);
   handle = 0;
   if (imageHandle != 0) {
     OS.GCHandle_Free(imageHandle);
     imageHandle = 0;
   }
   if (textHandle != 0) {
     OS.GCHandle_Free(textHandle);
     textHandle = 0;
   }
   if (arrowHandle != 0) {
     OS.GCHandle_Free(arrowHandle);
     arrowHandle = 0;
   }
   parent = null;
 }
示例#23
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);
   }
 }
示例#24
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(text)) return;
   super.setText(string);
   int strPtr = createDotNetString(string, true);
   if (strPtr == 0) error(SWT.ERROR_NO_HANDLES);
   OS.AccessText_Text(textHandle, strPtr);
   OS.GCHandle_Free(strPtr);
   OS.UIElement_Visibility(
       textHandle,
       string.length() == 0 && image != null ? OS.Visibility_Collapsed : OS.Visibility_Visible);
   int spacing = image != null && text.length() != 0 ? 3 : 0;
   int margin =
       (parent.style & SWT.RIGHT) != 0
           ? OS.gcnew_Thickness(0, 0, spacing, 0)
           : OS.gcnew_Thickness(0, 0, 0, spacing);
   OS.FrameworkElement_Margin(imageHandle, margin);
   OS.GCHandle_Free(margin);
 }
示例#25
0
 void hookEvents() {
   super.hookEvents();
   OS.g_signal_connect_closure(handle, OS.activate, display.closures[ACTIVATE], false);
   OS.g_signal_connect_closure(handle, OS.activate, display.closures[ACTIVATE_INVERSE], true);
   OS.g_signal_connect_closure_by_id(
       handle,
       display.signalIds[BUTTON_PRESS_EVENT],
       0,
       display.closures[BUTTON_PRESS_EVENT],
       false);
   OS.g_signal_connect_closure_by_id(
       handle, display.signalIds[FOCUS_OUT_EVENT], 0, display.closures[FOCUS_OUT_EVENT], false);
   OS.g_signal_connect_closure(
       clientHandle, OS.size_allocate, display.closures[SIZE_ALLOCATE], true);
   OS.g_signal_connect_closure_by_id(
       handle,
       display.signalIds[ENTER_NOTIFY_EVENT],
       0,
       display.closures[ENTER_NOTIFY_EVENT],
       false);
 }
示例#26
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(text)) return;
    super.setText(string);
    long /*int*/ hwnd = parent.handle;
    TBBUTTONINFO info = new TBBUTTONINFO();
    info.cbSize = TBBUTTONINFO.sizeof;
    info.dwMask = OS.TBIF_TEXT | OS.TBIF_STYLE;
    info.fsStyle = (byte) (widgetStyle() | OS.BTNS_AUTOSIZE);
    long /*int*/ hHeap = OS.GetProcessHeap(), pszText = 0;
    if (string.length() != 0) {
      info.fsStyle |= OS.BTNS_SHOWTEXT;
      TCHAR buffer = new TCHAR(parent.getCodePage(), string, true);
      int byteCount = buffer.length() * TCHAR.sizeof;
      pszText = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
      OS.MoveMemory(pszText, buffer, byteCount);
      info.pszText = pszText;
    }
    OS.SendMessage(hwnd, OS.TB_SETBUTTONINFO, id, info);
    if (pszText != 0) OS.HeapFree(hHeap, 0, pszText);

    /*
     * Bug in Windows.  For some reason, when the font is set
     * before any tool item has text, the tool items resize to
     * a very small size.  Also, a tool item will only show text
     * when text has already been set on one item and then a new
     * item is created.  The fix is to use WM_SETFONT to force
     * the tool bar to redraw and layout.
     */
    parent.setDropDownItems(false);
    long /*int*/ hFont = OS.SendMessage(hwnd, OS.WM_GETFONT, 0, 0);
    OS.SendMessage(hwnd, OS.WM_SETFONT, hFont, 0);
    parent.setDropDownItems(true);
    parent.layoutItems();
  }
示例#27
0
 void releaseHandle() {
   super.releaseHandle();
   arrowHandle = labelHandle = imageHandle = eventHandle = 0;
 }
示例#28
0
 void releaseHandle() {
   super.releaseHandle();
   parent = null;
 }
示例#29
0
 public void dispose() {
   if (isDisposed()) return;
   ToolBar parent = this.parent;
   super.dispose();
   parent.relayout();
 }
示例#30
0
 void destroyWidget() {
   parent.destroyItem(this);
   super.destroyWidget();
 }