Пример #1
0
 void updateCursor(Control c, int dir) {
   if (!(c instanceof Sash)) {
     Cursor cursor = null;
     switch (dir) {
       case VERTICAL:
         if (fAncestorVisible) {
           if (fVSashCursor == null) fVSashCursor = new Cursor(c.getDisplay(), SWT.CURSOR_SIZENS);
           cursor = fVSashCursor;
         } else {
           if (fNormalCursor == null) fNormalCursor = new Cursor(c.getDisplay(), SWT.CURSOR_ARROW);
           cursor = fNormalCursor;
         }
         break;
       case HORIZONTAL:
         if (fHSashCursor == null) fHSashCursor = new Cursor(c.getDisplay(), SWT.CURSOR_SIZEWE);
         cursor = fHSashCursor;
         break;
       case VERTICAL + HORIZONTAL:
         if (fAncestorVisible) {
           if (fHVSashCursor == null)
             fHVSashCursor = new Cursor(c.getDisplay(), SWT.CURSOR_SIZEALL);
           cursor = fHVSashCursor;
         } else {
           if (fHSashCursor == null) fHSashCursor = new Cursor(c.getDisplay(), SWT.CURSOR_SIZEWE);
           cursor = fHSashCursor;
         }
         break;
     }
     if (cursor != null) c.setCursor(cursor);
   }
 }
Пример #2
0
    private void resize(MouseEvent e) {
      int dx = e.x - fX;
      int dy = e.y - fY;

      int centerWidth = fCenter.getSize().x;

      if (fWidth1 + dx > centerWidth && fWidth2 - dx > centerWidth) {
        fWidth1 += dx;
        fWidth2 -= dx;
        if ((fDirection & HORIZONTAL) != 0)
          fHSplit = (double) fWidth1 / (double) (fWidth1 + fWidth2);
      }
      if (fHeight1 + dy > centerWidth && fHeight2 - dy > centerWidth) {
        fHeight1 += dy;
        fHeight2 -= dy;
        if ((fDirection & VERTICAL) != 0)
          fVSplit = (double) fHeight1 / (double) (fHeight1 + fHeight2);
      }

      fComposite.layout(true);
      fControl.getDisplay().update();
    }