if (type == Skin.INPUT_TYPE_BUTTON || type == Skin.INPUT_TYPE_IMAGE) {
super.calculateWidth(containerWidth);
return;
}
Style style = element.getComputedStyle();
int fh = style.getFont().getHeight();
int right = style.getPx(Style.MARGIN_RIGHT, containerWidth);
int left = style.getPx(Style.MARGIN_LEFT, containerWidth);
int w;
if (style.lengthIsFixed(Style.WIDTH, false)) {
w = left + style.getPx(Style.WIDTH, containerWidth) + right;
} else {
switch (type) {
case Skin.INPUT_TYPE_CHECKBOX:
case Skin.INPUT_TYPE_RADIOBUTTON:
case Skin.INPUT_TYPE_OPTION:
case Skin.INPUT_TYPE_SUBMIT:
case Skin.INPUT_TYPE_RESET:
w = Skin.get().calculateWidth(type, style.getFont(), text) + left + right;
break;
case Skin.INPUT_TYPE_SELECT:
int longest = 0;
String longestText = "";
for (int i = 0; i < element.getChildCount(); i++) {
if (element.getChildType(i) == Element.ELEMENT) {
Element option = element.getElement(i);
if ("option".equals(option.getName())) {
String s = option.getText();
if (text == null || option.getAttributeBoolean("selected")) {
text = s;
}
int l = style.getFont().stringWidth(s);
if (l > longest) {
longest = l;
longestText = s;
}
}
}
}
w = Skin.get().calculateWidth(type, style.getFont(), longestText) + left + right;
break;
case Skin.INPUT_TYPE_TEXTAREA:
w = element.getAttributeInt("cols", 40) * fh / 2;
break;