001: /* WindowDefault.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Wed Sep 5 11:58:40 2007, Created by tomyeh
010: }}IS_NOTE
011:
012: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
013:
014: {{IS_RIGHT
015: This program is distributed under GPL Version 2.0 in the hope that
016: it will be useful, but WITHOUT ANY WARRANTY.
017: }}IS_RIGHT
018: */
019: package org.zkoss.zkmax.zul.render;
020:
021: import java.util.Iterator;
022: import java.io.Writer;
023: import java.io.IOException;
024:
025: import org.zkoss.zk.ui.Executions;
026: import org.zkoss.zk.ui.Execution;
027: import org.zkoss.zk.ui.Component;
028: import org.zkoss.zk.ui.render.ComponentRenderer;
029: import org.zkoss.zk.ui.render.Out;
030: import org.zkoss.zk.ui.render.SmartWriter;
031: import org.zkoss.zul.Window;
032: import org.zkoss.zul.Caption;
033:
034: /**
035: * {@link Window}'s default mold.
036: *
037: * @author tomyeh
038: * @since 3.0.0
039: */
040: public class WindowDefault implements ComponentRenderer {
041: public void render(Component comp, Writer out) throws IOException {
042: final SmartWriter wh = new SmartWriter(out);
043: final Window self = (Window) comp;
044: final String uuid = self.getUuid();
045: final Execution exec = Executions.getCurrent();
046:
047: wh.write("<div id=\"").write(uuid).write(
048: "\" z.type=\"zul.wnd.Wnd\" z.autoz=\"true\"");
049: wh.write(self.getOuterAttrs()).write(self.getInnerAttrs())
050: .write(">");
051:
052: final Caption caption = self.getCaption();
053: final String title = self.getTitle(), titlesc = self
054: .getTitleSclass();
055: String wcExtStyle;
056: if (caption == null && title.length() == 0) {
057: wcExtStyle = "";
058: if (exec.isExplorer() && !exec.isExplorer7()) { /* Bug 1579515: to clickable, a child with 100% width is required for DIV */
059: wh
060: .writeln(
061: "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">")
062: .write(
063: "<tr height=\"1px\"><td></td></tr>\n</table>");
064: }
065: } else {
066: wcExtStyle = "border-top:0;";
067: wh
068: .writeln("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
069: if (caption == null) {
070: wh.write("<tr id=\"").write(uuid).write(
071: "!caption\" class=\"title\">").write(
072: "<td class=\"l").write(titlesc).writeln(
073: "\"></td>").write("<td class=\"m").write(
074: titlesc).write("\">");
075: new Out(title).render(out);
076: wh.writeln("</td>");
077:
078: if (self.isClosable()) {
079: wh
080: .write("<td width=\"16\" class=\"m")
081: .write(titlesc)
082: .write("\"><img id=\"")
083: .write(uuid)
084: .write("!close\" src=\"")
085: .write(
086: exec
087: .encodeURL("~./zul/img/close-off.gif"))
088: .writeln("\"/></td>");
089: }
090:
091: wh.write("<td class=\"r").write(titlesc).writeln(
092: "\"></td></tr>");
093: } else {
094: wh.write("<tr id=\"").write(uuid).write(
095: "!caption\"><td class=\"l").write(titlesc)
096: .write("\"></td>\n<td class=\"m")
097: .write(titlesc).write("\">").write(caption)
098: .write("</td>\n<td class=\"r").write(titlesc)
099: .writeln("\"></td></tr>");
100: }
101: wh.write("</table>");
102: }
103:
104: final String cs = self.getContentStyle();
105: if (cs != null) {
106: wcExtStyle += cs;
107: }
108: wh.write("<div id=\"").write(uuid).write("!cave\" class=\"");
109: wh.write(self.getContentSclass()).write("\"").writeAttr(
110: "style", wcExtStyle);
111: wh.write(">");
112:
113: for (Iterator it = self.getChildren().iterator(); it.hasNext();) {
114: final Component child = (Component) it.next();
115: if (child != caption)
116: wh.write(child);
117: }
118: wh.write("</div></div>"); /* we don't generate shadow here since it looks odd when on top of modal mask */
119: }
120: }
|