protected Point getArea() { org.eclipse.swt.graphics.Rectangle rect = canvas.getClientArea(); Point area = new Point( rect.width, rect.height ); return area; }
gc.fillRectangle( canvas.getClientArea() ); return; gc.fillRectangle( canvas.getClientArea() ); gc.setBackgroundPattern( null ); return;
@Override public void paintControl(final PaintEvent e) { if(clockDrawer != null) { Rectangle rc = canvas.getClientArea(); clockDrawer.drawClock(date, rc.x, rc.y, rc.width, rc.height, e.gc); } }
org.eclipse.swt.graphics.Point getCenteredOrigin() { final Rectangle rect = image.getBounds(); final Rectangle client = canvas.getClientArea(); final int zeroX = client.x + client.width / 2 - rect.width / 2; final int zeroY = client.y + client.height / 2 - rect.height / 2; return new org.eclipse.swt.graphics.Point(origin.x + zeroX, origin.y + zeroY); }
public static void renderClientArea( Canvas canvas ) { renderProperty( canvas, PROP_CLIENT_AREA, canvas.getClientArea(), null ); }
void scrollHorizontally(ScrollBar scrollBar) { if (image == null) return; Rectangle canvasBounds = imageCanvas.getClientArea(); int width = Math.round(imageData.width * xscale); int height = Math.round(imageData.height * yscale); if (width > canvasBounds.width) { // Only scroll if the image is bigger than the canvas. int x = -scrollBar.getSelection(); if (x + width < canvasBounds.width) { // Don't scroll past the end of the image. x = canvasBounds.width - width; } imageCanvas.scroll(x, iy, ix, iy, width, height, false); ix = x; } }
void scrollVertically(ScrollBar scrollBar) { if (image == null) return; Rectangle canvasBounds = imageCanvas.getClientArea(); int width = Math.round(imageData.width * xscale); int height = Math.round(imageData.height * yscale); if (height > canvasBounds.height) { // Only scroll if the image is bigger than the canvas. int y = -scrollBar.getSelection(); if (y + height < canvasBounds.height) { // Don't scroll past the end of the image. y = canvasBounds.height - height; } imageCanvas.scroll(ix, y, ix, iy, width, height, false); iy = y; } }
@Override void internalSetRedraw( boolean redraw ) { super.internalSetRedraw( redraw ); if( redraw ) { repaint( getClientArea() ); } }
/** * Scrolls the canvas horizontally. * * @param scrollBar */ void scrollHorizontal (ScrollBar scrollBar) { Rectangle bounds = canvas.getClientArea(); int x = -scrollBar.getSelection(); if (x + maxX < bounds.width) { x = bounds.width - maxX; } canvas.scroll(x, cy, cx, cy, maxX, maxY, false); cx = x; }
/** * Scrolls the canvas vertically. * * @param scrollBar */ void scrollVertical (ScrollBar scrollBar) { Rectangle bounds = canvas.getClientArea(); int y = -scrollBar.getSelection(); if (y + maxY < bounds.height) { y = bounds.height - maxY; } canvas.scroll(cx, y, cx, cy, maxX, maxY, false); cy = y; }
@Override public void paintControl(@Nullable PaintEvent e) { assert e != null; timelineBar.update(timeline.getWidth()); e.gc.setBackground( e.display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); e.gc.fillRectangle(0, 0, barCanvas.get().getClientArea().width, barCanvas.get().getClientArea().height); e.gc.drawImage(timelineBar.contents, origin.x, 0); e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED)); e.gc.drawLine(origin.x + (int) (currentTime / TIME_PER_PIXEL), FONT_SIZE, origin.x + (int) (currentTime / TIME_PER_PIXEL), barCanvas.get().getClientArea().height); } });
@Override public void preserveValues( Canvas canvas ) { WidgetLCAUtil.preserveBackgroundGradient( canvas ); WidgetLCAUtil.preserveRoundedBorder( canvas ); WidgetLCAUtil.preserveProperty( canvas, PROP_CLIENT_AREA, canvas.getClientArea() ); }
@Override public void handleEvent(Event e) { Rectangle bounds = paletteCanvas.getClientArea(); Color color = getColorAt(bounds, e.x, e.y); if (e.button == 1) setForegroundColor(color); else setBackgroundColor(color); } private Color getColorAt(Rectangle bounds, int x, int y) {
void scrollPalette(ScrollBar scrollBar) { if (image == null) return; Rectangle canvasBounds = paletteCanvas.getClientArea(); int paletteHeight = imageData.palette.getRGBs().length * 10 + 20; if (paletteHeight > canvasBounds.height) { // Only scroll if the palette is bigger than the canvas. int y = -scrollBar.getSelection(); if (y + paletteHeight < canvasBounds.height) { // Don't scroll past the end of the palette. y = canvasBounds.height - paletteHeight; } paletteCanvas.scroll(0, y, 0, py, paletteWidth, paletteHeight, false); py = y; } }
@Override void notifyResize( Point oldSize ) { super.notifyResize( oldSize ); if( !oldSize.equals( getSize() ) ) { repaint( getClientArea() ); } }
@Override public void paintControl(PaintEvent e) { timeline.update(); e.gc.drawImage(timeline.contents, origin.x, origin.y); e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED)); e.gc.drawLine(origin.x + (int) (currentTime / timeline.timePerPixel), 0, origin.x + (int) (currentTime / timeline.timePerPixel), canvas.getClientArea().height); hBar.setMaximum(timeline.getWidth() == 0 ? 1 : timeline.getWidth() + 20); vBar.setMaximum(timeline.getHeight() + 5); hBar.setThumb(Math.min(timeline.getWidth() + 20, canvas.getClientArea().width)); vBar.setThumb(Math.min(timeline.getHeight() + 5, canvas.getClientArea().height)); } });
void updateScrollbars(boolean adaptToScrollbar) { final Rectangle rect = image.getBounds(); final Rectangle client = canvas.getClientArea(); hBar.setMaximum(rect.width); vBar.setMaximum(rect.height); hBar.setThumb(Math.min(rect.width, client.width)); vBar.setThumb(Math.min(rect.height, client.height)); if (!adaptToScrollbar) { final org.eclipse.swt.graphics.Point center = getCenteredOrigin(); hBar.setSelection(-center.x); vBar.setSelection(-center.y); } }
@Override public void handleEvent(Event e) { Rectangle clientArea = ((Canvas) e.widget).getClientArea(); e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_NORMAL_SHADOW)); e.gc.drawRectangle(clientArea); clientArea.y++; e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW)); e.gc.drawRectangle(clientArea); } });
@Override public void handleEvent(Event e) { Rectangle clientArea = ((Canvas) e.widget).getClientArea(); e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_NORMAL_SHADOW)); e.gc.drawRectangle(clientArea); clientArea.y++; e.gc.setForeground(Colors.getSystemColor(e.display, SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW)); e.gc.drawRectangle(clientArea); } });
@Override public void paintControl(PaintEvent e) { timelineBar.update(timeline.getWidth()); e.gc.drawImage(timelineBar.contents, origin.x, 0); e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED)); e.gc.drawLine(origin.x + (int) (currentTime / timeline.timePerPixel), 10, origin.x + (int) (currentTime / timeline.timePerPixel), barCanvas.getClientArea().height); } });