@Override long /*int*/ gtk_key_press_event(long /*int*/ widget, long /*int*/ eventPtr) { long /*int*/ result = super.gtk_key_press_event(widget, eventPtr); if (result != 0) return result; if (focusIndex == -1) return result; GdkEventKey gdkEvent = new GdkEventKey(); OS.memmove(gdkEvent, eventPtr, GdkEventKey.sizeof); switch (gdkEvent.keyval) { case OS.GDK_Return: case OS.GDK_KP_Enter: case OS.GDK_space: Event event = new Event(); event.text = ids[focusIndex]; sendSelectionEvent(SWT.Selection, event, true); break; case OS.GDK_Tab: if (focusIndex < offsets.length - 1) { focusIndex++; redraw(); } break; case OS.GDK_ISO_Left_Tab: if (focusIndex > 0) { focusIndex--; redraw(); } break; } return result; }
LRESULT wmNotifyChild(NMHDR hdr, int /*long*/ wParam, int /*long*/ lParam) { if (OS.COMCTL32_MAJOR >= 6) { switch (hdr.code) { case OS.NM_RETURN: case OS.NM_CLICK: NMLINK item = new NMLINK(); OS.MoveMemory(item, lParam, NMLINK.sizeof); Event event = new Event(); event.text = ids[item.iLink]; sendSelectionEvent(SWT.Selection, event, true); break; } } return super.wmNotifyChild(hdr, wParam, lParam); }
void drawWidget(GC gc, RECT rect) { drawBackground(gc.handle, rect); int selStart = selection.x; int selEnd = selection.y; if (selStart > selEnd) { selStart = selection.y; selEnd = selection.x; } // temporary code to disable text selection selStart = selEnd = -1; if (!OS.IsWindowEnabled(handle)) gc.setForeground(disabledColor); layout.draw(gc, 0, 0, selStart, selEnd, null, null); if (hasFocus() && focusIndex != -1) { Rectangle[] rects = getRectangles(focusIndex); for (int i = 0; i < rects.length; i++) { Rectangle rectangle = rects[i]; gc.drawFocus(rectangle.x, rectangle.y, rectangle.width, rectangle.height); } } if (hooks(SWT.Paint) || filters(SWT.Paint)) { Event event = new Event(); event.gc = gc; event.x = rect.left; event.y = rect.top; event.width = rect.right - rect.left; event.height = rect.bottom - rect.top; sendEvent(SWT.Paint, event); event.gc = null; } }
LRESULT WM_CHAR(int /*long*/ wParam, int /*long*/ lParam) { LRESULT result = super.WM_CHAR(wParam, lParam); if (result != null) return result; if (OS.COMCTL32_MAJOR < 6) { if (focusIndex == -1) return result; switch ((int) /*64*/ wParam) { case ' ': case SWT.CR: Event event = new Event(); event.text = ids[focusIndex]; sendSelectionEvent(SWT.Selection, event, true); break; case SWT.TAB: boolean next = OS.GetKeyState(OS.VK_SHIFT) >= 0; if (next) { if (focusIndex < offsets.length - 1) { focusIndex++; redraw(); } } else { if (focusIndex > 0) { focusIndex--; redraw(); } } break; } } else { switch ((int) /*64*/ wParam) { case ' ': case SWT.CR: case SWT.TAB: /* * NOTE: Call the window proc with WM_KEYDOWN rather than WM_CHAR * so that the key that was ignored during WM_KEYDOWN is processed. * This allows the application to cancel an operation that is normally * performed in WM_KEYDOWN from WM_CHAR. */ int /*long*/ code = callWindowProc(handle, OS.WM_KEYDOWN, wParam, lParam); return new LRESULT(code); } } return result; }
LRESULT WM_LBUTTONUP(int /*long*/ wParam, int /*long*/ lParam) { LRESULT result = super.WM_LBUTTONUP(wParam, lParam); if (result == LRESULT.ZERO) return result; if (OS.COMCTL32_MAJOR < 6) { if (mouseDownIndex == -1) return result; int x = OS.GET_X_LPARAM(lParam); int y = OS.GET_Y_LPARAM(lParam); Rectangle[] rects = getRectangles(mouseDownIndex); for (int i = 0; i < rects.length; i++) { Rectangle rect = rects[i]; if (rect.contains(x, y)) { Event event = new Event(); event.text = ids[mouseDownIndex]; sendSelectionEvent(SWT.Selection, event, true); break; } } } mouseDownIndex = -1; return result; }
@Override long /*int*/ gtk_button_release_event(long /*int*/ widget, long /*int*/ event) { long /*int*/ result = super.gtk_button_release_event(widget, event); if (result != 0) return result; if (focusIndex == -1) return result; GdkEventButton gdkEvent = new GdkEventButton(); OS.memmove(gdkEvent, event, GdkEventButton.sizeof); if (gdkEvent.button == 1) { int x = (int) gdkEvent.x; int y = (int) gdkEvent.y; if ((style & SWT.MIRRORED) != 0) x = getClientWidth() - x; Rectangle[] rects = getRectangles(focusIndex); for (int i = 0; i < rects.length; i++) { Rectangle rect = rects[i]; if (rect.contains(x, y)) { Event ev = new Event(); ev.text = ids[focusIndex]; sendSelectionEvent(SWT.Selection, ev, true); return result; } } } return result; }
void onDispose(Event event) { removeListener(SWT.Dispose, listener); notifyListeners(SWT.Dispose, event); event.type = SWT.None; table.removeListener(SWT.FocusIn, tableListener); table.removeListener(SWT.MouseDown, tableListener); unhookRowColumnListeners(); ScrollBar hBar = table.getHorizontalBar(); if (hBar != null) { hBar.removeListener(SWT.Selection, resizeListener); } ScrollBar vBar = table.getVerticalBar(); if (vBar != null) { vBar.removeListener(SWT.Selection, resizeListener); } }
void onDispose(Event event) { /* make this handler run after other dispose listeners */ if (ignoreDispose) { ignoreDispose = false; return; } ignoreDispose = true; notifyListeners(event.type, event); event.type = SWT.NONE; gradientColors = null; gradientPercents = null; backgroundImage = null; text = null; image = null; appToolTipText = null; }