01: /* Hbox.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Sep 5, 2007 2:15:45 PM , 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:
20: package org.zkoss.zkmax.zul.render;
21:
22: import java.io.IOException;
23: import java.io.Writer;
24: import java.util.Iterator;
25:
26: import org.zkoss.zk.ui.Component;
27: import org.zkoss.zk.ui.render.ComponentRenderer;
28: import org.zkoss.zk.ui.render.SmartWriter;
29: import org.zkoss.zul.Box;
30:
31: /**
32: * {@link Box}'s horizontal mold.
33: * @author robbiecheng
34: * @since 3.0.0
35: */
36:
37: public class BoxHorizontal implements ComponentRenderer {
38: public void render(Component comp, Writer out) throws IOException {
39: final SmartWriter wh = new SmartWriter(out);
40: final Box self = (Box) comp;
41: final String uuid = self.getUuid();
42: String spscls = null, spstyle = null;
43:
44: wh.write("<table id=\"").write(uuid).write(
45: "\" z.type=\"zul.box.Box\"")
46: .write(self.getOuterAttrs())
47: .write(self.getInnerAttrs()).writeln(
48: " cellpadding=\"0\" cellspacing=\"0\">").write(
49: "<tr id=\"").write(uuid).writeln("!cave\"")
50: .write(self.getCaveAttrs()).write('>');
51: for (Iterator it = self.getChildren().iterator(); it.hasNext();) {
52: final Component child = (Component) it.next();
53: wh.write("<td id=\"").write(child.getUuid()).write(
54: "!chdextr\"").write(self.getChildOuterAttrs(child))
55: .write(self.getChildInnerAttrs(child)).write(">")
56: .write(child).writeln("</td>");
57:
58: if (child.getNextSibling() != null) {
59: if (spscls == null) {
60: spscls = self.getSclass();
61: spscls = spscls == null || spscls.length() == 0 ? "hbox-sp"
62: : spscls + "-sp";
63: final String spacing = self.getSpacing();
64: if (spacing != null)
65: spstyle = "width:" + spacing;
66: }
67:
68: wh.write("<td id=\"").write(child.getUuid()).write(
69: "!chdextr2\" class=\"").write(spscls).write(
70: "\"");
71:
72: if (!child.isVisible()) {
73: wh.write(" style=\"display:none;");
74: if (spstyle != null)
75: wh.write(spstyle);
76: wh.write("\"");
77: } else if (spstyle != null) {
78: wh.write(" style=\"").write(spstyle).write("\"");
79: }
80:
81: wh.writeln("></td>");
82: }
83: }
84: wh.write("</tr></table>");
85: }
86: }
|