use of com.servoy.j2db.ISupportNavigator in project servoy-client by Servoy.
the class WebForm method getBounds.
public Rectangle getBounds(IComponent component) {
if (// $NON-NLS-1$
component instanceof Component && Utils.getAsBoolean(formController.getApplication().getRuntimeProperties().get("enableAnchors"))) {
IPersist persist = getPersist(((Component) component).getId());
if (persist instanceof ISupportAnchors && ((ISupportAnchors) persist).getAnchors() > 0 && ((ISupportAnchors) persist).getAnchors() != IAnchorConstants.DEFAULT) {
int anchors = ((ISupportAnchors) persist).getAnchors();
IDataRenderer renderer = ((Component) component).findParent(IDataRenderer.class);
int partHeight = 0;
if (renderer != null) {
partHeight = renderer.getSize().height;
}
int designWidth = formController.getForm().getWidth();
int designHeight = 0;
Part part = formController.getForm().getPartAt(((BaseComponent) persist).getLocation().y);
if (part != null) {
int top = formController.getForm().getPartStartYPos(part.getID());
designHeight = part.getHeight() - top;
}
if (partHeight > 0 && formWidth > 0 && designWidth > 0 && designHeight > 0) {
int navid = formController.getForm().getNavigatorID();
int navigatorWidth = 0;
if (navid == Form.NAVIGATOR_DEFAULT && formController.getForm().getView() != FormController.TABLE_VIEW && formController.getForm().getView() != FormController.LOCKED_TABLE_VIEW) {
navigatorWidth = WebDefaultRecordNavigator.DEFAULT_WIDTH;
} else if (navid != Form.NAVIGATOR_NONE) {
ISupportNavigator navigatorSupport = findParent(ISupportNavigator.class);
if (navigatorSupport != null) {
FormController currentNavFC = navigatorSupport.getNavigator();
if (currentNavFC != null) {
navigatorWidth = currentNavFC.getForm().getWidth();
}
}
}
Rectangle bounds = new Rectangle(component.getLocation(), component.getSize());
if ((anchors & IAnchorConstants.EAST) != 0 && (anchors & IAnchorConstants.WEST) == 0) {
bounds.x += formWidth - designWidth - navigatorWidth;
}
if ((anchors & IAnchorConstants.SOUTH) != 0 && (anchors & IAnchorConstants.NORTH) == 0) {
bounds.y += partHeight - designHeight;
}
if ((anchors & IAnchorConstants.EAST) != 0 && (anchors & IAnchorConstants.WEST) != 0 && (formWidth - designWidth - navigatorWidth > 0)) {
bounds.width += formWidth - designWidth - navigatorWidth;
}
if ((anchors & IAnchorConstants.SOUTH) != 0 && (anchors & IAnchorConstants.NORTH) != 0 && (partHeight - designHeight > 0)) {
bounds.height += partHeight - designHeight;
}
return bounds;
}
}
}
return null;
}
Aggregations