Search in sources :

Example 56 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class TMX2TXTConverterDialog method createMenu.

private void createMenu(Composite tparent) {
    Menu menuBar = new Menu(getShell(), SWT.BAR);
    getShell().setMenuBar(menuBar);
    getShell().pack();
    Rectangle screenSize = Display.getDefault().getClientArea();
    Rectangle frameSize = getShell().getBounds();
    getShell().setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    // 文件菜单
    Menu fileMenu = new Menu(menuBar);
    MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE);
    fileItem.setText(Messages.getString("dialog.TMX2TXTConverterDialog.fileMenu"));
    fileItem.setMenu(fileMenu);
    MenuItem quitItem = new MenuItem(fileMenu, SWT.PUSH);
    quitItem.setText(Messages.getString("dialog.TMX2TXTConverterDialog.quitItem"));
    quitItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            close();
        }
    });
    // 帮助菜单
    Menu helpMenu = new Menu(menuBar);
    MenuItem helpItem = new MenuItem(menuBar, SWT.CASCADE);
    helpItem.setText(Messages.getString("dialog.TMX2TXTConverterDialog.helpMenu"));
    helpItem.setMenu(helpMenu);
    MenuItem aboutItem = new MenuItem(helpMenu, SWT.PUSH);
    aboutItem.setText(Messages.getString("dialog.TMX2TXTConverterDialog.aboutItem"));
    String aboutPath = PluginUtil.getAbsolutePath(PluginConstants.LOGO_TMX2TXTCONVERTER_MENU_PATH);
    aboutItem.setImage(new Image(Display.getDefault(), aboutPath));
    aboutItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            AboutDialog dialog = new AboutDialog(getShell(), Messages.getString("dialog.TMX2TXTConverterDialog.aboutItemName"), imagePath, Messages.getString("dialog.TMX2TXTConverterDialog.version"));
            dialog.open();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) Image(org.eclipse.swt.graphics.Image) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 57 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class TMXValidatorDialog method createMenu.

private void createMenu(Composite tparent) {
    Menu menuBar = new Menu(getShell(), SWT.BAR);
    getShell().setMenuBar(menuBar);
    getShell().pack();
    Rectangle screenSize = Display.getDefault().getClientArea();
    Rectangle frameSize = getShell().getBounds();
    getShell().setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    // 文件菜单
    Menu fileMenu = new Menu(menuBar);
    MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE);
    fileItem.setText(Messages.getString("dialog.TMXValidatorDialog.fileMenu"));
    fileItem.setMenu(fileMenu);
    MenuItem openFileItem = new MenuItem(fileMenu, SWT.PUSH);
    openFileItem.setText(Messages.getString("dialog.TMXValidatorDialog.openFileItem"));
    openFileItem.setImage(new Image(Display.getDefault(), openFilePath));
    openFileItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            openFile();
        }
    });
    MenuItem clearCharItem = new MenuItem(fileMenu, SWT.PUSH);
    clearCharItem.setText(Messages.getString("dialog.TMXValidatorDialog.clearCharItem"));
    clearCharItem.setImage(new Image(Display.getDefault(), clearCharPath));
    clearCharItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            cleanCharacters();
        }
    });
    new MenuItem(fileMenu, SWT.SEPARATOR);
    MenuItem quitItem = new MenuItem(fileMenu, SWT.PUSH);
    quitItem.setText(Messages.getString("dialog.TMXValidatorDialog.quitItem"));
    quitItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            close();
        }
    });
    // 帮助菜单
    Menu helpMenu = new Menu(menuBar);
    MenuItem helpItem = new MenuItem(menuBar, SWT.CASCADE);
    helpItem.setText(Messages.getString("dialog.TMXValidatorDialog.helpMenu"));
    helpItem.setMenu(helpMenu);
    MenuItem aboutItem = new MenuItem(helpMenu, SWT.PUSH);
    aboutItem.setText(Messages.getString("dialog.TMXValidatorDialog.aboutItem"));
    String aboutPath = PluginUtil.getAbsolutePath(PluginConstants.LOGO_TMXVALIDATOR_MENU_PATH);
    aboutItem.setImage(new Image(Display.getDefault(), aboutPath));
    aboutItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            AboutDialog dialog = new AboutDialog(getShell(), Messages.getString("dialog.TMXValidatorDialog.aboutItemName"), imagePath, Messages.getString("dialog.TMXValidatorDialog.version"));
            dialog.open();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) Image(org.eclipse.swt.graphics.Image) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 58 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class XSLTransformationDialog method createMenu.

/**
	 * 创建菜单 ;
	 */
private void createMenu() {
    Menu menu = new Menu(getShell(), SWT.BAR);
    getShell().setMenuBar(menu);
    getShell().pack();
    Rectangle screenSize = Display.getDefault().getClientArea();
    Rectangle frameSize = getShell().getBounds();
    getShell().setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    Menu fileMenu = new Menu(menu);
    MenuItem fileItem = new MenuItem(menu, SWT.CASCADE);
    fileItem.setText(Messages.getString("dialog.XSLTransformationDialog.fileItem"));
    fileItem.setMenu(fileMenu);
    MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH);
    exitItem.setText(Messages.getString("dialog.XSLTransformationDialog.exitItem"));
    exitItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            close();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    Menu helpMenu = new Menu(menu);
    MenuItem helpItem = new MenuItem(menu, SWT.CASCADE);
    helpItem.setText(Messages.getString("dialog.XSLTransformationDialog.helpMenu"));
    helpItem.setMenu(helpMenu);
    MenuItem aboutItem = new MenuItem(helpMenu, SWT.PUSH);
    aboutItem.setText(Messages.getString("dialog.XSLTransformationDialog.aboutItem"));
    String imgPath = PluginUtil.getAbsolutePath(PluginConstants.LOGO_XSL_MENU_PATH);
    aboutItem.setImage(new Image(Display.getDefault(), imgPath));
    aboutItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            AboutDialog dialog = new AboutDialog(getShell(), Messages.getString("dialog.XSLTransformationDialog.aboutItemName"), imagePath, Messages.getString("dialog.XSLTransformationDialog.aboutItemVersion"));
            dialog.open();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) Image(org.eclipse.swt.graphics.Image) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 59 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class MatchViewPart method createPartControl.

@Override
public void createPartControl(Composite parent) {
    GridLayout parentGl = new GridLayout(1, false);
    parentGl.marginWidth = 0;
    parentGl.marginHeight = 0;
    parent.setLayout(parentGl);
    final Composite composite = new Composite(parent, SWT.NONE);
    GridLayout compositeGl = new GridLayout(1, false);
    compositeGl.marginBottom = -1;
    compositeGl.marginLeft = -1;
    compositeGl.marginRight = -1;
    compositeGl.marginTop = 0;
    compositeGl.marginWidth = 0;
    compositeGl.marginHeight = 0;
    compositeGl.verticalSpacing = 0;
    composite.setLayout(compositeGl);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    // sourceText = new StyledText(composite, SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
    // GridData sTextGd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    // Font f = JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT);
    // sourceText.setFont(f);
    // int lineH = sourceText.getLineHeight() * 3;
    // sTextGd.heightHint = lineH;
    // sTextGd.minimumHeight = lineH;
    // sourceText.setLayoutData(sTextGd);
    SashForm sashForm = new SashForm(composite, SWT.VERTICAL);
    sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    sourceText = new SegmentViewer(sashForm, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL, null);
    StyledText srcTextControl = sourceText.getTextWidget();
    srcTextControl.setLineSpacing(net.heartsome.cat.ts.ui.Constants.SEGMENT_LINE_SPACING);
    srcTextControl.setLeftMargin(net.heartsome.cat.ts.ui.Constants.SEGMENT_LEFT_MARGIN);
    srcTextControl.setRightMargin(net.heartsome.cat.ts.ui.Constants.SEGMENT_RIGHT_MARGIN);
    srcTextControl.setTopMargin(net.heartsome.cat.ts.ui.Constants.SEGMENT_TOP_MARGIN);
    srcTextControl.setBottomMargin(net.heartsome.cat.ts.ui.Constants.SEGMENT_TOP_MARGIN);
    srcTextControl.setFont(JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT));
    sourceText.setSource("");
    sourceColunmCellRenderer.setSegmentViewer(sourceText);
    GridData sTextGd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    Font f = JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT);
    srcTextControl.setFont(f);
    int lineH = srcTextControl.getLineHeight() * 2;
    sTextGd.heightHint = lineH;
    sTextGd.minimumHeight = lineH;
    srcTextControl.setLayoutData(sTextGd);
    net.heartsome.cat.ts.ui.innertag.tagstyle.TagStyleConfigurator.configure(sourceText);
    gridTable = new Grid(sashForm, SWT.BORDER | SWT.V_SCROLL);
    gridTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    gridTable.setHeaderVisible(false);
    gridTable.setAutoHeight(true);
    gridTable.setRowsResizeable(true);
    gridTable.setData("selectedBgColor", selectedBgColor);
    final GridColumn sourceCln = new GridColumn(gridTable, SWT.NONE);
    sourceColunmCellRenderer.setFont(JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT));
    sourceCln.setCellRenderer(sourceColunmCellRenderer);
    sourceCln.setText(Messages.getString("view.MatchViewPart.sourceCln"));
    sourceCln.setWordWrap(true);
    sourceCln.setAlignment(SWT.CENTER);
    sourceCln.setResizeable(false);
    final GridColumn typeCln = new GridColumn(gridTable, SWT.NONE);
    typeColumnCellRenderer.setVerticalAlignment(SWT.CENTER);
    typeCln.setCellRenderer(typeColumnCellRenderer);
    typeCln.setText(Messages.getString("view.MatchViewPart.typeCln"));
    typeCln.setWordWrap(true);
    typeCln.setAlignment(SWT.CENTER);
    typeCln.setResizeable(false);
    final GridColumn targetCln = new GridColumn(gridTable, SWT.NONE);
    targetColumnCellRenderer.setFont(JFaceResources.getFont(net.heartsome.cat.ts.ui.Constants.MATCH_VIEWER_TEXT_FONT));
    targetCln.setCellRenderer(targetColumnCellRenderer);
    targetCln.setText(Messages.getString("view.MatchViewPart.targetCln"));
    targetCln.setWordWrap(true);
    targetCln.setAlignment(SWT.CENTER);
    targetCln.setResizeable(false);
    // 设置可复制功能
    copyEnable = new GridCopyEnable(gridTable);
    sourceColunmCellRenderer.setCopyEnable(copyEnable);
    targetColumnCellRenderer.setCopyEnable(copyEnable);
    Composite statusComposite = new Composite(composite, SWT.NONE);
    GridLayout statusComptGridLayout = new GridLayout(2, false);
    statusComptGridLayout.marginBottom = -1;
    statusComptGridLayout.marginLeft = -1;
    statusComptGridLayout.marginRight = -1;
    statusComptGridLayout.marginTop = -1;
    statusComptGridLayout.marginWidth = 0;
    statusComptGridLayout.marginHeight = 0;
    statusComposite.setLayout(statusComptGridLayout);
    statusComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    tipLabel = new CLabel(statusComposite, SWT.NONE);
    tipLabel.setAlignment(SWT.LEFT);
    infoLabel = new CLabel(statusComposite, SWT.NONE);
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gd.heightHint = 20;
    infoLabel.setLayoutData(gd);
    infoLabel.setAlignment(SWT.RIGHT);
    // 设置列宽按比例4.5:1:4.5
    composite.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            Rectangle area = composite.getClientArea();
            Point preferredSize = gridTable.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            // - 2 * gridTable.getBorderWidth();
            int width = area.width;
            if (preferredSize.y > area.height + gridTable.getHeaderHeight()) {
                Point vBarSize = gridTable.getVerticalBar().getSize();
                width -= vBarSize.x;
            }
            gridTable.setSize(area.width, area.height);
            width = width - 42;
            sourceCln.setWidth((int) (width * 0.5));
            typeCln.setWidth(42);
            targetCln.setWidth((int) (width * 0.5));
        }
    });
    gridTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            StyledText text = sourceText.getTextWidget();
            text.setText(text.getText());
            updateActionState();
            GridItem[] selItems = gridTable.getSelection();
            if (selItems.length != 1) {
                return;
            }
            GridItem item = selItems[0];
            setMatchMessage(infoLabelImage, item.getData("info").toString(), item.getData("infoTooltip").toString());
            composite.layout();
        }
    });
    gridTable.addListener(SWT.MouseDoubleClick, new Listener() {

        public void handleEvent(Event event) {
            menuMgr.acceptMatchAction.run();
        }
    });
    createActions();
    sashForm.setWeights(new int[] { 3, 8 });
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) SegmentViewer(net.heartsome.cat.ts.ui.innertag.SegmentViewer) StyledText(org.eclipse.swt.custom.StyledText) ISelectionListener(org.eclipse.ui.ISelectionListener) Listener(org.eclipse.swt.widgets.Listener) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) Composite(org.eclipse.swt.widgets.Composite) ControlAdapter(org.eclipse.swt.events.ControlAdapter) Grid(org.eclipse.nebula.widgets.grid.Grid) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) Point(org.eclipse.swt.graphics.Point) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridItem(org.eclipse.nebula.widgets.grid.GridItem) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) GridCopyEnable(net.heartsome.cat.ts.ui.grid.GridCopyEnable) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 60 with Rectangle

use of org.eclipse.swt.graphics.Rectangle in project translationstudio8 by heartsome.

the class CellRenderer method overCheck.

private boolean overCheck(GridItem item, Point point) {
    if (isCenteredCheckBoxOnly(item)) {
        point = new Point(point.x, point.y);
        point.x -= getBounds().x;
        point.y -= getBounds().y;
        Rectangle checkBounds = new Rectangle(0, 0, 0, 0);
        checkBounds.x = (getBounds().width - checkRenderer.getBounds().width) / 2;
        checkBounds.y = ((getBounds().height - checkRenderer.getBounds().height) / 2);
        checkBounds.width = checkRenderer.getBounds().width;
        checkBounds.height = checkRenderer.getBounds().height;
        return checkBounds.contains(point);
    } else {
        point = new Point(point.x, point.y);
        point.x -= getBounds().x;
        point.y -= getBounds().y;
        int x = leftMargin;
        if (isTree()) {
            x += getToggleIndent(item);
            x += toggleRenderer.getSize().x + insideMargin;
        }
        if (point.x >= x && point.x < (x + checkRenderer.getSize().x)) {
            int yStart = ((getBounds().height - checkRenderer.getBounds().height) / 2);
            if (point.y >= yStart && point.y < yStart + checkRenderer.getSize().y) {
                return true;
            }
        }
        return false;
    }
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Aggregations

Rectangle (org.eclipse.swt.graphics.Rectangle)651 Point (org.eclipse.swt.graphics.Point)370 Image (org.eclipse.swt.graphics.Image)114 GC (org.eclipse.swt.graphics.GC)104 Test (org.junit.Test)80 Color (org.eclipse.swt.graphics.Color)61 Shell (org.eclipse.swt.widgets.Shell)54 Composite (org.eclipse.swt.widgets.Composite)53 SelectionEvent (org.eclipse.swt.events.SelectionEvent)51 TableItem (org.eclipse.swt.widgets.TableItem)47 GridLayout (org.eclipse.swt.layout.GridLayout)44 Display (org.eclipse.swt.widgets.Display)44 Button (org.eclipse.swt.widgets.Button)42 Menu (org.eclipse.swt.widgets.Menu)40 GridData (org.eclipse.swt.layout.GridData)38 Label (org.eclipse.swt.widgets.Label)37 SWT (org.eclipse.swt.SWT)34 Event (org.eclipse.swt.widgets.Event)34 Font (org.eclipse.swt.graphics.Font)30 Listener (org.eclipse.swt.widgets.Listener)29