Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Layout Problems
Layout Problems [message #505300] Tue, 29 December 2009 12:31 Go to next message
Jordan Borisov is currently offline Jordan BorisovFriend
Messages: 9
Registered: July 2009
Junior Member
I have problems with getting the size and the location of layout widget for example a Canvas. The layout which I'm using is GridLayout and I need the height and the width of the canvas but I can't get them.
The result of calling the method getSize is 0 - width , 0- height.
My question is how can I get the size of a canvas when I'm using layouts?
Re: Layout Problems [message #505650 is a reply to message #505300] Mon, 04 January 2010 02:06 Go to previous messageGo to next message
Jordan Borisov is currently offline Jordan BorisovFriend
Messages: 9
Registered: July 2009
Junior Member
I found a way to get the size of Canvas positioned with layout. In a paint listener I can get the bounds of the widget. But I don't like this method because I can't use the size parameters before the widget is painted.
How can I get the size of a Canvas without a paint listener?
Re: Layout Problems [message #505717 is a reply to message #505650] Mon, 04 January 2010 16:25 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi,

A Control's size is 0,0 until it has been set, either by you (eg.- with
Control.setSize(...)), or by a layout. Once it has been set then
Control.getSize() should always work. Are you asking it for its size before
it has been laid out? If so, maybe
Control.computeSize(SWT.DEFAULT,SWT.DEFAULT) is what you want (in which case
the default answer for Canvas is 64x64)?

Grant


"Jordan Borisov" <xstream9014@gmail.com> wrote in message
news:hhs3vu$5n0$1@build.eclipse.org...
> I found a way to get the size of Canvas positioned with layout. In a
paint listener I can get the bounds of the widget. But I don't like this
method because I can't use the size parameters before the widget is
painted.
> How can I get the size of a Canvas without a paint listener?
Previous Topic:[Linux/GTK Q] How are the arrow keys, pgup/pgdn, & bksp read differently than other keys?
Next Topic:Reparenting shell problem
Goto Forum:
  


Current Time: Mon Dec 09 04:19:45 GMT 2024

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

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

Back to the top