use of com.codename1.ui.layouts.Layout in project CodenameOne by codenameone.
the class MultiButton method setLinesTogetherMode.
/**
* Changes the layout so the lines of the button are grouped together
* @param l true to group the lines together
*/
public void setLinesTogetherMode(boolean l) {
if (l != isLinesTogetherMode()) {
if (l) {
firstRow.getParent().removeComponent(firstRow);
Container p = secondRow.getParent();
p.addComponent(0, firstRow);
Container pp = p.getParent();
pp.removeComponent(p);
pp.addComponent(BorderLayout.CENTER, p);
} else {
secondRow.getParent().removeComponent(secondRow);
thirdRow.getParent().addComponent(0, secondRow);
}
}
}
use of com.codename1.ui.layouts.Layout in project CodenameOne by codenameone.
the class GroupLayout method layoutContainer.
/**
* Returns the minimum size for the specified container.
*
* @param parent the container to return size for
* @throws IllegalArgumentException if <code>parent</code> is not
* the same <code>Container</code> that this was created with
* @throws IllegalStateException if any of the components added to
* this layout are not in both a horizontal and vertical group
* @see java.awt.Container#getMinimumSize
*/
/*public Dimension minimumLayoutSize(Container parent) {
checkParent(parent);
prepare(MIN_SIZE);
return adjustSize(horizontalGroup.getMinimumSize(HORIZONTAL),
verticalGroup.getMinimumSize(VERTICAL));
}*/
/**
* Lays out the specified container.
*
* @param parent the container to be laid out
* @throws IllegalStateException if any of the components added to
* this layout are not in both a horizontal and vertical group
*/
public void layoutContainer(Container parent) {
// Step 1: Prepare for layout.
prepare(SPECIFIC_SIZE);
int insetLeft = parent.getStyle().getMarginLeftNoRTL();
int insetTop = parent.getStyle().getMarginTop();
int insetRight = parent.getStyle().getMarginRightNoRTL();
int insetBottom = parent.getStyle().getMarginBottom();
int width = parent.getWidth() - insetLeft - insetRight;
int height = parent.getHeight() - insetTop - insetBottom;
boolean ltr = isLeftToRight();
if (getAutocreateGaps() || getAutocreateContainerGaps() || hasPreferredPaddingSprings) {
// Step 2: Calculate autopadding springs
calculateAutopadding(horizontalGroup, HORIZONTAL, SPECIFIC_SIZE, 0, width);
calculateAutopadding(verticalGroup, VERTICAL, SPECIFIC_SIZE, 0, height);
}
// Step 3: set the size of the groups.
horizontalGroup.setSize(HORIZONTAL, 0, width);
verticalGroup.setSize(VERTICAL, 0, height);
// Step 4: apply the size to the components.
Iterator componentInfo = componentInfos.values().iterator();
while (componentInfo.hasNext()) {
ComponentInfo info = (ComponentInfo) componentInfo.next();
Component c = info.getComponent();
info.setBounds(insetLeft, insetTop, width, ltr);
}
}
use of com.codename1.ui.layouts.Layout in project CodenameOne by codenameone.
the class MigLayout method resetLastInvalidOnParent.
/**
* @since 3.7.3
*/
private void resetLastInvalidOnParent(Container parent) {
while (parent != null) {
Layout layoutManager = parent.getLayout();
if (layoutManager instanceof MigLayout) {
((MigLayout) layoutManager).lastWasInvalid = false;
}
parent = parent.getParent();
}
}
use of com.codename1.ui.layouts.Layout in project CodenameOne by codenameone.
the class MigLayout method setComponentConstraintsImpl.
/**
* Sets the component constraint for the component that already must be
* handled by this layout manager.
* <p>
* See the class JavaDocs for information on how this string is formatted.
*
* @param constr The component constraints as a String or
* {@link net.miginfocom.layout.CC}. <code>null</code> is ok.
* @param comp The component to set the constraints for.
* @param noCheck Doe not check if the component is handled if true
* @throws RuntimeException if the constraint was not valid.
* @throws IllegalArgumentException If the component is not handling the
* component.
*/
private void setComponentConstraintsImpl(Component comp, Object constr, boolean noCheck) {
Container parent = comp.getParent();
if (noCheck == false && scrConstrMap.containsKey(comp) == false) {
throw new IllegalArgumentException("Component must already be added to parent!");
}
ComponentWrapper cw = new CodenameOneMiGComponentWrapper(comp);
if (constr == null || constr instanceof String) {
String cStr = ConstraintParser.prepare((String) constr);
scrConstrMap.put(comp, constr);
ccMap.put(cw, ConstraintParser.parseComponentConstraint(cStr));
} else if (constr instanceof CC) {
scrConstrMap.put(comp, constr);
ccMap.put(cw, (CC) constr);
} else {
throw new IllegalArgumentException("Constraint must be String or ComponentConstraint: " + constr.getClass().toString());
}
dirty = true;
}
use of com.codename1.ui.layouts.Layout in project CodenameOne by codenameone.
the class UserInterfaceEditor method reflowTableLayout.
private void reflowTableLayout(com.codename1.ui.Container parent) {
// affects the layout initially
if (parent.getLayout() instanceof com.codename1.ui.table.TableLayout) {
List<com.codename1.ui.Component> cmpList = new ArrayList<com.codename1.ui.Component>();
List constraintList = new ArrayList();
for (int iter = 0; iter < parent.getComponentCount(); iter++) {
com.codename1.ui.Component currentCmp = parent.getComponentAt(iter);
cmpList.add(currentCmp);
constraintList.add(parent.getLayout().getComponentConstraint(currentCmp));
}
parent.removeAll();
for (int iter = 0; iter < cmpList.size(); iter++) {
parent.addComponent(constraintList.get(iter), cmpList.get(iter));
}
}
}
Aggregations