/**
  * Specifies the button's text color as an alpha-red-green-blue integer.
  *
  * @param argb text RGB color with alpha
  */
 @DesignerProperty(
     editorType = PropertyTypeConstants.PROPERTY_TYPE_COLOR,
     defaultValue = Component.DEFAULT_VALUE_COLOR_DEFAULT)
 @SimpleProperty
 public void TextColor(int argb) {
   // TODO(user): I think there is a way of only setting the color for the enabled state
   textColor = argb;
   if (argb != Component.COLOR_DEFAULT) {
     TextViewUtil.setTextColor(view, argb);
   } else {
     TextViewUtil.setTextColors(view, defaultColorStateList);
   }
 }
 /**
  * Specifies the button's text's font size, measured in pixels.
  *
  * @param size font size in pixel
  */
 @DesignerProperty(
     editorType = PropertyTypeConstants.PROPERTY_TYPE_NON_NEGATIVE_FLOAT,
     defaultValue = Component.FONT_DEFAULT_SIZE + "")
 @SimpleProperty(userVisible = false)
 public void FontSize(float size) {
   TextViewUtil.setFontSize(view, size);
 }
 // Update appearance based on values of backgroundImageDrawable, backgroundColor and shape.
 // Images take precedence over background colors.
 private void updateAppearance() {
   // If there is no background image,
   // the appearance depends solely on the background color and shape.
   if (backgroundImageDrawable == null) {
     if (shape == Component.BUTTON_SHAPE_DEFAULT) {
       if (backgroundColor == Component.COLOR_DEFAULT) {
         // If there is no background image and color is default,
         // restore original 3D bevel appearance.
         ViewUtil.setBackgroundDrawable(view, defaultButtonDrawable);
       } else {
         // Clear the background image.
         ViewUtil.setBackgroundDrawable(view, null);
         // Set to the specified color (possibly COLOR_NONE for transparent).
         TextViewUtil.setBackgroundColor(view, backgroundColor);
       }
     } else {
       // If there is no background image and the shape is something other than default,
       // create a drawable with the appropriate shape and color.
       setShape();
     }
   } else {
     // If there is a background image
     ViewUtil.setBackgroundImage(view, backgroundImageDrawable);
   }
 }
  /**
   * Creates a new ButtonBase component.
   *
   * @param container container, component will be placed in
   */
  public ButtonBase(ComponentContainer container) {
    super(container);
    view = new android.widget.Button(container.$context());

    // Save the default values in case the user wants them back later.
    defaultButtonDrawable = view.getBackground();
    defaultColorStateList = view.getTextColors();

    // Adds the component to its designated container
    container.$add(this);

    // Listen to clicks and focus changes
    view.setOnClickListener(this);
    view.setOnFocusChangeListener(this);
    view.setOnLongClickListener(this);
    view.setOnTouchListener(this);

    // Default property values
    TextAlignment(Component.ALIGNMENT_CENTER);
    // BackgroundColor and Image are dangerous properties:
    // Once either of them is set, the 3D bevel effect for the button is
    // irretrievable, except by reloading defaultButtonDrawable, defined above.
    BackgroundColor(Component.COLOR_DEFAULT);
    Image("");
    Enabled(true);
    fontTypeface = Component.TYPEFACE_DEFAULT;
    TextViewUtil.setFontTypeface(view, fontTypeface, bold, italic);
    FontSize(Component.FONT_DEFAULT_SIZE);
    Text("");
    TextColor(Component.COLOR_DEFAULT);
    Shape(Component.BUTTON_SHAPE_DEFAULT);
  }
 /**
  * Specifies the button's text's font face as default, serif, sans serif, or monospace.
  *
  * @param typeface one of {@link Component#TYPEFACE_DEFAULT}, {@link Component#TYPEFACE_SERIF},
  *     {@link Component#TYPEFACE_SANSSERIF} or {@link Component#TYPEFACE_MONOSPACE}
  */
 @DesignerProperty(
     editorType = PropertyTypeConstants.PROPERTY_TYPE_TYPEFACE,
     defaultValue = Component.TYPEFACE_DEFAULT + "")
 @SimpleProperty(userVisible = false)
 public void FontTypeface(int typeface) {
   fontTypeface = typeface;
   TextViewUtil.setFontTypeface(view, fontTypeface, bold, italic);
 }
 /**
  * Specifies whether the button's text should be italic. Some fonts do not support italic.
  *
  * @param italic {@code true} indicates italic, {@code false} normal
  */
 @DesignerProperty(
     editorType = PropertyTypeConstants.PROPERTY_TYPE_BOOLEAN,
     defaultValue = "False")
 @SimpleProperty(userVisible = false)
 public void FontItalic(boolean italic) {
   this.italic = italic;
   TextViewUtil.setFontTypeface(view, fontTypeface, bold, italic);
 }
 /**
  * Specifies the alignment of the button's text: center, normal (e.g., left-justified if text is
  * written left to right), or opposite (e.g., right-justified if text is written left to right).
  *
  * @param alignment one of {@link Component#ALIGNMENT_NORMAL}, {@link Component#ALIGNMENT_CENTER}
  *     or {@link Component#ALIGNMENT_OPPOSITE}
  */
 @DesignerProperty(
     editorType = PropertyTypeConstants.PROPERTY_TYPE_TEXTALIGNMENT,
     defaultValue = Component.ALIGNMENT_CENTER + "")
 @SimpleProperty(userVisible = false)
 public void TextAlignment(int alignment) {
   this.textAlignment = alignment;
   TextViewUtil.setAlignment(view, alignment, true);
 }
 /**
  * Specifies the text displayed by the button.
  *
  * @param text new caption for button
  */
 @DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_STRING, defaultValue = "")
 @SimpleProperty
 public void Text(String text) {
   TextViewUtil.setText(view, text);
 }
 /**
  * Returns the text displayed by the button.
  *
  * @return button caption
  */
 @SimpleProperty(category = PropertyCategory.APPEARANCE)
 public String Text() {
   return TextViewUtil.getText(view);
 }
 /**
  * Returns the button's text's font size, measured in pixels.
  *
  * @return font size in pixel
  */
 @SimpleProperty(category = PropertyCategory.APPEARANCE, userVisible = false)
 public float FontSize() {
   return TextViewUtil.getFontSize(view);
 }
 /**
  * Specifies whether the button should be active and clickable.
  *
  * @param enabled {@code true} for enabled, {@code false} disabled
  */
 @DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_BOOLEAN, defaultValue = "True")
 @SimpleProperty
 public void Enabled(boolean enabled) {
   TextViewUtil.setEnabled(view, enabled);
 }
 /**
  * Returns true if the button is active and clickable.
  *
  * @return {@code true} indicates enabled, {@code false} disabled
  */
 @SimpleProperty(category = PropertyCategory.BEHAVIOR)
 public boolean Enabled() {
   return TextViewUtil.isEnabled(view);
 }