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.SBoxLayout;
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 BoxLayoutCG 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:
33: final SBoxLayout layout = (SBoxLayout) l;
34: final List components = layout.getComponents();
35: final int cols = layout.getOrientation() == SBoxLayout.HORIZONTAL ? components
36: .size()
37: : 1;
38: final TableCellStyle styles = cellLayoutStyle(layout);
39:
40: openLayouterBody(d, layout);
41:
42: printLayouterTableBody(d, layout.getContainer(), cols,
43: components, styles);
44:
45: closeLayouterBody(d, layout);
46: }
47:
48: protected int getLayoutHGap(SLayoutManager layout) {
49: SBoxLayout boxLayout = (SBoxLayout) layout;
50: return boxLayout.getHgap();
51: }
52:
53: protected int getLayoutVGap(SLayoutManager layout) {
54: SBoxLayout boxLayout = (SBoxLayout) layout;
55: return boxLayout.getVgap();
56: }
57:
58: protected int getLayoutBorder(SLayoutManager layout) {
59: SBoxLayout boxLayout = (SBoxLayout) layout;
60: return boxLayout.getBorder();
61: }
62:
63: protected int layoutOversize(SLayoutManager layout) {
64: SBoxLayout boxLayout = (SBoxLayout) layout;
65: return boxLayout.getHgap() + boxLayout.getBorder();
66: }
67:
68: public int getDefaultLayoutCellHAlignment() {
69: return SConstants.CENTER;
70: }
71:
72: public int getDefaultLayoutCellVAlignment() {
73: return SConstants.CENTER;
74: }
75: }
|