1 14 package org.wings.plaf.css; 15 16 import org.wings.*; 17 import org.wings.io.Device; 18 import org.wings.plaf.LayoutCG; 19 20 import java.io.IOException ; 21 import java.util.Iterator ; 22 import java.util.List ; 23 24 public class FlowLayoutCG extends AbstractLayoutCG { 25 30 public void write(Device d, SLayoutManager l) throws IOException { 31 final SFlowLayout layout = (SFlowLayout) l; 32 final List components = layout.getComponents(); 33 final int alignment = layout.getAlignment(); 34 final int orientation = layout.getOrientation(); 35 final SContainer container = layout.getContainer(); 36 37 Utils.printNewline(d, container); 38 d.print("<div"); 39 Utils.printDivHorizontalAlignment(d, alignment); 40 if (alignment == SConstants.CENTER) 41 d.print(" style=\"display:table; margin-left:auto; margin-right:auto;\""); 43 else 44 d.print(" style=\"display:table; width:100%;\""); d.print(" class=\"SFlowLayout\">"); 46 47 final String alignmentStyle; 48 if (orientation == SConstants.HORIZONTAL) { 49 if (alignment == SConstants.LEFT) 50 alignmentStyle = "float:left;"; 51 else if (alignment == SConstants.RIGHT) 52 alignmentStyle = "float:right;"; 53 else if (alignment == SConstants.CENTER) 54 alignmentStyle = "float:left; "; else 56 alignmentStyle = ""; 57 } else { 58 alignmentStyle = "display:block;"; } 60 61 if (components.size() > 0) { 62 64 d.print("<div class=\"spacer\"> </div>"); 65 66 for (Iterator componentIterator = components.iterator(); componentIterator.hasNext();) { 67 SComponent component = (SComponent) componentIterator.next(); 68 if (component.isVisible()) { 69 Utils.printNewline(d, component); 70 d.print("<div style=\""); 71 d.print(alignmentStyle); 72 d.print("\">"); 73 component.write(d); Utils.printNewline(d, component); 75 d.print("</div>"); 76 } 77 } 78 79 80 d.print("<div class=\"spacer\"> </div>"); 81 } 82 Utils.printNewline(d, container); 83 d.print("</div>"); 84 } 85 } 86 87 88 | Popular Tags |