use of org.apache.pivot.wtk.Cursor in project pivot by apache.
the class TerraSheetSkin method mouseMove.
@Override
public boolean mouseMove(Component component, int x, int y) {
boolean consumed = super.mouseMove(component, x, y);
if (Mouse.getCapturer() == component) {
Sheet sheet = (Sheet) getComponent();
Display display = sheet.getDisplay();
Point location = sheet.mapPointToAncestor(display, x, y);
// Pretend that the mouse can't move off screen (off the display)
location = new Point(Math.min(Math.max(location.x, 0), display.getWidth() - 1), Math.min(Math.max(location.y, 0), display.getHeight() - 1));
if (resizeOffset != null) {
// Resize the frame
int preferredWidth = -1;
int preferredHeight = -1;
boolean preferredWidthSet = component.isPreferredWidthSet();
boolean preferredHeightSet = component.isPreferredHeightSet();
boolean noPreferredSet = !(preferredWidthSet || preferredHeightSet);
if (preferredWidthSet || noPreferredSet) {
preferredWidth = Math.max(location.x - sheet.getX() + resizeOffset.x, 2);
preferredWidth = Math.min(preferredWidth, sheet.getMaximumWidth());
preferredWidth = Math.max(preferredWidth, sheet.getMinimumWidth());
}
if (preferredHeightSet || noPreferredSet) {
preferredHeight = Math.max(location.y - sheet.getY() + resizeOffset.y, resizeHandle.getHeight() + 7);
preferredHeight = Math.min(preferredHeight, sheet.getMaximumHeight());
preferredHeight = Math.max(preferredHeight, sheet.getMinimumHeight());
}
sheet.setPreferredSize(preferredWidth, preferredHeight);
}
} else {
Cursor cursor = null;
Bounds resizeHandleBounds = resizeHandle.getBounds();
if (resizable && resizeHandleBounds.contains(x, y)) {
boolean preferredWidthSet = component.isPreferredWidthSet();
boolean preferredHeightSet = component.isPreferredHeightSet();
if (preferredWidthSet && preferredHeightSet) {
cursor = Cursor.RESIZE_SOUTH_EAST;
} else if (preferredWidthSet) {
cursor = Cursor.RESIZE_EAST;
} else if (preferredHeightSet) {
cursor = Cursor.RESIZE_SOUTH;
} else {
cursor = Cursor.RESIZE_SOUTH_EAST;
}
}
component.setCursor(cursor);
}
return consumed;
}
use of org.apache.pivot.wtk.Cursor in project pivot by apache.
the class TerraPaletteSkin method mouseMove.
@Override
public boolean mouseMove(Component component, int x, int y) {
boolean consumed = super.mouseMove(component, x, y);
if (Mouse.getCapturer() == component) {
Palette palette = (Palette) getComponent();
Display display = palette.getDisplay();
Point location = palette.mapPointToAncestor(display, x, y);
// Pretend that the mouse can't move off screen (off the display)
location = new Point(Math.min(Math.max(location.x, 0), display.getWidth() - 1), Math.min(Math.max(location.y, 0), display.getHeight() - 1));
if (dragOffset != null) {
// Move the window
palette.setLocation(location.x - dragOffset.x, location.y - dragOffset.y);
} else {
if (resizeOffset != null) {
// Resize the frame
int preferredWidth = -1;
int preferredHeight = -1;
if (palette.isPreferredWidthSet()) {
preferredWidth = Math.max(location.x - palette.getX() + resizeOffset.x, titleBarTablePane.getPreferredWidth(-1) + 2);
preferredWidth = Math.min(preferredWidth, palette.getMaximumWidth());
preferredWidth = Math.max(preferredWidth, palette.getMinimumWidth());
}
if (palette.isPreferredHeightSet()) {
preferredHeight = Math.max(location.y - palette.getY() + resizeOffset.y, titleBarTablePane.getHeight() + resizeHandle.getHeight() + 7);
preferredHeight = Math.min(preferredHeight, palette.getMaximumHeight());
preferredHeight = Math.max(preferredHeight, palette.getMinimumHeight());
}
palette.setPreferredSize(preferredWidth, preferredHeight);
}
}
} else {
Cursor cursor = null;
if (resizeHandle.isVisible() && x > resizeHandle.getX() && y > resizeHandle.getY()) {
boolean preferredWidthSet = component.isPreferredWidthSet();
boolean preferredHeightSet = component.isPreferredHeightSet();
if (preferredWidthSet && preferredHeightSet) {
cursor = Cursor.RESIZE_SOUTH_EAST;
} else if (preferredWidthSet) {
cursor = Cursor.RESIZE_EAST;
} else if (preferredHeightSet) {
cursor = Cursor.RESIZE_SOUTH;
}
}
component.setCursor(cursor);
}
return consumed;
}
use of org.apache.pivot.wtk.Cursor in project pivot by apache.
the class TerraFrameSkin method mouseMove.
@Override
public boolean mouseMove(Component component, int x, int y) {
boolean consumed = super.mouseMove(component, x, y);
if (Mouse.getCapturer() == component) {
Frame frame = (Frame) getComponent();
Display display = frame.getDisplay();
Point location = frame.mapPointToAncestor(display, x, y);
// Pretend that the mouse can't move off screen (off the display)
location = new Point(Math.min(Math.max(location.x, 0), display.getWidth() - 1), Math.min(Math.max(location.y, 0), display.getHeight() - 1));
if (dragOffset != null) {
// Move the frame
frame.setLocation(location.x - dragOffset.x, location.y - dragOffset.y);
} else {
if (resizeOffset != null) {
// Resize the frame
int preferredWidth = -1;
int preferredHeight = -1;
if (frame.isPreferredWidthSet()) {
preferredWidth = Math.max(location.x - frame.getX() + resizeOffset.x, titleBarTablePane.getPreferredWidth(-1) + 2);
preferredWidth = Math.min(preferredWidth, frame.getMaximumWidth());
preferredWidth = Math.max(preferredWidth, frame.getMinimumWidth());
}
if (frame.isPreferredHeightSet()) {
preferredHeight = Math.max(location.y - frame.getY() + resizeOffset.y, titleBarTablePane.getHeight() + resizeHandle.getHeight() + (showContentBevel ? 1 : 0) + 6);
preferredHeight = Math.min(preferredHeight, frame.getMaximumHeight());
preferredHeight = Math.max(preferredHeight, frame.getMinimumHeight());
}
frame.setPreferredSize(preferredWidth, preferredHeight);
}
}
} else {
Cursor cursor = null;
if (resizeHandle.isVisible() && x > resizeHandle.getX() && y > resizeHandle.getY()) {
boolean preferredWidthSet = component.isPreferredWidthSet();
boolean preferredHeightSet = component.isPreferredHeightSet();
if (preferredWidthSet && preferredHeightSet) {
cursor = Cursor.RESIZE_SOUTH_EAST;
} else if (preferredWidthSet) {
cursor = Cursor.RESIZE_EAST;
} else if (preferredHeightSet) {
cursor = Cursor.RESIZE_SOUTH;
}
}
component.setCursor(cursor);
}
return consumed;
}
use of org.apache.pivot.wtk.Cursor in project pivot by apache.
the class TerraSplitPaneSkin method updateSplitterCursor.
private void updateSplitterCursor() {
Cursor cursor = Cursor.DEFAULT;
SplitPane splitPane = (SplitPane) getComponent();
if (!splitPane.isLocked()) {
switch(splitPane.getOrientation()) {
case HORIZONTAL:
{
switch(splitPane.getPrimaryRegion()) {
case TOP_LEFT:
{
cursor = Cursor.RESIZE_EAST;
break;
}
case BOTTOM_RIGHT:
{
cursor = Cursor.RESIZE_WEST;
break;
}
default:
{
break;
}
}
break;
}
case VERTICAL:
{
switch(splitPane.getPrimaryRegion()) {
case TOP_LEFT:
{
cursor = Cursor.RESIZE_SOUTH;
break;
}
case BOTTOM_RIGHT:
{
cursor = Cursor.RESIZE_NORTH;
break;
}
default:
{
break;
}
}
break;
}
default:
{
break;
}
}
}
splitter.setCursor(cursor);
}
Aggregations