Search in sources :

Example 86 with Form

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

the class MasterDetail method bindTabletLandscapeMaster.

/**
 * @deprecated this was a half baked idea that made it into the public API
 */
public static void bindTabletLandscapeMaster(final Form rootForm, Container parentContainer, Component landscapeUI, final Component portraitUI, final String commandTitle, Image commandIcon) {
    landscapeUI.setHideInPortrait(true);
    parentContainer.addComponent(BorderLayout.WEST, landscapeUI);
    final Command masterCommand = new Command(commandTitle, commandIcon) {

        public void actionPerformed(ActionEvent ev) {
            Dialog dlg = new Dialog();
            dlg.setLayout(new BorderLayout());
            dlg.setDialogUIID("Container");
            dlg.getContentPane().setUIID("Container");
            Container titleArea = new Container(new BorderLayout());
            dlg.addComponent(BorderLayout.NORTH, titleArea);
            titleArea.setUIID("TitleArea");
            Label title = new Label(commandTitle);
            titleArea.addComponent(BorderLayout.CENTER, title);
            title.setUIID("Title");
            Container body = new Container(new BorderLayout());
            body.setUIID("Form");
            body.addComponent(BorderLayout.CENTER, portraitUI);
            dlg.setTransitionInAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 250));
            dlg.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, true, 250));
            dlg.addComponent(BorderLayout.CENTER, body);
            dlg.setDisposeWhenPointerOutOfBounds(true);
            dlg.showStetched(BorderLayout.WEST, true);
            dlg.removeComponent(portraitUI);
        }
    };
    if (Display.getInstance().isPortrait()) {
        if (rootForm.getCommandCount() > 0) {
            rootForm.addCommand(masterCommand, 1);
        } else {
            rootForm.addCommand(masterCommand);
        }
    }
    rootForm.addOrientationListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            if (portraitUI.getParent() != null) {
                Form f = Display.getInstance().getCurrent();
                if (f instanceof Dialog) {
                    ((Dialog) f).dispose();
                }
            }
            if (Display.getInstance().isPortrait()) {
                rootForm.addCommand(masterCommand, 1);
            } else {
                rootForm.removeCommand(masterCommand);
                rootForm.revalidate();
            }
        }
    });
}
Also used : Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) ActionListener(com.codename1.ui.events.ActionListener) Command(com.codename1.ui.Command) Form(com.codename1.ui.Form) ActionEvent(com.codename1.ui.events.ActionEvent) Dialog(com.codename1.ui.Dialog) Label(com.codename1.ui.Label)

Example 87 with Form

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

the class FloatingActionButton method bindFabToContainer.

/**
 * This is a utility method to bind the FAB to a given Container, it will return a new container to add or will
 * use the layered pane if the container is a content pane.
 *
 * @param cnt the Container to add the FAB to
 * @param orientation one of Component.RIGHT/LEFT/CENTER
 * @param valign one of Component.TOP/BOTTOM/CENTER
 *
 * @return a new Container that contains the cnt and the FAB on top or null in the case of a content pane
 */
public Container bindFabToContainer(Component cnt, int orientation, int valign) {
    FlowLayout flow = new FlowLayout(orientation);
    flow.setValign(valign);
    Form f = cnt.getComponentForm();
    if (f != null && (f.getContentPane() == cnt || f == cnt)) {
        // special case for content pane installs the button directly on the content pane
        Container layers = f.getLayeredPane(getClass(), true);
        layers.setLayout(flow);
        layers.add(this);
        return null;
    }
    Container conUpper = new Container(flow);
    conUpper.add(this);
    return LayeredLayout.encloseIn(cnt, conUpper);
}
Also used : Container(com.codename1.ui.Container) FlowLayout(com.codename1.ui.layouts.FlowLayout) Form(com.codename1.ui.Form)

Example 88 with Form

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

the class FloatingActionButton method released.

@Override
public void released(int x, int y) {
    super.released(x, y);
    if (current != null) {
        current.dispose();
        current = null;
    }
    // if this fab has sub fab's display them
    if (subMenu != null) {
        final Container con = createPopupContent(subMenu);
        Dialog d = new Dialog();
        d.setDialogUIID("Container");
        d.getContentPane().setUIID("Container");
        d.setLayout(new BorderLayout());
        d.add(BorderLayout.CENTER, con);
        for (FloatingActionButton next : subMenu) {
            next.current = d;
        }
        d.setTransitionInAnimator(CommonTransitions.createEmpty());
        d.setTransitionOutAnimator(CommonTransitions.createEmpty());
        for (Component c : con) {
            c.setVisible(false);
        }
        Form f = getComponentForm();
        int oldTint = f.getTintColor();
        f.setTintColor(0);
        d.setBlurBackgroundRadius(-1);
        d.addShowListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                for (Component c : con) {
                    c.setY(con.getHeight());
                    c.setVisible(true);
                }
                con.animateLayout(200);
            }
        });
        showPopupDialog(d);
        f.setTintColor(oldTint);
        for (FloatingActionButton next : subMenu) {
            next.remove();
        }
        con.removeAll();
    }
}
Also used : Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) ActionListener(com.codename1.ui.events.ActionListener) Form(com.codename1.ui.Form) Dialog(com.codename1.ui.Dialog) ActionEvent(com.codename1.ui.events.ActionEvent) Component(com.codename1.ui.Component)

Example 89 with Form

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

the class InfiniteProgress method showInifiniteBlocking.

/**
 * Shows the infinite progress over the whole screen, the blocking can be competed by calling <code>dispose()</code>
 * on the returned <code>Dialog</code>.
 *<script src="https://gist.github.com/codenameone/a0a6abca781cd86e4f5e.js"></script>
 * @return the dialog created for the blocking effect, disposing it will return to the previous form and remove the input block.
 */
public Dialog showInifiniteBlocking() {
    Form f = Display.getInstance().getCurrent();
    if (f == null) {
        f = new Form();
        f.show();
    }
    if (f.getClientProperty("isInfiniteProgress") == null) {
        f.setTintColor(tintColor);
    }
    Dialog d = new Dialog();
    d.putClientProperty("isInfiniteProgress", true);
    d.setTintColor(0x0);
    d.setDialogUIID("Container");
    d.setLayout(new BorderLayout());
    d.addComponent(BorderLayout.CENTER, this);
    d.setTransitionInAnimator(CommonTransitions.createEmpty());
    d.setTransitionOutAnimator(CommonTransitions.createEmpty());
    d.showPacked(BorderLayout.CENTER, false);
    return d;
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout) Form(com.codename1.ui.Form) Dialog(com.codename1.ui.Dialog)

Example 90 with Form

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

the class InfiniteProgress method deinitialize.

/**
 * {@inheritDoc}
 */
protected void deinitialize() {
    super.deinitialize();
    Form f = getComponentForm();
    if (f == null) {
        f = Display.getInstance().getCurrent();
    }
    f.deregisterAnimated(this);
}
Also used : Form(com.codename1.ui.Form)

Aggregations

Form (com.codename1.ui.Form)90 ActionEvent (com.codename1.ui.events.ActionEvent)41 Component (com.codename1.ui.Component)38 BorderLayout (com.codename1.ui.layouts.BorderLayout)38 Container (com.codename1.ui.Container)26 ActionListener (com.codename1.ui.events.ActionListener)25 Dialog (com.codename1.ui.Dialog)21 Command (com.codename1.ui.Command)19 Hashtable (java.util.Hashtable)17 Label (com.codename1.ui.Label)14 Style (com.codename1.ui.plaf.Style)14 IOException (java.io.IOException)14 TextArea (com.codename1.ui.TextArea)13 Vector (java.util.Vector)12 Button (com.codename1.ui.Button)11 Graphics (com.codename1.ui.Graphics)9 RadioButton (com.codename1.ui.RadioButton)9 Animation (com.codename1.ui.animations.Animation)9 Image (com.codename1.ui.Image)8 UIManager (com.codename1.ui.plaf.UIManager)8