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 org.wings.*;
16: import org.wings.io.Device;
17: import org.wings.plaf.css.script.LayoutFillScript;
18: import org.wings.session.ScriptManager;
19:
20: public class ContainerCG extends AbstractComponentCG implements
21: org.wings.plaf.PanelCG {
22: private static final long serialVersionUID = 1L;
23:
24: public void writeInternal(final Device device,
25: final SComponent component) throws java.io.IOException {
26: final SContainer container = (SContainer) component;
27: final SLayoutManager layout = container.getLayout();
28:
29: SDimension preferredSize = container.getPreferredSize();
30: String height = preferredSize != null ? preferredSize
31: .getHeight() : null;
32: boolean clientLayout = height != null
33: && isMSIE(container)
34: && !"auto".equals(height)
35: && (layout instanceof SBorderLayout
36: || layout instanceof SGridBagLayout || layout instanceof SCardLayout);
37:
38: device.print("<table");
39:
40: if (clientLayout) {
41: Utils.optAttribute(device, "layoutHeight", height);
42: preferredSize.setHeight(null);
43: }
44:
45: Utils.writeAllAttributes(device, component);
46: Utils.writeEvents(device, component, null);
47:
48: if (clientLayout) {
49: preferredSize.setHeight(height);
50: ScriptManager.getInstance().addScriptListener(
51: new LayoutFillScript(component.getName()));
52: }
53:
54: device.print(">");
55:
56: // special case templateLayout and card layout. We open a TABLE cell for them.
57: final boolean writeTableData = layout instanceof STemplateLayout;
58: if (writeTableData) {
59: device.print("<tr><td");
60: Utils.printTableCellAlignment(device, component,
61: SConstants.LEFT_ALIGN, SConstants.TOP_ALIGN);
62: device.print(">");
63: }
64:
65: Utils.renderContainer(device, container);
66:
67: if (writeTableData) {
68: device.print("</td></tr>");
69: }
70:
71: device.print("</table>");
72: }
73: }
|