Search in sources :

Example 11 with Form

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

the class LazyValueC method getContainerState.

/**
 * This method is the container navigation equivalent of getFormState() see
 * that method for details.
 * @param cnt the container
 * @return the state
 */
protected Hashtable getContainerState(Container cnt) {
    Component c = null;
    Form parentForm = cnt.getComponentForm();
    if (parentForm != null) {
        c = parentForm.getFocused();
    }
    Hashtable h = new Hashtable();
    h.put(FORM_STATE_KEY_NAME, cnt.getName());
    h.put(FORM_STATE_KEY_CONTAINER, "");
    if (c != null && isParentOf(cnt, c)) {
        if (c instanceof List) {
            h.put(FORM_STATE_KEY_SELECTION, new Integer(((List) c).getSelectedIndex()));
        }
        if (c.getName() != null) {
            h.put(FORM_STATE_KEY_FOCUS, c.getName());
        }
        return h;
    }
    storeComponentState(cnt, h);
    return h;
}
Also used : Form(com.codename1.ui.Form) Hashtable(java.util.Hashtable) List(com.codename1.ui.List) ContainerList(com.codename1.ui.list.ContainerList) Component(com.codename1.ui.Component)

Example 12 with Form

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

the class LazyValueC method getFormListenerInstance.

private FormListener getFormListenerInstance(Component cmp, EmbeddedContainer embedded) {
    if (embedded != null) {
        FormListener fc = (FormListener) embedded.getClientProperty("!FormListener!");
        if (fc != null) {
            return fc;
        }
        fc = new FormListener();
        embedded.putClientProperty("!FormListener!", fc);
        return fc;
    }
    Form f = cmp.getComponentForm();
    if (f == null) {
        return null;
    }
    FormListener fc = (FormListener) f.getClientProperty("!FormListener!");
    if (fc != null) {
        return fc;
    }
    fc = new FormListener();
    f.putClientProperty("!FormListener!", fc);
    f.addCommandListener(fc);
    return fc;
}
Also used : Form(com.codename1.ui.Form)

Example 13 with Form

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

the class LazyValueC method processCommandImpl.

private void processCommandImpl(ActionEvent ev, Command cmd) {
    processCommand(ev, cmd);
    if (ev.isConsumed()) {
        return;
    }
    if (globalCommandListeners != null) {
        globalCommandListeners.fireActionEvent(ev);
        if (ev.isConsumed()) {
            return;
        }
    }
    if (localCommandListeners != null) {
        Form f = Display.getInstance().getCurrent();
        EventDispatcher e = (EventDispatcher) localCommandListeners.get(f.getName());
        if (e != null) {
            e.fireActionEvent(ev);
        }
    }
}
Also used : Form(com.codename1.ui.Form)

Example 14 with Form

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

the class SwipeBackSupport method startBackTransition.

void startBackTransition(final Form currentForm, Form destination) {
    final Transition t = destination.getTransitionOutAnimator().copy(true);
    if (t instanceof CommonTransitions) {
        Transition originalTransition = currentForm.getTransitionOutAnimator();
        currentForm.setTransitionOutAnimator(CommonTransitions.createEmpty());
        Form blank = new Form() {

            protected boolean shouldSendPointerReleaseToOtherForm() {
                return true;
            }
        };
        blank.addPointerDraggedListener(pointerDragged);
        blank.addPointerReleasedListener(pointerReleased);
        blank.addPointerPressedListener(pointerPressed);
        blank.setTransitionInAnimator(CommonTransitions.createEmpty());
        blank.setTransitionOutAnimator(CommonTransitions.createEmpty());
        blank.show();
        currentForm.setTransitionOutAnimator(originalTransition);
        ((CommonTransitions) t).setMotion(new LazyValue<Motion>() {

            public Motion get(Object... args) {
                return new ManualMotion(((Integer) args[0]).intValue(), ((Integer) args[1]).intValue(), ((Integer) args[2]).intValue());
            }
        });
        t.init(currentForm, destination);
        t.initTransition();
        blank.setGlassPane(new Painter() {

            public void paint(Graphics g, Rectangle rect) {
                t.animate();
                t.paint(g);
            }
        });
    }
}
Also used : Graphics(com.codename1.ui.Graphics) Motion(com.codename1.ui.animations.Motion) CommonTransitions(com.codename1.ui.animations.CommonTransitions) Form(com.codename1.ui.Form) Transition(com.codename1.ui.animations.Transition) Painter(com.codename1.ui.Painter) Rectangle(com.codename1.ui.geom.Rectangle)

Example 15 with Form

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

the class ContainerList method updateComponentCount.

private void updateComponentCount() {
    int cc = getComponentCount();
    int modelCount = model.getSize();
    if (cc != modelCount) {
        if (cc < modelCount) {
            for (int iter = cc; iter < modelCount; iter++) {
                addComponent(new Entry(iter));
            }
        } else {
            while (getComponentCount() > modelCount) {
                removeComponent(getComponentAt(getComponentCount() - 1));
            }
        }
        Form f = getComponentForm();
        if (f != null) {
            f.revalidate();
        }
    }
}
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