public void paintControl( final PaintEvent event ) { if ( transGraph.trans != null && transGraph.trans.isFinished() ) { refreshImage( event.gc ); if ( image != null && !image.isDisposed() ) { event.gc.drawImage( image, 0, 0 ); } } else { Rectangle bounds = canvas.getBounds(); if ( bounds.width <= 0 || bounds.height <= 0 ) { return; } event.gc.setForeground( GUIResource.getInstance().getColorWhite() ); event.gc.setBackground( GUIResource.getInstance().getColorWhite() ); event.gc.fillRectangle( new Rectangle( 0, 0, bounds.width, bounds.height ) ); event.gc.setForeground( GUIResource.getInstance().getColorBlack() ); String metricsMessage = BaseMessages.getString( PKG, "TransMetricsDelegate.TransformationIsNotRunning.Message" ); org.eclipse.swt.graphics.Point extent = event.gc.textExtent( metricsMessage ); event.gc.drawText( metricsMessage, ( bounds.width - extent.x ) / 2, ( bounds.height - extent.y ) / 2 ); } } } );
private boolean isInAdd( Point screen ) { if ( size_add == null || screen == null ) { return false; } return size_add.contains( screen ); }
@Override public void handleEvent(Event event) { Rectangle clientArea = table.getClientArea(); Point pt = new Point(event.x, event.y); int index = table.getTopIndex(); int count = table.getItemCount(); while (index < count) { boolean visible = false; TableItem item = table.getItem(index); for (int i = 0; i < table.getColumnCount(); i++) { Rectangle rect = item.getBounds(i); if (rect.contains(pt)) { beforeEdit(); clickRow(item, i); return; } if (!visible && rect.intersects(clientArea)) { visible = true; } } if (!visible) return; index++; } } protected void beforeEdit() {
Image createButtonImage(Display display, int button) { GC tempGC = new GC (this); Point size = renderer.computeSize(button, SWT.NONE, tempGC, SWT.DEFAULT, SWT.DEFAULT); tempGC.dispose(); Rectangle trim = renderer.computeTrim(button, SWT.NONE, 0, 0, 0, 0); Image image = new Image (display, size.x - trim.width, size.y - trim.height); GC gc = new GC (image); RGB transparent; if (button == CTabFolderRenderer.PART_CHEVRON_BUTTON) { transparent = new RGB(0xFF, 0xFF, 0xFF); } else { transparent = new RGB(0xFD, 0, 0); } Color transColor = new Color(display, transparent); gc.setBackground(transColor); gc.fillRectangle(image.getBounds()); renderer.draw(button, SWT.NONE, new Rectangle(trim.x, trim.y, size.x, size.y), gc); gc.dispose (); transColor.dispose(); ImageData imageData = image.getImageData(); imageData.transparentPixel = imageData.palette.getPixel(transparent); image.dispose(); image = new Image(display, imageData); return image; } void createItem (CTabItem item, int index) {
shell.setMaximized( maximized ); shell.setBounds( rectangle ); Rectangle bounds = shell.getBounds(); if ( bounds.width < minWidth ) { bounds.width = minWidth; shell.setBounds( shellSize ); Rectangle entireClientArea = shell.getDisplay().getClientArea(); Rectangle resizedRect = Geometry.copy( shellSize ); constrainRectangleToContainer( resizedRect, entireClientArea ); if ( !resizedRect.equals( shellSize ) || isClippedByUnalignedMonitors( resizedRect, shell.getDisplay() ) ) { Monitor monitor = shell.getDisplay().getPrimaryMonitor(); if ( shell.getParent() != null ) { monitor = shell.getParent().getMonitor();
public static void setSize( Shell shell, int prefWidth, int prefHeight ) { PropsUI props = PropsUI.getInstance(); WindowProperty winprop = props.getScreen( shell.getText() ); if ( winprop != null ) { winprop.setShell( shell, prefWidth, prefHeight ); } else { shell.layout(); winprop = new WindowProperty( shell.getText(), false, new Rectangle( 0, 0, prefWidth, prefHeight ) ); winprop.setShell( shell ); // Now, as this is the first time it gets opened, try to put it in the middle of the screen... Rectangle shellBounds = shell.getBounds(); Monitor monitor = shell.getDisplay().getPrimaryMonitor(); if ( shell.getParent() != null ) { monitor = shell.getParent().getMonitor(); } Rectangle monitorClientArea = monitor.getClientArea(); int middleX = monitorClientArea.x + ( monitorClientArea.width - shellBounds.width ) / 2; int middleY = monitorClientArea.y + ( monitorClientArea.height - shellBounds.height ) / 2; shell.setLocation( middleX, middleY ); } }
void createShadow(final Display display) { if (shadowImage != null) { shadowImage.dispose(); shadowImage = null; } ImageData data = new ImageData(60, 60, 32, new PaletteData(0xFF0000, 0xFF00, 0xFF)); Image tmpImage = shadowImage = new Image(display, data); GC gc = new GC(tmpImage); if (shadowColor == null) shadowColor = gc.getDevice().getSystemColor(SWT.COLOR_GRAY); gc.setBackground(shadowColor); drawTabBody(gc, new Rectangle(0, 0, 60, 60), SWT.None); ImageData blured = blur(tmpImage, 5, 25); shadowImage = new Image(display, blured); tmpImage.dispose(); }
private void updateButtonColor(final Display display, final int rV, final int gV, final int bV) { Image oldImg = img; img = new Image(display,25,10); GC gc = new GC(img); if ( r >= 0 && g >= 0 && b >= 0 ){ Color color = ColorCache.getColor(display, rV, gV, bV); gc.setBackground(color); gc.fillRectangle(0,0,25,10); }else{ Color color = colorChooser.getBackground(); gc.setBackground(color); gc.fillRectangle(0,0,25,10); new GCStringPrinter( gc, "-", new Rectangle( 0, 0, 25, 10 ), 0, SWT.CENTER ).printString(); } gc.dispose(); colorChooser.setImage(img); if(oldImg != null && ! oldImg.isDisposed()) oldImg.dispose(); }
@Override public Image getBackgroundImage() { if (bounds == null || bounds.isEmpty()) { return null; } Image image = new Image(Display.getDefault(), bounds.width - (marginWidth * 2), bounds.height - (marginHeight * 2)); GC gc = new GC(image); gc.setForeground(getBackgroundSWT()); gc.setBackground(getBackgroundSWT()); gc.fillRectangle(0, 0, bounds.width, bounds.height); gc.dispose(); return image; }
String operator = condition.getOperatorDesc(); size_oper[nr] = new Rectangle( opx, opy, opw, oph ); if ( nr == hover_operator ) { gc.setBackground( gray ); gc.fillRectangle( Real2Screen( size_oper[nr] ) ); gc.drawRectangle( Real2Screen( size_oper[nr] ) ); gc.setBackground( bg ); size_cond[nr] = new Rectangle( cx, cy, cw, ch );
/** * @param image * @param bounds * @param text */ public static void obfuscateArea(Image image, Rectangle bounds, String text) { if (bounds.isEmpty()) return; if (text == null || text.length() == 0) { obfuscateArea(image, bounds); return; } GC gc = new GC(image); try { Device device = image.getDevice(); gc.setBackground(Colors.getSystemColor(device, SWT.COLOR_WHITE)); gc.setForeground(Colors.getSystemColor(device, SWT.COLOR_RED)); gc.fillRectangle(bounds); gc.drawRectangle(bounds); Utils.setClipping(gc, bounds); gc.drawText(text, bounds.x + 2, bounds.y + 1); } finally { gc.dispose(); } }
protected Point getStackedLocation(Shell shell, Shell parent) { Point p= parent.getLocation(); Point size= parent.getSize(); p.x += size.x / 4; p.y += size.y; p= parent.toDisplay(p); Point shellSize= shell.getSize(); Monitor monitor= getClosestMonitor(parent.getDisplay(), new Rectangle(p.x, p.y, 0, 0)); Rectangle displayBounds= monitor.getClientArea(); constrainLocation(p, shellSize, displayBounds); return p; }
public void paintControl(PaintEvent event) { Control control = (Control) event.widget; Rectangle rect = new Rectangle(0, 0, control.getSize().x, control.getSize().y); GC gc = event.gc; //System.out.println(event.count); Color color = gc.getForeground(); gc.setForeground(event.display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW)); gc.drawLine(rect.x, rect.y, rect.width, rect.y); gc.drawLine(rect.x, rect.y, rect.x, rect.height); gc.setForeground(event.display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW)); gc.drawLine(rect.x, rect.height-1, rect.width, rect.height-1); gc.drawLine(rect.width-1, rect.y, rect.width-1, rect.height); gc.setForeground(color); }
private Rectangle computeShellBounds() { Rectangle result = new Rectangle( 0, 0, 0, 0 ); Point preferredSize = shell.computeSize( SWT.DEFAULT, SWT.DEFAULT ); Rectangle displaySize = parent.getDisplay().getBounds(); result.x = ( displaySize.width - preferredSize.x ) / 2 + displaySize.x; result.y = ( displaySize.height - preferredSize.y ) / 2 + displaySize.y; result.width = Math.min( preferredSize.x, MAX_WIDTH ); result.height = preferredSize.y; return result; }
private void layoutBullet(GC gc, Locator loc, int lineHeight, Hashtable<String, Object> resourceTable) { int x = loc.x - getIndent() + getBulletIndent(); int rowHeight = loc.heights.get(0)[0]; if (style == CIRCLE) { int y = loc.y + rowHeight / 2 - CIRCLE_DIAM / 2; bbounds = new Rectangle(x, y, CIRCLE_DIAM, CIRCLE_DIAM); } else if (style == TEXT && text != null) { //int height = gc.getFontMetrics().getHeight(); Point textSize = gc.textExtent(text); bbounds = new Rectangle(x, loc.y, textSize.x, textSize.y); } else if (style == IMAGE && text != null) { Image image = (Image) resourceTable.get(text); if (image != null) { Rectangle ibounds = image.getBounds(); int y = loc.y + rowHeight / 2 - ibounds.height / 2; bbounds = new Rectangle(x, y, ibounds.width, ibounds.height); } } }
/** * Constrain the shell size to be no larger than the display bounds. * * @since 2.0 */ protected void constrainShellSize() { // limit the shell size to the display size Rectangle bounds = shell.getBounds(); Rectangle constrained = getConstrainedShellBounds(bounds); if (!bounds.equals(constrained)) { shell.setBounds(constrained); } }
@Override public void mouseExit(MouseEvent e) { if (fComposite == null) return; Control[] children= fComposite.getChildren(); Rectangle bounds= null; for (int i= 0; i < children.length; i++) { if (bounds == null) bounds= children[i].getBounds(); else bounds.add(children[i].getBounds()); if (bounds.contains(e.x, e.y)) return; } // if none of the children contains the event, we leave the popup dispose(); }
@Override public void paintControl(PaintEvent e) { GC gc = e.gc; gc.setForeground( Colors.grey); Point size = engine_comp.getSize(); gc.drawRectangle( new Rectangle( 0, 0, size.x-1, size.y-1 )); } });
private Rectangle getAndNotSize( GC gc ) { Point p = gc.textExtent( Condition.operators[Condition.OPERATOR_AND_NOT] ); return new Rectangle( 0, 0, p.x, p.y ); }
@Override protected void computeInformation() { if (fProposal instanceof ICompletionProposalExtension3) setCustomInformationControlCreator(((ICompletionProposalExtension3) fProposal).getInformationControlCreator()); else setCustomInformationControlCreator(null); // compute subject area Point size= fProposalTable.getShell().getSize(); // set information & subject area setInformation(fInformation, new Rectangle(0, 0, size.x, size.y)); }