use of com.codename1.ui.Image in project CodenameOne by codenameone.
the class MultiButton method setCheckBox.
/**
* Turns the multi-button into a checkbox multi-button
*
* @param b true for a checkbox multi-button
*/
public void setCheckBox(boolean b) {
if (b != isCheckBox()) {
Container par = emblem.getParent();
Button old = emblem;
if (b) {
emblem = new CheckBox();
} else {
emblem = new Button();
}
emblem.setUIID(old.getUIID());
emblem.setName(old.getName());
java.util.List actionListeners = (java.util.List) old.getListeners();
if (actionListeners != null) {
for (int iter = 0; iter < actionListeners.size(); iter++) {
emblem.addActionListener((ActionListener) actionListeners.get(iter));
}
}
if (old.getCommand() != null) {
Image img = old.getIcon();
emblem.setCommand(old.getCommand());
emblem.setText("");
emblem.setIcon(img);
} else {
emblem.setText(old.getText());
if (old.getIcon() != null) {
emblem.setIcon(old.getIcon());
}
}
par.replace(old, emblem, null);
setLeadComponent(emblem);
}
}
use of com.codename1.ui.Image in project CodenameOne by codenameone.
the class MultiButton method setRadioButton.
/**
* Turns the multi-button into a radio multi-button
*
* @param b true for a radio multi-button
*/
public void setRadioButton(boolean b) {
if (b != isRadioButton()) {
Container par = emblem.getParent();
Button old = emblem;
if (b) {
emblem = new RadioButton();
if (group != null) {
((RadioButton) emblem).setGroup(group);
}
} else {
emblem = new Button();
}
emblem.setName(old.getName());
emblem.setUIID(old.getUIID());
java.util.List actionListeners = (java.util.List) old.getListeners();
if (actionListeners != null) {
for (int iter = 0; iter < actionListeners.size(); iter++) {
emblem.addActionListener((ActionListener) actionListeners.get(iter));
}
}
if (old.getCommand() != null) {
Image img = old.getIcon();
emblem.setCommand(old.getCommand());
emblem.setText("");
emblem.setIcon(img);
}
par.replace(old, emblem, null);
setLeadComponent(emblem);
emblem.setShowEvenIfBlank(true);
}
}
use of com.codename1.ui.Image in project CodenameOne by codenameone.
the class ScaleImageLabel method calcPreferredSize.
/**
* {@inheritDoc}
*/
@Override
protected Dimension calcPreferredSize() {
Image i = getIcon();
if (i == null) {
return new Dimension();
}
int dw = Display.getInstance().getDisplayWidth();
int iw = i.getWidth();
int ih = i.getHeight();
// a scrollable container the vertical height might be granted providing so much space as to make this unrealistic...
if (iw > dw) {
float ratio = ((float) iw) / ((float) dw);
iw = (int) (((float) iw) / ((float) ratio));
ih = (int) (((float) ih) / ((float) ratio));
}
Style s = getStyle();
return new Dimension(iw + s.getPaddingLeftNoRTL() + s.getPaddingRightNoRTL(), ih + s.getPaddingTop() + s.getPaddingBottom());
}
use of com.codename1.ui.Image in project CodenameOne by codenameone.
the class ScaleImageLabel method refreshTheme.
@Override
protected void refreshTheme(String id, boolean merge) {
byte type = getBackgroundType();
Image icon = getIcon();
super.refreshTheme(id, merge);
setIcon(icon);
getAllStyles().setBackgroundType(type);
}
use of com.codename1.ui.Image in project CodenameOne by codenameone.
the class ScaleImageButton method refreshTheme.
@Override
protected void refreshTheme(String id, boolean merge) {
byte type = getBackgroundType();
Image icon = getIcon();
super.refreshTheme(id, merge);
setIcon(icon);
getAllStyles().setBackgroundType(type);
getAllStyles().setBgTransparency(255);
}
Aggregations