本文整理汇总了Java中org.eclipse.swt.widgets.ToolItem.getBounds方法的典型用法代码示例。如果您正苦于以下问题:Java ToolItem.getBounds方法的具体用法?Java ToolItem.getBounds怎么用?Java ToolItem.getBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.ToolItem
的用法示例。
在下文中一共展示了ToolItem.getBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: widgetSelected
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void widgetSelected(final SelectionEvent event) {
if (event.detail == SWT.ARROW) {
/*
* Show the menu.
*/
final ToolItem item = (ToolItem) event.widget;
final Rectangle itemRectangle = item.getBounds();
final Point point = item.getParent().toDisplay(new Point(itemRectangle.x, itemRectangle.y));
menu.setLocation(point.x, point.y + itemRectangle.height);
menu.setVisible(true);
} else {
/*
* Select the menu item
*/
if (lastSelectedMenuItem != null) {
final MenuItemSelectedHandler handler =
(MenuItemSelectedHandler) lastSelectedMenuItem.getData(MENU_ITEM_SELECTED_HANDLER_WIDGET_DATA_KEY);
handler.onMenuItemSelected(lastSelectedMenuItem);
}
}
}
示例2: runWithEvent
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
@Override
public void runWithEvent(final Event event) {
if (showMenuForDefaultAction) {
final ToolItem item = (ToolItem) event.widget;
final Rectangle itemRectangle = item.getBounds();
final Point point = item.getParent().toDisplay(new Point(itemRectangle.x, itemRectangle.y));
final Menu menu = getSubActionMenu(item.getParent());
menu.setLocation(point.x, point.y + itemRectangle.height);
menu.setVisible(true);
} else {
final IAction defaultSubAction = getDefaultSubAction();
if (defaultSubAction != null && defaultSubAction.isEnabled()) {
defaultSubAction.runWithEvent(event);
}
}
}
示例3: createMenu
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
public void createMenu(TGToolBar toolBar, ToolItem item) {
Caret caret = TuxGuitar.getInstance().getTablatureEditor().getTablature().getCaret();
int selection = ((caret.getSelectedNote() != null) ? caret.getSelectedNote().getVelocity() : caret.getVelocity());
boolean running = TuxGuitar.getInstance().getPlayer().isRunning();
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
Menu menu = new Menu(item.getParent().getShell());
this.createMenuItem(toolBar, menu, TGVelocities.PIANO_PIANISSIMO, selection, running);
this.createMenuItem(toolBar, menu, TGVelocities.PIANISSIMO, selection, running);
this.createMenuItem(toolBar, menu, TGVelocities.PIANO, selection, running);
this.createMenuItem(toolBar, menu, TGVelocities.MEZZO_PIANO, selection, running);
this.createMenuItem(toolBar, menu, TGVelocities.MEZZO_FORTE, selection, running);
this.createMenuItem(toolBar, menu, TGVelocities.FORTE, selection, running);
this.createMenuItem(toolBar, menu, TGVelocities.FORTISSIMO, selection, running);
this.createMenuItem(toolBar, menu, TGVelocities.FORTE_FORTISSIMO, selection, running);
menu.setLocation(pt.x, pt.y + rect.height);
menu.setVisible(true);
}
示例4: createDurationMenu
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
public void createDurationMenu(TGToolBar toolBar, ToolItem item) {
TGDuration duration = TablatureEditor.getInstance(toolBar.getContext()).getTablature().getCaret().getDuration();
boolean running = TuxGuitar.getInstance().getPlayer().isRunning();
Menu menu = new Menu(item.getParent().getShell());
this.createDurationMenuItem(toolBar, menu, TGDuration.WHOLE, duration.getValue(), running);
this.createDurationMenuItem(toolBar, menu, TGDuration.HALF, duration.getValue(), running);
this.createDurationMenuItem(toolBar, menu, TGDuration.QUARTER, duration.getValue(), running);
this.createDurationMenuItem(toolBar, menu, TGDuration.EIGHTH, duration.getValue(), running);
this.createDurationMenuItem(toolBar, menu, TGDuration.SIXTEENTH, duration.getValue(), running);
this.createDurationMenuItem(toolBar, menu, TGDuration.THIRTY_SECOND, duration.getValue(), running);
this.createDurationMenuItem(toolBar, menu, TGDuration.SIXTY_FOURTH, duration.getValue(), running);
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
menu.setLocation(pt.x, pt.y + rect.height);
menu.setVisible(true);
}
示例5: createDivisionTypeMenu
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
private void createDivisionTypeMenu(TGToolBar toolBar, ToolItem item) {
TGDuration duration = TablatureEditor.getInstance(toolBar.getContext()).getTablature().getCaret().getDuration();
Menu menu = new Menu(item.getParent().getShell());
for( int i = 0 ; i < TGDivisionType.ALTERED_DIVISION_TYPES.length ; i ++ ){
TGDivisionType divisionType = TGDivisionType.ALTERED_DIVISION_TYPES[i];
MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
menuItem.setText(toolBar.toCheckString(Integer.toString(TGDivisionType.ALTERED_DIVISION_TYPES[i].getEnters()), (divisionType.isEqual(duration.getDivision()))));
menuItem.addSelectionListener(this.createDivisionTypeAction(toolBar, divisionType));
}
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
menu.setLocation(pt.x, pt.y + rect.height);
menu.setVisible(true);
}
示例6: createMenu
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
public void createMenu(TGToolBar toolBar, ToolItem item) {
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
Menu menu = new Menu(item.getParent().getShell());
TGCustomChordManager customChordManager = TuxGuitar.getInstance().getCustomChordManager();
for(int i = 0; i < customChordManager.countChords(); i++){
TGChord chord = TuxGuitar.getInstance().getCustomChordManager().getChord(i);
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(chord.getName());
menuItem.addSelectionListener(this.createInsertChordAction(toolBar, chord));
}
menu.setLocation(pt.x, pt.y + rect.height);
menu.setVisible(true);
}
示例7: runWithEvent
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
@Override
public void runWithEvent(final Event event) {
if (event.widget instanceof ToolItem) {
final ToolItem toolItem = (ToolItem) event.widget;
final Control control = toolItem.getParent();
@SuppressWarnings("hiding")
final Menu menu = getMenu(control);
final Rectangle bounds = toolItem.getBounds();
final Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
menu.setLocation(control.toDisplay(topLeft));
menu.setVisible(true);
}
}
示例8: runWithEvent
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
@Override
public void runWithEvent(Event event) {
if (event.widget instanceof ToolItem) {
final ToolItem toolItem = (ToolItem) event.widget;
final Control control = toolItem.getParent();
final Menu menu = getMenuCreator().getMenu(control);
final Rectangle bounds = toolItem.getBounds();
final Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
menu.setLocation(control.toDisplay(topLeft));
menu.setVisible(true);
}
}
示例9: widgetSelected
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
/**
* Handle selection events.
*/
public void widgetSelected(SelectionEvent event) {
/**
* A selection event will be fired when a drop down tool
* item is selected in the main area and in the drop
* down arrow. Examine the event detail to determine
* where the widget was selected.
*/
if (event.detail == SWT.ARROW) {
/*
* The drop down arrow was selected.
*/
if (visible) {
// Hide the menu to give the Arrow the appearance of being a toggle button.
setMenuVisible(false);
} else {
// Position the menu below and vertically aligned with the the drop down tool button.
final ToolItem toolItem = (ToolItem) event.widget;
final ToolBar toolBar = toolItem.getParent();
Rectangle toolItemBounds = toolItem.getBounds();
Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y));
menu.setLocation(point.x, point.y + toolItemBounds.height);
setMenuVisible(true);
}
} else {
/*
* Main area of drop down tool item selected.
* An application would invoke the code to perform the action for the tool item.
*/
}
}
示例10: execute
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
// Sanity check.
if (null == event) {
return null;
}
// Class check.
if (!(event.getTrigger() instanceof Event)) {
return null;
}
final Event eventWidget = (Event) event.getTrigger();
// Makes sure event came from a ToolItem.
if (!(eventWidget.widget instanceof ToolItem)) {
return null;
}
final ToolItem toolItem = (ToolItem) eventWidget.widget;
// Creates fake selection event.
final Event newEvent = new Event();
newEvent.button = 1;
newEvent.widget = toolItem;
newEvent.detail = SWT.ARROW;
newEvent.x = toolItem.getBounds().x;
newEvent.y = toolItem.getBounds().y + toolItem.getBounds().height;
// Dispatches the event.
toolItem.notifyListeners(SWT.Selection, newEvent);
return null;
}
示例11: createMenu
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
public void createMenu(TGToolBar toolBar, ToolItem item) {
TGLayout layout = toolBar.getTablature().getViewLayout();
int style = layout.getStyle();
Menu menu = new Menu(item.getParent().getShell());
MenuItem pageLayout = new MenuItem(menu, SWT.PUSH);
pageLayout.addSelectionListener(toolBar.createActionProcessor(TGSetPageLayoutAction.NAME));
pageLayout.setText(toolBar.getText("view.layout.page", (layout instanceof TGLayoutVertical)));
pageLayout.setImage(toolBar.getIconManager().getLayoutPage());
MenuItem linearLayout = new MenuItem(menu, SWT.PUSH);
linearLayout.addSelectionListener(toolBar.createActionProcessor(TGSetLinearLayoutAction.NAME));
linearLayout.setText(toolBar.getText("view.layout.linear", (layout instanceof TGLayoutHorizontal)));
linearLayout.setImage(toolBar.getIconManager().getLayoutLinear());
MenuItem multitrack = new MenuItem(menu, SWT.PUSH);
multitrack.addSelectionListener(toolBar.createActionProcessor(TGSetMultitrackViewAction.NAME));
multitrack.setText(toolBar.getText("view.layout.multitrack", ( (style & TGLayout.DISPLAY_MULTITRACK) != 0 )));
multitrack.setImage(toolBar.getIconManager().getLayoutMultitrack());
MenuItem scoreEnabled = new MenuItem(menu, SWT.PUSH);
scoreEnabled.addSelectionListener(toolBar.createActionProcessor(TGSetScoreEnabledAction.NAME));
scoreEnabled.setText(toolBar.getText("view.layout.score-enabled", ( (style & TGLayout.DISPLAY_SCORE) != 0 )));
scoreEnabled.setImage(toolBar.getIconManager().getLayoutScore());
MenuItem compact = new MenuItem(menu, SWT.PUSH);
compact.addSelectionListener(toolBar.createActionProcessor(TGSetCompactViewAction.NAME));
compact.setText(toolBar.getText("view.layout.compact", ( (style & TGLayout.DISPLAY_COMPACT) != 0 )));
compact.setImage(toolBar.getIconManager().getLayoutCompact());
compact.setEnabled((style & TGLayout.DISPLAY_MULTITRACK) == 0 || toolBar.getSong().countTracks() == 1);
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
menu.setLocation(pt.x, pt.y + rect.height);
menu.setVisible(true);
}
示例12: createMenu
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
public void createMenu(TGToolBar toolBar, ToolItem item) {
Menu menu = new Menu(item.getParent().getShell());
//--FRETBOARD--
MenuItem showFretBoard = new MenuItem(menu, SWT.PUSH);
showFretBoard.addSelectionListener(toolBar.createActionProcessor(TGToggleFretBoardEditorAction.NAME));
showFretBoard.setImage(toolBar.getIconManager().getFretboard());
showFretBoard.setText(toolBar.getText("view.show-fretboard", TGFretBoardEditor.getInstance(toolBar.getContext()).isVisible()));
//--INSTRUMENTS--
MenuItem showInstruments = new MenuItem(menu, SWT.PUSH);
showInstruments.addSelectionListener(toolBar.createActionProcessor(TGToggleChannelsDialogAction.NAME));
showInstruments.setImage(toolBar.getIconManager().getInstruments());
showInstruments.setText(toolBar.getText("view.show-instruments", (!TGChannelManagerDialog.getInstance(toolBar.getContext()).isDisposed())));
//--TRANSPORT--
MenuItem showTransport = new MenuItem(menu, SWT.PUSH);
showTransport.addSelectionListener(toolBar.createActionProcessor(TGToggleTransportDialogAction.NAME));
showTransport.setImage(toolBar.getIconManager().getTransport());
showTransport.setText(toolBar.getText("view.show-transport", (!TGTransportDialog.getInstance(toolBar.getContext()).isDisposed())));
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
menu.setLocation(pt.x, pt.y + rect.height);
menu.setVisible(true);
}
示例13: widgetSelected
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
public void widgetSelected(SelectionEvent event) {
if (event.detail == SWT.ARROW && this.subMenuItems != null && this.subMenuItems.length > 0) {
ToolItem item = (ToolItem) event.widget;
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
this.menu.setLocation(pt.x, pt.y + rect.height);
this.menu.setVisible(true);
}else{
new TGActionProcessor(TuxGuitar.getInstance().getContext(), TGOpenChordDialogAction.NAME).process();
}
}
示例14: widgetSelected
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
@Override
public void widgetSelected(SelectionEvent event) {
if (event.detail == SWT.ARROW) {
ToolItem item = (ToolItem) event.widget;
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
menu.setLocation(pt.x, pt.y + rect.height);
menu.setVisible(true);
} else {
System.out.println(dropdown.getText() + " Pressed");
}
}
示例15: createMenu
import org.eclipse.swt.widgets.ToolItem; //导入方法依赖的package包/类
public void createMenu(TGToolBar toolBar, ToolItem item) {
TablatureEditor editor = TablatureEditor.getInstance(toolBar.getContext());
EditorKit editorKit = editor.getTablature().getEditorKit();
boolean running = TuxGuitar.getInstance().getPlayer().isRunning();
Menu menu = new Menu(item.getParent().getShell());
MenuItem voice1 = new MenuItem(menu, SWT.PUSH);
voice1.addSelectionListener(toolBar.createActionProcessor(TGSetVoice1Action.NAME));
voice1.setText(toolBar.getText("edit.voice-1", (editor.getTablature().getCaret().getVoice() == 0)));
voice1.setImage(toolBar.getIconManager().getEditVoice1());
voice1.setEnabled(!running);
MenuItem voice2 = new MenuItem(menu, SWT.PUSH);
voice2.addSelectionListener(toolBar.createActionProcessor(TGSetVoice2Action.NAME));
voice2.setText(toolBar.getText("edit.voice-2", (editor.getTablature().getCaret().getVoice() == 1)));
voice2.setImage(toolBar.getIconManager().getEditVoice2());
voice2.setEnabled(!running);
new MenuItem(menu, SWT.SEPARATOR);
MenuItem modeSelection = new MenuItem(menu, SWT.PUSH);
modeSelection.addSelectionListener(toolBar.createActionProcessor(TGSetMouseModeSelectionAction.NAME));
modeSelection.setText(toolBar.getText("edit.mouse-mode-selection", (editorKit.getMouseMode() == EditorKit.MOUSE_MODE_SELECTION)));
modeSelection.setImage(toolBar.getIconManager().getEditModeSelection());
modeSelection.setEnabled(!running);
MenuItem modeEdition = new MenuItem(menu, SWT.PUSH);
modeEdition.addSelectionListener(toolBar.createActionProcessor(TGSetMouseModeEditionAction.NAME));
modeEdition.setText(toolBar.getText("edit.mouse-mode-edition", (editorKit.getMouseMode() == EditorKit.MOUSE_MODE_EDITION)));
modeEdition.setImage(toolBar.getIconManager().getEditModeEdition());
modeEdition.setEnabled(!running);
MenuItem notNaturalKey = new MenuItem(menu, SWT.PUSH);
notNaturalKey.addSelectionListener(toolBar.createActionProcessor(TGSetNaturalKeyAction.NAME));
notNaturalKey.setText(toolBar.getText("edit.not-natural-key", (!editorKit.isNatural())));
notNaturalKey.setImage(toolBar.getIconManager().getEditModeEditionNotNatural());
notNaturalKey.setEnabled(!running && editorKit.getMouseMode() == EditorKit.MOUSE_MODE_EDITION);
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
menu.setLocation(pt.x, pt.y + rect.height);
menu.setVisible(true);
}