01: /* HeaderElement.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Wed Jan 11 11:55:13 2006, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2006 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.zul.impl;
20:
21: import org.zkoss.lang.Objects;
22: import org.zkoss.xml.HTMLs;
23: import org.zkoss.zk.ui.UiException;
24:
25: /**
26: * A skeletal implementation for a header.
27: *
28: * @author tomyeh
29: */
30: abstract public class HeaderElement extends LabelImageElement {
31: private String _align, _valign;
32:
33: /** Returns the horizontal alignment of this column.
34: * <p>Default: null (system default: left unless CSS specified).
35: */
36: public String getAlign() {
37: return _align;
38: }
39:
40: /** Sets the horizontal alignment of this column.
41: */
42: public void setAlign(String align) {
43: if (!Objects.equals(_align, align)) {
44: _align = align;
45: invalidateWhole();
46: }
47: }
48:
49: /** Returns the vertical alignment of this grid.
50: * <p>Default: null (system default: top).
51: */
52: public String getValign() {
53: return _valign;
54: }
55:
56: /** Sets the vertical alignment of this grid.
57: */
58: public void setValign(String valign) {
59: if (!Objects.equals(_valign, valign)) {
60: _valign = valign;
61: invalidateWhole();
62: }
63: }
64:
65: /** Called when this component's content is changed.
66: *
67: * <p>Derived must override it to either do nothing, or invalidate
68: * parent or others.
69: */
70: abstract protected void invalidateWhole();
71:
72: /** Returns the attributes used to generate HTML TD tag for each
73: * cell of the rows contained in the parent control,
74: * e.g., {@link org.zkoss.zul.Listcell}.
75: * <p>Used by component developers.
76: */
77: public String getColAttrs() {
78: final StringBuffer sb = new StringBuffer(32);
79: HTMLs.appendAttribute(sb, "align", _align);
80: HTMLs.appendAttribute(sb, "valign", _valign);
81: return sb.toString();
82: }
83:
84: //-- super --//
85: public boolean setVisible(boolean visible) {
86: final boolean vis = super .setVisible(visible);
87: invalidateWhole();
88: return vis;
89: }
90:
91: public String getOuterAttrs() {
92: return super.getOuterAttrs() + getColAttrs();
93: }
94:
95: }
|