| Summary: | Control.print(GC) doesn't work | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | GRudiD <GRudiD.esmartweb> |
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | remy.suen |
| Version: | 3.6.1 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Solaris-GTK | ||
| Whiteboard: | |||
Solaris is no longer a supported platform. |
Build Identifier: eclipse-rcp-helios-SR1-linux-gtk.tar.gz The printing of a control via control.print(gc) on a composite produces a strange image on display. See the following code to repoduce this behaviour: import org.eclipse.swt.SWT; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Transform; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.Shell; public class SWTTest { private Composite seComposite; private Composite nwComposite; private Composite neComposite; private Composite swComposite; private Label label; public SWTTest(final Composite parent, int style) { int headerHeight = 20; int fixedWidth = 50; FormData formData; formData = new FormData(); formData.top = new FormAttachment(0, 0); formData.right = new FormAttachment(0, fixedWidth); formData.bottom = new FormAttachment(0, headerHeight); formData.left = new FormAttachment(0, 0); nwComposite = new Composite(parent, SWT.NONE); nwComposite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_YELLOW)); nwComposite.setLayoutData(formData); formData = new FormData(); formData.top = new FormAttachment(0, 0); formData.right = new FormAttachment(100, 0); formData.bottom = new FormAttachment(0, headerHeight); formData.left = new FormAttachment(0, fixedWidth); neComposite = new Composite(parent, SWT.NONE); neComposite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_RED)); neComposite.setLayoutData(formData); formData = new FormData(); formData.top = new FormAttachment(0, headerHeight); formData.right = new FormAttachment(0, fixedWidth); formData.bottom = new FormAttachment(100, 0); formData.left = new FormAttachment(0, 0); swComposite = new Composite(parent, SWT.NONE); swComposite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GREEN)); swComposite.setLayoutData(formData); formData = new FormData(); formData.top = new FormAttachment(0, headerHeight); formData.right = new FormAttachment(100, 0); formData.bottom = new FormAttachment(100, 0); formData.left = new FormAttachment(0, fixedWidth); seComposite = new Composite(parent, SWT.H_SCROLL | SWT.V_SCROLL); seComposite.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE)); seComposite.setLayoutData(formData); seComposite.addPaintListener(new PaintListener() { public void paintControl(PaintEvent event) { if (label == null || label.isDisposed()) return; event.gc.setClipping(0, 0, 100, 20); Transform transform = new Transform(event.gc.getDevice()); transform.translate(-5, -5); event.gc.setTransform(transform); // produce strange image label.print(event.gc); event.gc.dispose(); } }); label = new Label(seComposite, SWT.NONE); label.setText("TEST 123 TEST 456"); label.setBackground(label.getDisplay().getSystemColor(SWT.COLOR_CYAN)); label.setBounds(100, 100, 100, 20); } public static void main(String[] args) { Display display = Display.getDefault(); Shell shell = new Shell(); shell.setText("Shell"); shell.setLayout(new FormLayout()); new SWTTest(shell, SWT.NONE); shell.setSize(400, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } Reproducible: Always