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