Face abstract class
Represents a button's face. Each face is associated with its own style modifier and, optionally, its own contents html, text, or image.
abstract class Face implements HasHtml {
static String STYLENAME_HTML_FACE = "html-face";
Face delegateTo;
dart_html.Element face;
CustomButton _customButton;
/**
* Constructor for <code>Face</code>. Creates a new face that delegates to
* the supplied face.
*
* @param delegateTo default content provider
*/
Face(this._customButton, this.delegateTo);
//**************************
// Implementation of HasHtml
//**************************
/**
* Gets the face's contents as html.
*
* @return face's contents as html
*
*/
String get html => getFace().innerHtml;
/**
* Set the face's contents as html.
*
* @param html html to set as face's contents html
*
*/
void set html(String value) {
face = new dart_html.DivElement();
UiObject.manageElementStyleName(face, STYLENAME_HTML_FACE, true);
face.innerHtml = value;
updateButtonFace();
}
//**************************
// Implementation of HasText
//**************************
/**
* Gets the face's contents as text.
*
* @return face's contents as text
*
*/
String get text => getFace().text;
/**
* Sets the face's contents as text.
*
* @param text text to set as face's contents
*/
void set text(String value) {
face = new dart_html.DivElement();
UiObject.manageElementStyleName(face, STYLENAME_HTML_FACE, true);
face.text = value;
updateButtonFace();
}
//*******
// Images
//*******
/**
* Set the face's contents as an image.
*
* @param image image to set as face contents
*/
void setImage(Image image) {
face = image.getElement();
updateButtonFace();
}
/**
* Gets the contents associated with this face.
*/
dart_html.Element getFace() {
if (face == null) {
if (delegateTo == null) {
// provide a default face as none was supplied.
face = new dart_html.DivElement();
return face;
} else {
return delegateTo.getFace();
}
} else {
return face;
}
}
void updateButtonFace() {
if (_customButton._curFace != null && _customButton._curFace.getFace() == this.getFace()) {
_customButton._setCurrentFaceElement(face);
}
}
String toString() {
return this.getName();
}
/**
* Gets the ID associated with this face. This will be a bitwise and of all
* of the attributes that comprise this face.
*/
int getFaceID();
/**
* Get the name of the face. This property is also used as a modifier on the
* <code>CustomButton</code> style. <p/> For instance, if the
* <code>CustomButton</code> style is "gwt-PushButton" and the face name is
* "up", then the CSS class name will be "gwt-PushButton-up".
*
* @return the face's name
*/
String getName();
}
Subclasses
Implements
Static Properties
String STYLENAME_HTML_FACE #
static String STYLENAME_HTML_FACE = "html-face"
Constructors
new Face(CustomButton _customButton, Face delegateTo) #
Constructor for <code>Face</code>. Creates a new face that delegates to the supplied face.
@param delegateTo default content provider
Face(this._customButton, this.delegateTo);
Properties
Element face #
dart_html.Element face
String get html #
Gets the face's contents as html.
@return face's contents as html
String get html => getFace().innerHtml;
void set html(String value) #
Set the face's contents as html.
@param html html to set as face's contents html
void set html(String value) {
face = new dart_html.DivElement();
UiObject.manageElementStyleName(face, STYLENAME_HTML_FACE, true);
face.innerHtml = value;
updateButtonFace();
}
String get text #
Gets the face's contents as text.
@return face's contents as text
String get text => getFace().text;
void set text(String value) #
Sets the face's contents as text.
@param text text to set as face's contents
void set text(String value) {
face = new dart_html.DivElement();
UiObject.manageElementStyleName(face, STYLENAME_HTML_FACE, true);
face.text = value;
updateButtonFace();
}
Methods
Element getFace() #
Gets the contents associated with this face.
dart_html.Element getFace() {
if (face == null) {
if (delegateTo == null) {
// provide a default face as none was supplied.
face = new dart_html.DivElement();
return face;
} else {
return delegateTo.getFace();
}
} else {
return face;
}
}
abstract int getFaceID() #
Gets the ID associated with this face. This will be a bitwise and of all of the attributes that comprise this face.
abstract String getName() #
Get the name of the face. This property is also used as a modifier on the <code>CustomButton</code> style. <p/> For instance, if the <code>CustomButton</code> style is "gwt-PushButton" and the face name is "up", then the CSS class name will be "gwt-PushButton-up".
@return the face's name
void setImage(Image image) #
Set the face's contents as an image.
@param image image to set as face contents
void setImage(Image image) {
face = image.getElement();
updateButtonFace();
}
String toString() #
Returns a string representation of this object.
String toString() {
return this.getName();
}
void updateButtonFace() #
void updateButtonFace() {
if (_customButton._curFace != null && _customButton._curFace.getFace() == this.getFace()) {
_customButton._setCurrentFaceElement(face);
}
}