use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.
the class AlignProperty method setValueImpl.
protected void setValueImpl(final RadComponent component, final Integer value) throws Exception {
int anchorMask = myHorizontal ? 0x0C : 3;
int fillMask = myHorizontal ? 1 : 2;
int anchor = 0;
int fill = 0;
switch(value.intValue()) {
case GridConstraints.ALIGN_FILL:
fill = myHorizontal ? GridConstraints.FILL_HORIZONTAL : GridConstraints.FILL_VERTICAL;
break;
case GridConstraints.ALIGN_LEFT:
anchor = myHorizontal ? GridConstraints.ANCHOR_WEST : GridConstraints.ANCHOR_NORTH;
break;
case GridConstraints.ALIGN_RIGHT:
anchor = myHorizontal ? GridConstraints.ANCHOR_EAST : GridConstraints.ANCHOR_SOUTH;
break;
}
GridConstraints gc = component.getConstraints();
GridConstraints oldGC = (GridConstraints) gc.clone();
gc.setAnchor((gc.getAnchor() & ~anchorMask) | anchor);
gc.setFill((gc.getFill() & ~fillMask) | fill);
AlignPropertyProvider provider = getAlignPropertyProvider(component);
if (provider != null) {
provider.setAlignment(component, myHorizontal, value.intValue());
}
component.fireConstraintsChanged(oldGC);
}
use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.
the class RadFormLayoutManager method gridToCellConstraints.
private static CellConstraints gridToCellConstraints(final RadComponent component) {
GridConstraints gc = component.getConstraints();
CellConstraints.Alignment hAlign = ((gc.getHSizePolicy() & GridConstraints.SIZEPOLICY_WANT_GROW) != 0) ? CellConstraints.FILL : CellConstraints.DEFAULT;
CellConstraints.Alignment vAlign = ((gc.getVSizePolicy() & GridConstraints.SIZEPOLICY_WANT_GROW) != 0) ? CellConstraints.FILL : CellConstraints.DEFAULT;
if (component.getCustomLayoutConstraints() instanceof CellConstraints) {
CellConstraints cc = (CellConstraints) component.getCustomLayoutConstraints();
hAlign = cc.hAlign;
vAlign = cc.vAlign;
}
return new CellConstraints(gc.getColumn() + 1, gc.getRow() + 1, gc.getColSpan(), gc.getRowSpan(), hAlign, vAlign);
}
use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.
the class RadAbstractGridLayoutManager method moveComponent.
@Override
public void moveComponent(RadComponent c, int rowDelta, int colDelta, final int rowSpanDelta, final int colSpanDelta) {
GridConstraints constraints = c.getConstraints();
GridConstraints oldConstraints = (GridConstraints) constraints.clone();
constraints.setRow(getNewRow(c, rowDelta));
constraints.setColumn(getNewColumn(c, colDelta));
constraints.setRowSpan(getNewRowSpan(c, rowSpanDelta));
constraints.setColSpan(getNewColSpan(c, colSpanDelta));
c.fireConstraintsChanged(oldConstraints);
}
use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.
the class RadAbstractGridLayoutManager method getComponentAtGrid.
@Nullable
public static RadComponent getComponentAtGrid(RadContainer container, final int row, final int column) {
// If the target cell is not empty does not allow drop.
for (int i = 0; i < container.getComponentCount(); i++) {
final RadComponent component = container.getComponent(i);
if (component.isDragging()) {
continue;
}
final GridConstraints constraints = component.getConstraints();
if (constraints.getRow() <= row && row < constraints.getRow() + constraints.getRowSpan() && constraints.getColumn() <= column && column < constraints.getColumn() + constraints.getColSpan()) {
return component;
}
}
return null;
}
use of com.intellij.uiDesigner.core.GridConstraints in project intellij-community by JetBrains.
the class RadAbstractGridLayoutManager method writeGridConstraints.
protected static void writeGridConstraints(final XmlWriter writer, final RadComponent child) {
// Constraints in Grid layout
writer.startElement("grid");
try {
final GridConstraints constraints = child.getConstraints();
writer.addAttribute("row", constraints.getRow());
writer.addAttribute("column", constraints.getColumn());
writer.addAttribute("row-span", constraints.getRowSpan());
writer.addAttribute("col-span", constraints.getColSpan());
writer.addAttribute("vsize-policy", constraints.getVSizePolicy());
writer.addAttribute("hsize-policy", constraints.getHSizePolicy());
writer.addAttribute("anchor", constraints.getAnchor());
writer.addAttribute("fill", constraints.getFill());
writer.addAttribute(UIFormXmlConstants.ATTRIBUTE_INDENT, constraints.getIndent());
writer.addAttribute(UIFormXmlConstants.ATTRIBUTE_USE_PARENT_LAYOUT, constraints.isUseParentLayout());
// preferred size
writer.writeDimension(constraints.myMinimumSize, "minimum-size");
writer.writeDimension(constraints.myPreferredSize, "preferred-size");
writer.writeDimension(constraints.myMaximumSize, "maximum-size");
} finally {
// grid
writer.endElement();
}
}
Aggregations