View Javadoc
1   package org.argeo.cms.ui.util;
2   
3   import org.argeo.cms.ui.UxContext;
4   import org.eclipse.swt.graphics.Point;
5   import org.eclipse.swt.graphics.Rectangle;
6   import org.eclipse.swt.widgets.Display;
7   
8   public class SimpleUxContext implements UxContext {
9   	private Point size;
10  	private Point small = new Point(400, 400);
11  
12  	public SimpleUxContext() {
13  		this(Display.getCurrent().getBounds());
14  	}
15  
16  	public SimpleUxContext(Rectangle rect) {
17  		this.size = new Point(rect.width, rect.height);
18  	}
19  
20  	public SimpleUxContext(Point size) {
21  		this.size = size;
22  	}
23  
24  	@Override
25  	public boolean isPortrait() {
26  		return size.x >= size.y;
27  	}
28  
29  	@Override
30  	public boolean isLandscape() {
31  		return size.x < size.y;
32  	}
33  
34  	@Override
35  	public boolean isSquare() {
36  		return size.x == size.y;
37  	}
38  
39  	@Override
40  	public boolean isSmall() {
41  		return size.x <= small.x || size.y <= small.y;
42  	}
43  
44  	@Override
45  	public boolean isMasterData() {
46  		// TODO make it configurable
47  		return true;
48  	}
49  
50  }