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: package com.gwtext.sample.showcase2.client.button;
09:
10: import com.gwtext.client.widgets.Panel;
11: import com.gwtext.client.widgets.Toolbar;
12: import com.gwtext.client.widgets.ToolbarButton;
13: import com.gwtext.sample.showcase2.client.ShowcasePanel;
14:
15: public class ToggleButtonSample extends ShowcasePanel {
16:
17: public String getSourceUrl() {
18: return "source/button/ToggleButtonSample.java.html";
19: }
20:
21: public String getCssUrl() {
22: return "source/button/ToggleButtonSample.css.html";
23: }
24:
25: public Panel getViewPanel() {
26: if (panel == null) {
27: panel = new Panel();
28:
29: Toolbar toolbar = new Toolbar();
30: toolbar.setWidth(400);
31:
32: ToolbarButton bold = new ToolbarButton();
33: bold.setEnableToggle(true);
34: bold.setIconCls("text-bold");
35: bold.setTooltip("<b>Bold</b>");
36: toolbar.addButton(bold);
37:
38: ToolbarButton italic = new ToolbarButton();
39: italic.setEnableToggle(true);
40: italic.setIconCls("text-italic");
41: italic.setTooltip("<i>Italic</i>");
42: toolbar.addButton(italic);
43:
44: ToolbarButton underline = new ToolbarButton();
45: underline.setEnableToggle(true);
46: underline.setIconCls("text-underline");
47: underline.setTooltip("<u>Underline</u>");
48: toolbar.addButton(underline);
49:
50: toolbar.addSeparator();
51:
52: ToolbarButton left = new ToolbarButton();
53: left.setToggleGroup("alignment");
54: left.setTooltip("Left Align");
55: left.setIconCls("text-align-left");
56: toolbar.addButton(left);
57:
58: ToolbarButton right = new ToolbarButton();
59: right.setToggleGroup("alignment");
60: right.setIconCls("text-align-right");
61: right.setTooltip("Right Align");
62: toolbar.addButton(right);
63:
64: ToolbarButton center = new ToolbarButton();
65: center.setToggleGroup("alignment");
66: center.setIconCls("text-align-center");
67: center.setTooltip("Center");
68: toolbar.addButton(center);
69:
70: ToolbarButton justify = new ToolbarButton();
71: justify.setToggleGroup("alignment");
72: justify.setIconCls("text-align-justify");
73: justify.setTooltip("Justify");
74: toolbar.addButton(justify);
75:
76: panel.add(toolbar);
77: }
78: return panel;
79: }
80:
81: public String getIntro() {
82: return "<p>This example illustrates Toggle Buttons. When clicked, such Buttons toggle thier 'pressed' state.</p>"
83: + "<p>The Bold, Italic and Underline toggle Buttons operate independently with respect to thier toggle state while "
84: + "the text alignment icon Buttons belong to the same toggle group and so when one of them is click, the previously pressed "
85: + "Button returns to its normal state.<p>";
86: }
87: }
|