Search in sources :

Example 1 with List

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

the class GenericListCellRenderer method extractLastClickedComponent.

/**
 * Allows partitioning the renderer into "areas" that can be clicked. When
 * receiving an action event in the list this method allows a developer to
 * query the renderer to "see" whether a button within the component was "touched"
 * by the user on a touch screen device.
 * This method will reset the value to null after returning a none-null value!
 *
 * @return a button or null
 */
public Button extractLastClickedComponent() {
    Button c = lastClickedComponent;
    lastClickedComponent = null;
    return c;
}
Also used : RadioButton(com.codename1.ui.RadioButton) Button(com.codename1.ui.Button)

Example 2 with List

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

the class GenericListCellRenderer method setComponentValueWithTickering.

private void setComponentValueWithTickering(Component cmp, Object value, Component l, Component rootRenderer) {
    setComponentValue(cmp, value, l, rootRenderer);
    if (cmp instanceof Label) {
        if (selectionListener) {
            if (l instanceof List) {
                ((List) l).addActionListener(mon);
            }
            parentList = l;
        }
        Label label = (Label) cmp;
        if (label.shouldTickerStart() && Display.getInstance().shouldRenderSelection()) {
            if (!label.isTickerRunning()) {
                parentList = l;
                if (parentList != null) {
                    Form f = parentList.getComponentForm();
                    if (f != null) {
                        f.registerAnimated(mon);
                        label.startTicker(cmp.getUIManager().getLookAndFeel().getTickerSpeed(), true);
                    }
                }
            }
        } else {
            if (label.isTickerRunning()) {
                label.stopTicker();
            }
            label.setTextPosition(0);
        }
    }
}
Also used : Form(com.codename1.ui.Form) Label(com.codename1.ui.Label) List(com.codename1.ui.List) ArrayList(java.util.ArrayList)

Example 3 with List

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

the class DefaultLookAndFeel method getListPreferredSize.

/**
 * {@inheritDoc}
 */
public Dimension getListPreferredSize(List l) {
    Dimension d = getListPreferredSizeImpl(l);
    Style style = l.getStyle();
    if (style.getBorder() != null) {
        d.setWidth(Math.max(style.getBorder().getMinimumWidth(), d.getWidth()));
        d.setHeight(Math.max(style.getBorder().getMinimumHeight(), d.getHeight()));
    }
    return d;
}
Also used : Dimension(com.codename1.ui.geom.Dimension)

Example 4 with List

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

the class LazyValueC method storeComponentStateImpl.

private void storeComponentStateImpl(Component c, Hashtable destination) {
    if (c.getName() == null || destination.containsKey(c.getName()) || c.getClientProperty("CN1IgnoreStore") != null) {
        return;
    }
    if (c instanceof Tabs) {
        destination.put(c.getName(), new Integer(((Tabs) c).getSelectedIndex()));
    }
    if (c instanceof Container) {
        Container cnt = (Container) c;
        int count = cnt.getComponentCount();
        for (int iter = 0; iter < count; iter++) {
            storeComponentStateImpl(cnt.getComponentAt(iter), destination);
        }
        return;
    }
    if (c instanceof List) {
        destination.put(c.getName(), new Integer(((List) c).getSelectedIndex()));
        return;
    }
    Object o = c.getComponentState();
    if (o != null) {
        destination.put(c.getName(), o);
    }
}
Also used : Container(com.codename1.ui.Container) Tabs(com.codename1.ui.Tabs) List(com.codename1.ui.List) ContainerList(com.codename1.ui.list.ContainerList)

Example 5 with List

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

the class LazyValueC method restoreComponentState.

/**
 * By default Codename One stores the states of components in the navigation graph
 * as it moves between forms. However, some components aren't recognized by Codename One
 * by default to enable smaller executable size. This method can be overriden to enable
 * storing the state of custom components
 *
 * @param c the component whose state should be restored
 * @param destination the hashtable containing the state
 */
protected void restoreComponentState(Component c, Hashtable destination) {
    if (shouldAutoStoreState()) {
        Enumeration e = destination.keys();
        while (e.hasMoreElements()) {
            String currentKey = (String) e.nextElement();
            Component cmp = findByName(currentKey, c);
            if (cmp != null) {
                Object value = destination.get(currentKey);
                if (value instanceof Integer) {
                    if (cmp instanceof List) {
                        ((List) cmp).setSelectedIndex(((Integer) value).intValue());
                        continue;
                    }
                    if (cmp instanceof Tabs) {
                        int val = ((Integer) value).intValue();
                        Tabs t = (Tabs) cmp;
                        if (t.getTabCount() > val) {
                            t.setSelectedIndex(val);
                        }
                        continue;
                    }
                }
                cmp.setComponentState(value);
            }
        }
    }
}
Also used : Enumeration(java.util.Enumeration) Tabs(com.codename1.ui.Tabs) List(com.codename1.ui.List) ContainerList(com.codename1.ui.list.ContainerList) Component(com.codename1.ui.Component)

Aggregations

Paint (com.codename1.charts.compat.Paint)26 ArrayList (java.util.ArrayList)24 Component (com.codename1.ui.Component)16 List (com.codename1.ui.List)13 Point (com.codename1.charts.models.Point)11 BorderLayout (com.codename1.ui.layouts.BorderLayout)11 Hashtable (java.util.Hashtable)11 Container (com.codename1.ui.Container)9 ContainerList (com.codename1.ui.list.ContainerList)9 Button (com.codename1.ui.Button)8 List (java.util.List)8 TextArea (com.codename1.ui.TextArea)7 Dimension (com.codename1.ui.geom.Dimension)7 EncodedImage (com.codename1.ui.EncodedImage)6 Label (com.codename1.ui.Label)6 RadioButton (com.codename1.ui.RadioButton)5 ActionListener (com.codename1.ui.events.ActionListener)5 JList (javax.swing.JList)4 FileEncodedImage (com.codename1.components.FileEncodedImage)3 StorageImage (com.codename1.components.StorageImage)3