Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Canvas overlaying Shell
Canvas overlaying Shell [message #780966] Fri, 20 January 2012 04:04 Go to next message
Paul Morris is currently offline Paul Morris
Messages: 9
Registered: December 2011
Junior Member
Is it possible to position a canvas to overlay the shell wherein it takes up the whole space that the shell does? I've tried looking into layouts and trying to force the canvas to overlay the shell by using setLocation and setBounds but I think I'm working against the API here. I'm doing this:


getWindowConfigurer().setShellStyle(SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_BACKGROUND);


then this:


Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension dim = toolkit.getScreenSize();
Shell shell = getWindowConfigurer().getWindow().getShell();
shell.setBounds(new Rectangle(0, 0, (int)dim.getWidth(), (int)dim.getHeight()));
shell.setAlpha(20);


and then this (with parent being a reference to the shell):


FillLayout fill = new FillLayout();
parent.setLayout(fill);
final Canvas paintCanvas = new Canvas(parent, SWT.NO_REDRAW_RESIZE | SWT.NONE);
paintCanvas.setLocation(0, 0);
paintCanvas.setBounds(parent.getBounds());
Re: Canvas overlaying Shell [message #781145 is a reply to message #780966] Fri, 20 January 2012 17:25 Go to previous message
Brian de Alwis is currently offline Brian de Alwis
Messages: 189
Registered: January 2012
Senior Member

A layout is responsible for managing the children's positions and bounds. The next time your shell is moved or resized, your canvas may be resized. You either do manual positioning OR you use a layout.

Though in your case, providing the shell has no other children, the FillLayout should do exactly hat you want.

BTW: I'm assuming the Toolkit calls are to the AWT toolkit: avoid mixing SWT and Swing/AWT. You can get the screen details from SWT's Display.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Problems with the tutorial HelloWorldSWT
Next Topic:Simple Example of Drawing Rectangle with Mouse
Goto Forum:
  


Current Time: Mon Sep 22 00:13:19 GMT 2014

Powered by FUDForum. Page generated in 0.10339 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software