From a2f09981ee7d590204bf865314c2cdf802c4ed77 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 9 Apr 2019 12:55:49 +0200 Subject: Bug 1362: TestSWTAccessor02NewtGLWindow demonstrates a fix by letting the Canvas PAINT! This commit shows the very little change set required to allow working on SWT >= 4.10 + GTK3, i.e. adding the PAINT listener to Canvas and letting it paint. Almost too ridiculous? I stumbled over it by creating this test in the first place when copying the 01 test -> 02 and adding the native parenting. Possible explanation: The parent Canvas may need to paint once at least due to some lazy initialization within SWT or GTK3?! --- .../test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/test/com') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java index 4aae75484..ddca13914 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java @@ -31,6 +31,8 @@ package com.jogamp.opengl.test.junit.jogl.swt; import java.lang.reflect.InvocationTargetException; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; @@ -158,6 +160,15 @@ public class TestSWTAccessor02NewtGLWindow extends UITestCase { SWTAccessor.invoke(true, new Runnable() { public void run() { canvas[0] = new Canvas (composite, SWT.NO_BACKGROUND); + canvas[0].setBackground(new Color(display, 255, 255, 255)); + canvas[0].setForeground(new Color(display, 255, 0, 0)); + canvas[0].addPaintListener (new PaintListener() { + public void paintControl(final PaintEvent e) { + final Rectangle r = canvas[0].getClientArea(); + e.gc.fillRectangle(0, 0, r.width, r.height); + e.gc.drawRectangle(50, 50, r.width-100, r.height-100); + e.gc.drawString("I am a Canvas", r.width/2, r.height/2); + }}); shell.setText( getClass().getName() ); shell.setBounds( 0, 0, 700, 700 ); shell.open(); -- cgit v1.2.3