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; } }
@Override void drawWidget(GC gc) { 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 ((state & DISABLED) != 0) 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 rect = rects[i]; gc.drawFocus(rect.x, rect.y, rect.width, rect.height); } } }
private void paintCanvas(GC gc, int px, int py, int pw, int ph) { if (canvas == null || canvas.isDisposed()) return; Rectangle r = canvas.getBounds(); Color b1 = canvas.getBackground(); gc.setAntialias(SWT.ON); gc.setTextAntialias(SWT.ON); // Draw selection background: if (isSelected()) { gc.setBackground(selectedBackground); gc.fillRoundRectangle(0, 0, r.width, r.height, CORNER, CORNER); } else if (showingHover) { int oldAlpha = gc.getAlpha(); gc.setAlpha(96 * oldAlpha / 255); gc.setBackground(selectedBackground); gc.fillRoundRectangle(0, 0, r.width, r.height, CORNER, CORNER); gc.setAlpha(oldAlpha); } // Draw edit indicator: if (showingEditorHover) { int oldAlpha = gc.getAlpha(); gc.setAlpha(192 * oldAlpha / 255); gc.setBackground(b1); gc.fillRoundRectangle( r.width / 2 + HOVER_SHRINK_H, HOVER_SHRINK_V, r.width / 2 - HOVER_SHRINK_H - HOVER_SHRINK_H, r.height - HOVER_SHRINK_V - HOVER_SHRINK_V, HOVER_CORNER, HOVER_CORNER); gc.setAlpha(oldAlpha); // // Control ec = editor == null ? null : editor.getControl(); // if (ec != null && !ec.isDisposed()) { // Rectangle eb = ec.getBounds(); // gc.setAlpha(192); // gc.setBackground(b1); // gc.fillRoundRectangle(eb.x, eb.y, eb.width, eb.height, 8, 8); // gc.setAlpha(255); // } } // Draw property name label: gc.setForeground(canvas.getForeground()); gc.setFont(canvas.getFont()); if (nameLayout != null && !nameLayout.isDisposed()) { Rectangle nb = nameLayout.getBounds(); nameLayout.draw(gc, MARGIN_H, (r.height - nb.height) / 2); } // Draw property value repsentating image: int right = r.width - MARGIN_H; if (valueImage != null && !valueImage.isDisposed()) { Rectangle ib = valueImage.getBounds(); int iw, ih; if (ib.height > r.height) { ih = r.height; iw = ib.width * r.height / ib.height; } else { ih = ib.height; iw = ib.width; } gc.drawImage(valueImage, 0, 0, ib.width, ib.height, right - iw, (r.height - ih) / 2, iw, ih); right = right - iw - 3; } // Draw property value label: if (valueLayout != null && !valueLayout.isDisposed()) { Rectangle vb = valueLayout.getBounds(); valueLayout.draw(gc, right - vb.width, (r.height - vb.height) / 2); } }