protected void open(final Decorations parent, final SelectionEvent trigger) { // final boolean asMenu = trigger.detail == SWT.ARROW; final boolean init = mainMenu == null; // if (!asMenu) { // openView(); // } else { final ToolItem target = (ToolItem) trigger.widget; final ToolBar toolBar = target.getParent(); if (init) { mainMenu = new Menu(parent, SWT.POP_UP); // AD: again. In the first call, the mainMenu was perhaps not // yet initialized fillMenu(); // mainMenu.addMenuListener(tooltipListener); } final Point point = toolBar.toDisplay(new Point(trigger.x, trigger.y)); mainMenu.setLocation(point.x, point.y); mainMenu.setVisible(true); // } }
/** * Create header context menu which has the action to modify columns * * @param composite * @param defaultContextMenu * @return */ private Menu createHCM_0_Menu(final Composite composite, final Menu defaultContextMenu) { final Decorations shell = composite.getShell(); final Menu headerContextMenu = new Menu(shell, SWT.POP_UP); /* * IMPORTANT: Dispose the menus (only the current menu, when menu is set with setMenu() it * will be disposed automatically) */ composite.addListener(SWT.Dispose, new Listener() { @Override public void handleEvent(final Event event) { headerContextMenu.dispose(); if (defaultContextMenu != null) { defaultContextMenu.dispose(); } } }); return headerContextMenu; }
/** * Creates the trim widgets around the content area. * * @param shell * the shell * @since 3.0 */ protected void createTrimWidgets(Shell shell) { if (menuBarManager != null) { shell.setMenuBar(menuBarManager.createMenuBar((Decorations) shell)); menuBarManager.updateAll(true); } if (showTopSeperator()) { seperator1 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); } // will create either a cool bar or a tool bar createToolBarControl(shell); createCoolBarControl(shell); createStatusLine(shell); }
@Override protected void open(final Decorations parent, final SelectionEvent trigger) { if (colorMenu == null) { colorMenu = new GamaColorMenu(mainMenu); } final ToolItem target = (ToolItem) trigger.widget; final ToolBar toolBar = target.getParent(); colorMenu.open(toolBar, trigger, colorInserter, runnable); }
protected Menu createPopupMenu(Decorations parent) { Menu menu = new Menu(parent.getShell(), SWT.POP_UP); MenuItem actionItem = new MenuItem(menu, SWT.PUSH); actionItem.setText("Set to default"); actionItem.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { if (! isDefault) { setDefault(true); notifyChangeListener(); } } }); return menu; }
private static Swt_popup_grp new_grp(String key, Decorations owner_win) { Swt_popup_grp rv = new Swt_popup_grp(key); rv.owner_win = owner_win; rv.menu = new Menu(owner_win, SWT.DROP_DOWN); return rv; }
public TrpMenuBar(Decorations parent) { init(parent); }
private void init(Decorations parent) { menuBar = new Menu(parent, SWT.POP_UP); // DOCUMENTS MENU: docsMenu = createCascadeMenu(menuBar, null, "&Document"); openLocalDocItem = createItem(docsMenu.m, SWT.NONE, Images.FOLDER, "Open local document..."); uploadItem = createItem(docsMenu.m, SWT.NONE, Images.FOLDER_IMPORT, "Import document(s)..."); exportItem = createItem(docsMenu.m, SWT.NONE, Images.FOLDER_GO, "Export document..."); syncXmlItem = createItem(docsMenu.m, SWT.NONE, Images.getOrLoad("/icons/database_refresh.png"), "Sync local transcriptions with doc..."); createThumbsMenuItem = createItem(docsMenu.m, SWT.CHECK, null, "Create thumbs when opening local folder"); // FILE MENU: fileMenu = createCascadeMenu(menuBar, null, "&Page"); saveTranscriptionMenuItem = createItem(fileMenu.m, SWT.NONE, Images.DISK, "Save"); saveTranscriptionToNewFileMenuItem = createItem(fileMenu.m, SWT.NONE, Images.getOrLoad("/icons/page_save.png"), "Save transcription to new file"); replaceImageItem = createItem(fileMenu.m, SWT.NONE, Images.IMAGE_EDIT, "Replace image of current page on server..."); openLocalPageFileItem = createItem(fileMenu.m, 0, null, "Open local page file for current page..."); deletePageMenuItem = createItem(fileMenu.m, 0, null, "Delete current page from server"); addPageMenuItem = createItem(fileMenu.m, 0, null, "Add page to document on server..."); syncWordsWithLinesMenuItem = createItem(fileMenu.m, SWT.NONE, null, "Sync word transcription with text in lines"); collMenu = createCascadeMenu(menuBar, null, "&Collections"); manageCollectionsItem = createItem(collMenu.m, SWT.NONE, null, "Manage..."); userActivityItem = createItem(collMenu.m, SWT.NONE, null, "Show user activity..."); // VIEW menu viewMenu = createCascadeMenu(menuBar, null, "&View"); viewSettingsMenuItem = createItem(viewMenu.m, SWT.PUSH, Images.getOrLoad("/icons/palette.png"), "Change viewing settings"); // SEGMENTATION SUB-MENU: segmentationMenu = createCascadeMenu(viewMenu.m, null, "Segmentation"); showAllMenuItem = createItem(segmentationMenu.m, SWT.PUSH, null, "Show all"); hideAllMenuItem = createItem(segmentationMenu.m, SWT.PUSH, null, "Hide all"); showRegionsMenuItem = createItem(segmentationMenu.m, SWT.CHECK, null, "Show regions"); showLinesMenuItem = createItem(segmentationMenu.m, SWT.CHECK, null, "Show lines"); showBaselinesMenuItem = createItem(segmentationMenu.m, SWT.CHECK, null, "Show baselines"); showWordsMenuItem = createItem(segmentationMenu.m, SWT.CHECK, null, "Show words"); showPrintspaceMenuItem = createItem(segmentationMenu.m, SWT.CHECK, null, "Show printspace"); tipsOfTheDayMenuItem = createItem(viewMenu.m, SWT.PUSH, null, "Show tips of the day..."); // HELP MENU: // mntmhelp = new MenuItem(menuBar, SWT.CASCADE); // mntmhelp.setText("&Help"); // // helpMenu = new Menu(mntmhelp); // mntmhelp.setMenu(helpMenu); proxySettingsMenuItem = createItem(menuBar, SWT.PUSH, Images.getOrLoad("/icons/server_connect.png"), "Proxy settings..."); autoSaveSettingsMenuItem = createItem(menuBar, SWT.NONE, Images.DISK, "Autosave settings"); if (false) { languageMenu = createCascadeMenu(menuBar, null, "Language (todo)"); for (Locale l : Msgs.LOCALES) { MenuItem li = new MenuItem(languageMenu.m, SWT.RADIO); li.setText(l.getDisplayName()); li.setData(l); if (l.equals(TrpConfig.getTrpSettings().getLocale())) li.setSelection(true); } } updateMenuItem = createItem(menuBar, SWT.NONE, Images.getOrLoad("/icons/update_wiz.gif"), "Check for updates"); installMenuItem = createItem(menuBar, SWT.NONE, Images.getOrLoad("/icons/install_wiz.gif"), "Install a specific version..."); bugReportItem = createItem(menuBar, SWT.NONE, Images.BUG, "Send a bug report or feature request"); aboutMenuIItem = createItem(menuBar, SWT.NONE, Images.getOrLoad("/icons/information.png"), "About"); exitItem = createItem(menuBar, SWT.NONE, Images.getOrLoad("/icons/door_out.png"), "Exit"); }
/** * set context menu depending on the position of the mouse * * @param tree * @param defaultContextMenu * can be <code>null</code> */ public void createHeaderContextMenu(final Tree tree, final Menu defaultContextMenu) { // remove old listener if (_treeMenuDetectListener != null) { tree.removeListener(SWT.MenuDetect, _treeMenuDetectListener); } final Menu headerContextMenu = createHCM_0_Menu(tree, defaultContextMenu); // add the context menu to the tree viewer _treeMenuDetectListener = new Listener() { @Override public void handleEvent(final Event event) { final Decorations shell = tree.getShell(); final Display display = shell.getDisplay(); final Point mousePosition = display.map(null, tree, new Point(event.x, event.y)); final Rectangle clientArea = tree.getClientArea(); final int headerHeight = tree.getHeaderHeight(); final int headerBottom = clientArea.y + headerHeight; final boolean isTreeHeaderHit = clientArea.y <= mousePosition.y && mousePosition.y < headerBottom; _headerColumn = getHeaderColumn(tree, mousePosition, isTreeHeaderHit); final Menu contextMenu = getContextMenu(isTreeHeaderHit, headerContextMenu, defaultContextMenu); tree.setMenu(contextMenu); /* * Set context menu position to the right border of the column */ if (_headerColumn != null) { int posX = _headerColumn.columnRightBorder; int xOffset = 0; final ScrollBar hBar = tree.getHorizontalBar(); if (hBar != null) { xOffset = hBar.getSelection(); } /* * It is possible that the context menu is outside of the tree, this occures * when the column is very wide and horizonal scrolled. */ if (posX - xOffset > clientArea.width) { posX = xOffset + clientArea.width; } final Point displayPosition = tree.toDisplay(posX, headerBottom); event.x = displayPosition.x - 1; event.y = displayPosition.y - 2; } } }; tree.addListener(SWT.MenuDetect, _treeMenuDetectListener); }
public static Rectangle computeTrim( Decorations decorations, Rectangle bounds ) { return decorations.computeTrim( bounds.x, bounds.y, bounds.width, bounds.height ); }
/** * Creates and returns an SWT menu bar control for this menu, for use in the * given <code>Decorations</code>, and installs all registered * contributions. Does not create a new control if one already exists. * * @param parent * the parent decorations * @return the menu control * @since 2.1 */ public Menu createMenuBar(Decorations parent) { if (!menuExist()) { menu = new Menu(parent, SWT.BAR); menu.setData(MANAGER_KEY, this); update(false); } return menu; }
/** * Creates and returns an SWT menu bar control for this menu, for use in the * given <code>Decorations</code>, and installs all registered contributions. * Does not create a new control if one already exists. * * @param parent * the parent decorations * @return the menu control * @since 2.1 */ public Menu createMenuBar(Decorations parent) { if (! menuExist()) { menu = new Menu(parent, SWT.BAR); menu.setData(MANAGER_KEY, this); update(false); } return menu; }
/** * Creates and returns an SWT menu bar control for this menu, * for use in the given <code>Decorations</code>, and installs all registered * contributions. Does not create a new control if one already exists. * * @param parent the parent decorations * @return the menu control * @since 2.1 */ public Menu createMenuBar(Decorations parent) { if (!menuExist()) { menu = new Menu(parent, SWT.BAR); update(false); } return menu; }
/** * Creates and returns an SWT menu bar control for this menu, for use in the * given <code>Shell</code>, and installs all registered contributions. Does * not create a new control if one already exists. This implementation * simply calls the <code>createMenuBar(Decorations)</code> method * * @param parent * the parent decorations * @return the menu control * @deprecated use <code>createMenuBar(Decorations)</code> instead. */ public Menu createMenuBar(Shell parent) { return createMenuBar((Decorations) parent); }
/** * Creates and returns an SWT menu bar control for this menu, for use in the * given <code>Shell</code>, and installs all registered contributions. Does not * create a new control if one already exists. This implementation simply calls * the <code>createMenuBar(Decorations)</code> method * * @param parent the parent decorations * @return the menu control * @deprecated use <code>createMenuBar(Decorations)</code> instead. */ public Menu createMenuBar(Shell parent) { return createMenuBar((Decorations) parent); }