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.SGridLayout;
16: import org.wings.SLayoutManager;
17: import org.wings.SConstants;
18: import org.wings.io.Device;
19:
20: import java.io.IOException;
21: import java.util.List;
22:
23: public class GridLayoutCG extends AbstractLayoutCG {
24: private static final long serialVersionUID = 1L;
25:
26: /**
27: * @param d the device to write the code to
28: * @param l the layout manager
29: * @throws IOException
30: */
31: public void write(Device d, SLayoutManager l) throws IOException {
32: final SGridLayout layout = (SGridLayout) l;
33: final List components = layout.getComponents();
34: final int rows = layout.getRows();
35:
36: final TableCellStyle styles = cellLayoutStyle(layout);
37: styles.renderAsTH = layout.getRenderFirstLineAsHeader();
38:
39: int cols = layout.getColumns();
40: if (cols <= 0) {
41: cols = components.size() / rows;
42: }
43:
44: openLayouterBody(d, layout);
45:
46: printLayouterTableBody(d, layout.getContainer(), cols, layout
47: .getComponents(), styles);
48:
49: closeLayouterBody(d, layout);
50: }
51:
52: protected int getLayoutHGap(SLayoutManager layout) {
53: SGridLayout gridLayout = (SGridLayout) layout;
54: return gridLayout.getHgap();
55: }
56:
57: protected int getLayoutVGap(SLayoutManager layout) {
58: SGridLayout gridLayout = (SGridLayout) layout;
59: return gridLayout.getVgap();
60: }
61:
62: protected int getLayoutBorder(SLayoutManager layout) {
63: SGridLayout gridLayout = (SGridLayout) layout;
64: return gridLayout.getBorder();
65: }
66:
67: protected int layoutOversize(SLayoutManager layout) {
68: SGridLayout gridLayout = (SGridLayout) layout;
69: return gridLayout.getHgap() + gridLayout.getBorder();
70: }
71:
72: public int getDefaultLayoutCellHAlignment() {
73: return SConstants.CENTER;
74: }
75:
76: public int getDefaultLayoutCellVAlignment() {
77: return SConstants.CENTER;
78: }
79:
80: }
|