Search in sources :

Example 21 with CoolBar

use of org.eclipse.swt.widgets.CoolBar in project eclipse.platform.swt by eclipse.

the class Tab method refreshLayoutComposite.

/**
 * Refreshes the composite and draws all controls
 * in the layout example.
 */
void refreshLayoutComposite() {
    /* Remove children that are already laid out */
    children = layoutComposite.getChildren();
    for (Control child : children) {
        child.dispose();
    }
    /* Add all children listed in the table */
    TableItem[] items = table.getItems();
    children = new Control[items.length];
    String[] itemValues = new String[] { LayoutExample.getResourceString("Item", new String[] { "1" }), LayoutExample.getResourceString("Item", new String[] { "2" }), LayoutExample.getResourceString("Item", new String[] { "3" }) };
    for (int i = 0; i < items.length; i++) {
        String control = items[i].getText(1);
        String controlName = items[i].getText(0);
        if (control.equals("Button")) {
            Button button = new Button(layoutComposite, SWT.PUSH);
            button.setText(controlName);
            children[i] = button;
        } else if (control.equals("Canvas")) {
            Canvas canvas = new Canvas(layoutComposite, SWT.BORDER);
            children[i] = canvas;
        } else if (control.equals("Combo")) {
            Combo combo = new Combo(layoutComposite, SWT.NONE);
            combo.setItems(itemValues);
            combo.setText(controlName);
            children[i] = combo;
        } else if (control.equals("Composite")) {
            Composite composite = new Composite(layoutComposite, SWT.BORDER);
            children[i] = composite;
        } else if (control.equals("CoolBar")) {
            CoolBar coolBar = new CoolBar(layoutComposite, SWT.NONE);
            ToolBar toolBar = new ToolBar(coolBar, SWT.BORDER);
            ToolItem item = new ToolItem(toolBar, 0);
            item.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
            item = new ToolItem(toolBar, 0);
            item.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
            CoolItem coolItem1 = new CoolItem(coolBar, 0);
            coolItem1.setControl(toolBar);
            toolBar = new ToolBar(coolBar, SWT.BORDER);
            item = new ToolItem(toolBar, 0);
            item.setText(LayoutExample.getResourceString("Item", new String[] { "3" }));
            item = new ToolItem(toolBar, 0);
            item.setText(LayoutExample.getResourceString("Item", new String[] { "4" }));
            CoolItem coolItem2 = new CoolItem(coolBar, 0);
            coolItem2.setControl(toolBar);
            Point size = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            coolItem1.setSize(coolItem1.computeSize(size.x, size.y));
            coolItem2.setSize(coolItem2.computeSize(size.x, size.y));
            coolBar.setSize(coolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            children[i] = coolBar;
        } else if (control.equals("Group")) {
            Group group = new Group(layoutComposite, SWT.NONE);
            group.setText(controlName);
            children[i] = group;
        } else if (control.equals("Label")) {
            Label label = new Label(layoutComposite, SWT.NONE);
            label.setText(controlName);
            children[i] = label;
        } else if (control.equals("Link")) {
            Link link = new Link(layoutComposite, SWT.NONE);
            link.setText(controlName);
            children[i] = link;
        } else if (control.equals("List")) {
            org.eclipse.swt.widgets.List list = new org.eclipse.swt.widgets.List(layoutComposite, SWT.BORDER);
            list.setItems(itemValues);
            children[i] = list;
        } else if (control.equals("ProgressBar")) {
            ProgressBar progress = new ProgressBar(layoutComposite, SWT.NONE);
            progress.setSelection(50);
            children[i] = progress;
        } else if (control.equals("Scale")) {
            Scale scale = new Scale(layoutComposite, SWT.NONE);
            children[i] = scale;
        } else if (control.equals("Slider")) {
            Slider slider = new Slider(layoutComposite, SWT.NONE);
            children[i] = slider;
        } else if (control.equals("StyledText")) {
            StyledText styledText = new StyledText(layoutComposite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
            styledText.setText(controlName);
            children[i] = styledText;
        } else if (control.equals("Table")) {
            Table table = new Table(layoutComposite, SWT.BORDER);
            table.setLinesVisible(true);
            TableItem item1 = new TableItem(table, 0);
            item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
            TableItem item2 = new TableItem(table, 0);
            item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
            children[i] = table;
        } else if (control.equals("Text")) {
            Text text = new Text(layoutComposite, SWT.BORDER);
            text.setText(controlName);
            children[i] = text;
        } else if (control.equals("ToolBar")) {
            ToolBar toolBar = new ToolBar(layoutComposite, SWT.BORDER);
            ToolItem item1 = new ToolItem(toolBar, 0);
            item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
            ToolItem item2 = new ToolItem(toolBar, 0);
            item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
            children[i] = toolBar;
        } else {
            Tree tree = new Tree(layoutComposite, SWT.BORDER);
            TreeItem item1 = new TreeItem(tree, 0);
            item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
            TreeItem item2 = new TreeItem(tree, 0);
            item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
            children[i] = tree;
        }
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) Slider(org.eclipse.swt.widgets.Slider) TreeItem(org.eclipse.swt.widgets.TreeItem) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) CCombo(org.eclipse.swt.custom.CCombo) Combo(org.eclipse.swt.widgets.Combo) Control(org.eclipse.swt.widgets.Control) CoolBar(org.eclipse.swt.widgets.CoolBar) Button(org.eclipse.swt.widgets.Button) Tree(org.eclipse.swt.widgets.Tree) ArrayList(java.util.ArrayList) List(java.util.List) CoolItem(org.eclipse.swt.widgets.CoolItem) ProgressBar(org.eclipse.swt.widgets.ProgressBar) ToolItem(org.eclipse.swt.widgets.ToolItem) StyledText(org.eclipse.swt.custom.StyledText) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Canvas(org.eclipse.swt.widgets.Canvas) Scale(org.eclipse.swt.widgets.Scale) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) ToolBar(org.eclipse.swt.widgets.ToolBar) Link(org.eclipse.swt.widgets.Link)

Example 22 with CoolBar

use of org.eclipse.swt.widgets.CoolBar in project eclipse.platform.swt by eclipse.

the class TextEditor method createToolBar.

void createToolBar() {
    coolBar = new CoolBar(shell, SWT.FLAT);
    ToolBar styleToolBar = new ToolBar(coolBar, SWT.FLAT);
    boldControl = new ToolItem(styleToolBar, SWT.CHECK);
    boldControl.setImage(iBold);
    // $NON-NLS-1$
    boldControl.setToolTipText(getResourceString("Bold"));
    boldControl.addSelectionListener(widgetSelectedAdapter(event -> setStyle(BOLD)));
    italicControl = new ToolItem(styleToolBar, SWT.CHECK);
    italicControl.setImage(iItalic);
    // $NON-NLS-1$
    italicControl.setToolTipText(getResourceString("Italic"));
    italicControl.addSelectionListener(widgetSelectedAdapter(event -> setStyle(ITALIC)));
    final Menu underlineMenu = new Menu(shell, SWT.POP_UP);
    underlineSingleItem = new MenuItem(underlineMenu, SWT.RADIO);
    // $NON-NLS-1$
    underlineSingleItem.setText(getResourceString("Single_menuitem"));
    underlineSingleItem.addSelectionListener(widgetSelectedAdapter(event -> {
        if (underlineSingleItem.getSelection()) {
            setStyle(UNDERLINE_SINGLE);
        }
    }));
    underlineSingleItem.setSelection(true);
    underlineDoubleItem = new MenuItem(underlineMenu, SWT.RADIO);
    // $NON-NLS-1$
    underlineDoubleItem.setText(getResourceString("Double_menuitem"));
    underlineDoubleItem.addSelectionListener(widgetSelectedAdapter(event -> {
        if (underlineDoubleItem.getSelection()) {
            setStyle(UNDERLINE_DOUBLE);
        }
    }));
    underlineSquiggleItem = new MenuItem(underlineMenu, SWT.RADIO);
    // $NON-NLS-1$
    underlineSquiggleItem.setText(getResourceString("Squiggle_menuitem"));
    underlineSquiggleItem.addSelectionListener(widgetSelectedAdapter(event -> {
        if (underlineSquiggleItem.getSelection()) {
            setStyle(UNDERLINE_SQUIGGLE);
        }
    }));
    underlineErrorItem = new MenuItem(underlineMenu, SWT.RADIO);
    // $NON-NLS-1$
    underlineErrorItem.setText(getResourceString("Error_menuitem"));
    underlineErrorItem.addSelectionListener(widgetSelectedAdapter(event -> {
        if (underlineErrorItem.getSelection()) {
            setStyle(UNDERLINE_ERROR);
        }
    }));
    MenuItem underlineColorItem = new MenuItem(underlineMenu, SWT.PUSH);
    // $NON-NLS-1$
    underlineColorItem.setText(getResourceString("Color_menuitem"));
    underlineColorItem.addSelectionListener(widgetSelectedAdapter(event -> {
        ColorDialog dialog = new ColorDialog(shell);
        RGB rgb = underlineColor != null ? underlineColor.getRGB() : null;
        dialog.setRGB(rgb);
        RGB newRgb = dialog.open();
        if (newRgb != null) {
            if (!newRgb.equals(rgb)) {
                disposeResource(underlineColor);
                underlineColor = new Color(display, newRgb);
            }
            if (underlineSingleItem.getSelection())
                setStyle(UNDERLINE_SINGLE);
            else if (underlineDoubleItem.getSelection())
                setStyle(UNDERLINE_DOUBLE);
            else if (underlineErrorItem.getSelection())
                setStyle(UNDERLINE_ERROR);
            else if (underlineSquiggleItem.getSelection())
                setStyle(UNDERLINE_SQUIGGLE);
        }
    }));
    final ToolItem underlineControl = new ToolItem(styleToolBar, SWT.DROP_DOWN);
    underlineControl.setImage(iUnderline);
    // $NON-NLS-1$
    underlineControl.setToolTipText(getResourceString("Underline"));
    underlineControl.addSelectionListener(widgetSelectedAdapter(event -> {
        if (event.detail == SWT.ARROW) {
            Rectangle rect = underlineControl.getBounds();
            Point pt = new Point(rect.x, rect.y + rect.height);
            underlineMenu.setLocation(display.map(underlineControl.getParent(), null, pt));
            underlineMenu.setVisible(true);
        } else {
            if (underlineSingleItem.getSelection())
                setStyle(UNDERLINE_SINGLE);
            else if (underlineDoubleItem.getSelection())
                setStyle(UNDERLINE_DOUBLE);
            else if (underlineErrorItem.getSelection())
                setStyle(UNDERLINE_ERROR);
            else if (underlineSquiggleItem.getSelection())
                setStyle(UNDERLINE_SQUIGGLE);
        }
    }));
    ToolItem strikeoutControl = new ToolItem(styleToolBar, SWT.DROP_DOWN);
    strikeoutControl.setImage(iStrikeout);
    // $NON-NLS-1$
    strikeoutControl.setToolTipText(getResourceString("Strikeout"));
    strikeoutControl.addSelectionListener(widgetSelectedAdapter(event -> {
        if (event.detail == SWT.ARROW) {
            ColorDialog dialog = new ColorDialog(shell);
            RGB rgb = strikeoutColor != null ? strikeoutColor.getRGB() : null;
            dialog.setRGB(rgb);
            RGB newRgb = dialog.open();
            if (newRgb == null)
                return;
            if (!newRgb.equals(rgb)) {
                disposeResource(strikeoutColor);
                strikeoutColor = new Color(display, newRgb);
            }
        }
        setStyle(STRIKEOUT);
    }));
    final Menu borderMenu = new Menu(shell, SWT.POP_UP);
    borderSolidItem = new MenuItem(borderMenu, SWT.RADIO);
    // $NON-NLS-1$
    borderSolidItem.setText(getResourceString("Solid"));
    borderSolidItem.addSelectionListener(widgetSelectedAdapter(event -> {
        if (borderSolidItem.getSelection()) {
            setStyle(BORDER_SOLID);
        }
    }));
    borderSolidItem.setSelection(true);
    borderDashItem = new MenuItem(borderMenu, SWT.RADIO);
    // $NON-NLS-1$
    borderDashItem.setText(getResourceString("Dash"));
    borderDashItem.addSelectionListener(widgetSelectedAdapter(event -> {
        if (borderDashItem.getSelection()) {
            setStyle(BORDER_DASH);
        }
    }));
    borderDotItem = new MenuItem(borderMenu, SWT.RADIO);
    // $NON-NLS-1$
    borderDotItem.setText(getResourceString("Dot"));
    borderDotItem.addSelectionListener(widgetSelectedAdapter(event -> {
        if (borderDotItem.getSelection()) {
            setStyle(BORDER_DOT);
        }
    }));
    MenuItem borderColorItem = new MenuItem(borderMenu, SWT.PUSH);
    // $NON-NLS-1$
    borderColorItem.setText(getResourceString("Color_menuitem"));
    borderColorItem.addSelectionListener(widgetSelectedAdapter(event -> {
        ColorDialog dialog = new ColorDialog(shell);
        RGB rgb = borderColor != null ? borderColor.getRGB() : null;
        dialog.setRGB(rgb);
        RGB newRgb = dialog.open();
        if (newRgb != null) {
            if (!newRgb.equals(rgb)) {
                disposeResource(borderColor);
                borderColor = new Color(display, newRgb);
            }
            if (borderDashItem.getSelection())
                setStyle(BORDER_DASH);
            else if (borderDotItem.getSelection())
                setStyle(BORDER_DOT);
            else if (borderSolidItem.getSelection())
                setStyle(BORDER_SOLID);
        }
    }));
    final ToolItem borderControl = new ToolItem(styleToolBar, SWT.DROP_DOWN);
    borderControl.setImage(iBorderStyle);
    // $NON-NLS-1$
    borderControl.setToolTipText(getResourceString("Box"));
    borderControl.addSelectionListener(widgetSelectedAdapter(event -> {
        if (event.detail == SWT.ARROW) {
            Rectangle rect = borderControl.getBounds();
            Point pt = new Point(rect.x, rect.y + rect.height);
            borderMenu.setLocation(display.map(borderControl.getParent(), null, pt));
            borderMenu.setVisible(true);
        } else {
            if (borderDashItem.getSelection())
                setStyle(BORDER_DASH);
            else if (borderDotItem.getSelection())
                setStyle(BORDER_DOT);
            else if (borderSolidItem.getSelection())
                setStyle(BORDER_SOLID);
        }
    }));
    ToolItem foregroundItem = new ToolItem(styleToolBar, SWT.DROP_DOWN);
    foregroundItem.setImage(iTextForeground);
    // $NON-NLS-1$
    foregroundItem.setToolTipText(getResourceString("TextForeground"));
    foregroundItem.addSelectionListener(widgetSelectedAdapter(event -> {
        if (event.detail == SWT.ARROW || textForeground == null) {
            ColorDialog dialog = new ColorDialog(shell);
            RGB rgb = textForeground != null ? textForeground.getRGB() : null;
            dialog.setRGB(rgb);
            RGB newRgb = dialog.open();
            if (newRgb == null)
                return;
            if (!newRgb.equals(rgb)) {
                disposeResource(textForeground);
                textForeground = new Color(display, newRgb);
            }
        }
        setStyle(FOREGROUND);
    }));
    ToolItem backgroundItem = new ToolItem(styleToolBar, SWT.DROP_DOWN);
    backgroundItem.setImage(iTextBackground);
    // $NON-NLS-1$
    backgroundItem.setToolTipText(getResourceString("TextBackground"));
    backgroundItem.addSelectionListener(widgetSelectedAdapter(event -> {
        if (event.detail == SWT.ARROW || textBackground == null) {
            ColorDialog dialog = new ColorDialog(shell);
            RGB rgb = textBackground != null ? textBackground.getRGB() : null;
            dialog.setRGB(rgb);
            RGB newRgb = dialog.open();
            if (newRgb == null)
                return;
            if (!newRgb.equals(rgb)) {
                disposeResource(textBackground);
                textBackground = new Color(display, newRgb);
            }
        }
        setStyle(BACKGROUND);
    }));
    ToolItem baselineUpItem = new ToolItem(styleToolBar, SWT.PUSH);
    baselineUpItem.setImage(iBaselineUp);
    // $NON-NLS-1$
    String tooltip = "IncreaseFont";
    // $NON-NLS-1$
    if (USE_BASELINE)
        tooltip = "IncreaseBaseline";
    baselineUpItem.setToolTipText(getResourceString(tooltip));
    baselineUpItem.addSelectionListener(widgetSelectedAdapter(event -> {
        if (USE_BASELINE) {
            setStyle(BASELINE_UP);
        } else {
            adjustFontSize(1);
        }
    }));
    ToolItem baselineDownItem = new ToolItem(styleToolBar, SWT.PUSH);
    baselineDownItem.setImage(iBaselineDown);
    // $NON-NLS-1$
    tooltip = "DecreaseFont";
    // $NON-NLS-1$
    if (USE_BASELINE)
        tooltip = "DecreaseBaseline";
    baselineDownItem.setToolTipText(getResourceString(tooltip));
    baselineDownItem.addSelectionListener(widgetSelectedAdapter(event -> {
        if (USE_BASELINE) {
            setStyle(BASELINE_DOWN);
        } else {
            adjustFontSize(-1);
        }
    }));
    ToolItem linkItem = new ToolItem(styleToolBar, SWT.PUSH);
    linkItem.setImage(iLink);
    // $NON-NLS-1$
    linkItem.setToolTipText(getResourceString("Link"));
    linkItem.addSelectionListener(widgetSelectedAdapter(event -> setLink()));
    CoolItem coolItem = new CoolItem(coolBar, SWT.NONE);
    coolItem.setControl(styleToolBar);
    Composite composite = new Composite(coolBar, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 1;
    composite.setLayout(layout);
    fontNameControl = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
    fontNameControl.setItems(getFontNames());
    fontNameControl.setVisibleItemCount(12);
    fontSizeControl = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
    fontSizeControl.setItems(FONT_SIZES);
    fontSizeControl.setVisibleItemCount(8);
    SelectionListener adapter = widgetSelectedAdapter(event -> {
        String name = fontNameControl.getText();
        int size = Integer.parseInt(fontSizeControl.getText());
        disposeResource(textFont);
        textFont = new Font(display, name, size, SWT.NORMAL);
        setStyle(FONT);
    });
    fontSizeControl.addSelectionListener(adapter);
    fontNameControl.addSelectionListener(adapter);
    coolItem = new CoolItem(coolBar, SWT.NONE);
    coolItem.setControl(composite);
    ToolBar alignmentToolBar = new ToolBar(coolBar, SWT.FLAT);
    blockSelectionItem = new ToolItem(alignmentToolBar, SWT.CHECK);
    blockSelectionItem.setImage(iBlockSelection);
    // $NON-NLS-1$
    blockSelectionItem.setToolTipText(getResourceString("BlockSelection"));
    blockSelectionItem.addSelectionListener(widgetSelectedAdapter(event -> styledText.invokeAction(ST.TOGGLE_BLOCKSELECTION)));
    leftAlignmentItem = new ToolItem(alignmentToolBar, SWT.RADIO);
    leftAlignmentItem.setImage(iLeftAlignment);
    // $NON-NLS-1$
    leftAlignmentItem.setToolTipText(getResourceString("AlignLeft"));
    leftAlignmentItem.setSelection(true);
    leftAlignmentItem.addSelectionListener(widgetSelectedAdapter(event -> {
        Point selection = styledText.getSelection();
        int lineStart = styledText.getLineAtOffset(selection.x);
        int lineEnd = styledText.getLineAtOffset(selection.y);
        styledText.setLineAlignment(lineStart, lineEnd - lineStart + 1, SWT.LEFT);
    }));
    leftAlignmentItem.setEnabled(false);
    centerAlignmentItem = new ToolItem(alignmentToolBar, SWT.RADIO);
    centerAlignmentItem.setImage(iCenterAlignment);
    // $NON-NLS-1$
    centerAlignmentItem.setToolTipText(getResourceString("Center_menuitem"));
    centerAlignmentItem.addSelectionListener(widgetSelectedAdapter(event -> {
        Point selection = styledText.getSelection();
        int lineStart = styledText.getLineAtOffset(selection.x);
        int lineEnd = styledText.getLineAtOffset(selection.y);
        styledText.setLineAlignment(lineStart, lineEnd - lineStart + 1, SWT.CENTER);
    }));
    centerAlignmentItem.setEnabled(false);
    rightAlignmentItem = new ToolItem(alignmentToolBar, SWT.RADIO);
    rightAlignmentItem.setImage(iRightAlignment);
    // $NON-NLS-1$
    rightAlignmentItem.setToolTipText(getResourceString("AlignRight"));
    rightAlignmentItem.addSelectionListener(widgetSelectedAdapter(event -> {
        Point selection = styledText.getSelection();
        int lineStart = styledText.getLineAtOffset(selection.x);
        int lineEnd = styledText.getLineAtOffset(selection.y);
        styledText.setLineAlignment(lineStart, lineEnd - lineStart + 1, SWT.RIGHT);
    }));
    rightAlignmentItem.setEnabled(false);
    justifyAlignmentItem = new ToolItem(alignmentToolBar, SWT.CHECK);
    justifyAlignmentItem.setImage(iJustifyAlignment);
    // $NON-NLS-1$
    justifyAlignmentItem.setToolTipText(getResourceString("Justify"));
    justifyAlignmentItem.addSelectionListener(widgetSelectedAdapter(event -> {
        Point selection = styledText.getSelection();
        int lineStart = styledText.getLineAtOffset(selection.x);
        int lineEnd = styledText.getLineAtOffset(selection.y);
        styledText.setLineJustify(lineStart, lineEnd - lineStart + 1, justifyAlignmentItem.getSelection());
    }));
    justifyAlignmentItem.setEnabled(false);
    ToolItem bulletListItem = new ToolItem(alignmentToolBar, SWT.PUSH);
    bulletListItem.setImage(iBulletList);
    // $NON-NLS-1$
    bulletListItem.setToolTipText(getResourceString("BulletList"));
    bulletListItem.addSelectionListener(widgetSelectedAdapter(event -> setBullet(ST.BULLET_DOT)));
    ToolItem numberedListItem = new ToolItem(alignmentToolBar, SWT.PUSH);
    numberedListItem.setImage(iNumberedList);
    // $NON-NLS-1$
    numberedListItem.setToolTipText(getResourceString("NumberedList"));
    numberedListItem.addSelectionListener(widgetSelectedAdapter(event -> setBullet(ST.BULLET_NUMBER | ST.BULLET_TEXT)));
    coolItem = new CoolItem(coolBar, SWT.NONE);
    coolItem.setControl(alignmentToolBar);
    composite = new Composite(coolBar, SWT.NONE);
    layout = new GridLayout(4, false);
    layout.marginHeight = 1;
    composite.setLayout(layout);
    Label label = new Label(composite, SWT.NONE);
    // $NON-NLS-1$
    label.setText(getResourceString("Indent"));
    Spinner indent = new Spinner(composite, SWT.BORDER);
    indent.addSelectionListener(widgetSelectedAdapter(event -> {
        Spinner spinner = (Spinner) event.widget;
        styledText.setIndent(spinner.getSelection());
    }));
    label = new Label(composite, SWT.NONE);
    // $NON-NLS-1$
    label.setText(getResourceString("Spacing"));
    Spinner spacing = new Spinner(composite, SWT.BORDER);
    spacing.addSelectionListener(widgetSelectedAdapter(event -> {
        Spinner spinner = (Spinner) event.widget;
        styledText.setLineSpacing(spinner.getSelection());
    }));
    coolItem = new CoolItem(coolBar, SWT.NONE);
    coolItem.setControl(composite);
    CoolItem[] coolItems = coolBar.getItems();
    for (CoolItem item : coolItems) {
        Control control = item.getControl();
        Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
        item.setMinimumSize(size);
        size = item.computeSize(size.x, size.y);
        item.setPreferredSize(size);
        item.setSize(size);
    }
    coolBar.addControlListener(ControlListener.controlResizedAdapter(event -> handleResize(event)));
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) CoolBar(org.eclipse.swt.widgets.CoolBar) ToolBar(org.eclipse.swt.widgets.ToolBar) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) ColorDialog(org.eclipse.swt.widgets.ColorDialog) MenuEvent(org.eclipse.swt.events.MenuEvent) Composite(org.eclipse.swt.widgets.Composite) Bullet(org.eclipse.swt.custom.Bullet) Text(org.eclipse.swt.widgets.Text) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) MissingResourceException(java.util.MissingResourceException) GlyphMetrics(org.eclipse.swt.graphics.GlyphMetrics) Display(org.eclipse.swt.widgets.Display) ToolItem(org.eclipse.swt.widgets.ToolItem) MenuListener.menuShownAdapter(org.eclipse.swt.events.MenuListener.menuShownAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) SWT(org.eclipse.swt.SWT) PaintObjectEvent(org.eclipse.swt.custom.PaintObjectEvent) Label(org.eclipse.swt.widgets.Label) SelectionListener(org.eclipse.swt.events.SelectionListener) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) Spinner(org.eclipse.swt.widgets.Spinner) ControlListener(org.eclipse.swt.events.ControlListener) MenuAdapter(org.eclipse.swt.events.MenuAdapter) ImageData(org.eclipse.swt.graphics.ImageData) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) VerifyEvent(org.eclipse.swt.events.VerifyEvent) ResourceBundle(java.util.ResourceBundle) StringTokenizer(java.util.StringTokenizer) Listener(org.eclipse.swt.widgets.Listener) RGB(org.eclipse.swt.graphics.RGB) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) Resource(org.eclipse.swt.graphics.Resource) Browser(org.eclipse.swt.browser.Browser) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) FileDialog(org.eclipse.swt.widgets.FileDialog) FileWriter(java.io.FileWriter) StyleRange(org.eclipse.swt.custom.StyleRange) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) FontDialog(org.eclipse.swt.widgets.FontDialog) InputStreamReader(java.io.InputStreamReader) CoolItem(org.eclipse.swt.widgets.CoolItem) Color(org.eclipse.swt.graphics.Color) ST(org.eclipse.swt.custom.ST) FontData(org.eclipse.swt.graphics.FontData) MessageBox(org.eclipse.swt.widgets.MessageBox) BufferedReader(java.io.BufferedReader) Menu(org.eclipse.swt.widgets.Menu) Control(org.eclipse.swt.widgets.Control) InputStream(java.io.InputStream) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Spinner(org.eclipse.swt.widgets.Spinner) Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.swt.graphics.Rectangle) Label(org.eclipse.swt.widgets.Label) MenuItem(org.eclipse.swt.widgets.MenuItem) Combo(org.eclipse.swt.widgets.Combo) Point(org.eclipse.swt.graphics.Point) RGB(org.eclipse.swt.graphics.RGB) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) ColorDialog(org.eclipse.swt.widgets.ColorDialog) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) CoolBar(org.eclipse.swt.widgets.CoolBar) ToolBar(org.eclipse.swt.widgets.ToolBar) Menu(org.eclipse.swt.widgets.Menu) CoolItem(org.eclipse.swt.widgets.CoolItem) ToolItem(org.eclipse.swt.widgets.ToolItem) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

CoolBar (org.eclipse.swt.widgets.CoolBar)22 CoolItem (org.eclipse.swt.widgets.CoolItem)20 Point (org.eclipse.swt.graphics.Point)15 Button (org.eclipse.swt.widgets.Button)14 Test (org.junit.Test)13 ToolBar (org.eclipse.swt.widgets.ToolBar)6 ToolItem (org.eclipse.swt.widgets.ToolItem)6 Control (org.eclipse.swt.widgets.Control)5 Text (org.eclipse.swt.widgets.Text)5 StyledText (org.eclipse.swt.custom.StyledText)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 GridData (org.eclipse.swt.layout.GridData)4 Combo (org.eclipse.swt.widgets.Combo)4 Label (org.eclipse.swt.widgets.Label)4 CCombo (org.eclipse.swt.custom.CCombo)3 FillLayout (org.eclipse.swt.layout.FillLayout)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Canvas (org.eclipse.swt.widgets.Canvas)3 Composite (org.eclipse.swt.widgets.Composite)3 Display (org.eclipse.swt.widgets.Display)3