danger.ui
Class Button

java.lang.Object
  extended by danger.app.Listener
      extended by danger.ui.View
          extended by danger.ui.Container
              extended by danger.ui.Control
                  extended by danger.ui.Button
All Implemented Interfaces:
ToolTipOwner
Direct Known Subclasses:
MultiModeButton, URLButton


public class Button
extends Control

A standard push button that can be used to activate an event.


Field Summary
static int ALIGN_BOTTOM
          Possible argument to setBitmapAlignment(int).
static int ALIGN_LEFT
          Possible argument to setBitmapAlignment(int).
static int ALIGN_RIGHT
          Possible argument to setBitmapAlignment(int).
static int ALIGN_TOP
          Possible argument to setBitmapAlignment(int).
protected static int BITMAP_ONLY_PADDING
          Deprecated. For internal use only.
protected static int CAP_WIDTH
          Deprecated. For internal use only.
protected static int DEBOUNCE_TIMEOUT
          Deprecated. For internal use only.
protected  Bitmap mBitmap
          Deprecated. Use setBitmap(danger.ui.Bitmap) and getCurrentBitmap() instead.
protected  int mBitmapAlignment
          Deprecated. Use setBitmapAlignment(int) instead.
protected  int mBitmapTitlePadding
          Deprecated. Use setBitmapTitlePadding(int) and getBitmapTitlePadding() instead.
protected  int mBottomPadding
          Deprecated. Use setVerticalBitmapPadding(int, int) instead.
protected  boolean mDebouncing
          Deprecated. For internal use only.
protected  Bitmap mDisabledBitmap
          Deprecated. Use setBitmap(danger.ui.Bitmap) and getCurrentBitmap() instead.
protected  Bitmap mDisabledIconTitle
          Deprecated. Use setIconTitle(danger.ui.Bitmap) and getCurrentIconTitle() instead.
protected  Bitmap mFocusedBitmap
          Deprecated. Use setBitmap(danger.ui.Bitmap) and getCurrentBitmap() instead.
protected  Bitmap mFocusedIconTitle
          Deprecated. Use setIconTitle(danger.ui.Bitmap) and getCurrentIconTitle() instead.
protected  Bitmap mIconTitle
          Deprecated. Use setIconTitle(danger.ui.Bitmap) and getCurrentIconTitle() instead.
protected  boolean mInvertOnHighlight
          Deprecated. Use setBitmapInvertOnHighlight(boolean) instead.
protected  int mLeftPadding
          Deprecated. Use setHorizontalPadding(int) and getLeftPadding() instead.
protected  int mMinWidth
          Deprecated. Use setMinWidth(int) instead.
protected  int mRightPadding
          Deprecated. Use setHorizontalPadding(int) and getRightPadding() instead.
protected  char mShortcut
          Deprecated. Use setShortcut(char) and matchAndDispatchShortcut(char, danger.app.Event) instead.
protected  int mShortcutColor
          Deprecated. Use setShortcutColor(int) instead.
protected  String mShortcutLabel
          Deprecated. Use setShortcutLabel(java.lang.String) and hasShortcutLabel() instead.
protected  int mShortcutModifiers
          Deprecated. Use setShortcut(char) and matchAndDispatchShortcut(char, danger.app.Event) instead.
protected  int mShortcutPadding
          Deprecated. Use setShortcutPadding(int) instead.
protected  int mTitleJustification
          Deprecated. Use setTitleJustification(int) instead.
protected  int mTopPadding
          Deprecated. Use setVerticalBitmapPadding(int, int) instead.
protected static int PAD_BITMAP_HEIGHT
          Deprecated. For internal use only.
protected static int PAD_BITMAP_STRING
          Deprecated. For internal use only.
protected static int PAD_FONT_HEIGHT
          Deprecated. For internal use only.
protected static int SHORTCUT_PADDING
          Deprecated. For internal use only.
protected static int UNDEFINED_COLOR
          Deprecated. For internal use only.
 
Fields inherited from class danger.ui.Control
mValue
 
Fields inherited from class danger.ui.View
DEFAULT_SCROLL_FOCUS_MARGIN, FOCUS_DEFAULT, FOCUS_DOWNWARD, FOCUS_LEFTWARD, FOCUS_NONE, FOCUS_RIGHTWARD, FOCUS_UPWARD, mOriginX, mOriginY, mStyle, POSITION_ABOVE, POSITION_ALIGN_BASELINE, POSITION_ALIGN_BOTTOM, POSITION_ALIGN_HORIZONTALLY, POSITION_ALIGN_LEFT, POSITION_ALIGN_PARENT_BOTTOM, POSITION_ALIGN_PARENT_RIGHT, POSITION_ALIGN_RIGHT, POSITION_ALIGN_TOP, POSITION_ALIGN_VERTICALLY, POSITION_BELOW, POSITION_CENTER_HORIZONTALLY, POSITION_CENTER_VERTICALLY, POSITION_TO_LEFT, POSITION_TO_RIGHT, PREFER_DIRECTION_NONE, PREFER_HORIZONTAL_DIRECTION, PREFER_VERTICAL_DIRECTION, STATE_AT_AND_SPACE_PAGE, STATE_CAN_FOCUS, STATE_DEBUG_BOUNDS, STATE_ENABLED, STATE_FOCUSED, STATE_MAKE_DING, STATE_PARTIAL_FOCUS_OK, STATE_TRANSPARENT, STATE_VISIBLE, WIDTH_FILL_TO_RIGHT
 
Constructor Summary
Button()
          Create a Button with no title or bitmap.
Button(Bitmap inBitmap)
          Create a Button with the specified bitmap, but no title.
Button(Bitmap inBitmap, CharSequence inTitle)
          Create a Button with the specified bitmap and title.
Button(Bitmap inBitmap, String inTitle)
          Create a Button with the specified bitmap and title.
Button(CharSequence inTitle)
          Create a Button with the specified title.
Button(CharSequence title, char shortcut, int shortcutPadding)
          Create a Button with the specified title, shortcut, and shortcut padding.
Button(CharSequence title, char shortcut, int shortcutPadding, int shortcutModifiers)
          Create a Button with the specified title, shortcut, shortcut padding, and shortcut modifiers.
Button(String inTitle)
          Create a Button with the specified title.
Button(String title, char shortcut, int shortcutPadding)
          Create a Button with the specified title, shortcut, and shortcut padding.
Button(String title, char shortcut, int shortcutPadding, int shortcutModifiers)
          Create a Button with the specified title, shortcut, shortcut padding, and shortcut modifiers.
 
Method Summary
 void calcSize()
          Change the width and height of the button to fit its component parts (title, bitmap, and shortcut (if any)).
protected  void drawBitmap(Pen pen, int x, int y, Bitmap bitmap)
          Draw the bitmap at the specified location.
protected  void drawFrame(Pen p, Rect dim)
          Draw the frame of the button.
protected  void drawShortcut(Pen pen, int x, int y)
          Draw the button shortcut at the specified location.
protected  void drawTitle(Pen pen, int x, int y)
          Draw the button title at the specified location.
 boolean eventKeyDown(char inChar, Event event)
          This method is called when the user presses a key.
 boolean eventKeyUp(char inChar, Event event)
          Processes key releases directed at this container.
 boolean eventWidgetDown(int inWhichWidget, Event event)
          Handle the pressing of a device widget
 boolean eventWidgetUp(int inWhichWidget, Event event)
          Handle the release of a device widget
 int getBaseline()
          Get the baseline of this Control's text or label.
 int getBitmapTitlePadding()
           
 Bitmap getCurrentBitmap()
          Return the bitmap being displayed in the button.
 Bitmap getCurrentIconTitle()
          Return the icon title being displayed in the button.
 int getLeftPadding()
           
 int getRightPadding()
           
 int getShortcutLabelWidth(Font font)
           
 boolean hasShortcutLabel()
           
protected  boolean hasTitle()
          Returns true if the button has a title or title icon.
 boolean matchAndDispatchShortcut(char shortcut, Event event)
          Determine if the shortcut matches the shortcut for this button.
protected  void onSetTitle(String title)
          This method is called when the title is set via a call to Control.setTitle(java.lang.String), to allow subclasses to perform any necessary actions associated with the event.
protected  void onStyleChanged(int attribute)
          This method is called when the specified attribute of this view's style has been modified.
 void paint(Pen pen)
          Draw the contents of this View.
 boolean receiveEvent(Event event)
          Entry point for event processing.
 void resizeHeightToFit()
          Change the height of the button to fit its component parts (title, bitmap, and shortcut (if any)).
 void resizeWidthToFit()
          Change the width of the button to fit its component parts (title, bitmap, and shortcut (if any)).
 void setBitmap(Bitmap inBitmap)
          Set the bitmap to display in the button.
 void setBitmap(Bitmap inBitmap, Bitmap inFocusedBitmap, Bitmap inDisabledBitmap)
          Set the bitmap to display in the button.
 void setBitmap(Bitmap inBitmap, Bitmap inFocusedBitmap, Bitmap inDisabledBitmap, boolean inResize)
          Set the bitmap to display in the button.
 void setBitmap(Bitmap inBitmap, boolean inResize)
          Set the bitmap to display in the button.
 void setBitmapAlignment(int alignment)
          Set the bitmap alignment - ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BOTTOM, or ALIGN_TOP - relative to the button title.
 void setBitmapAlignment(int alignment, boolean inResize)
          Set the bitmap alignment - ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BOTTOM, or ALIGN_TOP - relative to the button title.
 void setBitmapInvertOnHighlight(boolean invertOnHighlight)
          Specify whether the bitmap should be inverted when the button is focused.
 void setBitmapTitlePadding(int padding)
          Specify the number of pixels between the bitmap and title.
 void setBitmapTitlePadding(int padding, boolean inResize)
           
 void setHorizontalPadding(int padding)
          Specify the amount of space from the left edge of the button to the bitmap (if any) or title.
 void setHorizontalPadding(int left, int right)
          Specify the amount of space from the left edge of the button to the bitmap (if any) or title.
 void setHorizontalPadding(int left, int right, boolean inResize)
           
 void setIconTitle(Bitmap iconTitle)
          Specifies an icons to use for the title.
 void setIconTitle(Bitmap iconTitle, Bitmap focusedIconTitle, Bitmap disabledIconTitle)
          Specifies a set of unfocused/focused/disabled icons to use for the title.
 void setIconTitle(Bitmap iconTitle, Bitmap focusedIconTitle, Bitmap disabledIconTitle, boolean inResize)
          Specifies a set of unfocused/focused/disabled icons to use for the title.
 void setMinWidth(int minWidth)
          Set the minimum width for the button.
 void setShortcut(char shortcut)
          Set the shortcut for the button.
 void setShortcut(char shortcut, int modifiers)
          Set the shortcut for the button.
 void setShortcut(char shortcut, int modifiers, boolean inResize)
          Set the shortcut for the button.
 void setShortcut(char shortcut, int modifiers, String shortcutLabel, boolean inResize)
          Set the shortcut for the button.
 void setShortcut(char shortcut, String shortcutLabel)
          Set the shortcut for the button.
 void setShortcut(char shortcut, String shortcutLabel, boolean inResize)
          Set the shortcut for the button.
 void setShortcutColor(int color)
           
 void setShortcutLabel(String shortcutLabel)
          Specify the shortcut label.
 void setShortcutLabel(String shortcutLabel, boolean inResize)
          Specify the shortcut label.
 void setShortcutPadding(int padding)
           
 void setTitleJustification(int justification)
           
 void setVerticalBitmapPadding(int top, int bottom)
          Specify the amount of padding above and below the bitmap or icon title.
 void setVerticalBitmapPadding(int top, int bottom, boolean inResize)
           
 
Methods inherited from class danger.ui.Control
drawFocusBox, drawIdleBox, drawIdleBox, getEvent, getEventListener, getEventType, getHasBorder, getMaxToolTipLines, getTitle, getTitleSequence, getToolTip, getValue, hasToolTip, loseFocus, onSetHasBorder, sendEvent, setEvent, setEvent, setEvent, setEvent, setEvent, setEventArg, setEventListener, setHasBorder, setMaxToolTipLines, setTitle, setTitle, setToolTip, setValue, showToolTip, takeFocus
 
Methods inherited from class danger.ui.Container
addChild, addChild, addChildAt, addChildAt, addFromContainerResource, addFromContainerResource, addFromContainerResource, addFromDialogResource, addFromDialogResource, advanceFocus, advanceFocusInWindow, childCount, childIsOnScreen, disable, enable, eventKeyHeld, eventKeyRepeat, eventPeriodicPulse, eventRawKeyDown, eventRawKeyHeld, eventRawKeyRepeat, eventRawKeyUp, eventShortcut, eventWidgetHeld, focusedDescendantIsValid, getBottomChild, getBottomChild, getChildAt, getChildIndex, getChildWithID, getControlWithID, getDescendantWithID, getFirstChild, getFirstFocusableChild, getFocusableChildInWindow, getFocusedChild, getFocusedLeaf, getInterestingRect, getLastChild, getLastFocusableChild, getLeftMostChild, getNextFocusableChild, getNextFocusableChild, getPageHeight, getPrevFocusableChild, getPrevFocusableChild, getRightMostChild, getRightMostChild, handleButtonShortcut, hideAllChildren, isDescendant, keepRectInView, moveChildToIndex, onChildPositionChanged, onChildSizeChanged, onChildVisibilityChanged, pageToEnd, pageToHome, paintChildren, reflowChildren, removeAllChildren, removeChild, reverseFocus, setFocusedChild, setFocusedChild, setFocusedChild, setFocusedDescendant, setFocusedDescendant, setFocusedDescendant, setFocusToFirstDescendant, setFormatDateForControlWithID, setFormatDateForTextControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setListenerForAllControls, setReflowAdjustHeight, setWindow, showAllChildren, snapHeightToChildren, snapHeightToChildren, snapToChildren, snapWidthToChildren, snapWidthToChildren, willFocusWithin, willFocusWithin
 
Methods inherited from class danger.ui.View
boundsIntersect, boundsIntersect, canLoseFocus, clear, clear, copyStyle, getAcceptFocus, getBackgroundColor, getBottom, getBounds, getBounds, getFocusTraversalDirection, getFocusTraversalFrom, getFocusTraversalPolicy, getFrame, getFrame, getGlobalBottom, getGlobalLeft, getGlobalRight, getGlobalTop, getHeight, getID, getInterestingRect, getLabelFont, getLabelFont, getLeft, getOrigin, getOrigin, getOriginX, getOriginY, getParent, getParentContainer, getPartialFocusOK, getRight, getScrollFocusMargin, getSibling, getState, getStyle, getStyleColor, getStyleFont, getTop, getWidth, getWindow, globalToLocal, globalToLocalH, globalToLocalV, hide, invalidate, invalidate, invalidate, invalidateIndependentOfOrigin, invalidateIndependentOfOrigin, isEnabled, isFocusable, isFocused, isOnScreen, isTransparent, isVisible, isVisibleInHierarchy, isVisibleOnScreen, justSetVisible, localToGlobal, localToGlobal, localToGlobalH, localToGlobalV, localToWindow, moveBy, notifyWhenParentSizeChanges, notifyWhenPositionChanges, notifyWhenSizeChanges, offsetOrigin, offsetOrigin, onAddedToParent, onDecoded, onEnabledStateChanged, onHide, onPeriodicPulse, onPositionChanged, onRemovedFromParent, onShortcut, onShortcut, onShortcutConsumed, onShow, onSizeChanged, onViewPositionChanged, onViewSizeChanged, onWindowPaint, playLimitSound, receiveEventInternal, resetOrigin, sendEventToWindow, setAcceptFocus, setAtAndSpacePage, setBackground, setBackgroundColor, setBottom, setDebugBounds, setDynamicPosition, setDynamicWidth, setEnabled, setFocusTraversalDirection, setFocusTraversalFrom, setFocusTraversalPolicy, setFrame, setHeight, setKeyedValue, setLabelFont, setLeft, setMakeLimitNoise, setOrigin, setOrigin, setPartialFocusOK, setPosition, setPreferredDirection, setRight, setScrollFocusMargin, setSize, setStyle, setStyleColor, setStyleFont, setStyleFrameColor, setTop, setTransparent, setVisible, setWidth, shouldDropEvent, show, showContextMenu, styleIsDefault, swapStyleColors, windowToLocal
 
Methods inherited from class danger.app.Listener
cancelEvents, childEventPump, childEventPumpDone, eventProblem, isDispatchingThread, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendLowPriorityEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mBitmap

protected Bitmap mBitmap
Deprecated. Use setBitmap(danger.ui.Bitmap) and getCurrentBitmap() instead.

mFocusedBitmap

protected Bitmap mFocusedBitmap
Deprecated. Use setBitmap(danger.ui.Bitmap) and getCurrentBitmap() instead.

mDisabledBitmap

protected Bitmap mDisabledBitmap
Deprecated. Use setBitmap(danger.ui.Bitmap) and getCurrentBitmap() instead.

mIconTitle

protected Bitmap mIconTitle
Deprecated. Use setIconTitle(danger.ui.Bitmap) and getCurrentIconTitle() instead.

mFocusedIconTitle

protected Bitmap mFocusedIconTitle
Deprecated. Use setIconTitle(danger.ui.Bitmap) and getCurrentIconTitle() instead.

mDisabledIconTitle

protected Bitmap mDisabledIconTitle
Deprecated. Use setIconTitle(danger.ui.Bitmap) and getCurrentIconTitle() instead.

mBitmapAlignment

protected int mBitmapAlignment
Deprecated. Use setBitmapAlignment(int) instead.

mInvertOnHighlight

protected boolean mInvertOnHighlight
Deprecated. Use setBitmapInvertOnHighlight(boolean) instead.

mShortcut

protected char mShortcut
Deprecated. Use setShortcut(char) and matchAndDispatchShortcut(char, danger.app.Event) instead.

mShortcutModifiers

protected int mShortcutModifiers
Deprecated. Use setShortcut(char) and matchAndDispatchShortcut(char, danger.app.Event) instead.

mShortcutLabel

protected String mShortcutLabel
Deprecated. Use setShortcutLabel(java.lang.String) and hasShortcutLabel() instead.

mDebouncing

protected boolean mDebouncing
Deprecated. For internal use only.

mMinWidth

protected int mMinWidth
Deprecated. Use setMinWidth(int) instead.

mShortcutPadding

protected int mShortcutPadding
Deprecated. Use setShortcutPadding(int) instead.

mShortcutColor

protected int mShortcutColor
Deprecated. Use setShortcutColor(int) instead.

mTitleJustification

protected int mTitleJustification
Deprecated. Use setTitleJustification(int) instead.

mLeftPadding

protected int mLeftPadding
Deprecated. Use setHorizontalPadding(int) and getLeftPadding() instead.

mRightPadding

protected int mRightPadding
Deprecated. Use setHorizontalPadding(int) and getRightPadding() instead.

mBitmapTitlePadding

protected int mBitmapTitlePadding
Deprecated. Use setBitmapTitlePadding(int) and getBitmapTitlePadding() instead.

mTopPadding

protected int mTopPadding
Deprecated. Use setVerticalBitmapPadding(int, int) instead.

mBottomPadding

protected int mBottomPadding
Deprecated. Use setVerticalBitmapPadding(int, int) instead.

UNDEFINED_COLOR

protected static final int UNDEFINED_COLOR
Deprecated. For internal use only.
See Also:
Constant Field Values

CAP_WIDTH

protected static final int CAP_WIDTH
Deprecated. For internal use only.
See Also:
Constant Field Values

PAD_BITMAP_STRING

protected static final int PAD_BITMAP_STRING
Deprecated. For internal use only.
See Also:
Constant Field Values

PAD_BITMAP_HEIGHT

protected static final int PAD_BITMAP_HEIGHT
Deprecated. For internal use only.
See Also:
Constant Field Values

PAD_FONT_HEIGHT

protected static final int PAD_FONT_HEIGHT
Deprecated. For internal use only.
See Also:
Constant Field Values

BITMAP_ONLY_PADDING

protected static final int BITMAP_ONLY_PADDING
Deprecated. For internal use only.
See Also:
Constant Field Values

DEBOUNCE_TIMEOUT

protected static final int DEBOUNCE_TIMEOUT
Deprecated. For internal use only.
See Also:
Constant Field Values

SHORTCUT_PADDING

protected static final int SHORTCUT_PADDING
Deprecated. For internal use only.
See Also:
Constant Field Values

ALIGN_LEFT

public static final int ALIGN_LEFT
Possible argument to setBitmapAlignment(int). Specifies that the bitmap should be placed to the left of the title.

See Also:
Constant Field Values

ALIGN_RIGHT

public static final int ALIGN_RIGHT
Possible argument to setBitmapAlignment(int). Specifies that the bitmap should be placed to the right of the title.

See Also:
Constant Field Values

ALIGN_BOTTOM

public static final int ALIGN_BOTTOM
Possible argument to setBitmapAlignment(int). Specifies that the bitmap should be placed at the bottom of the button.

See Also:
Constant Field Values

ALIGN_TOP

public static final int ALIGN_TOP
Possible argument to setBitmapAlignment(int). Specifies that the bitmap should be placed at the top of the button.

See Also:
Constant Field Values
Constructor Detail

Button

public Button()
Create a Button with no title or bitmap.


Button

public Button(String inTitle)
Create a Button with the specified title.


Button

public Button(CharSequence inTitle)
Create a Button with the specified title.


Button

public Button(Bitmap inBitmap)
Create a Button with the specified bitmap, but no title.


Button

public Button(Bitmap inBitmap,
              String inTitle)
Create a Button with the specified bitmap and title.


Button

public Button(Bitmap inBitmap,
              CharSequence inTitle)
Create a Button with the specified bitmap and title.


Button

public Button(String title,
              char shortcut,
              int shortcutPadding)
Create a Button with the specified title, shortcut, and shortcut padding. The shortcut will not require any modifier keys to be held to activate the shortcut.

See Also:
setShortcutPadding(int)

Button

public Button(CharSequence title,
              char shortcut,
              int shortcutPadding)
Create a Button with the specified title, shortcut, and shortcut padding. The shortcut will not require any modifier keys to be held to activate the shortcut.

See Also:
setShortcutPadding(int)

Button

public Button(String title,
              char shortcut,
              int shortcutPadding,
              int shortcutModifiers)
Create a Button with the specified title, shortcut, shortcut padding, and shortcut modifiers.

Parameters:
shortcutModifiers - the modifiers that need to be held down to activate the shortcut. Can be any combination of Shortcut.MODIFIER_MENU, Shortcut.MODIFIER_SHIFT, and Shortcut.MODIFIER_ALT.
See Also:
setShortcutPadding(int)

Button

public Button(CharSequence title,
              char shortcut,
              int shortcutPadding,
              int shortcutModifiers)
Create a Button with the specified title, shortcut, shortcut padding, and shortcut modifiers.

Parameters:
shortcutModifiers - the modifiers that need to be held down to activate the shortcut. Can be any combination of Shortcut.MODIFIER_MENU, Shortcut.MODIFIER_SHIFT, and Shortcut.MODIFIER_ALT.
See Also:
setShortcutPadding(int)
Method Detail

setMinWidth

public void setMinWidth(int minWidth)
Set the minimum width for the button. By default, buttons can be any size. This method ensures that the button is no narrower than the specified value. Note that DialogWindow frame buttons already have this value set, so you do not need to call this method for those buttons.


onStyleChanged

protected void onStyleChanged(int attribute)
Description copied from class: View
This method is called when the specified attribute of this view's style has been modified. Base implementation does nothing.

Overrides:
onStyleChanged in class View

setBitmap

public void setBitmap(Bitmap inBitmap)
Set the bitmap to display in the button. The same bitmap will be used regardless of the state of the button. The button will automatically resize to fit the bitmap.


setBitmap

public void setBitmap(Bitmap inBitmap,
                      boolean inResize)
Set the bitmap to display in the button.

Parameters:
inResize - whether to resize to fit the bitmap precisely

setBitmap

public void setBitmap(Bitmap inBitmap,
                      Bitmap inFocusedBitmap,
                      Bitmap inDisabledBitmap)
Set the bitmap to display in the button. Use this method to specify different bitmaps depending on the state of the button - normal (enabled, not focused), focused, and disabled. The button will automatically resize to fit the bitmap.


setBitmap

public void setBitmap(Bitmap inBitmap,
                      Bitmap inFocusedBitmap,
                      Bitmap inDisabledBitmap,
                      boolean inResize)
Set the bitmap to display in the button. Use this method to specify different bitmaps depending on the state of the button - normal (enabled, not focused), focused, and disabled.

Parameters:
inResize - whether to resize to fit the bitmap precisely

setBitmapAlignment

public void setBitmapAlignment(int alignment)
Set the bitmap alignment - ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BOTTOM, or ALIGN_TOP - relative to the button title. The button will automatically resize to handle the new alignment.


setBitmapAlignment

public void setBitmapAlignment(int alignment,
                               boolean inResize)
Set the bitmap alignment - ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BOTTOM, or ALIGN_TOP - relative to the button title.

Parameters:
inResize - whether to resize to handle the new alignment

setBitmapInvertOnHighlight

public void setBitmapInvertOnHighlight(boolean invertOnHighlight)
Specify whether the bitmap should be inverted when the button is focused. By default, this is turned off.


resizeHeightToFit

public void resizeHeightToFit()
Change the height of the button to fit its component parts (title, bitmap, and shortcut (if any)). The width of the button is left unchanged.


resizeWidthToFit

public void resizeWidthToFit()
Change the width of the button to fit its component parts (title, bitmap, and shortcut (if any)). The height of the button is left unchanged.


calcSize

public void calcSize()
Change the width and height of the button to fit its component parts (title, bitmap, and shortcut (if any)).


paint

public void paint(Pen pen)
Description copied from class: View
Draw the contents of this View. This method is called by the graphics system when the View needs to be repainted. A Pen will be provided which is appropriately clipped and translated for drawing on this View.

The implementation of this method in this class will merely call clear() pen, if this View is opaque (not transparent), and will do nothing otherwise. If you don't need this behavior, then there is no point in calling super.paint() in an overriding method.

Overrides:
paint in class Container
Parameters:
pen - non-null; the pen to use for drawing operations

getBaseline

public int getBaseline()
Description copied from class: Control
Get the baseline of this Control's text or label. The standard implementation just returns the same as View.getHeight(), but subclasses that display text should override it to return something more appropriate.

Overrides:
getBaseline in class Control

drawFrame

protected void drawFrame(Pen p,
                         Rect dim)
Draw the frame of the button.


drawShortcut

protected void drawShortcut(Pen pen,
                            int x,
                            int y)
Draw the button shortcut at the specified location.


drawTitle

protected void drawTitle(Pen pen,
                         int x,
                         int y)
Draw the button title at the specified location.


drawBitmap

protected void drawBitmap(Pen pen,
                          int x,
                          int y,
                          Bitmap bitmap)
Draw the bitmap at the specified location.


getCurrentBitmap

public Bitmap getCurrentBitmap()
Return the bitmap being displayed in the button. This bitmap may be different depending on the state of the button: (enabled, not focused), focused, and disabled.

See Also:
setBitmap(danger.ui.Bitmap)

getCurrentIconTitle

public Bitmap getCurrentIconTitle()
Return the icon title being displayed in the button. This bitmap may be different depending on the state of the button.

See Also:
setIconTitle(danger.ui.Bitmap)

onSetTitle

protected void onSetTitle(String title)
Description copied from class: Control
This method is called when the title is set via a call to Control.setTitle(java.lang.String), to allow subclasses to perform any necessary actions associated with the event. The implementation in this class is empty, so it is not necessary for an overriding method to call super.onSetTitle().

Overrides:
onSetTitle in class Control
Parameters:
title - non-null; what the title was set to

eventWidgetDown

public boolean eventWidgetDown(int inWhichWidget,
                               Event event)
Description copied from class: Container
Handle the pressing of a device widget

Overrides:
eventWidgetDown in class Container
Parameters:
inWhichWidget - the widget that went up
Returns:
whether or not the event was consumed

eventWidgetUp

public boolean eventWidgetUp(int inWhichWidget,
                             Event event)
Description copied from class: Container
Handle the release of a device widget

Overrides:
eventWidgetUp in class Container
Parameters:
inWhichWidget - the widget that went down
Returns:
whether or not the event was consumed

eventKeyDown

public boolean eventKeyDown(char inChar,
                            Event event)
Description copied from class: View
This method is called when the user presses a key. The default implementation turns space and @ into page-down and page-up events if you have View.setAtAndSpacePage(boolean).

Overrides:
eventKeyDown in class Container

eventKeyUp

public boolean eventKeyUp(char inChar,
                          Event event)
Description copied from class: Container
Processes key releases directed at this container.

Overrides:
eventKeyUp in class Container
Parameters:
inChar - the character being released.

receiveEvent

public boolean receiveEvent(Event event)
Description copied from class: Listener
Entry point for event processing. This method is called from a Dispatcher when it reads an Event in its queue that is targetted at this instance. The default behavior is to do nothing and return false. Subclasses are expected to override this method to do something more useful.

Overrides:
receiveEvent in class Container
Parameters:
event - non-null; the event to process
Returns:
whether (true) or not (false) this method actually handled the event to completion

setShortcut

public void setShortcut(char shortcut)
Set the shortcut for the button. The shortcut will not require any modifier keys to be held to activate the shortcut.


setShortcut

public void setShortcut(char shortcut,
                        int modifiers)
Set the shortcut for the button.

Parameters:
modifiers - the modifiers that need to be held down to activate the shortcut. Can be any combination of Shortcut.MODIFIER_MENU, Shortcut.MODIFIER_SHIFT, and Shortcut.MODIFIER_ALT. The button will be resized automatically as necessary.

setShortcut

public void setShortcut(char shortcut,
                        int modifiers,
                        boolean inResize)
Set the shortcut for the button.

Parameters:
modifiers - the modifiers that need to be held down to activate the shortcut. Can be any combination of Shortcut.MODIFIER_MENU, Shortcut.MODIFIER_SHIFT, and Shortcut.MODIFIER_ALT.
inResize - whether to resize the button to fit

setShortcut

public void setShortcut(char shortcut,
                        String shortcutLabel)
Set the shortcut for the button. The shortcut will not require any modifier keys to be held to activate the shortcut. The specified label will be used for display purposes. This will not affect the actual keystrokes required to activate the shortcut. The button will be resized automatically as necessary.


setShortcut

public void setShortcut(char shortcut,
                        String shortcutLabel,
                        boolean inResize)
Set the shortcut for the button. The shortcut will not require any modifier keys to be held to activate the shortcut. The specified label will be used for display purposes. This will not affect the actual keystrokes required to activate the shortcut.

Parameters:
inResize - whether to resize the button to fit

setShortcut

public void setShortcut(char shortcut,
                        int modifiers,
                        String shortcutLabel,
                        boolean inResize)
Set the shortcut for the button. The specified label will be used for display purposes. This will not affect the actual keystrokes required to activate the shortcut.

Parameters:
modifiers - the modifiers that need to be held down to activate the shortcut. Can be any combination of Shortcut.MODIFIER_MENU, Shortcut.MODIFIER_SHIFT, and Shortcut.MODIFIER_ALT.
inResize - whether to resize the button to fit

setShortcutLabel

public void setShortcutLabel(String shortcutLabel)
Specify the shortcut label. The label will be used for display purposes. This will not affect the actual keystrokes required to activate the shortcut. The button will be resized automatically as necessary.

See Also:
setShortcut(char)

setShortcutLabel

public void setShortcutLabel(String shortcutLabel,
                             boolean inResize)
Specify the shortcut label. The label will be used for display purposes. This will not affect the actual keystrokes required to activate the shortcut.

Parameters:
inResize - whether to resize the button to fit
See Also:
setShortcut(char)

getShortcutLabelWidth

public int getShortcutLabelWidth(Font font)

getLeftPadding

public int getLeftPadding()

getRightPadding

public int getRightPadding()

getBitmapTitlePadding

public int getBitmapTitlePadding()

hasShortcutLabel

public boolean hasShortcutLabel()

matchAndDispatchShortcut

public boolean matchAndDispatchShortcut(char shortcut,
                                        Event event)
Determine if the shortcut matches the shortcut for this button. Activates the button if it does. Returns true if it matched and activated the button.


setShortcutPadding

public void setShortcutPadding(int padding)

setHorizontalPadding

public void setHorizontalPadding(int padding)
Specify the amount of space from the left edge of the button to the bitmap (if any) or title. The same value is also used for the right side, as well. Note that the padding includes the border (if any). The default value is 6.


setHorizontalPadding

public void setHorizontalPadding(int left,
                                 int right)
Specify the amount of space from the left edge of the button to the bitmap (if any) or title. Also set the right amount of padding to the specified amount. Note that the padding includes the border (if any). The default value is 6.


setHorizontalPadding

public void setHorizontalPadding(int left,
                                 int right,
                                 boolean inResize)

setVerticalBitmapPadding

public void setVerticalBitmapPadding(int top,
                                     int bottom)
Specify the amount of padding above and below the bitmap or icon title. The default value is BITMAP_ONLY_PADDING pixels above and the same amount below.


setVerticalBitmapPadding

public void setVerticalBitmapPadding(int top,
                                     int bottom,
                                     boolean inResize)

setBitmapTitlePadding

public void setBitmapTitlePadding(int padding)
Specify the number of pixels between the bitmap and title. The default value is 3.


setBitmapTitlePadding

public void setBitmapTitlePadding(int padding,
                                  boolean inResize)

setShortcutColor

public final void setShortcutColor(int color)

setTitleJustification

public void setTitleJustification(int justification)

setIconTitle

public void setIconTitle(Bitmap iconTitle)
Specifies an icons to use for the title. If this method is called, then the text title is not used. The button is resized automatically.

Parameters:
iconTitle - unfocused version of the icon title

setIconTitle

public void setIconTitle(Bitmap iconTitle,
                         Bitmap focusedIconTitle,
                         Bitmap disabledIconTitle)
Specifies a set of unfocused/focused/disabled icons to use for the title. If this method is called, then the text title is not used. The button is resized automatically.

Parameters:
iconTitle - unfocused version of the icon title
focusedIconTitle - focused version of the icon title; if null, then the iconTitle version is used
disabledIconTitle - disabled version of the icon title; if null, then the iconTitle version is used

setIconTitle

public void setIconTitle(Bitmap iconTitle,
                         Bitmap focusedIconTitle,
                         Bitmap disabledIconTitle,
                         boolean inResize)
Specifies a set of unfocused/focused/disabled icons to use for the title. If this method is called, then the text title is not used.

Parameters:
iconTitle - unfocused version of the icon title
focusedIconTitle - focused version of the icon title; if null, then the iconTitle version is used
disabledIconTitle - disabled version of the icon title; if null, then the iconTitle version is used
inResize - whether to resize the button now

hasTitle

protected boolean hasTitle()
Returns true if the button has a title or title icon.