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;
}
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;
}
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);
}
}
}
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);
}
});
}
}
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();
}
}
}
Aggregations