Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How translate between display and control coordinates?
How translate between display and control coordinates? [message #441984] Fri, 27 August 2004 00:32 Go to next message
Jonathan Edwards is currently offline Jonathan EdwardsFriend
Messages: 27
Registered: July 2009
Junior Member
I want to map the current mouse cursor (in Display coord's) to a
control's coordinate system.

The obvious algorithm of adding up the getLocation() of the parents up
to the Shell doesn't work. Shell.getLocation() returns the location of
the upper left corner of the outside of the shell's trim, while all the
controls inside are relative to the inside of the trim. How do I account
for the trim size? Is this a bug or just impossible through the API?
[Eclipse 3.0, Win XP]

Thanks,
Jonathan
Re: How translate between display and control coordinates? [message #441985 is a reply to message #441984] Fri, 27 August 2004 00:59 Go to previous message
Peter Sommerfeld is currently offline Peter SommerfeldFriend
Messages: 12
Registered: July 2009
Junior Member
"Jonathan Edwards" wrote:
> I want to map the current mouse cursor (in Display coord's) to a
> control's coordinate system.

import org.eclipse.swt.widgets.*;

Point map(Control from, Control to, Point point)
Point map(Control from, Control to, int x, int y)

Rectangle map(Control from, Control to, Rectangle)
Rectangle map(Control from, Control to, int x, int y, int width, int height)

Point xy = display.map(display, shell, mouse.x, mouse.y);

regards

Peter
Previous Topic:new SWT article: Viewing HTML pages with SWT Browser widget
Next Topic:A question about Table/TableViewer
Goto Forum:
  


Current Time: Thu May 09 15:36:17 GMT 2024

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

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

Back to the top