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: package com.gwtext.client.widgets;
009:
010: import com.google.gwt.user.client.Element;
011: import com.google.gwt.core.client.JavaScriptObject;
012:
013: /**
014: * This is the base class for {@link QuickTips} and Tooltip that provides the basic layout and positioning that
015: * all tip-based classes require. This class can be used directly for simple, statically-positioned tips that are
016: * displayed programmatically.
017: */
018: public class Tip extends Panel {
019:
020: public Tip() {
021: }
022:
023: public Tip(String html) {
024: setHtml(html);
025: }
026:
027: public Tip(JavaScriptObject jsObj) {
028: super (jsObj);
029: }
030:
031: protected native JavaScriptObject create(JavaScriptObject config) /*-{
032: return new $wnd.Ext.Tip(config);
033: }-*/;
034:
035: /**
036: * True to render a close tool button into the tooltip header (defaults to false).
037: *
038: * @param closable true for closable
039: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
040: */
041: public void setClosable(boolean closable)
042: throws IllegalStateException {
043: setAttribute("closable", closable, false);
044: }
045:
046: /**
047: * The default {@link com.gwtext.client.core.ExtElement#alignTo(String, String)} anchor position value for this tip
048: * relative to its element of origin. (defaults to "tl-bl?")
049: *
050: * @param defaultAlign the align poistion.
051: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
052: */
053: public void setDefaultAlign(String defaultAlign)
054: throws IllegalStateException {
055: setAttribute("defaultAlign", defaultAlign, true);
056: }
057:
058: /**
059: * The maximum width of the tip in pixels (defaults to 300). The maximum supported value is 500.
060: *
061: * @param maxWidth the max width
062: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
063: */
064: public void setMaxWidth(int maxWidth) throws IllegalStateException {
065: setAttribute("maxWidth", maxWidth, true);
066: }
067:
068: /**
069: * The minimum width of the tip in pixels (defaults to 40).
070: *
071: * @param minWidth the min width
072: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
073: */
074: public void setMinWidth(int minWidth) throws IllegalStateException {
075: setAttribute("minWidth", minWidth, true);
076: }
077:
078: /**
079: * True for shadows on sides.
080: *
081: * @param shadow true for shadow
082: */
083: public void setShadow(boolean shadow) {
084: setAttribute("shadow", shadow, true);
085: }
086:
087: /**
088: * Set a shadow type for the tooltip.
089: *
090: * @param shadow the shadow type
091: * @see com.gwtext.client.widgets.Shadow#SIDES
092: * @see com.gwtext.client.widgets.Shadow#FRAME
093: * @see com.gwtext.client.widgets.Shadow#DROP
094: */
095: public void setShadow(Shadow.Type shadow) {
096: setAttribute("shadow", shadow.getType(), true);
097: }
098:
099: /**
100: * Width in pixels of the tip (defaults to auto). Width will be ignored if it exceeds the bounds of minWidth or maxWidth.
101: * The maximum supported value is 500.
102: *
103: * @param width the tooltip width
104: */
105: public void setWidth(int width) {
106: setAttribute("width", width, true);
107: }
108:
109: /**
110: * Shows this tip at the specified XY position.
111: *
112: * @param x the X position
113: * @param y the Y position
114: */
115: public native void showAt(int x, int y) /*-{
116: var tip = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
117: tip.showAt([x, y]);
118: }-*/;
119:
120: /**
121: * Shows this tip at a position relative to another element. Default to the
122: * poistion defaults to 'tl-br?'
123: *
124: * @param element the element to show tip by
125: * @see com.gwtext.client.core.ExtElement#alignTo(String, String)
126: */
127: public native void showBy(Element element) /*-{
128: var tip = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
129: tip.showBy(element);
130: }-*/;
131:
132: /**
133: * Shows this tip at a position relative to another element. Default to the
134: * poistion defaults to 'tl-br?'
135: *
136: * @param elementID the element ID to show tip by
137: * @see com.gwtext.client.core.ExtElement#alignTo(String, String)
138: */
139: public native void showBy(String elementID) /*-{
140: var tip = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
141: tip.showBy(elementID);
142: }-*/;
143:
144: /**
145: * Shows this tip at a position relative to another element. Default to the
146: * poistion defaults to 'tl-br?'
147: *
148: * @param element the element to show tip by
149: * @param position the tooltip position
150: * @see com.gwtext.client.core.ExtElement#alignTo(String, String)
151: */
152: public native void showBy(Element element, String position) /*-{
153: var tip = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
154: tip.showBy(element, position);
155: }-*/;
156:
157: /**
158: * Shows this tip at a position relative to another element. Default to the
159: * poistion defaults to 'tl-br?'
160: *
161: * @param elementID the element ID to show tip by
162: * @param position the tooltip position
163: * @see com.gwtext.client.core.ExtElement#alignTo(String, String)
164: */
165: public native void showBy(String elementID, String position) /*-{
166: var tip = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
167: tip.showBy(elementID, position);
168: }-*/;
169: }
|