Search in sources :

Example 16 with Wrapper

use of com.codename1.util.Wrapper in project CodenameOne by codenameone.

the class DateTimeSpinner3D method addComponents.

void addComponents() {
    if (date != null) {
        // setLayout(new LayeredLayout());
        setLayout(new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE));
        add(BorderLayout.CENTER, wrapper);
        wrapper.addComponent(date);
        wrapper.addComponent(time);
    // LayeredLayout ll = (LayeredLayout)getLayout();
    // ll.setInsets(date, "0 auto 0 0")
    // .setInsets(time, "0 auto 0 0")
    // .setReferenceComponentLeft(time, date, 1f);
    }
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout)

Example 17 with Wrapper

use of com.codename1.util.Wrapper in project CodenameOne by codenameone.

the class DurationSpinner3D method init.

private void init() {
    setLayout(new BorderLayout());
    Container wrapper = new Container(new LayeredLayout());
    Container box = new Container(BoxLayout.x());
    UIManager uim = UIManager.getInstance();
    Style s = null;
    if (includeDays) {
        days = Spinner3D.create(0, 1000, 0, 1);
        days.setPreferredW(new Label("000", "Spinner3DRow").getPreferredW());
        s = Style.createProxyStyle(days.getRowStyle(), days.getSelectedRowStyle());
        s.setAlignment(Component.RIGHT);
        box.add(days);
        box.add(new Label(uim.localize("day", "day")));
    }
    if (includeHours) {
        hours = Spinner3D.create(0, includeDays ? 24 : 1000, 0, 1);
        hours.setPreferredW(new Label("000", "Spinner3DRow").getPreferredW());
        s = Style.createProxyStyle(hours.getRowStyle(), hours.getSelectedRowStyle());
        s.setAlignment(Component.RIGHT);
        box.add(hours);
        box.add(new Label(uim.localize("hour", "hour")));
    }
    if (includeMinutes) {
        minutes = Spinner3D.create(0, includeHours ? 59 : 1000, 0, 1);
        minutes.setPreferredW(new Label("000", "Spinner3DRow").getPreferredW());
        s = Style.createProxyStyle(minutes.getRowStyle(), minutes.getSelectedRowStyle());
        s.setAlignment(Component.RIGHT);
        box.add(minutes);
        box.add(new Label(uim.localize("min", "min")));
    }
    if (includeSeconds) {
        seconds = Spinner3D.create(0, includeMinutes ? 59 : 1000, 0, 1);
        seconds.setPreferredW(new Label("0000", "Spinner3DRow").getPreferredW());
        s = Style.createProxyStyle(seconds.getRowStyle(), seconds.getSelectedRowStyle());
        s.setAlignment(Component.RIGHT);
        box.add(seconds);
        box.add(new Label(uim.localize("sec", "sec")));
    }
    if (includeMilliseconds) {
        milliseconds = Spinner3D.create(0, 1000, 0, 1);
        milliseconds.setPreferredW(new Label("0000", "Spinner3DRow").getPreferredW());
        s = Style.createProxyStyle(milliseconds.getRowStyle(), milliseconds.getSelectedRowStyle());
        s.setAlignment(Component.RIGHT);
        box.add(milliseconds);
        box.add(new Label("ms", "ms"));
    }
    wrapper.add(box);
    LayeredLayout ll = (LayeredLayout) wrapper.getLayout();
    ll.setInsets(box, "0 auto 0 auto");
    add(BorderLayout.CENTER, wrapper);
}
Also used : Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) Label(com.codename1.ui.Label) UIManager(com.codename1.ui.plaf.UIManager) Style(com.codename1.ui.plaf.Style) LayeredLayout(com.codename1.ui.layouts.LayeredLayout)

Example 18 with Wrapper

use of com.codename1.util.Wrapper in project CodenameOne by codenameone.

the class FadeOutTransitionSample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", new BorderLayout());
    Button button1 = new Button("Button 1");
    $(button1).selectAllStyles().setBgColor(0xff0000);
    Button button2 = new Button("Button 2");
    $(button2).selectAllStyles().setBgColor(0x00ff00);
    Button doFade = new Button("Toggle");
    doFade.addActionListener(evt -> {
        Container contentPane = hi.getContentPane();
        if (contentPane.contains(button1)) {
            button2.remove();
            Container wrapper = BorderLayout.center(button2);
            contentPane.replace(button1.getParent(), wrapper, CommonTransitions.createFade(500));
        } else if (contentPane.contains(button2)) {
            Container empty = new Container();
            $(empty).selectAllStyles().setBgColor(0xeaeaea).setBgTransparency(0xff);
            contentPane.replace(button2.getParent(), empty, CommonTransitions.createFade(500));
        // contentPane.removeComponent(empty);
        } else {
            Container empty = new Container();
            button1.remove();
            contentPane.add(CENTER, empty);
            contentPane.revalidateWithAnimationSafety();
            contentPane.replace(empty, BorderLayout.center(button1), CommonTransitions.createFade(500));
        }
    });
    hi.add(NORTH, doFade);
    hi.show();
}
Also used : Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) Form(com.codename1.ui.Form) Button(com.codename1.ui.Button)

Example 19 with Wrapper

use of com.codename1.util.Wrapper in project CodenameOne by codenameone.

the class TestComponent method getComponentAt_int_int_nested.

private void getComponentAt_int_int_nested() {
    log("Testing getComponentAt(x, y) with layered nesting");
    int w = Display.getInstance().getDisplayWidth();
    int h = Display.getInstance().getDisplayHeight();
    Form f = new Form("My Form", new BorderLayout());
    Container bottom = new Container() {

        @Override
        protected Dimension calcPreferredSize() {
            return new Dimension(w, h);
        }
    };
    bottom.setGrabsPointerEvents(true);
    bottom.setName("Bottom");
    Container top = new Container(BoxLayout.y());
    // top.setScrollableY(true);
    top.setScrollableY(true);
    top.setGrabsPointerEvents(true);
    Component content = new Component() {

        @Override
        protected Dimension calcPreferredSize() {
            return new Dimension(w, h * 2);
        }
    };
    content.setFocusable(false);
    content.setGrabsPointerEvents(false);
    content.setName("Content");
    top.add(content);
    top.setName("Top");
    Container wrapper = new Container(new LayeredLayout());
    wrapper.add(bottom).add(top);
    f.add(BorderLayout.CENTER, wrapper);
    f.show();
    TestUtils.waitForFormTitle("My Form", 2000);
    Component middleComponent = f.getComponentAt(w / 2, h / 2);
    assertEqual(content, middleComponent, "Found wrong component");
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout) Dimension(com.codename1.ui.geom.Dimension) LayeredLayout(com.codename1.ui.layouts.LayeredLayout) Point(com.codename1.ui.geom.Point)

Example 20 with Wrapper

use of com.codename1.util.Wrapper in project CodeRAD by shannah.

the class EntityListView method requiresUpdate.

/**
 * Checks to see if the model has changed since last update, and requires update.
 * Update is required only if rows are added or removed.
 * @return
 */
private boolean requiresUpdate() {
    List<Entity> viewSet = new ArrayList<Entity>();
    EntityList<?> modelSet = getEntity();
    int modelSize = modelSet.size();
    int index = 0;
    for (Component child : wrapper) {
        if (child instanceof EntityView) {
            EntityView rowView = (EntityView) child;
            if (index >= modelSize && modelSet.get(index) != rowView) {
                return true;
            }
            index++;
        }
    }
    return index != modelSize;
}
Also used : Entity(com.codename1.rad.models.Entity) AbstractEntityView(com.codename1.rad.ui.AbstractEntityView) EntityView(com.codename1.rad.ui.EntityView) ArrayList(java.util.ArrayList) Component(com.codename1.ui.Component)

Aggregations

Container (com.codename1.ui.Container)9 BorderLayout (com.codename1.ui.layouts.BorderLayout)9 LayeredLayout (com.codename1.ui.layouts.LayeredLayout)6 IOException (java.io.IOException)6 Entity (com.codename1.rad.models.Entity)5 Form (com.codename1.ui.Form)5 ActionNode (com.codename1.rad.nodes.ActionNode)4 Label (com.codename1.ui.Label)4 Dimension (com.codename1.ui.geom.Dimension)4 ArrayList (java.util.ArrayList)4 EntityList (com.codename1.rad.models.EntityList)3 ActionEvent (com.codename1.ui.events.ActionEvent)3 ActionListener (com.codename1.ui.events.ActionListener)3 BoxLayout (com.codename1.ui.layouts.BoxLayout)3 UIManager (com.codename1.ui.plaf.UIManager)3 GZConnectionRequest (com.codename1.io.gzip.GZConnectionRequest)2 ControllerEvent (com.codename1.rad.controllers.ControllerEvent)2 EntityListProvider (com.codename1.rad.models.EntityListProvider)2 Button (com.codename1.ui.Button)2 Component (com.codename1.ui.Component)2