use of com.codename1.ui.Component 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.Component in project CodenameOne by codenameone.
the class LazyValueC method readRendererer.
private GenericListCellRenderer readRendererer(Resources res, DataInputStream in) throws IOException {
int rendererComponentCount = in.readByte();
String f = in.readUTF();
String s = in.readUTF();
if (rendererComponentCount == 2) {
Component selected = createContainer(res, f);
Component unselected = createContainer(res, s);
GenericListCellRenderer g = new GenericListCellRenderer(selected, unselected);
g.setFisheye(!f.equals(s));
return g;
} else {
Component selected = createContainer(res, f);
Component unselected = createContainer(res, s);
Component even = createContainer(res, in.readUTF());
Component evenU = createContainer(res, in.readUTF());
GenericListCellRenderer g = new GenericListCellRenderer(selected, unselected, even, evenU);
g.setFisheye(!f.equals(s));
return g;
}
}
use of com.codename1.ui.Component 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.Component in project CodenameOne by codenameone.
the class TableLayout method removeLayoutComponent.
/**
* {@inheritDoc}
*/
public void removeLayoutComponent(Component comp) {
// reflow the table
Vector comps = new Vector();
for (int r = 0; r < rows; r++) {
for (int c = 0; c < columns; c++) {
if (tablePositions[r * columns + c] != null) {
if (tablePositions[r * columns + c].parent != comp) {
comps.addElement(tablePositions[r * columns + c]);
} else {
tablePositions[r * columns + c].parent = null;
}
}
tablePositions[r * columns + c] = null;
}
}
currentRow = 0;
currentColumn = 0;
int count = comps.size();
for (int iter = 0; iter < count; iter++) {
Constraint con = (Constraint) comps.elementAt(iter);
if (con == H_SPAN_CONSTRAINT || con == V_SPAN_CONSTRAINT || con == VH_SPAN_CONSTRAINT) {
continue;
}
Component c = con.parent;
con.parent = null;
addLayoutComponent(con, c, c.getParent());
}
}
use of com.codename1.ui.Component in project CodenameOne by codenameone.
the class TableLayout method placeComponent.
/**
* Places the component/constraint in the proper alignment within the cell whose bounds are given
*/
private void placeComponent(boolean rtl, Constraint con, int x, int y, int width, int height) {
con.parent.setX(x);
con.parent.setY(y);
con.parent.setWidth(width);
con.parent.setHeight(height);
Dimension pref = con.parent.getPreferredSize();
int pWidth = pref.getWidth();
int pHeight = pref.getHeight();
if (pWidth < width) {
int d = (width - pWidth);
int a = con.align;
if (rtl) {
switch(a) {
case Component.LEFT:
a = Component.RIGHT;
break;
case Component.RIGHT:
a = Component.LEFT;
break;
}
}
switch(a) {
case Component.LEFT:
con.parent.setX(x);
con.parent.setWidth(width - d);
break;
case Component.RIGHT:
con.parent.setX(x + d);
con.parent.setWidth(width - d);
break;
case Component.CENTER:
con.parent.setX(x + d / 2);
con.parent.setWidth(width - d);
break;
}
}
if (pHeight < height) {
int d = (height - pHeight);
switch(con.valign) {
case Component.TOP:
con.parent.setY(y);
con.parent.setHeight(height - d);
break;
case Component.BOTTOM:
con.parent.setY(y + d);
con.parent.setHeight(height - d);
break;
case Component.CENTER:
con.parent.setY(y + d / 2);
con.parent.setHeight(height - d);
break;
}
}
}
Aggregations