Ejemplo n.º 1
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);
     }
   }
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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;
 }