Exemplo 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());
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 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(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);
 }
Exemplo n.º 5
0
 void releaseWidget() {
   super.releaseWidget();
   control = null;
   toolTipText = null;
   image = disabledImage = hotImage = null;
 }