Search in sources :

Example 6 with Grid

use of com.codename1.ui.layouts.mig.Grid in project CodenameOne by codenameone.

the class GridBagLayoutInfo method arrangeGridImpl.

private void arrangeGridImpl(Container parent, ParentInfo info) {
    validate(parent, info);
    // Do not check clientRect for emptiness. Grid must be updated anyway
    Rectangle clientRect = new Rectangle(0, 0, parent.getWidth(), parent.getHeight());
    info.grid.fit2Client(clientRect);
}
Also used : Rectangle(com.codename1.ui.geom.Rectangle)

Example 7 with Grid

use of com.codename1.ui.layouts.mig.Grid in project CodenameOne by codenameone.

the class MenuBar method calculateTouchCommandGridColumns.

/**
 * Calculates the amount of columns to give to the touch commands within the
 * grid
 *
 * @param grid container that will be arranged in the grid containing the
 * components
 * @return an integer representing the touch command grid size
 */
protected int calculateTouchCommandGridColumns(Container grid) {
    int count = grid.getComponentCount();
    int maxWidth = 10;
    for (int iter = 0; iter < count; iter++) {
        Component c = grid.getComponentAt(iter);
        Style s = c.getUnselectedStyle();
        // bidi doesn't matter since this is just a summary of width
        maxWidth = Math.max(maxWidth, c.getPreferredW() + s.getHorizontalMargins());
    }
    return Math.max(2, Display.getInstance().getDisplayWidth() / maxWidth);
}
Also used : Style(com.codename1.ui.plaf.Style)

Aggregations

Style (com.codename1.ui.plaf.Style)3 TextArea (com.codename1.ui.TextArea)2 Dimension (com.codename1.ui.geom.Dimension)2 Rectangle (com.codename1.ui.geom.Rectangle)2 Button (com.codename1.ui.Button)1 CheckBox (com.codename1.ui.CheckBox)1 Command (com.codename1.ui.Command)1 Container (com.codename1.ui.Container)1 Dialog (com.codename1.ui.Dialog)1 BoxLayout (com.codename1.ui.layouts.BoxLayout)1 GridLayout (com.codename1.ui.layouts.GridLayout)1 ComponentWrapper (com.codename1.ui.layouts.mig.ComponentWrapper)1 ContainerWrapper (com.codename1.ui.layouts.mig.ContainerWrapper)1 Grid (com.codename1.ui.layouts.mig.Grid)1