Search in sources :

Example 76 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.swt by eclipse.

the class AnimatedGraphicsTab method createControlPanel.

/**
 * Sets the layout of the composite to RowLayout and creates the toolbar.
 *
 * @see org.eclipse.swt.examples.graphics.GraphicsTab#createControlPanel(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createControlPanel(Composite parent) {
    // setup layout
    RowLayout layout = new RowLayout();
    layout.wrap = true;
    layout.spacing = 8;
    parent.setLayout(layout);
    createToolBar(parent);
}
Also used : RowLayout(org.eclipse.swt.layout.RowLayout)

Example 77 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.swt by eclipse.

the class CustomFontTab method createControlPanel.

@Override
public void createControlPanel(Composite parent) {
    Composite mainComp = new Composite(parent, SWT.NONE);
    mainComp.setLayout(new RowLayout());
    // create combo for font face
    Composite comp = new Composite(mainComp, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));
    // $NON-NLS-1$
    new Label(comp, SWT.LEFT).setText(GraphicsExample.getResourceString("FontFace"));
    fontFaceCb = new Combo(comp, SWT.DROP_DOWN);
    for (String name : fontNames) {
        fontFaceCb.add(name);
    }
    fontFaceCb.select(0);
    fontFaceCb.addListener(SWT.Selection, event -> example.redraw());
    // create combo for font style
    comp = new Composite(mainComp, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));
    // $NON-NLS-1$
    new Label(comp, SWT.LEFT).setText(GraphicsExample.getResourceString("FontStyle"));
    fontStyleCb = new Combo(comp, SWT.DROP_DOWN);
    for (String fontStyle : fontStyles) {
        fontStyleCb.add(fontStyle);
    }
    fontStyleCb.select(0);
    fontStyleCb.addListener(SWT.Selection, event -> example.redraw());
    // create spinner for font size (points)
    comp = new Composite(mainComp, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));
    // $NON-NLS-1$
    new Label(comp, SWT.LEFT).setText(GraphicsExample.getResourceString("FontSize"));
    fontPointSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP);
    fontPointSpinner.setMinimum(1);
    fontPointSpinner.setMaximum(1000);
    fontPointSpinner.setSelection(200);
    fontPointSpinner.addListener(SWT.Selection, event -> example.redraw());
    ColorMenu cm = new ColorMenu();
    cm.setColorItems(true);
    cm.setPatternItems(example.checkAdvancedGraphics());
    menu = cm.createMenu(parent.getParent(), gb -> {
        fontForeground = gb;
        colorButton.setImage(gb.getThumbNail());
        example.redraw();
    });
    // initialize the background to the 2nd item in the menu (black)
    fontForeground = (GraphicsBackground) menu.getItem(1).getData();
    // create color button
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout());
    colorButton = new Button(comp, SWT.PUSH);
    // $NON-NLS-1$
    colorButton.setText(GraphicsExample.getResourceString("Color"));
    colorButton.setImage(fontForeground.getThumbNail());
    colorButton.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu.setLocation(point.x, point.y + bounds.height);
        menu.setVisible(true);
    });
}
Also used : Combo(org.eclipse.swt.widgets.Combo) Button(org.eclipse.swt.widgets.Button) Device(org.eclipse.swt.graphics.Device) Pattern(org.eclipse.swt.graphics.Pattern) Rectangle(org.eclipse.swt.graphics.Rectangle) Spinner(org.eclipse.swt.widgets.Spinner) Display(org.eclipse.swt.widgets.Display) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) ArrayList(java.util.ArrayList) List(java.util.List) RowLayout(org.eclipse.swt.layout.RowLayout) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) FontData(org.eclipse.swt.graphics.FontData) Font(org.eclipse.swt.graphics.Font) Menu(org.eclipse.swt.widgets.Menu) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) RowLayout(org.eclipse.swt.layout.RowLayout) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) Combo(org.eclipse.swt.widgets.Combo) Point(org.eclipse.swt.graphics.Point)

Example 78 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.swt by eclipse.

the class GradientDialog method createDialogControls.

/**
 * Creates the controls of the dialog.
 */
public void createDialogControls(final Shell parent) {
    final Display display = parent.getDisplay();
    // message
    Label message = new Label(parent, SWT.NONE);
    message.setText(GraphicsExample.getResourceString("GradientDlgMsg"));
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gridData.horizontalSpan = 2;
    message.setLayoutData(gridData);
    // default colors are white and black
    if (rgb1 == null || rgb2 == null) {
        rgb1 = display.getSystemColor(SWT.COLOR_WHITE).getRGB();
        rgb2 = display.getSystemColor(SWT.COLOR_BLACK).getRGB();
    }
    // canvas
    canvas = new Canvas(parent, SWT.NONE);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.widthHint = 200;
    gridData.heightHint = 100;
    canvas.setLayoutData(gridData);
    canvas.addListener(SWT.Paint, e -> {
        Image preview = null;
        Point size = canvas.getSize();
        Color color1 = new Color(display, rgb1);
        Color color2 = new Color(display, rgb2);
        preview = GraphicsExample.createImage(display, color1, color2, size.x, size.y);
        if (preview != null) {
            e.gc.drawImage(preview, 0, 0);
        }
        preview.dispose();
        color1.dispose();
        color2.dispose();
    });
    // composite used for both color buttons
    Composite colorButtonComp = new Composite(parent, SWT.NONE);
    // layout buttons
    RowLayout layout = new RowLayout();
    layout.type = SWT.VERTICAL;
    layout.pack = false;
    colorButtonComp.setLayout(layout);
    // position composite
    gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    colorButtonComp.setLayoutData(gridData);
    ColorMenu colorMenu = new ColorMenu();
    // color controls: first color
    colorButton1 = new Button(colorButtonComp, SWT.PUSH);
    colorButton1.setText(GraphicsExample.getResourceString("GradientDlgButton1"));
    Color color1 = new Color(display, rgb1);
    Image img1 = GraphicsExample.createImage(display, color1);
    color1.dispose();
    colorButton1.setImage(img1);
    resources.add(img1);
    menu1 = colorMenu.createMenu(parent.getParent(), gb -> {
        rgb1 = gb.getBgColor1().getRGB();
        colorButton1.setImage(gb.getThumbNail());
        if (canvas != null)
            canvas.redraw();
    });
    colorButton1.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu1.setLocation(point.x, point.y + bounds.height);
        menu1.setVisible(true);
    });
    // color controls: second color
    colorButton2 = new Button(colorButtonComp, SWT.PUSH);
    colorButton2.setText(GraphicsExample.getResourceString("GradientDlgButton2"));
    Color color2 = new Color(display, rgb2);
    Image img2 = GraphicsExample.createImage(display, color2);
    color2.dispose();
    colorButton2.setImage(img2);
    resources.add(img2);
    menu2 = colorMenu.createMenu(parent.getParent(), gb -> {
        rgb2 = gb.getBgColor1().getRGB();
        colorButton2.setImage(gb.getThumbNail());
        if (canvas != null)
            canvas.redraw();
    });
    colorButton2.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu2.setLocation(point.x, point.y + bounds.height);
        menu2.setVisible(true);
    });
    // composite used for ok and cancel buttons
    Composite okCancelComp = new Composite(parent, SWT.NONE);
    // layout buttons
    RowLayout rowLayout = new RowLayout();
    rowLayout.pack = false;
    rowLayout.marginTop = 5;
    okCancelComp.setLayout(rowLayout);
    // position composite
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gridData.horizontalSpan = 2;
    okCancelComp.setLayoutData(gridData);
    // OK button
    okButton = new Button(okCancelComp, SWT.PUSH);
    okButton.setText("&OK");
    okButton.addListener(SWT.Selection, event -> {
        returnVal = SWT.OK;
        parent.close();
    });
    // cancel button
    cancelButton = new Button(okCancelComp, SWT.PUSH);
    cancelButton.setText("&Cancel");
    cancelButton.addListener(SWT.Selection, event -> parent.close());
}
Also used : Resource(org.eclipse.swt.graphics.Resource) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) Display(org.eclipse.swt.widgets.Display) Point(org.eclipse.swt.graphics.Point) Dialog(org.eclipse.swt.widgets.Dialog) ArrayList(java.util.ArrayList) List(java.util.List) RowLayout(org.eclipse.swt.layout.RowLayout) Color(org.eclipse.swt.graphics.Color) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) RGB(org.eclipse.swt.graphics.RGB) Canvas(org.eclipse.swt.widgets.Canvas) GridData(org.eclipse.swt.layout.GridData) Menu(org.eclipse.swt.widgets.Menu) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Canvas(org.eclipse.swt.widgets.Canvas) Color(org.eclipse.swt.graphics.Color) Label(org.eclipse.swt.widgets.Label) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Image(org.eclipse.swt.graphics.Image) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) Display(org.eclipse.swt.widgets.Display)

Example 79 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.swt by eclipse.

the class Bug510905_Browser_TwoJsConsoles method main.

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setSize(500, 600);
    shell.setLayout(new RowLayout());
    Composite leftBrowser = new Composite(shell, SWT.NONE);
    Composite rightBrowser = new Composite(shell, SWT.None);
    Button button = new Button(rightBrowser, SWT.PUSH);
    button.setText("my button");
    final Browser browser = makeBrowserWithConsole(leftBrowser, "theJavaFunction");
    new CustomFunction(browser, "theJavaFunction");
    final Browser browser2 = makeBrowserWithConsole(rightBrowser, "theJavaFunction");
    new CustomFunction(browser2, "theJavaFunction");
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) Display(org.eclipse.swt.widgets.Display) Browser(org.eclipse.swt.browser.Browser)

Example 80 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project eclipse.platform.text by eclipse.

the class MarkerInformationControl method createContent.

@Override
protected void createContent(Composite parent) {
    parent.setLayout(new RowLayout(SWT.VERTICAL));
    parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    parent.setBackgroundMode(SWT.INHERIT_DEFAULT);
    this.parent = parent;
}
Also used : RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData)

Aggregations

RowLayout (org.eclipse.swt.layout.RowLayout)86 Composite (org.eclipse.swt.widgets.Composite)73 GridData (org.eclipse.swt.layout.GridData)55 Button (org.eclipse.swt.widgets.Button)54 GridLayout (org.eclipse.swt.layout.GridLayout)52 Label (org.eclipse.swt.widgets.Label)44 SelectionEvent (org.eclipse.swt.events.SelectionEvent)41 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)34 Group (org.eclipse.swt.widgets.Group)27 Text (org.eclipse.swt.widgets.Text)23 Combo (org.eclipse.swt.widgets.Combo)19 Shell (org.eclipse.swt.widgets.Shell)17 Display (org.eclipse.swt.widgets.Display)16 Point (org.eclipse.swt.graphics.Point)12 ArrayList (java.util.ArrayList)10 StyledText (org.eclipse.swt.custom.StyledText)10 Table (org.eclipse.swt.widgets.Table)10 List (java.util.List)9 SelectionListener (org.eclipse.swt.events.SelectionListener)9 FillLayout (org.eclipse.swt.layout.FillLayout)9