Exemplo n.º 1
0
 Point adjustMoveCursor() {
   if (bounds == null) return null;
   int newX = bounds.x + bounds.width / 2;
   int newY = bounds.y;
   /*
    * Convert to screen coordinates if needed
    */
   if (parent != null) {
     Point pt = parent.toDisplay(newX, newY);
     newX = pt.x;
     newY = pt.y;
   }
   display.setCursorLocation(newX, newY);
   return new Point(newX, newY);
 }
Exemplo n.º 2
0
  Point adjustResizeCursor(boolean movePointer) {
    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;
    }

    /*
     * Convert to screen coordinates if needed
     */
    if (parent != null) {
      Point pt = parent.toDisplay(newX, newY);
      newX = pt.x;
      newY = pt.y;
    }
    if (movePointer) {
      display.setCursorLocation(newX, newY);
    }

    /*
     * If the client has not provided a custom cursor then determine
     * the appropriate resize cursor.
     */
    if (clientCursor == null) {
      Cursor newCursor = null;
      switch (cursorOrientation) {
        case SWT.UP:
          newCursor = new Cursor(display, SWT.CURSOR_SIZENS);
          break;
        case SWT.DOWN:
          newCursor = new Cursor(display, SWT.CURSOR_SIZENS);
          break;
        case SWT.LEFT:
          newCursor = new Cursor(display, SWT.CURSOR_SIZEWE);
          break;
        case SWT.RIGHT:
          newCursor = new Cursor(display, SWT.CURSOR_SIZEWE);
          break;
        case SWT.LEFT | SWT.UP:
          newCursor = new Cursor(display, SWT.CURSOR_SIZENWSE);
          break;
        case SWT.RIGHT | SWT.DOWN:
          newCursor = new Cursor(display, SWT.CURSOR_SIZENWSE);
          break;
        case SWT.LEFT | SWT.DOWN:
          newCursor = new Cursor(display, SWT.CURSOR_SIZENESW);
          break;
        case SWT.RIGHT | SWT.UP:
          newCursor = new Cursor(display, SWT.CURSOR_SIZENESW);
          break;
        default:
          newCursor = new Cursor(display, SWT.CURSOR_SIZEALL);
          break;
      }
      display.lockCursor = false;
      newCursor.handle.set();
      display.lockCursor = true;
      if (resizeCursor != null) {
        resizeCursor.dispose();
      }
      resizeCursor = newCursor;
    }

    return new Point(newX, newY);
  }