01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08:
09: package com.gwtext.client.widgets.menu;
10:
11: import com.google.gwt.core.client.JavaScriptObject;
12: import com.gwtext.client.util.JavaScriptObjectHelper;
13: import com.gwtext.client.widgets.menu.event.BaseItemListener;
14:
15: /**
16: * Adds a static text string to a menu, usually used as either a heading or group separator.
17: */
18: public class TextItem extends BaseItem {
19:
20: private static JavaScriptObject configPrototype;
21:
22: static {
23: init();
24: }
25:
26: private static native void init()/*-{
27: var c = new $wnd.Ext.menu.TextItem();
28: @com.gwtext.client.widgets.menu.TextItem::configPrototype = c.initialConfig;
29: }-*/;
30:
31: protected JavaScriptObject getConfigPrototype() {
32: return configPrototype;
33: }
34:
35: public TextItem() {
36: }
37:
38: /**
39: * Create a new TextItem.
40: *
41: * @param text the text. can pass html like <b class="menu-title">Choose a Theme</b> for custom styling
42: */
43: public TextItem(String text) {
44: setText(text);
45: }
46:
47: /**
48: * Create a new TextItem.
49: *
50: * @param text the text. can pass html like <b class="menu-title">Choose a Theme</b> for custom styling
51: * @param listener the listener
52: */
53: public TextItem(String text, BaseItemListener listener) {
54: setText(text);
55: addListener(listener);
56: }
57:
58: protected native JavaScriptObject create(JavaScriptObject config) /*-{
59: return new $wnd.Ext.menu.TextItem(config['text'] ||'');
60: }-*/;
61:
62: // --- config properties ---
63: /**
64: * Sets the text.
65: *
66: * @param text the text
67: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
68: */
69: public void setText(String text) throws IllegalStateException {
70: setAttribute("text", text, true);
71: }
72:
73: /**
74: * The default CSS class to use for text items (defaults to "x-menu-text").
75: *
76: * @param itemCls the item CSS class
77: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
78: */
79: public void setItemCls(String itemCls) throws IllegalStateException {
80: setAttribute("itemCls", itemCls, true);
81: }
82:
83: /**
84: * The default CSS class to use for text items (defaults to "x-menu-text").
85: *
86: * @return the default CSS class to use for text items
87: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
88: */
89: public String getItemCls() throws IllegalStateException {
90: return JavaScriptObjectHelper.getAttribute(config, "itemCls");
91: }
92:
93: }
|