/** * Utility method that creates a dimension from a dimension string separated by comma * * @return the create color */ public static SDimension makeDimension(String dimensionString) { if (dimensionString != null) { int commaIndex = dimensionString.indexOf(','); if (commaIndex > 0) { return new SDimension(dimensionString.substring(0, commaIndex), dimensionString.substring(commaIndex + 1)); } } return null; }
if (preferredSize != null) { boolean msie = isMSIE(component); if (msie && "px".equals(preferredSize.getWidthUnit())) { int oversize = calculateHorizontalOversize(component, false); styleString .append("width:") .append(preferredSize.getWidthInt() - oversize) .append("px;"); else if (!SDimension.AUTO.equals(preferredSize.getWidthUnit())) styleString.append("width:").append(preferredSize.getWidth()).append(';'); if (msie && "px".equals(preferredSize.getHeightUnit())) { int oversize = calculateVerticalOversize(component, false); styleString .append("height:") .append(preferredSize.getHeightInt() - oversize) .append("px;"); else if (!SDimension.AUTO.equals(preferredSize.getHeightUnit())) styleString.append("height:").append(preferredSize.getHeight()).append(';');
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); }
/** * Sets the preferred size of the given component. In case the component's current * dimension is unmodifiable (e.g. FULLAREA, FULLWIDTH, ...) a new dimension object * with the desired initial values is created and set for the component. * * @param component the component which needs to be changed in size * @param width the new width for the given component * @param height the new height for the given component */ public static void setPreferredSize(SComponent component, String width, String height) { try { component.getPreferredSize().setSize(width, height); } catch(UnsupportedOperationException e) { component.setPreferredSize(new SDimension(width, height)); } }
@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); } }
@Override public void writeInternal(Device device, final XRichTextEditor component) throws IOException { SDimension preferredSize = component.getPreferredSize(); boolean tableWrapping = Utils.isMSIE(component) && preferredSize != null && "%".equals(preferredSize.getWidthUnit()); if (tableWrapping) { String actualWidth = preferredSize.getWidth(); Utils.setPreferredSize(component, "100%", preferredSize.getHeight()); device.print("<table style=\"table-layout: fixed; width: " + actualWidth + "\"><tr>"); device.print("<td style=\"padding-right: " + Utils.calculateHorizontalOversize(component, true) + "px\">");
scrollPane.setPreferredSize(new SDimension("180px", scrollPane .getPreferredSize().getHeight())); IView<SComponent> view = constructView(scrollPane, viewDescriptor, connector);
/** * @param d the device to write the code to * @param l the layout manager * @throws IOException */ @Override public void write(Device d, SLayoutManager l) throws IOException { SCardLayout cardLayout = (SCardLayout) l; SContainer container = l.getContainer(); SComponent c = cardLayout.getVisibleComponent(); SDimension preferredSize = container.getPreferredSize(); String height = preferredSize != null ? preferredSize.getHeight() : null; boolean clientLayout = Utils.isMSIE(container) && height != null && !"auto".equals(height); if (clientLayout) d.print("<tr yweight=\"100\">"); else openLayouterRow(d, "100%"); openLayouterCell(d, c); // Just present visible component if (c != null) { c.write(d); } closeLayouterCell(d); closeLayouterRow(d); }
String height = preferredSize != null ? preferredSize.getHeight() : null; boolean clientLayout = height != null && Utils.isMSIE(container) && !"auto".equals(height) && (layout instanceof SBorderLayout || layout instanceof SGridBagLayout || layout instanceof SCardLayout); if (!"px".equals(preferredSize.getHeightUnit())) Utils.setPreferredSize(component, preferredSize.getWidth(), null); if (!"px".equals(preferredSize.getHeightUnit())) Utils.setPreferredSize(component, preferredSize.getWidth(), height); ScriptManager.getInstance().addScriptListener(new LayoutFillScript(component.getName()));
dialog.setPreferredSize(new SDimension(WIZARD_DIMENSION.getWidth(), SDimension.AUTO));
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(); }
SDimension preferredSize = component.getPreferredSize(); if (preferredSize != null) { String widthUnit = preferredSize.getWidthUnit(); if (!SDimension.AUTO.equals(widthUnit)) { if (percentageUnitOnly && !"%".equals(widthUnit))
int height = size != null ? size.getHeightInt() : 10;
boolean tableWrapping = Utils.isMSIE(component) && preferredSize != null && "%".equals(preferredSize.getWidthUnit()); String actualWidth = null; if (tableWrapping) { actualWidth = preferredSize.getWidth(); Utils.setPreferredSize(component, "100%", preferredSize.getHeight()); device.print("<table style=\"table-layout: fixed; width: " + actualWidth + "\"><tr>"); device.print("<td style=\"padding-right: " + Utils.calculateHorizontalOversize(component, true) + "px\">"); device.print("/>"); if (tableWrapping) { Utils.setPreferredSize(component, actualWidth, preferredSize.getHeight()); device.print("</td></tr></table>");
scrollPane.setPreferredSize(new SDimension("180px", scrollPane .getPreferredSize().getHeight())); IView<SComponent> view = constructView(scrollPane, viewDescriptor, connector);
String height = preferredSize != null ? preferredSize.getHeight() : null; boolean clientLayout = Utils.isMSIE(container) && height != null && !"auto".equals(height);
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:
/** * Sets the preferred size of the given component. In case the component's current * dimension is unmodifiable (e.g. FULLAREA, FULLWIDTH, ...) a new dimension object * with the desired initial values is created and set for the component. * * @param component the component which needs to be changed in size * @param width the new width for the given component * @param height the new height for the given component */ public static void setPreferredSize(SComponent component, int width, int height) { try { component.getPreferredSize().setSize(width, height); } catch(UnsupportedOperationException e) { component.setPreferredSize(new SDimension(width, height)); } }