use of org.eclipse.swt.widgets.Canvas in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_Caret method setUp.
@Override
@Before
public void setUp() {
super.setUp();
canvas = new Canvas(shell, SWT.NULL);
caret = new Caret(canvas, SWT.NULL);
setWidget(caret);
}
use of org.eclipse.swt.widgets.Canvas in project eclipse.platform.swt by eclipse.
the class Bug170631_NestedCompositeFocus method main.
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
final Canvas canvas = new Canvas(shell, SWT.NONE);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
canvas.setLayoutData(gridData);
canvas.addPaintListener(event -> {
Rectangle rect = canvas.getClientArea();
event.gc.drawOval(0, 0, rect.width - 1, rect.height - 1);
});
final Text text = new Text(shell, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
text.setText("I want focus");
shell.setBounds(10, 10, 200, 200);
shell.open();
// With shell.setFocus(), the Canvas gets focus. Without it, the Text does.
shell.setFocus();
System.out.println(shell.getDisplay().getFocusControl());
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
use of org.eclipse.swt.widgets.Canvas in project liferay-ide by liferay.
the class LiferayCustomXmlHoverControl method _createAnnotationInformation.
private void _createAnnotationInformation(Composite parent, Annotation annotation) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 2;
layout.marginWidth = 2;
layout.horizontalSpacing = 0;
composite.setLayout(layout);
// this paints the icon..
Canvas canvas = new Canvas(composite, SWT.NO_FOCUS);
GridData gridData = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
gridData.widthHint = 17;
gridData.heightHint = 16;
canvas.setLayoutData(gridData);
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.setFont(null);
_markerAccess.paint(annotation, e.gc, canvas, new Rectangle(0, 0, 16, 16));
}
});
// and now comes the text
StyledText text = new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
text.setLayoutData(data);
String annotationText = annotation.getText();
if (annotationText != null) {
text.setText(annotationText);
}
}
use of org.eclipse.swt.widgets.Canvas in project netxms by netxms.
the class Sleak method open.
public void open() {
display = Display.getCurrent();
shell = new Shell(display);
// $NON-NLS-1$
shell.setText("S-Leak");
list = new List(shell, SWT.BORDER | SWT.V_SCROLL);
list.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(final Event event) {
refreshObject();
}
});
text = new Text(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
canvas = new Canvas(shell, SWT.BORDER);
canvas.addListener(SWT.Paint, new Listener() {
@Override
public void handleEvent(final Event event) {
paintCanvas(event);
}
});
check = new Button(shell, SWT.CHECK);
// $NON-NLS-1$
check.setText("Stack");
check.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(final Event e) {
toggleStackTrace();
}
});
start = new Button(shell, SWT.PUSH);
// $NON-NLS-1$
start.setText("Snap");
start.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(final Event event) {
refreshAll();
}
});
stop = new Button(shell, SWT.PUSH);
// $NON-NLS-1$
stop.setText("Diff");
stop.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(final Event event) {
refreshDifference();
}
});
label = new Label(shell, SWT.BORDER);
// $NON-NLS-1$
label.setText("0 object(s)");
shell.addListener(SWT.Resize, new Listener() {
@Override
public void handleEvent(final Event e) {
layout();
}
});
check.setSelection(false);
text.setVisible(false);
final Point size = shell.getSize();
shell.setSize(size.x / 2, size.y / 2);
shell.open();
}
use of org.eclipse.swt.widgets.Canvas in project yamcs-studio by yamcs.
the class OverviewOutlinePage method createControl.
@Override
public void createControl(Composite parent) {
overview = new Canvas(parent, SWT.NONE);
var lws = new LightweightSystem(overview);
thumbnail = new ScrollableThumbnail((Viewport) rootEP.getFigure());
thumbnail.setBorder(new MarginBorder(3));
thumbnail.setSource(rootEP.getLayer(LayerConstants.PRINTABLE_LAYERS));
lws.setContents(thumbnail);
disposeListener = e -> {
if (thumbnail != null) {
thumbnail.deactivate();
thumbnail = null;
}
};
rootEP.getViewer().getControl().addDisposeListener(disposeListener);
}
Aggregations