KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > plaf > css > msie > FlowLayoutCG


1 /*
2  * $Id: FlowLayoutCG.java,v 1.3 2005/05/20 09:15:32 neurolabs Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.plaf.css.msie;
15
16 import org.wings.*;
17 import org.wings.io.Device;
18 import org.wings.plaf.css.Utils;
19
20 import java.io.IOException JavaDoc;
21 import java.util.List JavaDoc;
22
23 /**
24  * A special CG for the IE handling some special case the IE cannot hande via CSS.
25  *
26  * @author bschmid
27  */

28 public class FlowLayoutCG extends org.wings.plaf.css.FlowLayoutCG {
29    /**
30      * @param d the device to write the code to
31      * @param l the layout manager
32      * @throws java.io.IOException
33      */

34     public void write(Device d, SLayoutManager l) throws IOException JavaDoc {
35        final SFlowLayout layout = (SFlowLayout) l;
36        final int alignment = layout.getAlignment();
37        final int orientation = layout.getOrientation();
38
39        if (alignment == SConstants.CENTER && orientation == SConstants.HORIZONTAL) {
40            final List JavaDoc components = layout.getComponents();
41            final SContainer container = layout.getContainer();
42
43            Utils.printNewline(d, container);
44            d.print("<table");
45            Utils.printDivHorizontalAlignment(d, alignment);
46            d.print(" class=\"SFlowLayout\">");
47
48             int count = 0;
49             for (int i = 0; i < components.size(); i++) {
50                 SComponent comp = (SComponent) components.get(i);
51                 if (comp.isVisible()) {
52                     if (count == 0) {
53                         printLayouterTableHeader(d, null, 0, 0, 0, layout);
54                         d.print("<tr><td");
55                     } /*else if (orientation == SConstants.VERTICAL)
56                         d.print("</td></tr>\n<tr><td"); */

57                     else
58                         d.print("</td><td");
59
60                     Utils.printTableCellAlignment(d, comp);
61                     d.print(">");
62                     comp.write(d); // Render component itself
63
count++;
64                 }
65             }
66             if (count > 0) {
67                 d.print("</td></tr>");
68                 printLayouterTableFooter(d, "SFlowLayout", layout);
69             }
70
71            Utils.printNewline(d, container);
72            d.print("</table>");
73        } else {
74            // For all other cases the default implementation should work.
75
super.write(d, l);
76        }
77     }
78 }
79
Popular Tags