use of org.apache.pivot.wtk.Sheet in project pivot by apache.
the class TerraSheetSkin method getPreferredHeight.
@Override
public int getPreferredHeight(int width) {
int preferredHeight = 0;
Sheet sheet = (Sheet) getComponent();
Component content = sheet.getContent();
if (content != null) {
if (width != -1) {
width = Math.max(width - (padding.getWidth() + 2), 0);
}
preferredHeight = content.getPreferredHeight(width);
}
preferredHeight += (padding.getHeight() + 2);
return preferredHeight;
}
use of org.apache.pivot.wtk.Sheet in project pivot by apache.
the class TerraSheetSkin method mouseDown.
@Override
public boolean mouseDown(Container container, Mouse.Button button, int x, int y) {
Sheet sheet = (Sheet) container;
if (!sheet.isTopMost()) {
Window owner = sheet.getOwner();
owner.moveToFront();
}
boolean consumed = super.mouseDown(container, button, x, y);
if (resizable && button == Mouse.Button.LEFT) {
Bounds resizeHandleBounds = resizeHandle.getBounds();
if (resizeHandleBounds.contains(x, y)) {
resizeOffset = new Point(getWidth() - x, getHeight() - y);
Mouse.capture(container);
}
}
return consumed;
}
use of org.apache.pivot.wtk.Sheet in project pivot by apache.
the class TerraSheetSkin method keyPressed.
/**
* {@link KeyCode#ENTER ENTER} Close the sheet with a 'result' of true.<br>
* {@link KeyCode#ESCAPE ESCAPE} Close the sheet with a 'result' of false.
*/
@Override
public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
boolean consumed = false;
Sheet sheet = (Sheet) getComponent();
if (keyCode == Keyboard.KeyCode.ENTER) {
sheet.close(true);
consumed = true;
} else if (keyCode == Keyboard.KeyCode.ESCAPE) {
sheet.close(false);
consumed = true;
} else {
consumed = super.keyPressed(component, keyCode, keyLocation);
}
return consumed;
}
use of org.apache.pivot.wtk.Sheet in project pivot by apache.
the class TerraSheetSkin method layout.
@Override
public void layout() {
int width = getWidth();
int height = getHeight();
Sheet sheet = (Sheet) getComponent();
// Size/position resize handle
resizeHandle.setSize(resizeHandle.getPreferredSize());
resizeHandle.setLocation(width - resizeHandle.getWidth() - 2, height - resizeHandle.getHeight() - 2);
resizeHandle.setVisible(resizable && !sheet.isMaximized() && (sheet.isPreferredWidthSet() || sheet.isPreferredHeightSet()));
Component content = sheet.getContent();
if (content != null) {
content.setLocation(padding.left + 1, padding.top + 1);
int contentWidth = Math.max(width - (padding.getWidth() + 2), 0);
int contentHeight = Math.max(height - (padding.getHeight() + 2), 0);
content.setSize(contentWidth, contentHeight);
}
}
use of org.apache.pivot.wtk.Sheet in project pivot by apache.
the class TerraSheetSkin method getPreferredSize.
@Override
public Dimensions getPreferredSize() {
Dimensions preferredSize = Dimensions.ZERO;
Sheet sheet = (Sheet) getComponent();
Component content = sheet.getContent();
if (content != null) {
preferredSize = content.getPreferredSize();
}
// Account for border in the size
return preferredSize.expand(2).expand(padding);
}
Aggregations