Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Control positions are wrong ?
Control positions are wrong ? [message #845695] Sun, 15 April 2012 10:11 Go to next message
Nicola Zanaga is currently offline Nicola ZanagaFriend
Messages: 56
Registered: July 2009
Member
If i create a shell and a control on position (0,0) the control is over the shell bar.

Eclispe 4.2 with RAP 1.5M6


Display display = new Display ();
Shell shell = new Shell(display);
shell.setSize(600,300);

Text t = new Text(shell, SWT.BORDER);
t.setBounds( 0, 0, 200,50 );
t.setText("sample");
t.setBackground( display.getSystemColor(SWT.COLOR_RED) );

shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
Re: Control positions are wrong ? [message #845796 is a reply to message #845695] Sun, 15 April 2012 12:33 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 335
Registered: July 2009
Senior Member
Nicola,

SWT/RWT has the concept of a client area. The client area of a Composite
is a rectangle that describes the area within which other controls may
be placed. Use getClinentArea() to position controls inside a composite.
For example:
Rectangle clientArea = parent.getClientArea();
control.setBounds( clientArea.x, clientArea.y, 200,50 );

However, the recommended way to position widgets in SWT is to use layouts.

HTH
Rüdiger

On 15.04.2012 12:11, Nicola Zanaga wrote:
> If i create a shell and a control on position (0,0) the control is over
> the shell bar.
>
> Eclispe 4.2 with RAP 1.5M6
>
>
> Display display = new Display ();
> Shell shell = new Shell(display);
> shell.setSize(600,300);
>
> Text t = new Text(shell, SWT.BORDER);
> t.setBounds( 0, 0, 200,50 );
> t.setText("sample");
> t.setBackground( display.getSystemColor(SWT.COLOR_RED) );
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
--
Rüdiger Herrmann
http://codeaffine.com
Re: Control positions are wrong ? [message #845835 is a reply to message #845796] Sun, 15 April 2012 13:17 Go to previous messageGo to next message
Nicola Zanaga is currently offline Nicola ZanagaFriend
Messages: 56
Registered: July 2009
Member
thanks for the quick reply.
I know the client area, but in SWT Shell doesn't consider the shell BAR and position (0,0) will not draw in the shell bar.

For compability, I think RAP should must do the same
Re: Control positions are wrong ? [message #846694 is a reply to message #845835] Mon, 16 April 2012 08:54 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 335
Registered: July 2009
Senior Member
On 15.04.2012 15:17, Nicola Zanaga wrote:
> thanks for the quick reply.
> I know the client area, but in SWT Shell doesn't consider the shell BAR
> and position (0,0) will not draw in the shell bar.
This is only true for certain platforms and widgets.
From the "SWT book", chapter 4.2 [1]:
"Very often, the location of the client area within the control is (0,
0), but this is not always the case."

>
> For compability, I think RAP should must do the same
Regarding the client area, RAP is 100 percent compatible with SWT.

--
Rüdiger Herrmann
http://codeaffine.com

[1] http://books.google.de/books/about/SWT.html?id=Z9RQAAAAMAAJ&redir_esc=y
Re: Control positions are wrong ? [message #846696 is a reply to message #845835] Mon, 16 April 2012 09:19 Go to previous message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Although it works on most platforms, it's a mistake to position any
widget to (0,0) without taking the client area into account. See also
bug 332887 [1]. Correct code will work on SWT and RAP alike.

Regards, Ralf

[1] SWT Snippets use incorrect positioning
https://bugs.eclipse.org/bugs/show_bug.cgi?id=332887

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:Strange behavior with CLabel and his client area
Next Topic:Text widget, key event and caret position
Goto Forum:
  


Current Time: Thu Apr 25 05:43:34 GMT 2024

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

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

Back to the top