diff options
author | Sven Gothel <[email protected]> | 2019-04-09 12:55:49 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-04-09 12:55:49 +0200 |
commit | a2f09981ee7d590204bf865314c2cdf802c4ed77 (patch) | |
tree | e0d8ea19d3db0eb9f700444a09a22fa91d749849 /src/test/com/jogamp/opengl | |
parent | 9b53619079d29483a487e54ed16ed845dd16bcb0 (diff) |
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?!
Diffstat (limited to 'src/test/com/jogamp/opengl')
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02NewtGLWindow.java | 11 |
1 files changed, 11 insertions, 0 deletions
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(); |