public Point getRealPosition( Composite canvas, int x, int y ) { Point p = new Point( 0, 0 ); Composite follow = canvas; while ( follow != null ) { Point xy = new Point( follow.getLocation().x, follow.getLocation().y ); p.x += xy.x; p.y += xy.y; follow = follow.getParent(); } p.x = x - p.x - 8; p.y = y - p.y - 48; return screen2real( p.x, p.y ); }
public Point getRealPosition( Composite canvas, int x, int y ) { Point p = new Point( 0, 0 ); Composite follow = canvas; while ( follow != null ) { org.eclipse.swt.graphics.Point loc = follow.getLocation(); Point xy = new Point( loc.x, loc.y ); p.x += xy.x; p.y += xy.y; follow = follow.getParent(); } int offsetX = -16; int offsetY = -64; if ( Const.isOSX() ) { offsetX = -2; offsetY = -24; } p.x = x - p.x + offsetX; p.y = y - p.y + offsetY; return screen2real( p.x, p.y ); }
@Override public void widgetSelected( SelectionEvent e ) { if ( e.detail == SWT.DROP_DOWN ) { Menu menu = new Menu( shell, SWT.POP_UP ); MenuItem item1 = new MenuItem( menu, SWT.PUSH ); item1.setText( BaseMessages.getString( PKG, "Spoon.Menu.StopTranformation" ) ); item1.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e1 ) { stopTransformation(); } } ); MenuItem item2 = new MenuItem( menu, SWT.PUSH ); item2.setText( BaseMessages.getString( PKG, "Spoon.Menu.SafeStopTranformation" ) ); item2.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e2 ) { safeStop(); } } ); menu.setLocation( shell.getDisplay().map( mainComposite.getParent(), null, mainComposite.getLocation() ) ); menu.setVisible( true ); } else { stopTransformation(); } } } );
@Override public void widgetSelected( SelectionEvent e ) { if ( e.detail == SWT.DROP_DOWN ) { Menu menu = new Menu( shell, SWT.POP_UP ); MenuItem item1 = new MenuItem( menu, SWT.PUSH ); item1.setText( BaseMessages.getString( PKG, "Spoon.Run.Run" ) ); item1.setAccelerator( SWT.F9 ); item1.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e1 ) { runTransformation(); } } ); MenuItem item2 = new MenuItem( menu, SWT.PUSH ); item2.setText( BaseMessages.getString( PKG, "Spoon.Run.RunOptions" ) ); item2.setAccelerator( SWT.F8 ); item2.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e2 ) { runOptionsTransformation(); } } ); menu.setLocation( shell.getDisplay().map( mainComposite.getParent(), null, mainComposite.getLocation() ) ); menu.setVisible( true ); } else { runTransformation(); } } } );
@Override public void widgetSelected( SelectionEvent e ) { if ( e.detail == SWT.DROP_DOWN ) { Menu menu = new Menu( shell, SWT.POP_UP ); MenuItem item1 = new MenuItem( menu, SWT.PUSH ); item1.setText( BaseMessages.getString( PKG, "Spoon.Run.Run" ) ); item1.setAccelerator( SWT.F9 ); item1.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e1 ) { runJob(); } } ); MenuItem item2 = new MenuItem( menu, SWT.PUSH ); item2.setText( BaseMessages.getString( PKG, "Spoon.Run.RunOptions" ) ); item2.setAccelerator( SWT.F8 ); item2.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent e2 ) { runOptionsJob(); } } ); menu.setLocation( shell.getDisplay().map( mainComposite.getParent(), null, mainComposite.getLocation() ) ); menu.setVisible( true ); } else { runJob(); } } } );
public Point getLocation() { return container.getLocation(); }
/** * Gets the absolute location. * * @param control the control * @param x the x * @param y the y * @return the absolute location */ private Point getAbsoluteLocation(Control control, int x, int y) { Point point = new Point(x, y); Composite composite = control.getParent(); while (composite != null) { point.x += composite.getLocation().x; point.y += composite.getLocation().y; composite = composite.getParent(); } return point; }
public void setLocation(Point location) { Rectangle trim = fShell.computeTrim(0, 0, 0, 0); Point textLocation = fComposite.getLocation(); location.x += trim.x - textLocation.x; location.y += trim.y - textLocation.y; fShell.setLocation(location); }
public void setLocation(Point location) { Rectangle trim = fShell.computeTrim(0, 0, 0, 0); Point textLocation = fComposite.getLocation(); location.x += trim.x - textLocation.x; location.y += trim.y - textLocation.y; fShell.setLocation(location); }
private void invokeMenu(Composite widget) { Rectangle b = widget.getBounds(); Point p = widget.getLocation(); p.x += b.width + 3; bMouse = false; redraw(); clickMenu(p.x, p.y); } });
protected Point getMinSize() { Point size = getButtonComposite().getSize(); int bottomEnd = getButtonComposite().getLocation().y + size.y; int minWidth = size.x + 2*scaler.convertXToCurrent(HORIZONTAL_OFFSET) + 2*getShell().getBorderWidth(); int minHeight = bottomEnd + scaler.convertYToCurrent(SHELL_DEFAULT_MIN_HEIGHT); return new Point(minWidth,minHeight); }
protected Point getMinSize() { Point size = getButtonComposite().getSize(); int bottomEnd = getButtonComposite().getLocation().y + size.y; int minWidth = size.x + 2*scaler.convertXToCurrent(HORIZONTAL_OFFSET) + 2*getShell().getBorderWidth(); int minHeight = bottomEnd + scaler.convertYToCurrent(SHELL_DEFAULT_MIN_HEIGHT); return new Point(minWidth,minHeight); }
/** Opens the shell on this parent shell. */ public Shell openOn(Shell parent) { Preconditions.checkNotNull(parent); Shell shell = new Shell(parent, style); if (location == null) { Point parentPos = shell.getParent().getLocation(); int SHELL_MARGIN = SwtMisc.systemFontHeight(); parentPos.x += SHELL_MARGIN; parentPos.y += SHELL_MARGIN; location = Maps.immutableEntry(Corner.TOP_LEFT, parentPos); } setupShell(shell); return shell; }
Point loc = btnCntrl.getLocation(); Rectangle rect = btnCntrl.getBounds(); Point loc = btnCntrl2.getLocation(); Rectangle rect = btnCntrl2.getBounds();
protected Point getMinSize() { int minWidth = scaler.convertXToCurrent(23) + detailButton.getSize().x + scaler.convertXToCurrent(HORIZONTAL_OFFSET); minWidth += copyButton.getSize().x + scaler.convertXToCurrent(HORIZONTAL_OFFSET); minWidth += getButtonComposite().getSize().x + scaler.convertXToCurrent(HORIZONTAL_OFFSET); int okBottomEnd = getButtonComposite().getLocation().y + getButtonComposite().getSize().y; int minHeight = okBottomEnd + scaler.convertYToCurrent(SHELL_DEFAULT_MIN_HEIGHT); if(detailOpen) { minHeight += scaler.convertYToCurrent(100); } return new Point(minWidth,minHeight); }
protected Point getMinSize() { int minWidth = scaler.convertXToCurrent(23) + detailButton.getSize().x + scaler.convertXToCurrent(HORIZONTAL_OFFSET); minWidth += copyButton.getSize().x + scaler.convertXToCurrent(HORIZONTAL_OFFSET); minWidth += getButtonComposite().getSize().x + scaler.convertXToCurrent(HORIZONTAL_OFFSET); int okBottomEnd = getButtonComposite().getLocation().y + getButtonComposite().getSize().y; int minHeight = okBottomEnd + scaler.convertYToCurrent(SHELL_DEFAULT_MIN_HEIGHT); if(detailOpen) { minHeight += scaler.convertYToCurrent(100); } return new Point(minWidth,minHeight); }
private void adjustHeight(StyledText text) { int lineCount = text.getLineCount(); int lineHeight = text.getLineHeight(); int startPos = text.getLocation().y; Composite c = text.getParent(); while (c != null) { startPos += c.getLocation().y; c = c.getParent(); } // the text is not positioned yet, we assume that it will appear // on the bottom of the dialog startPos += text.getShell().getBounds().height; int screenHeight = text.getShell().getMonitor().getBounds().height; int availableScreenForText = screenHeight - startPos; if (availableScreenForText <= MINIMUM_HEIGHT) { // should not happen. But in that case nothing can improve user // experience. return; } int desiredHeight = lineCount * lineHeight; if (desiredHeight > availableScreenForText * 0.75) { ((GridData) text.getLayoutData()).heightHint = (int) (availableScreenForText * 0.75); } }
private void showStandaloneViewMenu(ExecutionEvent event, MPart model, MMenu menuModel, Composite partContainer) { Shell shell = partContainer.getShell(); Menu menu = (Menu) menuModel.getWidget(); if (menu == null) { IPresentationEngine engine = (IPresentationEngine) HandlerUtil.getVariable(event, IPresentationEngine.class.getName()); menu = (Menu) engine.createGui(menuModel, shell, model.getContext()); if (menu != null) { final Menu tmpMenu = menu; partContainer.addDisposeListener(e -> tmpMenu.dispose()); } } Display display = menu.getDisplay(); Point location = display.map(partContainer, null, partContainer.getLocation()); Point size = partContainer.getSize(); menu.setLocation(location.x + size.x, location.y); menu.setVisible(true); while (!menu.isDisposed() && menu.isVisible()) { if (!display.readAndDispatch()) display.sleep(); } if (!(menu.getData() instanceof MenuManager)) { menu.dispose(); } }