Search in sources :

Example 11 with Layout

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);
        }
    }
}
Also used : Container(com.codename1.ui.Container)

Example 12 with Layout

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);
    }
}
Also used : Iterator(java.util.Iterator) Component(com.codename1.ui.Component)

Example 13 with Layout

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();
    }
}
Also used : Layout(com.codename1.ui.layouts.Layout)

Example 14 with Layout

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;
}
Also used : CC(com.codename1.ui.layouts.mig.CC) Container(com.codename1.ui.Container) ComponentWrapper(com.codename1.ui.layouts.mig.ComponentWrapper)

Example 15 with Layout

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));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JList(javax.swing.JList) Component(java.awt.Component) JComponent(javax.swing.JComponent) TableLayout(com.codename1.ui.table.TableLayout) Point(java.awt.Point)

Aggregations

BorderLayout (com.codename1.ui.layouts.BorderLayout)9 Layout (com.codename1.ui.layouts.Layout)8 BoxLayout (com.codename1.ui.layouts.BoxLayout)7 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)7 Component (com.codename1.ui.Component)6 FlowLayout (com.codename1.ui.layouts.FlowLayout)5 Container (com.codename1.ui.Container)4 TableLayout (com.codename1.ui.table.TableLayout)4 Form (com.codename1.ui.Form)3 TextArea (com.codename1.ui.TextArea)3 Dimension (com.codename1.ui.geom.Dimension)3 ArrayList (java.util.ArrayList)3 Button (com.codename1.ui.Button)2 CheckBox (com.codename1.ui.CheckBox)2 Dialog (com.codename1.ui.Dialog)2 Label (com.codename1.ui.Label)2 List (com.codename1.ui.List)2 RadioButton (com.codename1.ui.RadioButton)2 Slider (com.codename1.ui.Slider)2 Tabs (com.codename1.ui.Tabs)2