Esempio n. 1
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;
 }
Esempio n. 2
0
 LRESULT wmCommandChild(long /*int*/ wParam, long /*int*/ lParam) {
   if ((style & SWT.RADIO) != 0) {
     if ((parent.getStyle() & SWT.NO_RADIO_GROUP) == 0) {
       selectRadio();
     }
   }
   sendSelectionEvent(SWT.Selection);
   return null;
 }