void redraw() { int display = OS.XtDisplay(handle); if (display == 0) return; int window = OS.XtWindow(handle); if (window == 0) return; OS.XClearArea(display, window, 0, 0, 0, 0, true); }
void releaseWidget() { super.releaseWidget(); if (cursor != 0) { int display = OS.XtDisplay(handle); if (display != 0) OS.XFreeCursor(display, cursor); } cursor = 0; }
boolean hasCursor() { int[] unused = new int[1], buffer = new int[1]; int xDisplay = OS.XtDisplay(handle); int xWindow, xParent = OS.XDefaultRootWindow(xDisplay); do { if (OS.XQueryPointer( xDisplay, xParent, unused, buffer, unused, unused, unused, unused, unused) == 0) return false; if ((xWindow = buffer[0]) != 0) xParent = xWindow; } while (xWindow != 0); return handle == OS.XtWindowToWidget(xDisplay, xParent); }
public void setCursor(Cursor cursor) { checkWidget(); super.setCursor(cursor); if (cursor == null && this.cursor != 0) { int xWindow = OS.XtWindow(handle); if (xWindow == 0) return; int xDisplay = OS.XtDisplay(handle); if (xDisplay == 0) return; OS.XDefineCursor(xDisplay, xWindow, this.cursor); OS.XFlush(xDisplay); } }
void realizeChildren() { super.realizeChildren(); int xWindow = OS.XtWindow(handle); if (xWindow == 0) return; int xDisplay = OS.XtDisplay(handle); if (xDisplay == 0) return; if ((style & SWT.HORIZONTAL) != 0) { cursor = OS.XCreateFontCursor(xDisplay, OS.XC_sb_v_double_arrow); } else { cursor = OS.XCreateFontCursor(xDisplay, OS.XC_sb_h_double_arrow); } if (super.cursor == null && isEnabled()) { OS.XDefineCursor(xDisplay, xWindow, cursor); OS.XFlush(xDisplay); } }
/** * Sets the control that is used to fill the bounds of the item when the item is a <code>SEPARATOR * </code>. * * @param control the new control * @exception IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree * </ul> * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver * </ul> */ public void setControl(Control control) { checkWidget(); if (control != null) { if (control.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); if (control.parent != parent) error(SWT.ERROR_INVALID_PARENT); } if ((style & SWT.SEPARATOR) == 0) return; if (this.control == control) return; this.control = control; int[] argList = { OS.XmNseparatorType, control == null ? ((parent.style & SWT.FLAT) != 0 ? OS.XmSHADOW_ETCHED_IN : OS.XmSHADOW_ETCHED_OUT) : OS.XmNO_LINE, }; OS.XtSetValues(handle, argList, argList.length / 2); if (control != null && !control.isDisposed()) { /* * It is possible that the control was created with a * z-order below that of the current tool item. In this * case, the control is not visible because it is * obscured by the tool item. The fix is to move the * control above this tool item in the z-order. * The code below is similar to the code found in * setZOrder. */ int xDisplay = OS.XtDisplay(handle); if (xDisplay == 0) return; if (!OS.XtIsRealized(handle)) { Shell shell = parent.getShell(); shell.realizeWidget(); } int topHandle1 = control.topHandle(); int window1 = OS.XtWindow(topHandle1); if (window1 == 0) return; int topHandle2 = this.topHandle(); int window2 = OS.XtWindow(topHandle2); if (window2 == 0) return; XWindowChanges struct = new XWindowChanges(); struct.sibling = window2; struct.stack_mode = OS.Above; int screen = OS.XDefaultScreen(xDisplay); int flags = OS.CWStackMode | OS.CWSibling; OS.XReconfigureWMWindow(xDisplay, window1, screen, flags, struct); } parent.relayout(); }
void drawBand(int x, int y, int width, int height) { if ((style & SWT.SMOOTH) != 0) return; int display = OS.XtDisplay(parent.handle); if (display == 0) return; int window = OS.XtWindow(parent.handle); if (window == 0) return; int foreground = parent.getForegroundPixel(); Control control = parent.findBackgroundControl(); if (control == null) control = parent; int background = control.getBackgroundPixel(); int color = foreground ^ background; byte[] bits = {-86, 85, -86, 85, -86, 85, -86, 85}; int stipplePixmap = OS.XCreateBitmapFromData(display, window, bits, 8, 8); int gc = OS.XCreateGC(display, window, 0, null); OS.XSetForeground(display, gc, color); OS.XSetStipple(display, gc, stipplePixmap); OS.XSetSubwindowMode(display, gc, OS.IncludeInferiors); OS.XSetFillStyle(display, gc, OS.FillStippled); OS.XSetFunction(display, gc, OS.GXxor); OS.XFillRectangle(display, window, gc, x, y, width, height); OS.XFreePixmap(display, stipplePixmap); OS.XFreeGC(display, gc); }
int XmNexposureCallback(int w, int client_data, int call_data) { if ((style & SWT.SEPARATOR) != 0) return 0; int xDisplay = OS.XtDisplay(handle); if (xDisplay == 0) return 0; int xWindow = OS.XtWindow(handle); if (xWindow == 0) return 0; int[] argList = { OS.XmNcolormap, 0, OS.XmNwidth, 0, OS.XmNheight, 0, }; OS.XtGetValues(handle, argList, argList.length / 2); int width = argList[3], height = argList[5]; Image currentImage = image; boolean enabled = getEnabled(); if ((parent.style & SWT.FLAT) != 0) { boolean hasCursor = hasCursor(); /* Set the shadow thickness */ int thickness = 0; if (set || (hasCursor && enabled)) { thickness = Math.min(2, display.buttonShadowThickness); } argList = new int[] {OS.XmNshadowThickness, thickness}; OS.XtSetValues(handle, argList, argList.length / 2); /* Determine if hot image should be used */ if (enabled && hasCursor && hotImage != null) { currentImage = hotImage; } } GCData data = new GCData(); data.device = display; data.display = xDisplay; data.drawable = xWindow; data.font = parent.font; data.colormap = argList[1]; int xGC = OS.XCreateGC(xDisplay, xWindow, 0, null); if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES); GC gc = GC.motif_new(xGC, data); XmAnyCallbackStruct cb = new XmAnyCallbackStruct(); OS.memmove(cb, call_data, XmAnyCallbackStruct.sizeof); if (cb.event != 0) { XExposeEvent xEvent = new XExposeEvent(); OS.memmove(xEvent, cb.event, XExposeEvent.sizeof); Rectangle rect = new Rectangle(xEvent.x, xEvent.y, xEvent.width, xEvent.height); gc.setClipping(rect); } if (!enabled) { currentImage = disabledImage; if (currentImage == null && image != null) { currentImage = new Image(display, image, SWT.IMAGE_DISABLE); } Color disabledColor = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); gc.setForeground(disabledColor); } else { gc.setForeground(parent.getForeground()); } gc.setBackground(parent.getBackground()); int textX = 0, textY = 0, textWidth = 0, textHeight = 0; if (text.length() != 0) { int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC; Point textExtent = gc.textExtent(text, flags); textWidth = textExtent.x; textHeight = textExtent.y; } int imageX = 0, imageY = 0, imageWidth = 0, imageHeight = 0; if (currentImage != null) { Rectangle imageBounds = currentImage.getBounds(); imageWidth = imageBounds.width; imageHeight = imageBounds.height; } int spacing = 0; if (textWidth != 0 && imageWidth != 0) spacing = 2; if ((parent.style & SWT.RIGHT) != 0) { imageX = (width - imageWidth - textWidth - spacing) / 2; imageY = (height - imageHeight) / 2; textX = spacing + imageX + imageWidth; textY = (height - textHeight) / 2; } else { imageX = (width - imageWidth) / 2; imageY = (height - imageHeight - textHeight - spacing) / 2; textX = (width - textWidth) / 2; textY = spacing + imageY + imageHeight; } if ((style & SWT.DROP_DOWN) != 0) { textX -= 6; imageX -= 6; } if (textWidth > 0) { int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC | SWT.DRAW_TRANSPARENT; gc.drawText(text, textX, textY, flags); } if (imageWidth > 0) gc.drawImage(currentImage, imageX, imageY); if ((style & SWT.DROP_DOWN) != 0) { int startX = width - 12, startY = (height - 2) / 2; int[] arrow = {startX, startY, startX + 3, startY + 3, startX + 6, startY}; gc.setBackground(parent.getForeground()); gc.fillPolygon(arrow); gc.drawPolygon(arrow); } gc.dispose(); OS.XFreeGC(xDisplay, xGC); if (!enabled && disabledImage == null) { if (currentImage != null) currentImage.dispose(); } return 0; }