01: /* BoxVertical.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Sep 6, 2007 11:51:57 AM , Created by robbiecheng
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.zkmax.zul.render;
20:
21: import java.io.IOException;
22: import java.io.Writer;
23: import java.util.Iterator;
24:
25: import org.zkoss.zk.ui.Component;
26: import org.zkoss.zk.ui.render.ComponentRenderer;
27: import org.zkoss.zk.ui.render.SmartWriter;
28: import org.zkoss.zul.Box;
29:
30: /**
31: * {@link Box}'s vertical mold.
32: * @author robbiecheng
33: * @since 3.0.0
34: */
35: public class BoxVertical implements ComponentRenderer {
36: public void render(Component comp, Writer out) throws IOException {
37: final SmartWriter wh = new SmartWriter(out);
38: final Box self = (Box) comp;
39: final String uuid = self.getUuid();
40: final String spacing = self.getSpacing();
41: String spscls = null, spstyle = null;
42:
43: wh.write("<table id=\"").write(uuid).write(
44: "\" z.type=\"zul.box.Box\"")
45: .write(self.getOuterAttrs())
46: .write(self.getInnerAttrs()).writeln(
47: " cellpadding=\"0\" cellspacing=\"0\">");
48: for (Iterator it = self.getChildren().iterator(); it.hasNext();) {
49: final Component child = (Component) it.next();
50: wh.write("<tr id=\"").write(child.getUuid()).write(
51: "!chdextr\"").write(self.getChildOuterAttrs(child))
52: .write(">\n<td").write(
53: self.getChildInnerAttrs(child)).write(">")
54: .write(child).writeln("</td></tr>");
55:
56: if (child.getNextSibling() != null) {
57: if (spscls == null) {
58: spscls = self.getSclass();
59: spscls = spscls == null || spscls.length() == 0 ? "vbox-sp"
60: : spscls + "-sp";
61: if (spacing != null)
62: spstyle = "height:" + spacing;
63: }
64:
65: wh.write("<tr id=\"").write(child.getUuid()).write(
66: "!chdextr2\" class=\"").write(spscls).write(
67: "\"");
68:
69: //note: we have to hide if spacing is 0 since IE7 shows some space
70: if (!child.isVisible() || "0".equals(spacing)
71: || "0px".equals(spacing)) {
72: wh.write(" style=\"display:none;");
73: if (spstyle != null)
74: wh.write(spstyle);
75: wh.write("\"");
76: } else if (spstyle != null) {
77: wh.write(" style=\"").write(spstyle).write("\"");
78: }
79:
80: wh.writeln("><td></td></tr>");
81: }
82: }
83: wh.write("</table>");
84: }
85: }
|