List of usage examples for org.eclipse.swt.widgets Composite toDisplay
public Point toDisplay(Point point)
From source file:org.eclipse.swt.examples.graphics.GraphicAntialiasTab.java
@Override public void createControlPanel(Composite parent) { Composite comp;//from w ww . ja v a 2 s . c o m // create drop down combo for antialiasing comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Antialiasing")); //$NON-NLS-1$ aliasCombo = new Combo(comp, SWT.DROP_DOWN); aliasCombo.add("OFF"); aliasCombo.add("DEFAULT"); aliasCombo.add("ON"); aliasCombo.select(0); aliasCombo.addListener(SWT.Selection, event -> example.redraw()); ColorMenu cm = new ColorMenu(); cm.setColorItems(true); menu = cm.createMenu(parent.getParent(), gb -> { ovalColorGB = gb; colorButton.setImage(gb.getThumbNail()); example.redraw(); }); // create color button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); // initialize the background to the 5th item in the menu (blue) ovalColorGB = (GraphicsBackground) menu.getItem(4).getData(); // color button colorButton = new Button(comp, SWT.PUSH); colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$ colorButton.setImage(ovalColorGB.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); }); }
From source file:org.eclipse.swt.examples.graphics.LineCapTab.java
@Override public void createControlPanel(Composite parent) { Composite comp;/* w ww .ja va2 s. co m*/ // create color button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); ColorMenu cm = new ColorMenu(); cm.setPatternItems(example.checkAdvancedGraphics()); menu = cm.createMenu(parent.getParent(), gb -> { foreground = gb; colorButton.setImage(gb.getThumbNail()); example.redraw(); }); // initialize the foreground to the 3rd item in the menu (red) foreground = (GraphicsBackground) menu.getItem(2).getData(); // color button colorButton = new Button(comp, SWT.PUSH); colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$ colorButton.setImage(foreground.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); }); }
From source file:org.eclipse.swt.examples.graphics.LineJoinTab.java
@Override public void createControlPanel(Composite parent) { // create drop down combo for choosing clipping Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("LineJoin")); //$NON-NLS-1$ joinCb = new Combo(comp, SWT.DROP_DOWN); joinCb.add(GraphicsExample.getResourceString("bevel")); //$NON-NLS-1$ joinCb.add(GraphicsExample.getResourceString("miter")); //$NON-NLS-1$ joinCb.add(GraphicsExample.getResourceString("round")); //$NON-NLS-1$ joinCb.select(1);// w w w . j av a2 s . co m joinCb.addListener(SWT.Selection, event -> example.redraw()); // color menu ColorMenu cm = new ColorMenu(); cm.setPatternItems(example.checkAdvancedGraphics()); menu = cm.createMenu(parent.getParent(), gb -> { shapeColor = gb; colorButton.setImage(gb.getThumbNail()); example.redraw(); }); // initialize the shape color to the 4th item in the menu (green) shapeColor = (GraphicsBackground) menu.getItem(3).getData(); // color button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); colorButton = new Button(comp, SWT.PUSH); colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$ colorButton.setImage(shapeColor.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); }); }
From source file:org.eclipse.swt.examples.graphics.SpiralTab.java
/** * This method creates a spinner for specifying the number of petals. The call to the * createControlPanel method in the super class create the controls that are * defined in the super class.//from w w w.j a v a2 s . c om * * @param parent The parent composite */ @Override public void createControlPanel(Composite parent) { super.createControlPanel(parent); // create spinner number of petals Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Petals")); //$NON-NLS-1$ petalSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP); petalSpinner.setSelection(8); petalSpinner.setMinimum(3); petalSpinner.setMaximum(20); petalSpinner.addListener(SWT.Selection, event -> example.redraw()); // create color button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); ColorMenu cm = new ColorMenu(); cm.setPatternItems(example.checkAdvancedGraphics()); menu = cm.createMenu(parent.getParent(), gb -> { foreground = gb; colorButton.setImage(gb.getThumbNail()); example.redraw(); }); // initialize the foreground to the 2nd item in the menu foreground = (GraphicsBackground) menu.getItem(1).getData(); // color button colorButton = new Button(comp, SWT.PUSH); colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$ colorButton.setImage(foreground.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); }); }
From source file:org.eclipse.swt.examples.graphics.LineStyleTab.java
@Override public void createControlPanel(Composite parent) { Composite comp;/*from w w w. jav a 2s .co m*/ comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("LineWidth")); //$NON-NLS-1$ lineWidthSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP); lineWidthSpinner.setSelection(10); lineWidthSpinner.setMinimum(1); lineWidthSpinner.setMaximum(30); lineWidthSpinner.addListener(SWT.Selection, event -> example.redraw()); ColorMenu cm = new ColorMenu(); cm.setPatternItems(example.checkAdvancedGraphics()); menu = cm.createMenu(parent.getParent(), gb -> { lineColor = gb; colorButton.setImage(gb.getThumbNail()); example.redraw(); }); // create color button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); // initialize the foreground to the 5th item in the menu (blue) lineColor = (GraphicsBackground) menu.getItem(4).getData(); // color button colorButton = new Button(comp, SWT.PUSH); colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$ colorButton.setImage(lineColor.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); }); }
From source file:org.eclipse.swt.examples.graphics.CustomAlphaTab.java
/** * Creates the widgets used to control the drawing. *///from w ww . j av a 2 s .c om @Override public void createControlPanel(Composite parent) { super.createControlPanel(parent); // create drop down combo for choosing clipping Composite comp; // create spinner for line width comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Alpha")); //$NON-NLS-1$ alphaSpinner = new Spinner(comp, SWT.BORDER | SWT.WRAP); alphaSpinner.setMinimum(0); alphaSpinner.setMaximum(255); alphaSpinner.setSelection(127); alphaSpinner.addListener(SWT.Selection, event -> example.redraw()); // color menu ColorMenu cm = new ColorMenu(); cm.setPatternItems(example.checkAdvancedGraphics()); menu = cm.createMenu(parent.getParent(), gb -> { background = gb; colorButton.setImage(gb.getThumbNail()); example.redraw(); }); // initialize the background to the 5th item in the menu (blue) background = (GraphicsBackground) menu.getItem(4).getData(); // color button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); colorButton = new Button(comp, SWT.PUSH); colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$ colorButton.setImage(background.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); }); }
From source file:org.eclipse.swt.examples.graphics.TextAntialiasTab.java
@Override public void createControlPanel(Composite parent) { Composite comp;/*w w w . j a v a2s. co m*/ // create drop down combo for antialiasing comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Antialiasing")); //$NON-NLS-1$ aliasCombo = new Combo(comp, SWT.DROP_DOWN); aliasCombo.add("OFF"); aliasCombo.add("DEFAULT"); aliasCombo.add("ON"); aliasCombo.select(0); aliasCombo.addListener(SWT.Selection, event -> example.redraw()); ColorMenu cm = new ColorMenu(); cm.setColorItems(true); menu = cm.createMenu(parent.getParent(), gb -> { textColor = gb; colorButton.setImage(gb.getThumbNail()); example.redraw(); }); // create color button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); // initialize the color to black textColor = (GraphicsBackground) menu.getItem(1).getData(); colorButton = new Button(comp, SWT.PUSH); colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$ colorButton.setImage(textColor.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); }); }
From source file:org.eclipse.swt.examples.graphics.PathTab.java
@Override public void createControlPanel(Composite parent) { Composite comp;/* www . j a v a 2 s. c o m*/ // create draw button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); drawButton = new Button(comp, SWT.TOGGLE); drawButton.setText(GraphicsExample.getResourceString("DrawPath")); //$NON-NLS-1$ drawButton.addListener(SWT.Selection, event -> example.redraw()); drawButton.setSelection(true); // create fill button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); fillButton = new Button(comp, SWT.TOGGLE); fillButton.setText(GraphicsExample.getResourceString("FillPath")); //$NON-NLS-1$ fillButton.addListener(SWT.Selection, event -> example.redraw()); // create close button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); closeButton = new Button(comp, SWT.TOGGLE); closeButton.setText(GraphicsExample.getResourceString("ClosePath")); //$NON-NLS-1$ closeButton.addListener(SWT.Selection, event -> example.redraw()); // create color button comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); ColorMenu cm = new ColorMenu(); cm.setPatternItems(example.checkAdvancedGraphics()); menu = cm.createMenu(parent.getParent(), gb -> { fillColor = gb; colorButton.setImage(gb.getThumbNail()); example.redraw(); }); // initialize the foreground to the 5th item in the menu (green) fillColor = (GraphicsBackground) menu.getItem(3).getData(); // color button colorButton = new Button(comp, SWT.PUSH); colorButton.setText(GraphicsExample.getResourceString("FillColor")); //$NON-NLS-1$ colorButton.setImage(fillColor.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); }); }
From source file:org.eclipse.swt.examples.graphics.PathClippingAnimTab.java
/** * Creates the widgets used to control the drawing. */// ww w . j a v a2 s .c om @Override public void createControlPanel(Composite parent) { super.createControlPanel(parent); // color menu ColorMenu cm = new ColorMenu(); cm.setPatternItems(example.checkAdvancedGraphics()); menu = cm.createMenu(parent.getParent(), gb -> { background = gb; colorButton.setImage(gb.getThumbNail()); example.redraw(); }); // initialize the background to the 5th item in the menu (blue) background = (GraphicsBackground) menu.getItem(4).getData(); // color button Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); colorButton = new Button(comp, SWT.PUSH); colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$ colorButton.setImage(background.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); }); }
From source file:org.eclipse.swt.examples.graphics.RegionClippingTab.java
/** * Creates the widgets used to control the drawing. *///from www.j a va2s . c o m @Override public void createControlPanel(Composite parent) { // create drop down combo for choosing clipping Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("Clipping")); //$NON-NLS-1$ clippingCb = new Combo(comp, SWT.DROP_DOWN); clippingCb.add(GraphicsExample.getResourceString("Region1")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Region2")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Add")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Sub")); //$NON-NLS-1$ clippingCb.add(GraphicsExample.getResourceString("Inter")); //$NON-NLS-1$ clippingCb.select(0); clippingCb.addListener(SWT.Selection, event -> example.redraw()); // color menu ColorMenu cm = new ColorMenu(); menu1 = cm.createMenu(parent.getParent(), gb -> { colorGB1 = gb; colorButton1.setImage(gb.getThumbNail()); example.redraw(); }); menu2 = cm.createMenu(parent.getParent(), gb -> { colorGB2 = gb; colorButton2.setImage(gb.getThumbNail()); example.redraw(); }); // initialize the color to blue colorGB1 = (GraphicsBackground) menu1.getItem(4).getData(); // initialize the color to red colorGB2 = (GraphicsBackground) menu2.getItem(2).getData(); // color button 1 comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); colorButton1 = new Button(comp, SWT.PUSH); colorButton1.setText(GraphicsExample.getResourceString("Color1")); //$NON-NLS-1$ colorButton1.setImage(colorGB1.getThumbNail()); 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 button 2 comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(2, false)); colorButton2 = new Button(comp, SWT.PUSH); colorButton2.setText(GraphicsExample.getResourceString("Color2")); //$NON-NLS-1$ colorButton2.setImage(colorGB2.getThumbNail()); 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); }); }