Search in sources :

Example 91 with Container

use of com.codename1.ui.Container in project CodenameOne by codenameone.

the class GridBagLayoutInfo method updateParentInfo.

private void updateParentInfo(Container parent) {
    int count = parent.getComponentCount();
    for (int iter = 0; iter < count; iter++) {
        Component element = parent.getComponentAt(iter);
        GridBagConstraints gbc = comptable.get(element);
        updateParentInfo(parent, gbc);
    }
}
Also used : Component(com.codename1.ui.Component)

Example 92 with Container

use of com.codename1.ui.Container in project CodenameOne by codenameone.

the class GridBagLayoutInfo method AdjustForGravity.

/*protected GridBagLayoutInfo getLayoutInfo(Container parent, int sizeflag) {
        return GetLayoutInfo(parent, sizeflag);
    }

    protected Dimension getMinSize(Container parent, GridBagLayoutInfo info) {
        toolkit.lockAWT();
        try {
            return GetMinSize(parent, info);
        } finally {
            toolkit.unlockAWT();
        }
    }*/
protected void AdjustForGravity(GridBagConstraints constraints, Rectangle r) {
    // Don't get parent as param, so have to use older info if exists
    if (layoutInfo == null) {
        r.setBounds(0, 0, 0, 0);
        return;
    }
    GridBagConstraints consClone = (GridBagConstraints) constraints.clone();
    consClone.fill = GridBagConstraints.BOTH;
    ComponentSide horSide = new ComponentSide();
    ComponentSide vertSide = new ComponentSide();
    Dimension dummySize = new Dimension(0, 0);
    initHorCompSide(horSide, consClone, dummySize, dummySize, lastParentInfo);
    initVertCompSide(vertSide, consClone, dummySize, dummySize, lastParentInfo);
    calculateComponentBounds(horSide, vertSide, r, lastParentInfo.grid);
}
Also used : Dimension(com.codename1.ui.geom.Dimension)

Example 93 with Container

use of com.codename1.ui.Container 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 94 with Container

use of com.codename1.ui.Container in project CodenameOne by codenameone.

the class HTMLTable method createCell.

/**
 * This method is overriden to return the component that is contained in the HTMLTableModel
 * (Since our model contains the actual component and does not store data that can be rendered using toString we can't use the original createCell method)
 *
 * @param value the new value object
 * @param row row number, -1 for the header rows
 * @param column column number
 * @param editable true if the cell is editable
 * @return cell component instance
 */
protected Component createCell(Object value, int row, int column, boolean editable) {
    Component cmp = null;
    if (value instanceof Component) {
        cmp = (Component) value;
    // TODO - table cells styling - needs to propogate downwards since the cell is usually a container, on the other hand can't wipe out the style of the container's components - TBD
    // boolean isHeader=((HTMLTableModel)getModel()).isHeader(value);
    // if (isHeader) {
    // cmp.setUIID("TableHeader");
    // } else {
    // cmp.setUIID("TableCell");
    // }
    } else {
        cmp = super.createCell(value, row, column, editable);
    }
    cmp.setFocusable(false);
    return cmp;
}
Also used : Component(com.codename1.ui.Component)

Example 95 with Container

use of com.codename1.ui.Container in project CodenameOne by codenameone.

the class BorderLayout method layoutContainer.

/**
 * {@inheritDoc}
 */
public void layoutContainer(Container target) {
    Style s = target.getStyle();
    int top = s.getPaddingTop();
    int bottom = target.getLayoutHeight() - target.getBottomGap() - s.getPaddingBottom();
    int left = s.getPaddingLeft(target.isRTL());
    int right = target.getLayoutWidth() - target.getSideGap() - s.getPaddingRight(target.isRTL());
    int targetWidth = target.getWidth();
    int targetHeight = target.getHeight();
    boolean rtl = target.isRTL();
    if (rtl) {
        left += target.getSideGap();
    }
    Component east = getEast();
    Component west = getWest();
    Component south = getSouth();
    Component north = getNorth();
    Component center = getCenter();
    if (north != null) {
        Component c = north;
        positionTopBottom(target, c, right, left, targetHeight);
        c.setY(top + c.getStyle().getMarginTop());
        top += (c.getHeight() + c.getStyle().getMarginTop() + c.getStyle().getMarginBottom());
    }
    if (south != null) {
        Component c = south;
        positionTopBottom(target, c, right, left, targetHeight);
        c.setY(bottom - c.getHeight() - c.getStyle().getMarginBottom());
        bottom -= (c.getHeight() + c.getStyle().getMarginTop() + c.getStyle().getMarginBottom());
    }
    Component realEast = east;
    Component realWest = west;
    if (rtl) {
        realEast = west;
        realWest = east;
    }
    if (realEast != null) {
        Component c = realEast;
        positionLeftRight(realEast, targetWidth, bottom, top);
        c.setX(right - c.getWidth() - c.getStyle().getMarginRight(rtl));
        right -= (c.getWidth() + c.getStyle().getHorizontalMargins());
    }
    if (realWest != null) {
        Component c = realWest;
        positionLeftRight(realWest, targetWidth, bottom, top);
        c.setX(left + c.getStyle().getMarginLeft(rtl));
        left += (c.getWidth() + c.getStyle().getMarginLeftNoRTL() + c.getStyle().getMarginRightNoRTL());
    }
    if (center != null) {
        Component c = center;
        int w = right - left - c.getStyle().getMarginLeftNoRTL() - c.getStyle().getMarginRightNoRTL();
        int h = bottom - top - c.getStyle().getMarginTop() - c.getStyle().getMarginBottom();
        int x = left + c.getStyle().getMarginLeft(rtl);
        int y = top + c.getStyle().getMarginTop();
        switch(centerBehavior) {
            case CENTER_BEHAVIOR_CENTER_ABSOLUTE:
                {
                    Dimension d = c.getPreferredSize();
                    if (d.getWidth() < w) {
                        int newX = (s.getPaddingLeft(rtl) - s.getPaddingRight(rtl)) + targetWidth / 2 - d.getWidth() / 2;
                        if (newX > x) {
                            x = newX;
                        }
                        w = d.getWidth();
                    }
                    int append = 0;
                    int th = targetHeight;
                    if (north != null) {
                        append = north.getHeight();
                        th -= append;
                    }
                    if (south != null) {
                        th -= south.getHeight();
                        append += south.getHeight();
                    }
                    if (d.getHeight() < h) {
                        int newY = (s.getPaddingTop() + th) / 2 - d.getHeight() / 2 + append;
                        if (newY > y) {
                            y = newY;
                        }
                        h = d.getHeight();
                    }
                    break;
                }
            case CENTER_BEHAVIOR_CENTER:
                {
                    Dimension d = c.getPreferredSize();
                    if (d.getWidth() < w) {
                        x += w / 2 - d.getWidth() / 2;
                        w = d.getWidth();
                    }
                    if (d.getHeight() < h) {
                        y += h / 2 - d.getHeight() / 2;
                        h = d.getHeight();
                    }
                    break;
                }
            case CENTER_BEHAVIOR_TOTAL_BELOW:
                {
                    w = targetWidth;
                    h = targetHeight;
                    x = s.getPaddingLeft(rtl);
                    y = s.getPaddingTop();
                    ;
                }
        }
        c.setWidth(w);
        c.setHeight(h);
        c.setX(x);
        c.setY(y);
    }
    if (overlay != null) {
        Component c = overlay;
        c.setWidth(targetWidth);
        c.setHeight(targetHeight);
        c.setX(0);
        c.setY(0);
    }
}
Also used : Style(com.codename1.ui.plaf.Style) Component(com.codename1.ui.Component)

Aggregations

Container (com.codename1.ui.Container)85 Component (com.codename1.ui.Component)65 BorderLayout (com.codename1.ui.layouts.BorderLayout)46 Style (com.codename1.ui.plaf.Style)38 ActionEvent (com.codename1.ui.events.ActionEvent)29 Form (com.codename1.ui.Form)26 Label (com.codename1.ui.Label)21 BoxLayout (com.codename1.ui.layouts.BoxLayout)21 Dimension (com.codename1.ui.geom.Dimension)20 ActionListener (com.codename1.ui.events.ActionListener)19 Button (com.codename1.ui.Button)15 FlowLayout (com.codename1.ui.layouts.FlowLayout)15 ArrayList (java.util.ArrayList)14 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)12 TextArea (com.codename1.ui.TextArea)11 Point (com.codename1.ui.geom.Point)11 Rectangle (com.codename1.ui.geom.Rectangle)11 Dialog (com.codename1.ui.Dialog)10 RadioButton (com.codename1.ui.RadioButton)10 Vector (java.util.Vector)9