Search in sources :

Example 11 with Dialog

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

the class InteractionDialog method disposeToTheLeft.

/**
 * Removes the interaction dialog from view with an animation to the left
 */
public void disposeToTheLeft() {
    disposed = true;
    final Container p = getParent();
    if (p != null) {
        final Form f = p.getComponentForm();
        if (f != null) {
            setX(-getWidth());
            if (animateShow) {
                p.animateUnlayout(400, 255, new Runnable() {

                    public void run() {
                        if (p.getParent() != null) {
                            Container pp = getLayeredPane(f);
                            remove();
                            p.remove();
                            pp.removeAll();
                            pp.revalidate();
                            cleanupLayer(f);
                        }
                    }
                });
            } else {
                p.revalidate();
                Container pp = getLayeredPane(f);
                remove();
                p.remove();
                pp.removeAll();
                pp.revalidate();
            }
        } else {
            remove();
        }
    }
}
Also used : Container(com.codename1.ui.Container) Form(com.codename1.ui.Form)

Example 12 with Dialog

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

the class InteractionDialog method showPopupDialog.

/**
 * A popup dialog is shown with the context of a component and  its selection, it is disposed seamlessly if the back button is pressed
 * or if the user touches outside its bounds. It can optionally provide an arrow in the theme to point at the context component. The popup
 * dialog has the PopupDialog style by default.
 *
 * @param c the context component which is used to position the dialog and can also be pointed at
 */
public void showPopupDialog(Component c) {
    disposed = false;
    Rectangle componentPos = c.getSelectedRect();
    componentPos.setX(componentPos.getX() - c.getScrollX());
    componentPos.setY(componentPos.getY() - c.getScrollY());
    showPopupDialog(componentPos);
}
Also used : Rectangle(com.codename1.ui.geom.Rectangle)

Example 13 with Dialog

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

the class InteractionDialog method dispose.

/**
 * Removes the interaction dialog from view
 */
public void dispose() {
    disposed = true;
    Container p = getParent();
    if (p != null) {
        Form f = p.getComponentForm();
        if (f != null) {
            if (animateShow) {
                if (repositionAnimation) {
                    setX(getX() + getWidth() / 2);
                    setY(getY() + getHeight() / 2);
                    setWidth(1);
                    setHeight(1);
                }
                p.animateUnlayoutAndWait(400, 100);
            }
            Container pp = getLayeredPane(f);
            remove();
            p.remove();
            pp.removeAll();
            pp.revalidate();
            cleanupLayer(f);
        } else {
            p.remove();
        }
    }
}
Also used : Container(com.codename1.ui.Container) Form(com.codename1.ui.Form)

Example 14 with Dialog

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

the class ToastBar method getToastBarComponent.

private ToastBarComponent getToastBarComponent() {
    Form f = Display.getInstance().getCurrent();
    if (f != null && !(f instanceof Dialog)) {
        ToastBarComponent c = (ToastBarComponent) f.getClientProperty("ToastBarComponent");
        if (c == null || c.getParent() == null) {
            c = new ToastBarComponent();
            c.hidden = true;
            f.putClientProperty("ToastBarComponent", c);
            Container layered = f.getLayeredPane(this.getClass(), true);
            layered.setLayout(new BorderLayout());
            layered.addComponent(position == Component.TOP ? BorderLayout.NORTH : BorderLayout.SOUTH, c);
            updateStatus();
        }
        if (position == Component.BOTTOM && f.getInvisibleAreaUnderVKB() > 0) {
            Style s = c.getAllStyles();
            s.setMarginUnit(Style.UNIT_TYPE_PIXELS);
            s.setMarginBottom(f.getInvisibleAreaUnderVKB());
        }
        return c;
    }
    return null;
}
Also used : Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) Form(com.codename1.ui.Form) Dialog(com.codename1.ui.Dialog) Style(com.codename1.ui.plaf.Style)

Example 15 with Dialog

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

the class ComboBox method createPopupDialog.

/**
 * Subclasses can override this method to change the creation of the dialog
 *
 * @param l the list of the popup
 * @return a dialog instance
 */
protected Dialog createPopupDialog(List<T> l) {
    Dialog popupDialog = new Dialog(getUIID() + "Popup", getUIID() + "PopupTitle") {

        void sizeChangedInternal(int w, int h) {
            // resize the popup just resize the parent form
            if (getWidth() == w && getHeight() != h) {
                Form frm = getPreviousForm();
                if (frm != null) {
                    frm.sizeChangedInternal(w, h);
                }
                setSize(new Dimension(w, h));
                repaint();
            } else {
                dispose();
            }
        }
    };
    popupDialog.setScrollable(false);
    popupDialog.getContentPane().setAlwaysTensile(false);
    popupDialog.setAlwaysTensile(false);
    popupDialog.getContentPane().setUIID("PopupContentPane");
    popupDialog.setDisposeWhenPointerOutOfBounds(true);
    popupDialog.setTransitionInAnimator(CommonTransitions.createEmpty());
    popupDialog.setTransitionOutAnimator(CommonTransitions.createEmpty());
    popupDialog.setLayout(new BorderLayout());
    popupDialog.addComponent(BorderLayout.CENTER, l);
    return popupDialog;
}
Also used : BorderLayout(com.codename1.ui.layouts.BorderLayout) Dimension(com.codename1.ui.geom.Dimension)

Aggregations

Dialog (com.codename1.ui.Dialog)28 Form (com.codename1.ui.Form)23 BorderLayout (com.codename1.ui.layouts.BorderLayout)17 Component (com.codename1.ui.Component)16 ActionEvent (com.codename1.ui.events.ActionEvent)14 Container (com.codename1.ui.Container)13 Style (com.codename1.ui.plaf.Style)12 ActionListener (com.codename1.ui.events.ActionListener)10 GridLayout (com.codename1.ui.layouts.GridLayout)8 UIManager (com.codename1.ui.plaf.UIManager)7 IOException (java.io.IOException)7 InfiniteProgress (com.codename1.components.InfiniteProgress)6 Command (com.codename1.ui.Command)6 Label (com.codename1.ui.Label)6 BoxLayout (com.codename1.ui.layouts.BoxLayout)6 ConnectionRequest (com.codename1.io.ConnectionRequest)4 Button (com.codename1.ui.Button)4 CheckBox (com.codename1.ui.CheckBox)4 Painter (com.codename1.ui.Painter)4 TextArea (com.codename1.ui.TextArea)4