Example #1
0
  int XPointerMotion(int w, int client_data, int call_data, int continue_to_dispatch) {
    display.addMouseHoverTimeOut(handle);

    /*
     * Forward the mouse event to the parent.
     * This is necessary so that mouse listeners
     * in the parent will be called, despite the
     * fact that the event did not really occur
     * in X in the parent.  This is done to be
     * compatible with Windows.
     */
    XMotionEvent xEvent = new XMotionEvent();
    OS.memmove(xEvent, call_data, XMotionEvent.sizeof);
    int[] argList = {OS.XmNx, 0, OS.XmNy, 0};
    OS.XtGetValues(handle, argList, argList.length / 2);
    xEvent.window = OS.XtWindow(parent.handle);
    xEvent.x += argList[1];
    xEvent.y += argList[3];
    /*
     * This code is intentionally commented.
     * Currently, the implementation of the
     * mouse move code in the parent interferes
     * with tool tips for tool items.
     */
    //	OS.memmove (callData, xEvent, XButtonEvent.sizeof);
    //	parent.XPointerMotion (w, client_data, call_data, continue_to_dispatch);
    if (!parent.sendMouseEvent(SWT.MouseMove, xEvent)) {
      OS.memmove(continue_to_dispatch, new int[1], 4);
      return 1;
    }
    return 0;
  }
Example #2
0
 int XButtonRelease(int w, int client_data, int call_data, int continue_to_dispatch) {
   int result = super.XButtonRelease(w, client_data, call_data, continue_to_dispatch);
   if (result != 0) return result;
   XButtonEvent xEvent = new XButtonEvent();
   OS.memmove(xEvent, call_data, XButtonEvent.sizeof);
   if (xEvent.button != 1) return result;
   if (!dragging) return result;
   dragging = false;
   int[] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
   OS.XtGetValues(handle, argList, argList.length / 2);
   int border = argList[5];
   int width = argList[1] + (border * 2), height = argList[3] + (border * 2);
   Event event = new Event();
   event.time = xEvent.time;
   event.x = lastX;
   event.y = lastY;
   event.width = width;
   event.height = height;
   drawBand(lastX, lastY, width, height);
   sendEvent(SWT.Selection, event);
   if (isDisposed()) return result;
   if (event.doit) {
     if ((style & SWT.SMOOTH) != 0) {
       setBounds(event.x, event.y, width, height);
       // widget could be disposed at this point
     }
   }
   return result;
 }
Example #3
0
 void redraw() {
   int display = OS.XtDisplay(handle);
   if (display == 0) return;
   int window = OS.XtWindow(handle);
   if (window == 0) return;
   OS.XClearArea(display, window, 0, 0, 0, 0, true);
 }
Example #4
0
 int XKeyPress(int w, int client_data, int call_data, int continue_to_dispatch) {
   int result = 0;
   XKeyEvent xEvent = new XKeyEvent();
   OS.memmove(xEvent, call_data, XKeyEvent.sizeof);
   int[] keysym = new int[1];
   OS.XLookupString(xEvent, null, 0, keysym, null);
   keysym[0] &= 0xFFFF;
   switch (keysym[0]) {
     case OS.XK_space:
       click(false, xEvent.state);
       result = 1;
       break;
     case OS.XK_Down:
       if ((style & SWT.DROP_DOWN) != 0) {
         click(true, xEvent.state);
         result = 1;
       }
       break;
   }
   /*
    * Forward the key event to the parent.
    * This is necessary so that key listeners
    * in the parent will be called, despite the
    * fact that the event did not really occur
    * in X in the parent.  This is done to be
    * compatible with Windows.
    */
   xEvent.window = OS.XtWindow(parent.handle);
   //	OS.memmove (callData, xEvent, XKeyEvent.sizeof);
   parent.XKeyPress(w, client_data, call_data, continue_to_dispatch);
   if (result == 1) {
     OS.memmove(continue_to_dispatch, new int[1], 4);
   }
   return result;
 }
Example #5
0
 int XButtonRelease(int w, int client_data, int call_data, int continue_to_dispatch) {
   display.hideToolTip();
   XButtonEvent xEvent = new XButtonEvent();
   OS.memmove(xEvent, call_data, XButtonEvent.sizeof);
   /*
    * Forward the mouse event to the parent.
    * This is necessary so that mouse listeners
    * in the parent will be called, despite the
    * fact that the event did not really occur
    * in X in the parent.  This is done to be
    * compatible with Windows.
    */
   int[] argList = {OS.XmNx, 0, OS.XmNy, 0};
   OS.XtGetValues(handle, argList, argList.length / 2);
   xEvent.window = OS.XtWindow(parent.handle);
   xEvent.x += argList[1];
   xEvent.y += argList[3];
   OS.memmove(call_data, xEvent, XButtonEvent.sizeof);
   int result = parent.XButtonRelease(w, client_data, call_data, continue_to_dispatch);
   xEvent.x -= argList[1];
   xEvent.y -= argList[3];
   if (result == 0 && xEvent.button == 1) {
     int[] argList2 = {OS.XmNwidth, 0, OS.XmNheight, 0};
     OS.XtGetValues(handle, argList2, argList2.length / 2);
     int width = argList2[1], height = argList2[3];
     if (0 <= xEvent.x && xEvent.x < width && 0 <= xEvent.y && xEvent.y < height) {
       click(xEvent.x > width - 12, xEvent.state);
     }
     setDrawPressed(set);
   }
   return result;
 }
Example #6
0
  Point adjustResizeCursor() {
    if (bounds == null) return null;
    int newX, newY;

    if ((cursorOrientation & SWT.LEFT) != 0) {
      newX = bounds.x;
    } else if ((cursorOrientation & SWT.RIGHT) != 0) {
      newX = bounds.x + bounds.width;
    } else {
      newX = bounds.x + bounds.width / 2;
    }

    if ((cursorOrientation & SWT.UP) != 0) {
      newY = bounds.y;
    } else if ((cursorOrientation & SWT.DOWN) != 0) {
      newY = bounds.y + bounds.height;
    } else {
      newY = bounds.y + bounds.height / 2;
    }

    final int unused[] = new int[1];
    int actualX[] = new int[1];
    int actualY[] = new int[1];
    int xDisplay = display.xDisplay;
    OS.XWarpPointer(xDisplay, 0, window, 0, 0, 0, 0, newX, newY);
    /*
     * The call to XWarpPointer does not always place the pointer on the
     * exact location that is specified, so do a query (below) to get the
     * actual location of the pointer after it has been moved.
     */
    OS.XQueryPointer(xDisplay, window, unused, unused, actualX, actualY, unused, unused, unused);
    return new Point(actualX[0], actualY[0]);
  }
Example #7
0
 void releaseWidget() {
   super.releaseWidget();
   if (cursor != 0) {
     int display = OS.XtDisplay(handle);
     if (display != 0) OS.XFreeCursor(display, cursor);
   }
   cursor = 0;
 }
Example #8
0
 boolean hasCursor() {
   int[] unused = new int[1], buffer = new int[1];
   int xDisplay = OS.XtDisplay(handle);
   int xWindow, xParent = OS.XDefaultRootWindow(xDisplay);
   do {
     if (OS.XQueryPointer(
             xDisplay, xParent, unused, buffer, unused, unused, unused, unused, unused)
         == 0) return false;
     if ((xWindow = buffer[0]) != 0) xParent = xWindow;
   } while (xWindow != 0);
   return handle == OS.XtWindowToWidget(xDisplay, xParent);
 }
Example #9
0
 int XPointerMotion(int w, int client_data, int call_data, int continue_to_dispatch) {
   int result = super.XPointerMotion(w, client_data, call_data, continue_to_dispatch);
   if (result != 0) return result;
   XMotionEvent xEvent = new XMotionEvent();
   OS.memmove(xEvent, call_data, XMotionEvent.sizeof);
   if (!dragging || (xEvent.state & OS.Button1Mask) == 0) return result;
   short[] x_root = new short[1], y_root = new short[1];
   OS.XtTranslateCoords(handle, (short) 0, (short) 0, x_root, y_root);
   int eventX = xEvent.x_root - x_root[0], eventY = xEvent.y_root - y_root[0];
   int[] argList1 = {
     OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0
   };
   OS.XtGetValues(handle, argList1, argList1.length / 2);
   int border = argList1[9],
       x = ((short) argList1[1]) - border,
       y = ((short) argList1[3]) - border;
   int width = argList1[5] + (border * 2), height = argList1[7] + (border * 2);
   int[] argList2 = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
   OS.XtGetValues(parent.handle, argList2, argList2.length / 2);
   int parentBorder = argList2[5];
   int parentWidth = argList2[1] + (parentBorder * 2);
   int parentHeight = argList2[3] + (parentBorder * 2);
   int newX = lastX, newY = lastY;
   if ((style & SWT.VERTICAL) != 0) {
     newX = Math.min(Math.max(0, eventX + x - startX - parentBorder), parentWidth - width);
   } else {
     newY = Math.min(Math.max(0, eventY + y - startY - parentBorder), parentHeight - height);
   }
   if (newX == lastX && newY == lastY) return result;
   drawBand(lastX, lastY, width, height);
   Event event = new Event();
   event.time = xEvent.time;
   event.x = newX;
   event.y = newY;
   event.width = width;
   event.height = height;
   if ((style & SWT.SMOOTH) == 0) {
     event.detail = SWT.DRAG;
   }
   sendEvent(SWT.Selection, event);
   if (isDisposed()) return result;
   if (event.doit) {
     lastX = event.x;
     lastY = event.y;
   }
   parent.update(true);
   drawBand(lastX, lastY, width, height);
   if ((style & SWT.SMOOTH) != 0) {
     setBounds(lastX, lastY, width, height);
     // widget could be disposed at this point
   }
   return result;
 }
Example #10
0
 public void setCursor(Cursor cursor) {
   checkWidget();
   super.setCursor(cursor);
   if (cursor == null && this.cursor != 0) {
     int xWindow = OS.XtWindow(handle);
     if (xWindow == 0) return;
     int xDisplay = OS.XtDisplay(handle);
     if (xDisplay == 0) return;
     OS.XDefineCursor(xDisplay, xWindow, this.cursor);
     OS.XFlush(xDisplay);
   }
 }
Example #11
0
 void destroy() {
   int xDisplay = device.xDisplay;
   int pixel = handle.pixel;
   if (device.colorRefCount != null) {
     /* If this was the last reference, remove the color from the list */
     if (--device.colorRefCount[pixel] == 0) {
       device.xcolors[pixel] = null;
     }
   }
   int colormap = OS.XDefaultColormap(xDisplay, OS.XDefaultScreen(xDisplay));
   OS.XFreeColors(xDisplay, colormap, new int[] {pixel}, 1, 0);
   handle = null;
 }
Example #12
0
 void createHandle(int index) {
   int parentHandle = parent.handle;
   if ((style & SWT.SEPARATOR) != 0) {
     int orientation = (parent.style & SWT.HORIZONTAL) != 0 ? OS.XmVERTICAL : OS.XmHORIZONTAL;
     int[] argList = {
       OS.XmNheight,
       orientation == OS.XmVERTICAL ? DEFAULT_HEIGHT : DEFAULT_SEPARATOR_WIDTH,
       OS.XmNwidth,
       orientation == OS.XmHORIZONTAL ? DEFAULT_WIDTH : DEFAULT_SEPARATOR_WIDTH,
       OS.XmNancestorSensitive,
       1,
       OS.XmNpositionIndex,
       index,
       OS.XmNorientation,
       orientation,
       OS.XmNseparatorType,
       (parent.style & SWT.FLAT) != 0 ? OS.XmSHADOW_ETCHED_IN : OS.XmSHADOW_ETCHED_OUT,
     };
     handle = OS.XmCreateSeparator(parentHandle, null, argList, argList.length / 2);
     if (handle == 0) error(SWT.ERROR_NO_HANDLES);
     return;
   }
   int[] argList = {
     OS.XmNwidth,
     DEFAULT_WIDTH,
     OS.XmNheight,
     DEFAULT_HEIGHT,
     OS.XmNrecomputeSize,
     0,
     OS.XmNhighlightThickness,
     (parent.style & SWT.NO_FOCUS) != 0 ? 0 : 1,
     OS.XmNmarginWidth,
     2,
     OS.XmNmarginHeight,
     1,
     OS.XmNtraversalOn,
     (parent.style & SWT.NO_FOCUS) != 0 ? 0 : 1,
     OS.XmNpositionIndex,
     index,
     OS.XmNshadowType,
     OS.XmSHADOW_OUT,
     OS.XmNancestorSensitive,
     1,
   };
   handle = OS.XmCreateDrawnButton(parentHandle, null, argList, argList.length / 2);
   if (handle == 0) error(SWT.ERROR_NO_HANDLES);
   Control control = parent.findBackgroundControl();
   if (control == null) control = parent;
   setBackgroundPixel(parent.getBackgroundPixel());
 }
Example #13
0
 void redrawWidget(
     int x, int y, int width, int height, boolean redrawAll, boolean allChildren, boolean trim) {
   super.redrawWidget(x, y, width, height, redrawAll, allChildren, trim);
   if (!trim) return;
   if (formHandle == 0 && scrolledHandle == 0) return;
   short[] root_x = new short[1], root_y = new short[1];
   OS.XtTranslateCoords(handle, (short) x, (short) y, root_x, root_y);
   if (formHandle != 0) {
     short[] form_x = new short[1], form_y = new short[1];
     OS.XtTranslateCoords(formHandle, (short) 0, (short) 0, form_x, form_y);
     redrawHandle(
         root_x[0] - form_x[0], root_y[0] - form_y[0], width, height, redrawAll, formHandle);
   }
   if (scrolledHandle != 0) {
     short[] scrolled_x = new short[1], scrolled_y = new short[1];
     OS.XtTranslateCoords(scrolledHandle, (short) 0, (short) 0, scrolled_x, scrolled_y);
     redrawHandle(
         root_x[0] - scrolled_x[0],
         root_y[0] - scrolled_y[0],
         width,
         height,
         redrawAll,
         scrolledHandle);
     if (horizontalBar != null && horizontalBar.getVisible()) {
       int horizontalHandle = horizontalBar.handle;
       short[] hscroll_x = new short[1], hscroll_y = new short[1];
       OS.XtTranslateCoords(horizontalHandle, (short) 0, (short) 0, hscroll_x, hscroll_y);
       redrawHandle(
           root_x[0] - hscroll_x[0],
           root_y[0] - hscroll_y[0],
           width,
           height,
           redrawAll,
           horizontalHandle);
     }
     if (verticalBar != null && verticalBar.getVisible()) {
       int verticalHandle = verticalBar.handle;
       short[] vscroll_x = new short[1], vscroll_y = new short[1];
       OS.XtTranslateCoords(verticalHandle, (short) 0, (short) 0, vscroll_x, vscroll_y);
       redrawHandle(
           root_x[0] - vscroll_x[0],
           root_y[0] - vscroll_y[0],
           width,
           height,
           redrawAll,
           verticalHandle);
     }
   }
 }
Example #14
0
 int XFocusChange(int w, int client_data, int call_data, int continue_to_dispatch) {
   /*
    * Forward the focus event to the parent.
    * This is necessary so that focus listeners
    * in the parent will be called, despite the
    * fact that the event did not really occur
    * in X in the parent.  This is done to be
    * compatible with Windows.
    */
   XFocusChangeEvent xEvent = new XFocusChangeEvent();
   OS.memmove(xEvent, call_data, XFocusChangeEvent.sizeof);
   xEvent.window = OS.XtWindow(parent.handle);
   //	OS.memmove (call_data, xEvent, XFocusChangeEvent.sizeof);
   parent.XFocusChange(w, client_data, call_data, continue_to_dispatch);
   return 0;
 }
Example #15
0
  boolean setScrollBarVisible(ScrollBar bar, boolean visible) {
    if (scrolledHandle == 0) return false;
    int barHandle = bar.handle;
    boolean managed = OS.XtIsManaged(barHandle);
    if (managed == visible) return false;

    /*
     * Feature in Motif.  Hiding or showing a scroll bar
     * can cause the widget to automatically resize in
     * the OS.  This behavior is unwanted.  The fix is
     * to force the widget to resize to original size.
     */
    int[] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
    OS.XtGetValues(scrolledHandle, argList, argList.length / 2);

    int[] argList1 = {OS.XmNwidth, 0, OS.XmNheight, 0};
    OS.XtGetValues(handle, argList1, argList1.length / 2);

    /* Hide or show the scroll bar */
    if (visible) {
      OS.XtManageChild(barHandle);
    } else {
      OS.XtUnmanageChild(barHandle);
    }
    if ((state & CANVAS) != 0) {
      if (formHandle != 0) {
        boolean showBorder = (style & SWT.BORDER) != 0;
        int margin = showBorder || visible ? 3 : 0;
        if ((bar.style & SWT.V_SCROLL) != 0) {
          int[] argList2 = new int[] {OS.XmNmarginWidth, margin};
          OS.XtSetValues(formHandle, argList2, argList2.length / 2);
        }
        if ((bar.style & SWT.H_SCROLL) != 0) {
          int[] argList2 = new int[] {OS.XmNmarginHeight, margin};
          OS.XtSetValues(formHandle, argList2, argList2.length / 2);
        }
      }
    }

    /*
     * Feature in Motif.  When XtSetValues() is used to restore the width and
     * height of the widget, the new width and height are sometimes ignored.
     * The fix is to use XtResizeWidget().
     */
    OS.XtResizeWidget(scrolledHandle, argList[1], argList[3], argList[5]);

    bar.sendEvent(visible ? SWT.Show : SWT.Hide);
    int[] argList3 = {OS.XmNwidth, 0, OS.XmNheight, 0};
    OS.XtGetValues(handle, argList3, argList3.length / 2);
    return argList1[1] != argList3[1] || argList1[3] != argList3[3];
  }
Example #16
0
 void setBounds(int x, int y, int width, int height) {
   /*
    * Feature in Motif.  Motif will not allow a window
    * to have a zero width or zero height.  The fix is
    * to ensure these values are never zero.
    */
   int newWidth = Math.max(width, 1), newHeight = Math.max(height, 1);
   OS.XtConfigureWidget(handle, x, y, newWidth, newHeight, 0);
 }
Example #17
0
 int xFocusIn(XFocusChangeEvent xEvent) {
   int result = super.xFocusIn(xEvent);
   if (handle == 0) return result;
   int[] argList = {OS.XmNx, 0, OS.XmNy, 0};
   OS.XtGetValues(handle, argList, argList.length / 2);
   lastX = argList[1];
   lastY = argList[3];
   return result;
 }
Example #18
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);
 }
Example #19
0
 int XEnterWindow(int w, int client_data, int call_data, int continue_to_dispatch) {
   XCrossingEvent xEvent = new XCrossingEvent();
   OS.memmove(xEvent, call_data, XCrossingEvent.sizeof);
   if ((xEvent.state & OS.Button1Mask) != 0) {
     setDrawPressed(!set);
   } else {
     if ((parent.style & SWT.FLAT) != 0) redraw();
   }
   return 0;
 }
Example #20
0
  Point adjustMoveCursor() {
    if (bounds == null) return null;
    final int unused[] = new int[1];
    int actualX[] = new int[1];
    int actualY[] = new int[1];

    int newX = bounds.x + bounds.width / 2;
    int newY = bounds.y;

    int xDisplay = display.xDisplay;
    OS.XWarpPointer(xDisplay, OS.None, window, 0, 0, 0, 0, newX, newY);
    /*
     * The call to XWarpPointer does not always place the pointer on the
     * exact location that is specified, so do a query (below) to get the
     * actual location of the pointer after it has been moved.
     */
    OS.XQueryPointer(xDisplay, window, unused, unused, actualX, actualY, unused, unused, unused);
    return new Point(actualX[0], actualY[0]);
  }
Example #21
0
 int XPointerMotion(int w, int client_data, int call_data, int continue_to_dispatch) {
   if (cursor != null) {
     int xDisplay = display.xDisplay;
     OS.XChangeActivePointerGrab(
         xDisplay,
         OS.ButtonPressMask | OS.ButtonReleaseMask | OS.PointerMotionMask,
         cursor.handle,
         OS.CurrentTime);
   }
   return xMouse(OS.MotionNotify, w, client_data, call_data, continue_to_dispatch);
 }
Example #22
0
 int XLeaveWindow(int w, int client_data, int call_data, int continue_to_dispatch) {
   display.removeMouseHoverTimeOut();
   display.hideToolTip();
   XCrossingEvent xEvent = new XCrossingEvent();
   OS.memmove(xEvent, call_data, XCrossingEvent.sizeof);
   if ((xEvent.state & OS.Button1Mask) != 0) {
     setDrawPressed(set);
   } else {
     if ((parent.style & SWT.FLAT) != 0) redraw();
   }
   return 0;
 }
Example #23
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();
   }
 }
Example #24
0
 int XButtonPress(int w, int client_data, int call_data, int continue_to_dispatch) {
   int result = super.XButtonPress(w, client_data, call_data, continue_to_dispatch);
   if (result != 0) return result;
   XButtonEvent xEvent = new XButtonEvent();
   OS.memmove(xEvent, call_data, XButtonEvent.sizeof);
   if (xEvent.button != 1) return result;
   short[] x_root = new short[1], y_root = new short[1];
   OS.XtTranslateCoords(handle, (short) 0, (short) 0, x_root, y_root);
   startX = xEvent.x_root - x_root[0];
   startY = xEvent.y_root - y_root[0];
   int[] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
   OS.XtGetValues(handle, argList, argList.length / 2);
   int border = argList[9], width = argList[5] + (border * 2), height = argList[7] + (border * 2);
   lastX = ((short) argList[1]) - border;
   lastY = ((short) argList[3]) - border;
   Event event = new Event();
   event.time = xEvent.time;
   event.x = lastX;
   event.y = lastY;
   event.width = width;
   event.height = height;
   if ((style & SWT.SMOOTH) == 0) {
     event.detail = SWT.DRAG;
   }
   sendEvent(SWT.Selection, event);
   if (isDisposed()) return result;
   if (event.doit) {
     dragging = true;
     lastX = event.x;
     lastY = event.y;
     parent.update(true);
     drawBand(event.x, event.y, width, height);
     if ((style & SWT.SMOOTH) != 0) {
       setBounds(event.x, event.y, width, height);
       // widget could be disposed at this point
     }
   }
   return result;
 }
Example #25
0
 void manageChildren() {
   if (scrolledHandle != 0) {
     OS.XtSetMappedWhenManaged(scrolledHandle, false);
     OS.XtManageChild(scrolledHandle);
   }
   if (formHandle != 0) {
     OS.XtSetMappedWhenManaged(formHandle, false);
     OS.XtManageChild(formHandle);
   }
   super.manageChildren();
   if (formHandle != 0) {
     int[] argList = {OS.XmNborderWidth, 0};
     OS.XtGetValues(formHandle, argList, argList.length / 2);
     OS.XtResizeWidget(formHandle, 1, 1, argList[1]);
     OS.XtSetMappedWhenManaged(formHandle, true);
   }
   if (scrolledHandle != 0) {
     int[] argList = {OS.XmNborderWidth, 0};
     OS.XtGetValues(scrolledHandle, argList, argList.length / 2);
     OS.XtResizeWidget(scrolledHandle, 1, 1, argList[1]);
     OS.XtSetMappedWhenManaged(scrolledHandle, true);
   }
 }
Example #26
0
 ScrollBar createStandardBar(int style) {
   if (scrolledHandle == 0) return null;
   ScrollBar bar = new ScrollBar();
   bar.parent = this;
   bar.style = style;
   bar.display = display;
   int[] argList = {OS.XmNhorizontalScrollBar, 0, OS.XmNverticalScrollBar, 0};
   OS.XtGetValues(scrolledHandle, argList, argList.length / 2);
   if (style == SWT.H_SCROLL) bar.handle = argList[1];
   if (style == SWT.V_SCROLL) bar.handle = argList[3];
   bar.hookEvents();
   bar.register();
   return bar;
 }
Example #27
0
 void createHandle(int index) {
   state |= THEME_BACKGROUND;
   int border = (style & SWT.BORDER) != 0 ? 1 : 0;
   int[] argList = {
     OS.XmNborderWidth, border,
     OS.XmNmarginWidth, 0,
     OS.XmNmarginHeight, 0,
     OS.XmNresizePolicy, OS.XmRESIZE_NONE,
     OS.XmNancestorSensitive, 1,
     OS.XmNtraversalOn, 0,
   };
   int parentHandle = parent.handle;
   handle = OS.XmCreateDrawingArea(parentHandle, null, argList, argList.length / 2);
 }
Example #28
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();
 }
Example #29
0
 void click(boolean dropDown, int state) {
   if ((style & SWT.RADIO) != 0) {
     selectRadio();
   } else {
     if ((style & SWT.CHECK) != 0) setSelection(!set);
   }
   Event event = new Event();
   if ((style & SWT.DROP_DOWN) != 0) {
     if (dropDown) {
       event.detail = SWT.ARROW;
       int[] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNheight, 0};
       OS.XtGetValues(handle, argList, argList.length / 2);
       event.x = (short) argList[1];
       event.y = (short) argList[3] + (short) argList[5];
     }
   }
   if (state != 0) setInputState(event, state);
   postEvent(SWT.Selection, event);
 }
Example #30
0
 void realizeChildren() {
   super.realizeChildren();
   int xWindow = OS.XtWindow(handle);
   if (xWindow == 0) return;
   int xDisplay = OS.XtDisplay(handle);
   if (xDisplay == 0) return;
   if ((style & SWT.HORIZONTAL) != 0) {
     cursor = OS.XCreateFontCursor(xDisplay, OS.XC_sb_v_double_arrow);
   } else {
     cursor = OS.XCreateFontCursor(xDisplay, OS.XC_sb_h_double_arrow);
   }
   if (super.cursor == null && isEnabled()) {
     OS.XDefineCursor(xDisplay, xWindow, cursor);
     OS.XFlush(xDisplay);
   }
 }