use of com.servoy.j2db.server.headlessclient.WrapperContainer in project servoy-client by Servoy.
the class WebAnchoringHelper method getWrapperComponent.
public static Component getWrapperComponent(Component comp, IFormElement obj, int start, Dimension panelSize, boolean leftToRight, boolean isInListView) {
MarkupContainer compWrapper = new WrapperContainer(ComponentFactory.getWebID(null, obj) + TemplateGenerator.WRAPPER_SUFFIX, comp);
Point l = (obj).getLocation();
if (isInListView) {
// substract left indicator
l.x = Math.max(l.x - 3, 0);
}
Dimension s = (obj).getSize();
int anchors = 0;
if (obj instanceof ISupportAnchors)
anchors = ((ISupportAnchors) obj).getAnchors();
int offsetWidth = s.width;
int offsetHeight = s.height;
if (comp instanceof ISupportWebBounds) {
Rectangle b = ((ISupportWebBounds) comp).getWebBounds();
offsetWidth = b.width;
offsetHeight = b.height;
}
final String styleToReturn = WebAnchoringHelper.computeWrapperDivStyle(l.y, l.x, offsetWidth, offsetHeight, s.width, s.height, anchors, start, start + panelSize.height, panelSize.width, leftToRight);
// first the default
compWrapper.add(new StyleAppendingModifier(new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return styleToReturn;
}
}));
// then the style t hat can be set on the wrapped component
compWrapper.add(StyleAttributeModifierModel.INSTANCE);
// TODO: this needs to be done in a cleaner way. See what is the relation between
// margin, padding and border when calculating the websize in ChangesRecorder vs. TemplateGenerator.
// Looks like one of the three is not taken into account during calculations. For now decided to remove
// the margin and leave the padding and border.
comp.add(new StyleAppendingModifier(new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
// $NON-NLS-1$
return "margin: 0px;";
}
}));
return compWrapper;
}
Aggregations