rebuild.ui.component
Class CustomButtonField

java.lang.Object
  extended by ButtonField
      extended by rebuild.ui.component.CustomButtonField

public class CustomButtonField
extends ButtonField

Customizable button

Since:
BBX 1.0.1

Field Summary
static int BOTTOM
          Put the text on the bottom of the button.
protected  EncodedImage cIcon
          Click icon for when the button is clicked.
protected  EncodedImage fIcon
          Focus icon for when the button is focused.
protected  int gap
          The gap between the icon and the text, used when the text is not centered.
static int HCENTER
          Put the text in the center (horizontal) of the button.
static int LEFT
          Put the text on the left of the button.
protected  int maxW
          The maximum width of the button, used only for text.
protected  EncodedImage nIcon
          Normal icon.
static int RIGHT
          Put the text on the right of the button.
protected  int scale
          The scale of the icon if one exists.
protected  int textLocation
          Flag that tells where the text is located.
static int TOP
          Put the text on the top of the button.
static int VCENTER
          Put the text in the center (vertical) of the button.
 
Constructor Summary
CustomButtonField()
          Create a new CustomButtonField.
CustomButtonField(long style)
          Create a new CustomButtonField.
CustomButtonField(java.lang.String label)
          Create a new CustomButtonField.
CustomButtonField(java.lang.String label, long style)
          Create a new CustomButtonField.
 
Method Summary
 Bitmap getClickIconBitmap()
          Get the click icon as a Bitmap.
 EncodedImage getClickIconEncoded()
          Get the click icon as a EncodedImage.
 Bitmap getFocusIconBitmap()
          Get the focus icon as a Bitmap.
 EncodedImage getFocusIconEncoded()
          Get the focus icon as a EncodedImage.
 int getIconScale()
          Get the scale that the icon/s should be drawn at as a Fixed32 number.
 int getMaxWidth()
          Get the maximum width of the button when displaying text.
 Bitmap getNormalIconBitmap()
          Get the normal icon as a Bitmap.
 EncodedImage getNormalIconEncoded()
          Get the normal icon as a EncodedImage.
 int getPreferredHeight()
          Retrieves this field's preferred height.
 int getPreferredWidth()
          Retrieves this field's preferred width.
 int getTextGap()
          Get the gap between the icon and the text.
 int getTextLocation()
          Get the text location.
protected  void paint(Graphics graphics)
          Invoked by the framework to redraw a portion of this field.
 void setClickIcon(Bitmap ico)
          Set the click icon using a Bitmap.
 void setClickIcon(EncodedImage ico)
          Set the click icon using a EncodedImage.
 void setFocusIcon(Bitmap ico)
          Set the focus icon using a Bitmap.
 void setFocusIcon(EncodedImage ico)
          Set the focus icon using a EncodedImage.
 void setIconScale(int fix32scale)
          Set the scale of the icon.
 void setMaxWidth(int w)
          Set the maximum width of the button when displaying text.
 void setNormalIcon(Bitmap ico)
          Set the normal icon using a Bitmap.
 void setNormalIcon(EncodedImage ico)
          Set the normal icon using a EncodedImage.
 void setTextGap(int g)
          Set the gap between the icon and the text.
 void setTextLocation(int loc)
          Set the text location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOTTOM

public static final int BOTTOM
Put the text on the bottom of the button.

See Also:
Constant Field Values

TOP

public static final int TOP
Put the text on the top of the button.

See Also:
Constant Field Values

LEFT

public static final int LEFT
Put the text on the left of the button.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Put the text on the right of the button.

See Also:
Constant Field Values

VCENTER

public static final int VCENTER
Put the text in the center (vertical) of the button.

See Also:
Constant Field Values

HCENTER

public static final int HCENTER
Put the text in the center (horizontal) of the button.

See Also:
Constant Field Values

nIcon

protected EncodedImage nIcon
Normal icon. This is the main icon to display.


fIcon

protected EncodedImage fIcon
Focus icon for when the button is focused.


cIcon

protected EncodedImage cIcon
Click icon for when the button is clicked.


textLocation

protected int textLocation
Flag that tells where the text is located.


gap

protected int gap
The gap between the icon and the text, used when the text is not centered.


scale

protected int scale
The scale of the icon if one exists. Scale is in the Fixed32 format.


maxW

protected int maxW
The maximum width of the button, used only for text.

Constructor Detail

CustomButtonField

public CustomButtonField()
Create a new CustomButtonField.


CustomButtonField

public CustomButtonField(long style)
Create a new CustomButtonField.

Parameters:
style - The button style, use the standard Field style flags.

CustomButtonField

public CustomButtonField(java.lang.String label)
Create a new CustomButtonField.

Parameters:
label - The text to use for the field.

CustomButtonField

public CustomButtonField(java.lang.String label,
                         long style)
Create a new CustomButtonField.

Parameters:
label - The text to use for the field.
style - The button style, use the standard Field style flags.
Method Detail

getPreferredHeight

public int getPreferredHeight()
Retrieves this field's preferred height.

Returns:
Preferred height for this field in pixels.

getPreferredWidth

public int getPreferredWidth()
Retrieves this field's preferred width.

Returns:
Preferred width for this field in pixels.

paint

protected void paint(Graphics graphics)
Invoked by the framework to redraw a portion of this field.

Parameters:
graphics - Graphics context for drawing in this field.

setNormalIcon

public void setNormalIcon(Bitmap ico)
Set the normal icon using a Bitmap.

Parameters:
ico - The icon to set or null if no normal icon should be set.

setNormalIcon

public void setNormalIcon(EncodedImage ico)
Set the normal icon using a EncodedImage.

Parameters:
ico - The icon to set or null if no normal icon should be set.

getNormalIconBitmap

public Bitmap getNormalIconBitmap()
Get the normal icon as a Bitmap.

Returns:
The icon as a Bitmap or null if one does not exist.

getNormalIconEncoded

public EncodedImage getNormalIconEncoded()
Get the normal icon as a EncodedImage.

Returns:
The icon as a EncodedImage or null if one does not exist.

setFocusIcon

public void setFocusIcon(Bitmap ico)
Set the focus icon using a Bitmap.

Parameters:
ico - The icon to set or null if no focus icon should be set.

setFocusIcon

public void setFocusIcon(EncodedImage ico)
Set the focus icon using a EncodedImage.

Parameters:
ico - The icon to set or null if no focus icon should be set.

getFocusIconBitmap

public Bitmap getFocusIconBitmap()
Get the focus icon as a Bitmap.

Returns:
The icon as a Bitmap or null if one does not exist.

getFocusIconEncoded

public EncodedImage getFocusIconEncoded()
Get the focus icon as a EncodedImage.

Returns:
The icon as a EncodedImage or null if one does not exist.

setClickIcon

public void setClickIcon(Bitmap ico)
Set the click icon using a Bitmap.

Parameters:
ico - The icon to set or null if no focus icon should be set.

setClickIcon

public void setClickIcon(EncodedImage ico)
Set the click icon using a EncodedImage.

Parameters:
ico - The icon to set or null if no focus icon should be set.

getClickIconBitmap

public Bitmap getClickIconBitmap()
Get the click icon as a Bitmap.

Returns:
The icon as a Bitmap or null if one does not exist.

getClickIconEncoded

public EncodedImage getClickIconEncoded()
Get the click icon as a EncodedImage.

Returns:
The icon as a EncodedImage or null if one does not exist.

setTextLocation

public void setTextLocation(int loc)
Set the text location.

Parameters:
loc - Use either BOTTOM, TOP, LEFT, RIGHT, VCENTER, HCENTER.

getTextLocation

public int getTextLocation()
Get the text location.

Returns:
One of the text locations location. One of the BOTTOM, TOP, LEFT, RIGHT, VCENTER, HCENTER.

setTextGap

public void setTextGap(int g)
Set the gap between the icon and the text.

Parameters:
g - The gap in pixels.

getTextGap

public int getTextGap()
Get the gap between the icon and the text.

Returns:
The gap in pixels.

setMaxWidth

public void setMaxWidth(int w)
Set the maximum width of the button when displaying text.

Parameters:
w - The maximum width, anything <= 0 means that there is no maximum width.

getMaxWidth

public int getMaxWidth()
Get the maximum width of the button when displaying text.

Returns:
The maximum width, anything <= 0 means that there is no maximum width.

setIconScale

public void setIconScale(int fix32scale)
Set the scale of the icon. Scale must be a valid Fixed32 number.

Parameters:
fix32scale - The scale the icon/s should be drawn at. Must be a valid Fixed32 number and must be in the format of 0 < fix32scale <= 1. 0 is equal to a 0x0 px icon, 1 is equal to the same size as the icon loaded, etc..

getIconScale

public int getIconScale()
Get the scale that the icon/s should be drawn at as a Fixed32 number.

Returns:
The scale of the icons.