public void newFileDropDown() { // Drop down a list below the "New" icon (new.png) // First problem: where is that icon? XulToolbarbutton button = (XulToolbarbutton) this.mainToolbar.getElementById( "file-new" ); Object object = button.getManagedObject(); if ( object instanceof ToolItem ) { // OK, let's determine the location of this widget... // ToolItem item = (ToolItem) object; Rectangle bounds = item.getBounds(); org.eclipse.swt.graphics.Point p = item.getParent().toDisplay( new org.eclipse.swt.graphics.Point( bounds.x, bounds.y ) ); fileMenus.setLocation( p.x, p.y + bounds.height ); fileMenus.setVisible( true ); } }
@Override public void widgetSelected( SelectionEvent e ) { Menu menu = new Menu( shell ); for ( final PerspectiveData perspectiveData : perspectiveList ) { MenuItem item = new MenuItem( menu, SWT.CHECK ); if ( perspectiveData.isHidden() ) { item.setEnabled( false ); } if ( activePerspective.getId().equals( perspectiveData.getId() ) ) { item.setSelection( true ); } item.setText( perspectiveData.getName() ); item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected( SelectionEvent selectionEvent ) { Spoon.getInstance().loadPerspective( perspectiveData.getId() ); swtToolbar.forceFocus(); } } ); } ToolItem item = (ToolItem) e.widget; Rectangle rect = item.getBounds(); Point pt = item.getParent().toDisplay( new Point( rect.x, rect.y + rect.height ) ); menu.setLocation( pt.x, pt.y ); menu.setVisible( true ); } } );
Rectangle rect = item.getBounds(); org.eclipse.swt.graphics.Point pt = item.getParent().toDisplay( new org.eclipse.swt.graphics.Point( rect.x, rect.y + rect.height ) );
private static Rectangle getBounds( ToolItem item ) { Rectangle bounds = item.getBounds(); bounds.y += bounds.height; return bounds; }
void resizeControl() { if( control != null && !control.isDisposed() ) { control.setBounds( getBounds() ); } }
public static Rectangle getBounds(Widget item){ if(item instanceof Control){ return ((Control) item).getBounds(); }else if(item instanceof ToolItem){ return ((ToolItem) item).getBounds(); }else if(item instanceof CoolItem){ return ((CoolItem) item).getBounds(); }else{ throw new ActionException("Can not get bounds from type " + item.getClass()); } } }
private void showStartupOptions(final Menu menu) { Rectangle rect = fStartupItem.getBounds(); Point pt = new Point(rect.x, rect.y + rect.height); pt = ftoolBar.toDisplay(pt); menu.setLocation(pt.x, pt.y); menu.setVisible(true); }
@Override public void handleEvent( Event event ) { ToolItem item = ( ToolItem )event.widget; Rectangle bounds = item.getBounds(); bounds.y += bounds.height; Point point = pageSwitcher.toDisplay( bounds.x + 10, bounds.y ); pageSwitcherMenu.setLocation( point ); pageSwitcherMenu.setVisible( true ); } }
public void widgetSelected(SelectionEvent e) { Rectangle b = dropDownItem.getBounds(); Point p = dropDownItem.getParent().toDisplay( new Point(b.x, b.y + b.height)); menu.setLocation(p.x, p.y); menu.setVisible(true); }
public void widgetSelected(SelectionEvent e) { Rectangle b = dropDownItem.getBounds(); Point p = dropDownItem.getParent().toDisplay( new Point(b.x, b.y + b.height)); menu.setLocation(p.x, p.y); menu.setVisible(true); }
private void showViewMenu() { Menu menu = fMenuManager.createContextMenu(getShell()); Rectangle bounds = fToolItem.getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = fToolBar.toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); }
public void widgetSelected(SelectionEvent e) { Menu menu = browseMenu.createContextMenu(getShell()); Rectangle bounds = browseItem.getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = browseToolBar.toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); } });
@Override public void widgetSelected(SelectionEvent e) { fControl.setFocus(); Rectangle rect= dropDown.getBounds(); Point pt= dropDown.getParent().toDisplay(new Point(rect.x, rect.y)); menu.setLocation(pt.x, pt.y + rect.height); menu.setVisible(true); } });
private void showViewMenu() { Menu menu = menuManager.createContextMenu(getShell()); Rectangle bounds = toolItem.getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = toolBar.toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); }
@Override public void runWithEvent(Event event) { if (event.widget instanceof ToolItem) { ToolItem toolItem= (ToolItem) event.widget; Control control= toolItem.getParent(); Menu menu= getMenu(control); Rectangle bounds= toolItem.getBounds(); Point topLeft= new Point(bounds.x, bounds.y + bounds.height); menu.setLocation(control.toDisplay(topLeft)); menu.setVisible(true); } }
private void showViewMenu() { Menu menu = fMenuManager.createContextMenu(getShell()); Rectangle bounds = fToolItem.getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = fToolBar.toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); }
private void showViewMenu() { Menu menu = fMenuManager.createContextMenu(getShell()); Rectangle bounds = fToolItem.getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = fToolBar.toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); }
private void showViewMenu() { Menu menu = fMenuManager.createContextMenu(getShell()); Rectangle bounds = fToolItem.getBounds(); Point topLeft = new Point(bounds.x, bounds.y + bounds.height); topLeft = fToolBar.toDisplay(topLeft); menu.setLocation(topLeft.x, topLeft.y); menu.setVisible(true); }
/** Returns this corner's position on the given ToolItem in display coordinates. */ public Point getPosition(ToolItem item) { ToolBar toolbar = item.getParent(); return toolbar.getDisplay().map(toolbar, null, getPosition(item.getBounds())); }
void layoutItems() { for( int i = 0; i < itemHolder.size(); i++ ) { ToolItem item = itemHolder.getItem( i ); Rectangle ibounds = item.getBounds(); Rectangle bounds = getBounds(); boolean hasEnoughWidth = ibounds.x + ibounds.width <= bounds.width; boolean hasEnoughHeight = ibounds.y + ibounds.height <= bounds.height; item.setVisible( hasEnoughWidth && hasEnoughHeight ); item.resizeControl(); } }