01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings.plaf.css;
14:
15: import java.io.IOException;
16:
17: import org.wings.*;
18: import org.wings.io.Device;
19: import org.wings.plaf.css.script.LayoutFillScript;
20: import org.wings.plaf.css.script.LayoutFixScript;
21: import org.wings.plaf.css.script.LayoutScrollPaneScript;
22: import org.wings.session.ScriptManager;
23:
24: public class ScrollPaneCG extends
25: org.wings.plaf.css.AbstractComponentCG implements
26: org.wings.plaf.ScrollPaneCG {
27:
28: private static final long serialVersionUID = 1L;
29:
30: public void writeInternal(Device device, SComponent component)
31: throws IOException {
32: SScrollPane scrollpane = (SScrollPane) component;
33:
34: if (scrollpane.getMode() == SScrollPane.MODE_COMPLETE) {
35: SDimension preferredSize = scrollpane.getPreferredSize();
36: if (preferredSize == null) {
37: scrollpane.setPreferredSize(new SDimension(200, 400));
38: } else {
39: if (preferredSize.getWidthInt() < 0)
40: preferredSize.setWidth(200);
41: if (preferredSize.getHeightInt() < 0)
42: preferredSize.setHeight(400);
43: }
44:
45: ScriptManager.getInstance().addScriptListener(
46: new LayoutScrollPaneScript(component.getName()));
47: writeContent(device, component);
48: } else {
49: writeContent(device, component);
50: }
51: }
52:
53: public void writeContent(Device device, SComponent c)
54: throws IOException {
55: SScrollPane scrollPane = (SScrollPane) c;
56:
57: SDimension preferredSize = scrollPane.getPreferredSize();
58: String height = preferredSize != null ? preferredSize
59: .getHeight() : null;
60: boolean clientLayout = isMSIE(scrollPane) && height != null
61: && !"auto".equals(height)
62: && scrollPane.getMode() != SScrollPane.MODE_COMPLETE;
63: boolean clientFix = isMSIE(scrollPane)
64: && (height == null || "auto".equals(height))
65: && scrollPane.getMode() != SScrollPane.MODE_COMPLETE;
66:
67: device.print("<table");
68:
69: if (clientLayout) {
70: Utils.optAttribute(device, "layoutHeight", height);
71: preferredSize.setHeight(null);
72: }
73:
74: Utils.writeAllAttributes(device, scrollPane);
75:
76: if (clientLayout) {
77: preferredSize.setHeight(height);
78: scrollPane.getSession().getScriptManager()
79: .addScriptListener(
80: new LayoutFillScript(scrollPane.getName()));
81: } else if (clientFix)
82: scrollPane.getSession().getScriptManager()
83: .addScriptListener(
84: new LayoutFixScript(scrollPane.getName()));
85:
86: device.print(">");
87:
88: Utils.renderContainer(device, scrollPane);
89: device.print("</table>");
90: }
91: }
|