001: /*
002: * GWT-Ext Widget Library
003: * Copyright(c) 2007-2008, GWT-Ext.
004: * licensing@gwt-ext.com
005: *
006: * http://www.gwt-ext.com/license
007: */
008:
009: package com.gwtext.client.widgets.form;
010:
011: import com.google.gwt.core.client.JavaScriptObject;
012: import com.gwtext.client.widgets.Panel;
013: import com.gwtext.client.widgets.layout.ContainerLayout;
014:
015: /**
016: * Creates a fieldset container for layout and rendering of fields in a {@link Form}.
017: *
018: */
019: public class FieldSet extends Panel {
020:
021: private static JavaScriptObject configPrototype;
022:
023: static {
024: init();
025: }
026:
027: private static native void init()/*-{
028: var c = new $wnd.Ext.form.FieldSet();
029: @com.gwtext.client.widgets.form.FieldSet::configPrototype = c.initialConfig;
030: }-*/;
031:
032: protected JavaScriptObject getConfigPrototype() {
033: return configPrototype;
034: }
035:
036: public String getXType() {
037: return "fieldset";
038: }
039:
040: /**
041: * Creates a new FieldSet.
042: */
043: public FieldSet() {
044: setAutoHeight(true);
045: }
046:
047: public FieldSet(String title) {
048: setTitle(title);
049: setAutoHeight(true);
050: }
051:
052: public FieldSet(String title, int labelWidth) {
053: setTitle(title);
054: setLabelWidth(labelWidth);
055: setAutoHeight(true);
056: }
057:
058: public FieldSet(JavaScriptObject jsObj) {
059: super (jsObj);
060: }
061:
062: protected native JavaScriptObject create(JavaScriptObject jsObj) /*-{
063: return new $wnd.Ext.form.FieldSet(jsObj);
064: }-*/;
065:
066: // --- config properties ---
067:
068: /**
069: * The base CSS class applied to the fieldset (defaults to 'x-fieldset').
070: *
071: * @param baseCls the base CSS class applied to the fieldset (defaults to 'x-fieldset').
072: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
073: */
074: public void setBaseCls(String baseCls) throws IllegalStateException {
075: setAttribute("baseCls", baseCls, true);
076: }
077:
078: /**
079: * The name to assign to the fieldset's checkbox if checkboxToggle = true (defaults to '[checkbox id]-checkbox').
080: *
081: * @param checkboxName the name to assign to the fieldset's checkbox if checkboxToggle = true (defaults to '[checkbox id]-checkbox').
082: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
083: */
084: public void setCheckboxName(String checkboxName)
085: throws IllegalStateException {
086: setAttribute("checkboxName", checkboxName, true);
087: }
088:
089: /**
090: * True to render a checkbox into the fieldset frame just in front of the legend (defaults to false). The fieldset
091: * will be expanded or collapsed when the checkbox is toggled.
092: *
093: * @param checkboxToggle true to render a checkbox into the fieldset frame just in front of the legend (defaults to false).
094: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
095: */
096: public void setCheckboxToggle(boolean checkboxToggle)
097: throws IllegalStateException {
098: setAttribute("checkboxToggle", checkboxToggle, true);
099: }
100:
101: /**
102: * A css class to apply to the x-form-item of fields. This property cascades to child containers.
103: *
104: * @param itemCls a css class to apply to the x-form-item of fields. This property cascades to child containers.
105: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
106: */
107: public void setItemCls(String itemCls) throws IllegalStateException {
108: setAttribute("itemCls", itemCls, true);
109: }
110:
111: /**
112: * The width of labels. This property cascades to child containers.
113: *
114: * @param labelWidth The width of labels. This property cascades to child containers.
115: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
116: */
117: public void setLabelWidth(int labelWidth)
118: throws IllegalStateException {
119: setAttribute("labelWidth", labelWidth, true);
120: }
121:
122: /**
123: * The {@link com.gwtext.client.widgets.Container} layout to use inside the fieldset (defaults to {@link com.gwtext.client.widgets.layout.FormLayout}).
124: *
125: * @param layout the container layout to use inside the fieldset
126: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
127: */
128: public void setLayout(ContainerLayout layout)
129: throws IllegalStateException {
130: setAttribute("layout", layout.getJsObj(), true);
131: }
132:
133: /**
134: * The fieldset legend text.
135: *
136: * @param legend the fieldset legend text.
137: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
138: */
139: public void setLegend(String legend) throws IllegalStateException {
140: setAttribute("legend", legend, true);
141: }
142: }
|