Example #1
0
 void sendSelection() {
   Event event = new Event();
   int hitPart = ((NSScroller) view).hitPart();
   int value = getSelection();
   switch (hitPart) {
     case OS.NSScrollerDecrementLine:
       event.detail = SWT.ARROW_UP;
       value -= increment;
       break;
     case OS.NSScrollerDecrementPage:
       value -= pageIncrement;
       event.detail = SWT.PAGE_UP;
       break;
     case OS.NSScrollerIncrementLine:
       value += increment;
       event.detail = SWT.PAGE_DOWN;
       break;
     case OS.NSScrollerIncrementPage:
       value += pageIncrement;
       event.detail = SWT.ARROW_DOWN;
       break;
     case OS.NSScrollerKnob:
       event.detail = SWT.DRAG;
       break;
   }
   if (event.detail != SWT.DRAG) {
     setSelection(value);
   }
   sendEvent(SWT.Selection, event);
 }
Example #2
0
 long /*int*/ gtk_clicked(long /*int*/ widget) {
   Event event = new Event();
   if ((style & SWT.DROP_DOWN) != 0) {
     long /*int*/ eventPtr = OS.gtk_get_current_event();
     if (eventPtr != 0) {
       GdkEvent gdkEvent = new GdkEvent();
       OS.memmove(gdkEvent, eventPtr, GdkEvent.sizeof);
       long /*int*/ topHandle = topHandle();
       switch (gdkEvent.type) {
         case OS.GDK_KEY_RELEASE: // Fall Through..
         case OS.GDK_BUTTON_PRESS:
         case OS.GDK_2BUTTON_PRESS:
         case OS.GDK_BUTTON_RELEASE:
           {
             boolean isArrow = false;
             if (OS.GTK_VERSION < OS.VERSION(2, 6, 0)) {
               double[] x_win = new double[1];
               double[] y_win = new double[1];
               OS.gdk_event_get_coords(eventPtr, x_win, y_win);
               int x = OS.GTK_WIDGET_X(arrowHandle) - OS.GTK_WIDGET_X(handle);
               int width = OS.GTK_WIDGET_WIDTH(arrowHandle);
               if ((((parent.style & SWT.RIGHT_TO_LEFT) == 0) && x <= (int) x_win[0])
                   || (((parent.style & SWT.RIGHT_TO_LEFT) != 0) && (int) x_win[0] <= x + width)) {
                 isArrow = true;
               }
             } else if (widget == arrowHandle) {
               isArrow = true;
               topHandle = widget;
               /*
                * Feature in GTK. ArrowButton stays in toggled state if there is no popup menu.
                * It is required to set back the state of arrow to normal state after it is clicked.
                */
               OS.g_signal_handlers_block_matched(
                   widget, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
               OS.gtk_toggle_button_set_active(widget, false);
               OS.g_signal_handlers_unblock_matched(
                   widget, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
             }
             if (isArrow) {
               event.detail = SWT.ARROW;
               event.x = OS.GTK_WIDGET_X(topHandle);
               if ((parent.style & SWT.MIRRORED) != 0)
                 event.x = parent.getClientWidth() - OS.GTK_WIDGET_WIDTH(topHandle) - event.x;
               event.y = OS.GTK_WIDGET_Y(topHandle) + OS.GTK_WIDGET_HEIGHT(topHandle);
             }
             break;
           }
       }
       OS.gdk_event_free(eventPtr);
     }
   }
   if ((style & SWT.RADIO) != 0) {
     if ((parent.getStyle() & SWT.NO_RADIO_GROUP) == 0) {
       selectRadio();
     }
   }
   sendSelectionEvent(SWT.Selection, event, false);
   return 0;
 }
Example #3
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 #4
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 #5
0
 void HandleClick(int sender, int e) {
   if (!checkEvent(e)) return;
   if (ignoreSelection) return;
   Event event = new Event();
   if ((style & SWT.DROP_DOWN) != 0) {
     int mousePos = OS.Mouse_GetPosition(handle);
     int zero = OS.gcnew_Point(0, OS.FrameworkElement_ActualHeight(topHandle()));
     int arrowPos = OS.UIElement_TranslatePoint(arrowHandle, zero, handle);
     if (OS.Point_X(mousePos) > OS.Point_X(arrowPos)) {
       event.detail = SWT.ARROW;
       int location = OS.UIElement_TranslatePoint(handle, zero, parent.handle);
       event.x = (int) OS.Point_X(location);
       event.y = (int) OS.Point_Y(location);
       OS.GCHandle_Free(location);
     }
     OS.GCHandle_Free(arrowPos);
     OS.GCHandle_Free(zero);
     OS.GCHandle_Free(mousePos);
   }
   postEvent(SWT.Selection, event);
 }
Example #6
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;
 }