break;
default:
// empty
}
SafeStylesBuilder stylesBuilder = new SafeStylesBuilder();
int width = -1;
if (cell.getWidth() != -1) {
int w = cell.getWidth();
if (w < cell.getMinWidth()) {
w = cell.getMinWidth();
}
stylesBuilder.appendTrustedString("width:" + w + "px;");
cls += " " + style.hasWidth() + " x-has-width";
width = w;
} else {
if (cell.getMinWidth() != -1) {
TextMetrics.get().bind(style.text());
int length = TextMetrics.get().getWidth(text);
length += 6; // frames
if (icon != null) {
switch (iconAlign) {
case LEFT:
case RIGHT:
length += icon.getWidth();
break;
default:
// empty
}
}
if (cell.getMinWidth() > length) {
stylesBuilder.appendTrustedString("width:" + cell.getMinWidth() + "px;");
cls += " " + style.hasWidth() + " x-has-width";
width = cell.getMinWidth();
}
}
}
final int height = cell.getHeight();
if (height != -1) {
stylesBuilder.appendTrustedString("height:" + height + "px;");
}
if (icon != null) {
switch (iconAlign) {
case TOP:
arrowCls += " " + style.iconTop();
break;
case BOTTOM:
arrowCls += " " + style.iconBottom();
break;
case LEFT:
arrowCls += " " + style.iconLeft();
break;
case RIGHT:
arrowCls += " " + style.iconRight();
break;
}
} else {
arrowCls += " " + style.noIcon();
}
// toggle button
if (value == Boolean.TRUE) {
cls += " " + frame.pressedClass();
}
sb.append(templates.outer(cls, new SafeStylesBuilder().toSafeStyles()));
SafeHtmlBuilder inside = new SafeHtmlBuilder();
String innerWrap = arrowCls;
if (GXT.isIE6() || GXT.isIE7()) {
arrowCls += " " + CommonStyles.get().inlineBlock();
}
inside.appendHtmlConstant("<div class='" + innerWrap + "'>");
inside.appendHtmlConstant("<table cellpadding=0 cellspacing=0 class='" + style.mainTable() + "'>");
boolean hasText = text != null && !text.equals("");
if (icon != null) {
switch (iconAlign) {
case LEFT:
inside.appendHtmlConstant("<tr>");
writeIcon(inside, icon, height);
if (hasText) {
int w = width - (icon != null ? icon.getWidth() : 0) - 4;
writeText(inside, text, w, height);
}
inside.appendHtmlConstant("</tr>");
break;
case RIGHT:
inside.appendHtmlConstant("<tr>");
if (hasText) {
int w = width - (icon != null ? icon.getWidth() : 0) - 4;
writeText(inside, text, w, height);
}
writeIcon(inside, icon, height);
inside.appendHtmlConstant("</tr>");
break;
case TOP:
inside.appendHtmlConstant("<tr>");
writeIcon(inside, icon, height);
inside.appendHtmlConstant("</tr>");
if (hasText) {
inside.appendHtmlConstant("<tr>");
writeText(inside, text, width, height);
inside.appendHtmlConstant("</tr>");
}
break;
case BOTTOM:
if (hasText) {
inside.appendHtmlConstant("<tr>");
writeText(inside, text, width, height);
inside.appendHtmlConstant("</tr>");
}
inside.appendHtmlConstant("<tr>");
writeIcon(inside, icon, height);
inside.appendHtmlConstant("</tr>");
break;
}
} else {
inside.appendHtmlConstant("<tr>");
if (text != null) {
writeText(inside, text, width, height);
}
inside.appendHtmlConstant("</tr>");
}
inside.appendHtmlConstant("</table>");
inside.appendHtmlConstant("</div>");
frame.render(sb, new Frame.FrameOptions(0, CommonStyles.get().noFocusOutline(), stylesBuilder.toSafeStyles()),
inside.toSafeHtml());
sb.appendHtmlConstant("</div>");
}