示例#1
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 (control == null) {
     int property = OS.Control_BackgroundProperty();
     OS.DependencyObject_ClearValue(handle, property);
     OS.GCHandle_Free(property);
     Control oldControl = this.control;
     if (oldControl != null && !oldControl.isDisposed()) OS.Panel_SetZIndex(oldControl.handle, 0);
   } else {
     int brush = OS.Brushes_Transparent();
     OS.Control_Background(handle, brush);
     OS.GCHandle_Free(brush);
     int pt = OS.gcnew_Point(0, 0);
     if (pt == 0) error(SWT.ERROR_NO_HANDLES);
     int loc = OS.UIElement_TranslatePoint(handle, pt, parent.parentingHandle);
     OS.GCHandle_Free(pt);
     OS.Canvas_SetLeft(control.handle, OS.Point_X(loc));
     OS.Canvas_SetTop(control.handle, OS.Point_Y(loc));
     OS.Panel_SetZIndex(control.handle, parent.childCount);
     OS.GCHandle_Free(loc);
   }
   this.control = control;
 }
示例#2
0
 void releaseHandle() {
   super.releaseHandle();
   if (textHandle != 0) OS.GCHandle_Free(textHandle);
   textHandle = 0;
   if (imageHandle != 0) OS.GCHandle_Free(imageHandle);
   imageHandle = 0;
 }
示例#3
0
 /**
  * Returns a rectangle describing the receiver's size and location relative to its parent.
  *
  * @return the receiver's bounding rectangle
  * @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 Rectangle getBounds() {
   checkWidget();
   int parentHandle = parent.handle;
   int topHandle = control == null ? topHandle() : control.topHandle();
   int point = OS.gcnew_Point(0, 0);
   if (point == 0) error(SWT.ERROR_NO_HANDLES);
   int location = OS.UIElement_TranslatePoint(topHandle, point, parentHandle);
   int x = (int) OS.Point_X(location);
   int y = (int) OS.Point_Y(location);
   OS.GCHandle_Free(point);
   OS.GCHandle_Free(location);
   int width = (int) OS.FrameworkElement_ActualWidth(topHandle);
   int height = (int) OS.FrameworkElement_ActualHeight(topHandle);
   return new Rectangle(x, y, width, height);
 }
示例#4
0
 void hookEvents() {
   super.hookEvents();
   if ((style & (SWT.TOGGLE | SWT.RADIO | SWT.CHECK)) != 0) {
     int handler = OS.gcnew_RoutedEventHandler(jniRef, "HandleClick");
     if (handler == 0) error(SWT.ERROR_NO_HANDLES);
     OS.ToggleButton_Checked(handle, handler);
     OS.GCHandle_Free(handler);
     handler = OS.gcnew_RoutedEventHandler(jniRef, "HandleClick");
     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);
   }
 }
示例#5
0
 void releaseWidget() {
   super.releaseWidget();
   text = null;
   image = null;
 }