@Override public void menuDetected( MenuDetectEvent e ) { Point screen = new Point( e.x, e.y ); Point widgetScreen = widget.toDisplay( 1, 1 ); Point wRel = new Point( screen.x - widgetScreen.x, screen.y - widgetScreen.y ); int area = getAreaCode( wRel ); setMenu( area, wRel ); }
public static Point calculateControlPosition( Control control ) { // Calculate the exact location... // Rectangle r = control.getBounds(); Point p = control.getParent().toDisplay( r.x, r.y ); return p; /* * Point location = control.getLocation(); * * Composite parent = control.getParent(); while (parent!=null) { * * Composite newParent = parent.getParent(); if (newParent!=null) { location.x+=parent.getLocation().x; * location.y+=parent.getLocation().y; } else { if (parent instanceof Shell) { // Top level shell. Shell shell = * (Shell)parent; Rectangle bounds = shell.getBounds(); Rectangle clientArea = shell.getClientArea(); location.x += * bounds.width-clientArea.width; location.y += bounds.height-clientArea.height; } } parent = newParent; } * * return location; */ }
@Override public Rectangle getBoundsOnDisplay() { Rectangle bounds = getBounds(); Point pt = composite.toDisplay(bounds.x, bounds.y); bounds.x = pt.x; bounds.y = pt.y; return bounds; }
public void run() { parentLoc[0] = getParent().toDisplay(0,0); } } ); return new Point(parentLoc[0].x, parentLoc[0].y);
/** * An accessor for the current location of this status line contribution * item -- relative to the display. * * @return The current location of this status line; <code>null</code> if * not yet initialized. */ public Point getDisplayLocation() { if ((label != null) && (statusLine != null)) { return statusLine.toDisplay(label.getLocation()); } return null; }
/** * An accessor for the current location of this status line contribution * item -- relative to the display. * * @return The current location of this status line; <code>null</code> if * not yet initialized. */ public Point getDisplayLocation() { if ((label != null) && (statusLine != null)) { return statusLine.toDisplay(label.getLocation()); } return null; }
/** * An accessor for the current location of this status line contribution * item -- relative to the display. * * @return The current location of this status line; <code>null</code> if * not yet initialized. */ public Point getDisplayLocation() { if ((label != null) && (statusLine != null)) { return statusLine.toDisplay(label.getLocation()); } return null; }
public void getLocation (AccessibleControlEvent e) { Rectangle location = getBounds (); Point pt = getParent().toDisplay (location.x, location.y); e.x = pt.x; e.y = pt.y; e.width = location.width; e.height = location.height; }
@Override public void getLocation (AccessibleControlEvent e) { Rectangle location = getBounds (); Point pt = getParent().toDisplay (location.x, location.y); e.x = pt.x; e.y = pt.y; e.width = location.width; e.height = location.height; }
@Override public void getLocation (AccessibleControlEvent e) { Rectangle location = getBounds (); Point pt = getParent().toDisplay (location.x, location.y); e.x = pt.x; e.y = pt.y; e.width = location.width; e.height = location.height; }
@Override public void getLocation (AccessibleControlEvent e) { Rectangle location = getBounds (); Point pt = getParent().toDisplay (location.x, location.y); e.x = pt.x; e.y = pt.y; e.width = location.width; e.height = location.height; }
public void updateFakeTooltipOver(String tooltip, Composite c) { Point pos = c.toDisplay(0, 0); Rectangle rect = c.getBounds(); rect.x = pos.x; rect.y = pos.y; updateFakeTooltip(tooltip, rect, true); }
@Override public void getLocation (AccessibleControlEvent e) { Rectangle location = getBounds (); Point pt = getParent().toDisplay (location.x, location.y); e.x = pt.x; e.y = pt.y; e.width = location.width; e.height = location.height; }
@Override public void clickMenu(int x, int y) { dropDownMenu = new Menu(parent.getShell(), SWT.POP_UP); addActionsToMenu(); Point p = parent.toDisplay(x, y); dropDownMenu.setLocation(p.x, p.y); dropDownMenu.setVisible(true); dropDownMenu = null; }
@Override public void getLocation(AccessibleControlEvent e) { Rectangle location = null; Point pt = null; int childID = e.childID; if (childID == ACC.CHILDID_SELF) { location = getClientArea(); pt = getParent().toDisplay(location.x, location.y); } else { location = itemBounds(childID); pt = toDisplay(location.x, location.y); } e.x = pt.x; e.y = pt.y; e.width = location.width; e.height = location.height; } @Override
@Override public void paintControl(PaintEvent e){ GC gc = e.gc; gc.setAdvanced(true); gc.setAntialias(SWT.ON); Point pp = parent.toDisplay(0, 0); Point cp = child.toDisplay(0, 0 ); Rectangle bounds = child.getBounds(); int width = bounds.width; int height = bounds.height; gc.setForeground(Colors.fadedRed ); gc.drawRectangle( cp.x-pp.x-1, cp.y-pp.y-1, width+2, height+2 ); } });
@Override public boolean isMouseOver() { if (isDisposed()) { return false; } Rectangle r = composite.getBounds(); if (cellArea != null) { r = new Rectangle(r.x + cellArea.x, r.y + cellArea.y, cellArea.width, cellArea.height); } Point ptStart = composite.toDisplay(r.x, r.y); r.x = ptStart.x; r.y = ptStart.y; Point ptCursor = composite.getDisplay().getCursorLocation(); return r.contains(ptCursor); }
private void showMenu(Button button, IContributionItem menuContribution) { Menu menu = new Menu(button); Point p = button.getLocation(); p.y = p.y + button.getSize().y; p = button.getParent().toDisplay(p); menu.setLocation(p); menuContribution.fill(menu, 0); menu.setVisible(true); } }
@Override public int[] getMouseOffset() { if (isDisposed()) { return null; } Rectangle r = composite.getBounds(); if (cellArea != null) { r = new Rectangle(r.x + cellArea.x, r.y + cellArea.y, cellArea.width, cellArea.height); } Point ptStart = composite.toDisplay(r.x, r.y); r.x = ptStart.x; r.y = ptStart.y; Point ptCursor = composite.getDisplay().getCursorLocation(); if (!r.contains(ptCursor)) { return null; } return new int[] { ptCursor.x - r.x, ptCursor.y - r.y }; }
public OpenDesignShellRunnable(MouseEvent event, DesignListener listener){ this.display = event.display; this.widget = event.widget; this.listener = listener; Control control = (Control) event.getSource(); if(control == null || control.getParent() == null){ return; } point = control.getParent().toDisplay(control.getLocation()); point.y = point.y - 16; ac = new ActionContext(); ac.getScope(0).put("parent", ((Control) widget).getShell()); ac.getScope(0).put("listener", listener); ac.getScope(0).put("theControl", widget); }