@Override protected void adjust() { ScrollBarCG cg = (ScrollBarCG)getCG(); if (cg != null) { Update update = cg.getAdjustmentUpdate(this, getValue(), getExtent(), getMaximum() - getMinimum()); if (update != null) update(update); } }
public VerticalScrollBarLayoutScript(SScrollBar sb) { super("wingS.scrollbar.layout_vertical(\"" + sb.getName() + "\");"); } }
@Override public void writeInternal(final Device d, final SScrollBar scrollBar) throws IOException { final String style = scrollBar.getStyle(); if (scrollBar.getOrientation() == SConstants.VERTICAL) { scrollBar.setStyle(style + " SScrollBar_vertical"); writeVerticalScrollbar(d, scrollBar); } else { scrollBar.setStyle(style + " SScrollBar_horizontal"); writeHorizontalScrollbar(d, scrollBar); } scrollBar.setStyle(style); }
static String params(SScrollBar sb) { final int value = sb.getValue(); final int extent = sb.getExtent(); final int minimum = sb.getMinimum(); final int maximum = sb.getMaximum(); final int size = maximum - minimum; return ", " + value + ", " + extent + ", " + size; } }
private static void writeVerticalScrollbar(Device device, SScrollBar sb) throws IOException { SDimension preferredSize = sb.getPreferredSize(); String height = preferredSize != null ? preferredSize.getHeight() : null; boolean clientLayout = Utils.isMSIE(sb) && height != null && !"auto".equals(height); Utils.printNewline(device, sb); device.print("<table"); if (clientLayout) { Utils.optAttribute(device, "layoutHeight", height); Utils.setPreferredSize(sb, preferredSize.getWidth(), null); } sb.setAttribute(CSSProperty.TABLE_LAYOUT, "fixed"); Utils.writeAllAttributes(device, sb); if (clientLayout) { Utils.setPreferredSize(sb, preferredSize.getWidth(), height); sb.getSession().getScriptManager().addScriptListener(new LayoutFillScript(sb.getName())); } device.print("><tbody><tr><td>\n"); device.print("<div class=\"outer\"><div class=\"inner\"/></div>\n"); device.print("</td></tr></tbody></table>"); sb.getSession().getScriptManager().addScriptListener(new VerticalScrollBarLayoutScript(sb)); sb.getSession().getScriptManager().addScriptListener(new VerticalScrollBarSetScript(sb)); }
public SScrollPane() { super(new SScrollPaneLayout()); setHorizontalScrollBar(new SScrollBar(SConstants.HORIZONTAL)); setVerticalScrollBar(new SScrollBar(SConstants.VERTICAL)); }
private static void writeHorizontalScrollbar(Device device, SScrollBar sb) throws IOException { device.print("<table"); Utils.writeAllAttributes(device, sb); device.print("><tbody><tr><td>\n"); device.print("<div class=\"outer\"><div class=\"inner\"/></div>\n"); device.print("</td></tr></tbody></table>"); sb.getSession().getScriptManager().addScriptListener(new HorizontalScrollBarLayoutScript(sb)); sb.getSession().getScriptManager().addScriptListener(new HorizontalScrollBarSetScript(sb)); }
public HorizontalScrollBarLayoutScript(SScrollBar sb) { super("wingS.scrollbar.layout_horizontal(\"" + sb.getName() + "\");"); } }
public VerticalScrollBarSetScript(SScrollBar sb) { super("wingS.scrollbar.set_vertical(\"" + sb.getName() + '"' + params(sb) + ");"); } }
public HorizontalScrollBarSetScript(SScrollBar sb) { super("wingS.scrollbar.set_horizontal(\"" + sb.getName() + '"' + params(sb) + ");"); } }
@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); } }