001: /*
002: * Copyright (c) 2005 Your Corporation. All Rights Reserved.
003: */
004: package org.wings.plaf.css;
005:
006: import org.wings.*;
007: import org.wings.io.Device;
008:
009: import java.io.IOException;
010: import java.util.Map;
011:
012: public class ScrollPaneLayoutCG extends AbstractLayoutCG {
013:
014: private static final long serialVersionUID = 1L;
015:
016: public void write(Device d, SLayoutManager l) throws IOException {
017: SScrollPaneLayout layout = (SScrollPaneLayout) l;
018: SScrollPane scrollpane = (SScrollPane) layout.getContainer();
019:
020: if (scrollpane.getMode() != SScrollPane.MODE_COMPLETE) {
021: writePaging(d, layout);
022: } else {
023: writeNonePaging(d, layout);
024: }
025: }
026:
027: protected void writeNonePaging(Device d, SScrollPaneLayout layout)
028: throws IOException {
029: openLayouterBody(d, layout);
030: d
031: .print("<tr><td valign=\"top\"><div style=\"overflow: auto; display: none\">");
032:
033: Map components = layout.getComponents();
034: SComponent center = (SComponent) components
035: .get(SScrollPaneLayout.VIEWPORT);
036:
037: writeComponent(d, center);
038:
039: d.print("</div></td></tr>");
040: closeLayouterBody(d, layout);
041: }
042:
043: protected void writePaging(Device d, SScrollPaneLayout layout)
044: throws IOException {
045: SContainer container = layout.getContainer();
046: Map components = layout.getComponents();
047: SComponent north = (SComponent) components
048: .get(SScrollPaneLayout.NORTH);
049: SComponent east = (SComponent) components
050: .get(SScrollPaneLayout.EAST);
051: SComponent center = (SComponent) components
052: .get(SScrollPaneLayout.VIEWPORT);
053: SComponent west = (SComponent) components
054: .get(SScrollPaneLayout.WEST);
055: SComponent south = (SComponent) components
056: .get(SScrollPaneLayout.SOUTH);
057:
058: SDimension preferredSize = container.getPreferredSize();
059: String height = preferredSize != null ? preferredSize
060: .getHeight() : null;
061: boolean clientLayout = isMSIE(container) && height != null
062: && !"auto".equals(height);
063:
064: openLayouterBody(d, layout);
065:
066: if (north != null) {
067: if (clientLayout)
068: d.print("<tr>");
069: else
070: d.print("<tr height=\"0%\">");
071:
072: if (west != null) {
073: d.print("<td width=\"0%\"></td>");
074: }
075:
076: d.print("<td width=\"100%\">");
077: writeComponent(d, north);
078: d.print("</td>");
079:
080: if (east != null) {
081: d.print("<td width=\"0%\"></td>");
082: }
083: d.print("</tr>\n");
084: }
085:
086: if (clientLayout)
087: d.print("<tr yweight=\"100\">");
088: else
089: d.print("<tr height=\"100%\">");
090:
091: if (west != null) {
092: d.print("<td width=\"0%\">");
093: writeComponent(d, west);
094: d.print("</td>");
095: }
096: if (center != null) {
097: d.print("<td width=\"100%\"");
098: Utils.printTableCellAlignment(d, center,
099: SConstants.LEFT_ALIGN, SConstants.TOP_ALIGN);
100: d.print(">");
101: writeComponent(d, center);
102: d.print("</td>");
103: }
104: if (east != null) {
105: d.print("<td width=\"0%\">");
106: writeComponent(d, east);
107: d.print("</td>");
108: }
109: d.print("</tr>\n");
110:
111: if (south != null) {
112: if (clientLayout)
113: d.print("<tr>");
114: else
115: d.print("<tr height=\"0%\">");
116:
117: if (west != null) {
118: d.print("<td width=\"0%\"></td>");
119: }
120:
121: d.print("<td width=\"100%\">");
122: writeComponent(d, south);
123: d.print("</td>");
124:
125: if (east != null) {
126: d.print("<td width=\"0%\"></td>");
127: }
128: d.print("</tr>\n");
129: }
130:
131: closeLayouterBody(d, layout);
132: }
133:
134: protected void writeComponent(Device d, SComponent c)
135: throws IOException {
136: c.write(d);
137: }
138:
139: protected int getLayoutHGap(SLayoutManager layout) {
140: return -1;
141: }
142:
143: protected int getLayoutVGap(SLayoutManager layout) {
144: return -1;
145: }
146:
147: protected int getLayoutBorder(SLayoutManager layout) {
148: return -1;
149: }
150:
151: protected int layoutOversize(SLayoutManager layout) {
152: return 0;
153: }
154:
155: public int getDefaultLayoutCellHAlignment() {
156: return SConstants.NO_ALIGN;
157: }
158:
159: public int getDefaultLayoutCellVAlignment() {
160: return SConstants.NO_ALIGN;
161: }
162:
163: }
|