Updated documentation on CustomButton.java,PushButton.java,ToggleButton.java. Also added another constructor to all three to help make the sample code prettier. Review by:jgw git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@824 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/doc/src/PushButton.png b/doc/src/PushButton.png new file mode 100644 index 0000000..d96a162 --- /dev/null +++ b/doc/src/PushButton.png Binary files differ
diff --git a/doc/src/ToggleButton.png b/doc/src/ToggleButton.png new file mode 100644 index 0000000..1ba556f --- /dev/null +++ b/doc/src/ToggleButton.png Binary files differ
diff --git a/user/javadoc/com/google/gwt/examples/PushButtonExample.java b/user/javadoc/com/google/gwt/examples/PushButtonExample.java new file mode 100644 index 0000000..f08db62 --- /dev/null +++ b/user/javadoc/com/google/gwt/examples/PushButtonExample.java
@@ -0,0 +1,43 @@ +/* + * Copyright 2006 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.examples; + +import com.google.gwt.core.client.EntryPoint; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.ClickListener; +import com.google.gwt.user.client.ui.PushButton; +import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.Widget; + +public class PushButtonExample implements EntryPoint { + + public void onModuleLoad() { + // Make a new button that does something when you click it. + PushButton b = new PushButton("Jump", "Jump?", new ClickListener() { + public void onClick(Widget sender) { + Window.alert("Crash..."); + Window.alert("Uh Oh..."); + } + }); + + // In a real application, you would have to have css styles defined for + // gwt-PushButton-up,gwt-PushButton-up-hovering,gwt-PushButton-up-disabled, + // gwt-PushButton-down,.gwt-PushButton-down-hovering,.gwt-PushButton-down-disabled + + // Add the push button to the root panel. + RootPanel.get().add(b); + } +} \ No newline at end of file
diff --git a/user/javadoc/com/google/gwt/examples/ToggleButtonExample.java b/user/javadoc/com/google/gwt/examples/ToggleButtonExample.java new file mode 100644 index 0000000..f6cb07e --- /dev/null +++ b/user/javadoc/com/google/gwt/examples/ToggleButtonExample.java
@@ -0,0 +1,46 @@ +/* + * Copyright 2006 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.examples; + +import com.google.gwt.core.client.EntryPoint; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.ClickListener; +import com.google.gwt.user.client.ui.RootPanel; +import com.google.gwt.user.client.ui.ToggleButton; +import com.google.gwt.user.client.ui.Widget; + +public class ToggleButtonExample implements EntryPoint { + public void onModuleLoad() { + // Make a new button that does something when you click it. + final ToggleButton toggleButton = new ToggleButton("Up", "Down"); + toggleButton.addClickListener(new ClickListener() { + public void onClick(Widget sender) { + if (toggleButton.isDown()) { + Window.alert("I have been toggled down"); + } else { + Window.alert("I have been toggled up"); + } + } + }); + + // In a real application, you would have to have css styles defined for + // gwt-ToggleButton-up,gwt-ToggleButton-up-hovering,gwt-ToggleButton-up-disabled, + // gwt-ToggleButton-down,.gwt-ToggleButton-down-hovering,.gwt-ToggleButton-down-disabled + + // Add the ToggleButton to the root panel. + RootPanel.get().add(toggleButton); + } +} \ No newline at end of file
diff --git a/user/src/com/google/gwt/user/client/ui/CustomButton.java b/user/src/com/google/gwt/user/client/ui/CustomButton.java index 3b4e9bd..7728ccc 100644 --- a/user/src/com/google/gwt/user/client/ui/CustomButton.java +++ b/user/src/com/google/gwt/user/client/ui/CustomButton.java
@@ -24,16 +24,16 @@ * Custom Button is a base button class with built in support for a set number * of button faces. * - * Each face has its own style modifier. For example, <code>downHovering</code> - * is assigned the CSS modifier <i>downHovering</i>. So, if the button's - * overall style name is <i>gwt-PushButton</i> then when showing the - * <code>downHovering</code> face, the button's style is <i> - * gwt-PushButton-downHovering</i>. + * Each face has its own style modifier. For example, the state for down and + * hovering is assigned the CSS modifier <i>down-hovering</i>. So, if the + * button's overall style name is <i>gwt-PushButton</i> then when showing the + * <code>down-hovering</code> face, the button's style is <i> + * gwt-PushButton-down-hovering</i>. * * <p> * Each button face can be assigned is own image, text, or html contents. If no * content is defined for a face, then the face will use the contents of another - * face. For example, if <code>downHovering</code> does not have defined + * face. For example, if <code>down-hovering</code> does not have defined * contents, it will use the contents defined by the <code>down</code> face. * </p> * @@ -65,28 +65,28 @@ * </tr> * * <tr> - * <td>upHovering</td> + * <td>up-hovering</td> * <td> {@link #getUpHoveringFace()} </td> * <td>face shown when button is up and hovering</td> * <td> up </td> * </tr> * * <tr> - * <td>upDisabled</td> + * <td>up-disabled</td> * <td> {@link #getUpDisabledFace()} </td> * <td>face shown when button is up and disabled</td> * <td> up</td> * </tr> * * <tr> - * <td>downHovering</td> + * <td>down-hovering</td> * <td> {@link #getDownHoveringFace()} </td> * <td>face shown when button is down and hovering</td> * <td> down</td> * </tr> * * <tr> - * <td>downDisabled</td> + * <td>down-disabled</td> * <td> {@link #getDownDisabledFace()} </td> * <td>face shown when button is down and disabled</td> * <td>down</td> @@ -380,6 +380,19 @@ */ public CustomButton(String upText, String downText) { this(upText); + getDownFace().setText(downText); + } + + /** + * Constructor for <code>CustomButton</code>. + * + * @param upText the text for the default (up) face of the button + * @param downText the text for the down face of the button + * @param listener the click listener + */ + public CustomButton(String upText, String downText, ClickListener listener) { + this(upText, downText); + addClickListener(listener); } /**
diff --git a/user/src/com/google/gwt/user/client/ui/PushButton.java b/user/src/com/google/gwt/user/client/ui/PushButton.java index f456fce..91e9b0f 100644 --- a/user/src/com/google/gwt/user/client/ui/PushButton.java +++ b/user/src/com/google/gwt/user/client/ui/PushButton.java
@@ -21,6 +21,19 @@ /** * A normal push button with custom styling. + * + * <p> + * <img class='gallery' src='PushButton.png'/> + * </p> + * + * <h3>CSS Style Rules</h3> + * <ul class="css"> + * <li>.gwt-PushButton-up/down/up-hovering/down-hovering/up-disabled/down-disabled {.html-face}</li> + * </ul> + * + * <p> + * <h3>Example</h3> {@example com.google.gwt.examples.PushButtonExample} + * </p> */ public class PushButton extends CustomButton { @@ -111,6 +124,16 @@ super(upText, downText); } + /** + * Constructor for <code>PushButton</code>. + * + * @param upText the text for the default (up) face of the button + * @param downText the text for down face of the button + * @param listener the click listener + */ + public PushButton(String upText, String downText, ClickListener listener) { + super(upText, downText, listener); + } public void onBrowserEvent(Event event) { // Should not act on button if the button is disabled. This can happen // because an event is bubbled up from a non-disabled interior component.
diff --git a/user/src/com/google/gwt/user/client/ui/ToggleButton.java b/user/src/com/google/gwt/user/client/ui/ToggleButton.java index 2cf1835..3ebd273 100644 --- a/user/src/com/google/gwt/user/client/ui/ToggleButton.java +++ b/user/src/com/google/gwt/user/client/ui/ToggleButton.java
@@ -23,6 +23,18 @@ * A <code>ToggleButton</code> is a stylish stateful button which allows the * user to toggle between <code>up</code> and <code>down</code> states. * + * <p> + * <img class='gallery' src='ToggleButton.png'/> + * </p> + * + * <h3>CSS Style Rules</h3> + * <ul class="css"> + * <li>.gwt-ToggleButton-up/down/up-hovering/down-hovering/up-disabled/down-disabled {.html-face}</li> + * </ul> + * + * <p> + * <h3>Example</h3> {@example com.google.gwt.examples.ToggleButtonExample} + * </p> */ public class ToggleButton extends CustomButton { private static String STYLENAME_DEFAULT = "gwt-ToggleButton";