use of com.codename1.ui.list.ListCellRenderer in project CodenameOne by codenameone.
the class Spinner method calcPreferredSize.
/**
* {@inheritDoc}
*/
protected Dimension calcPreferredSize() {
int boxWidth = 0;
int verticalPadding = getStyle().getVerticalPadding();
int horizontalPadding = getStyle().getHorizontalPadding();
Object prototype = getRenderingPrototype();
int selectedHeight;
ListCellRenderer renderer = getRenderer();
Component cmp;
if (prototype != null) {
cmp = renderer.getListCellRendererComponent(this, prototype, 0, true);
} else {
if (getModel().getSize() > 0) {
cmp = renderer.getListCellRendererComponent(this, getModel().getItemAt(0), 0, true);
} else {
cmp = renderer.getListCellRendererComponent(this, null, 0, true);
}
}
selectedHeight = cmp.getPreferredH();
if (spinnerHandle != null) {
if (spinnerHandle.getHeight() > selectedHeight) {
selectedHeight = spinnerHandle.getHeight();
}
boxWidth += spinnerHandle.getWidth();
}
Dimension d;
if (Display.getInstance().isTouchScreenDevice()) {
if (ios7Mode) {
d = new Dimension(cmp.getPreferredW() + boxWidth + horizontalPadding, (selectedHeight * 8 + verticalPadding));
} else {
d = new Dimension(cmp.getPreferredW() + boxWidth + horizontalPadding, (selectedHeight * getUIManager().getThemeConstant("spinnerElementsInt", 3) + verticalPadding));
}
} else {
d = new Dimension(cmp.getPreferredW() + boxWidth + horizontalPadding, (selectedHeight + verticalPadding));
}
Style style = 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.ListCellRenderer in project CodenameOne by codenameone.
the class List method setShouldCalcPreferredSize.
/**
* {@inheritDoc}
*/
public void setShouldCalcPreferredSize(boolean shouldCalcPreferredSize) {
super.setShouldCalcPreferredSize(shouldCalcPreferredSize);
elemSize = null;
selectedElemSize = null;
// we should try passing the should calcPreferredSize to the renderer so it can revalidate too
if (shouldCalcPreferredSize) {
ListCellRenderer r = getRenderer();
Object val;
if (renderingPrototype != null) {
val = renderingPrototype;
} else {
if (getModel().getSize() > 0) {
val = getModel().getItemAt(0);
} else {
return;
}
}
Component c = r.getListCellRendererComponent(this, val, 0, false);
c.setShouldCalcPreferredSize(shouldCalcPreferredSize);
c = r.getListCellRendererComponent(this, val, 0, true);
c.setShouldCalcPreferredSize(shouldCalcPreferredSize);
}
}
use of com.codename1.ui.list.ListCellRenderer in project CodenameOne by codenameone.
the class ComboBox method setUIID.
/**
* {@inheritDoc}
*/
public void setUIID(String uiid) {
super.setUIID(uiid);
ListCellRenderer r = getRenderer();
if (r instanceof Component) {
Component c = (Component) getRenderer();
c.setUIID(uiid + "Item");
}
Component c = getRenderer().getListFocusComponent(this);
if (c != null) {
c.setUIID(uiid + "Focus");
}
}
Aggregations