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;
010:
011: import com.google.gwt.core.client.JavaScriptObject;
012: import com.gwtext.client.util.JavaScriptObjectHelper;
013: import com.gwtext.client.widgets.event.ButtonListener;
014: import com.gwtext.client.widgets.event.SplitButtonListener;
015:
016: /**
017: * A split button that provides a built-in dropdown arrow that can fire an event separately from the default click event
018: * of the button. Typically this would be used to display a dropdown menu that provides additional options to the primary
019: * button action, but any custom handler can provide the arrowclick implementation.
020: */
021: public class SplitButton extends Button {
022:
023: /* private static JavaScriptObject configPrototype;
024:
025: static {
026: init();
027: }
028:
029: private static native void init()*//*-{
030: var c = new $wnd.Ext.SplitButton();
031: @com.gwtext.client.widgets.SplitButton::configPrototype = c.initialConfig;
032: }-*//*;
033:
034:
035: protected JavaScriptObject getConfigPrototype() {
036: return configPrototype;
037: }*/
038:
039: public String getXType() {
040: return "splitbutton";
041: }
042:
043: /**
044: * Create a new SplitButton.
045: */
046: public SplitButton() {
047: }
048:
049: /**
050: * Create a new SplitButton.
051: *
052: * @param text the button text
053: */
054: public SplitButton(String text) {
055: super (text);
056: }
057:
058: /**
059: * Create a new SplitButton.
060: *
061: * @param text the button text
062: * @param listener the button listener
063: */
064: public SplitButton(String text, SplitButtonListener listener) {
065: super (text, listener);
066: }
067:
068: /**
069: * Create a new SplitButton.
070: *
071: * @param text the button text
072: * @param listener the button listener
073: * @param icon the button icon image path
074: */
075: public SplitButton(String text, SplitButtonListener listener,
076: String icon) {
077: super (text, listener, icon);
078: }
079:
080: public SplitButton(JavaScriptObject jsObj) {
081: super (jsObj);
082: }
083:
084: protected native JavaScriptObject create(JavaScriptObject config) /*-{
085: return new $wnd.Ext.SplitButton(config);
086: }-*/;
087:
088: /**
089: * Add a listener.
090: *
091: * @param listener the listener
092: */
093: public native void addListener(SplitButtonListener listener) /*-{
094: this.@com.gwtext.client.widgets.Button::addListener(Lcom/gwtext/client/widgets/event/ButtonListener;)(listener);
095: var componentJ = this;
096:
097: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('arrowclick',
098: function(self, event) {
099: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
100: listener.@com.gwtext.client.widgets.event.SplitButtonListener::onArrowClick(Lcom/gwtext/client/widgets/SplitButton;Lcom/gwtext/client/core/EventObject;)(componentJ, e);
101: }
102: );
103: }-*/;
104:
105: // --- config properties ---
106:
107: /**
108: * The title attribute of the arrow.
109: *
110: * @param arrowTooltip the arrow tooltip
111: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
112: */
113: public void setArrowTooltip(String arrowTooltip)
114: throws IllegalStateException {
115: setAttribute("arrowTooltip", arrowTooltip, true);
116: }
117:
118: /**
119: * The title attribute of the arrow.
120: *
121: * @return the title attribute of the arrow.
122: */
123: public String getArrowTooltip() {
124: return JavaScriptObjectHelper.getAttribute(config,
125: "arrowTooltip");
126: }
127: }
|