Java Code Examples for org.eclipse.swt.widgets.Display.map()

The following are Jave code examples for showing how to use map() of the org.eclipse.swt.widgets.Display class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: xcalendar   File: XCalendarDefaultLayout.java   Source Code and License Vote up 6 votes
/**
 * 
 */
protected void setLocation(final XCalendar popup) {
	//
	final Shell shell = popup.getShell();
	final Display display = popup.getDisplay();
	final Rectangle r1 = display.map(prevParent, null, prevBounds);
	final Rectangle r2 = popup.getMonitor().getClientArea(); // Client area
	
	//
	final int margin = 2;
	final Point size = shell.getSize();
	int x = r1.x, y = r1.y + r1.height + margin;
	if(y + size.y > r2.y + r2.height) y = r1.y - size.y - margin;
	if(x < r2.x) x = r2.x; else if(x + size.x > r2.x + r2.width) x = r2.x + r2.width - size.x;
	shell.setLocation(x, y);
}