public static final boolean hasDimension(final SComponent component) { SDimension dim = component.getPreferredSize(); return dim != null && (dim.getHeightInt() != SDimension.AUTO_INT || dim.getWidthInt() != SDimension.AUTO_INT); }
break; case COMPONENT_MOVED: typeStr = "COMPONENT_MOVED (" + d.getWidthInt() + 'x' + d.getHeightInt()+ ')'; break; case COMPONENT_RESIZED: typeStr = "COMPONENT_RESIZED (" + d.getWidthInt() + 'x' + d.getHeightInt() + ')'; break; default:
private static String getInitScript(SPopup popup) { String anchor = popup.isAnchored() ? popup.getAnchor().getName() : ""; String corner = popup.isAnchored() ? popup.getCorner() : ""; String name = "popup_" + popup.getName(); SDimension dim = popup.getPreferredSize(); if (dim == null) { dim = DEFAULT_DIMENSION; } String heightUnit = dim.getHeightUnit(); if (heightUnit != null && !heightUnit.equals("px")) { throw new IllegalStateException("Only 'px' is a valid unit, but height was specified as " + dim.getHeight()); } String widthUnit = dim.getWidthUnit(); if (widthUnit != null && !widthUnit.equals("px")) { throw new IllegalStateException("Only 'px' is a valid unit, but width was specified as " + dim.getWidth()); } StringBuilder code = new StringBuilder(); code.append("if (document.getElementById('").append(popup.getName()).append("yahoo') != null) { return; }\n"); code.append(name). append(" = new wingS.Popup("). append('\'').append(popup.getName()).append("', ").append(popup.getX()).append(", ").append(popup.getY()).append(", "). append(dim.getWidthInt()).append(", "). append(dim.getHeightInt()).append(", "). append('\'').append(anchor).append("', "). append('\'').append(corner).append('\''). append(");"); code.append(name).append(".show();"); return code.toString(); }
styleString .append("width:") .append(preferredSize.getWidthInt() - oversize) .append("px;");
private void writeTableAttributes(Device device, STable table) throws IOException { final SDimension intercellPadding = table.getIntercellPadding(); final SDimension intercellSpacing = table.getIntercellSpacing(); Utils.writeEvents(device, table, (String[]) null); // TODO: border="" should be obsolete // TODO: cellspacing and cellpadding may be in conflict with border-collapse /* Tweaking: CG configured to have a fixed border="xy" width */ Utils.optAttribute(device, "border", fixedTableBorderWidth); Utils.optAttribute(device, "cellspacing", ((intercellSpacing != null) ? String.valueOf(intercellSpacing.getWidthInt()) : null)); Utils.optAttribute(device, "cellpadding", ((intercellPadding != null) ? String.valueOf(intercellPadding.getHeightInt()) : null)); }
public void showOption(SComponent c, String title, Object message) { if (title != null) setTitle(title); optionData.removeAll(); if (message instanceof SComponent) { optionData.add((SComponent) message); } else if (message != null) { StringTokenizer stringTokenizer = new StringTokenizer(message.toString(), "\n"); while (stringTokenizer.hasMoreElements()) { SLabel label = new SLabel(stringTokenizer.nextElement().toString()); if (SOptionPane.defaultSize != null && SOptionPane.defaultSize.getWidthInt() != SDimension.AUTO_INT) { label.setWordWrap(true); } optionData.add(label); } } setOwner(c); show(); }
private void writeTableAttributes(Device device, STable table) throws IOException { final SDimension intercellPadding = table.getIntercellPadding(); final SDimension intercellSpacing = table.getIntercellSpacing(); Utils.writeEvents(device, table, null); // TODO: border="" should be obsolete // TODO: cellspacing and cellpadding may be in conflict with border-collapse /* Tweaking: CG configured to have a fixed border="xy" width */ Utils.optAttribute(device, "border", fixedTableBorderWidth); Utils.optAttribute(device, "cellspacing", ((intercellSpacing != null) ? "" + intercellSpacing.getWidthInt() : null)); Utils.optAttribute(device, "cellpadding", ((intercellPadding != null) ? "" + intercellPadding.getHeightInt() : null)); }
@Override public void writeInternal(final Device device, final SComponent c) throws IOException { final SSpacer component = (SSpacer) c; int height = component.getPreferredSize().getHeightInt(); int width = component.getPreferredSize().getWidthInt(); device.print("<img"); Utils.optAttribute(device, "src", getBlindIcon().getURL()); Utils.optAttribute(device, "width", width); Utils.optAttribute(device, "height", height); Utils.optAttribute(device, "class", "spacer"); Utils.optAttribute(device, "id", c.getName()); Utils.attribute(device, "alt", null); device.print("/>"); } }
@Override public void writeInternal(Device device, SComponent component) throws IOException { SScrollPane scrollpane = (SScrollPane) component; if (scrollpane.getMode() == SScrollPane.MODE_COMPLETE) { SDimension preferredSize = scrollpane.getPreferredSize(); if (preferredSize == null) { scrollpane.setPreferredSize(new SDimension(200, 400)); } else { if (preferredSize.getWidthInt() < 0) Utils.setPreferredSize(component, "200", preferredSize.getHeight()); if (preferredSize.getHeightInt() < 0) Utils.setPreferredSize(component, preferredSize.getWidth(), "400");; } ScriptManager.getInstance().addScriptListener(new LayoutScrollPaneScript(component.getName())); writeContent(device, component); } else { writeContent(device, component); } Adjustable sb = scrollpane.getVerticalScrollBar(); SComponent viewport = (SComponent)scrollpane.getScrollable(); if (viewport != null && sb instanceof SScrollBar) { final JavaScriptDOMListener handleMouseWheel = new JavaScriptDOMListener( "DOMMouseScroll", "wingS.scrollbar.handleMouseWheel", '\'' +((SScrollBar)sb).getName()+ '\'', viewport); viewport.addScriptListener(handleMouseWheel); } }