|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.app.Listener
danger.ui.View
danger.ui.Container
danger.ui.Control
danger.ui.Button
public class Button
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 |
| 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.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 |
|---|
protected Bitmap mBitmap
setBitmap(danger.ui.Bitmap) and getCurrentBitmap()
instead.protected Bitmap mFocusedBitmap
setBitmap(danger.ui.Bitmap) and getCurrentBitmap()
instead.protected Bitmap mDisabledBitmap
setBitmap(danger.ui.Bitmap) and getCurrentBitmap()
instead.protected Bitmap mIconTitle
setIconTitle(danger.ui.Bitmap) and getCurrentIconTitle()
instead.protected Bitmap mFocusedIconTitle
setIconTitle(danger.ui.Bitmap) and getCurrentIconTitle()
instead.protected Bitmap mDisabledIconTitle
setIconTitle(danger.ui.Bitmap) and getCurrentIconTitle()
instead.protected int mBitmapAlignment
setBitmapAlignment(int)
instead.protected boolean mInvertOnHighlight
setBitmapInvertOnHighlight(boolean) instead.protected char mShortcut
setShortcut(char) and
matchAndDispatchShortcut(char, danger.app.Event) instead.protected int mShortcutModifiers
setShortcut(char) and
matchAndDispatchShortcut(char, danger.app.Event) instead.protected String mShortcutLabel
setShortcutLabel(java.lang.String) and
hasShortcutLabel() instead.protected boolean mDebouncing
protected int mMinWidth
setMinWidth(int) instead.protected int mShortcutPadding
setShortcutPadding(int) instead.protected int mShortcutColor
setShortcutColor(int) instead.protected int mTitleJustification
setTitleJustification(int) instead.protected int mLeftPadding
setHorizontalPadding(int) and
getLeftPadding() instead.protected int mRightPadding
setHorizontalPadding(int) and
getRightPadding() instead.protected int mBitmapTitlePadding
setBitmapTitlePadding(int) and
getBitmapTitlePadding() instead.protected int mTopPadding
setVerticalBitmapPadding(int, int) instead.protected int mBottomPadding
setVerticalBitmapPadding(int, int) instead.protected static final int UNDEFINED_COLOR
protected static final int CAP_WIDTH
protected static final int PAD_BITMAP_STRING
protected static final int PAD_BITMAP_HEIGHT
protected static final int PAD_FONT_HEIGHT
protected static final int BITMAP_ONLY_PADDING
protected static final int DEBOUNCE_TIMEOUT
protected static final int SHORTCUT_PADDING
public static final int ALIGN_LEFT
setBitmapAlignment(int). Specifies
that the bitmap should be placed to the left of the title.
public static final int ALIGN_RIGHT
setBitmapAlignment(int). Specifies
that the bitmap should be placed to the right of the title.
public static final int ALIGN_BOTTOM
setBitmapAlignment(int). Specifies
that the bitmap should be placed at the bottom of the button.
public static final int ALIGN_TOP
setBitmapAlignment(int). Specifies
that the bitmap should be placed at the top of the button.
| Constructor Detail |
|---|
public Button()
public Button(String inTitle)
public Button(CharSequence inTitle)
public Button(Bitmap inBitmap)
public Button(Bitmap inBitmap,
String inTitle)
public Button(Bitmap inBitmap,
CharSequence inTitle)
public Button(String title,
char shortcut,
int shortcutPadding)
setShortcutPadding(int)
public Button(CharSequence title,
char shortcut,
int shortcutPadding)
setShortcutPadding(int)
public Button(String title,
char shortcut,
int shortcutPadding,
int shortcutModifiers)
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.setShortcutPadding(int)
public Button(CharSequence title,
char shortcut,
int shortcutPadding,
int shortcutModifiers)
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.setShortcutPadding(int)| Method Detail |
|---|
public void setMinWidth(int minWidth)
DialogWindow frame buttons already have this
value set, so you do not need to call this method for those buttons.
protected void onStyleChanged(int attribute)
View
onStyleChanged in class Viewpublic void setBitmap(Bitmap inBitmap)
public void setBitmap(Bitmap inBitmap,
boolean inResize)
inResize - whether to resize to fit the bitmap precisely
public void setBitmap(Bitmap inBitmap,
Bitmap inFocusedBitmap,
Bitmap inDisabledBitmap)
public void setBitmap(Bitmap inBitmap,
Bitmap inFocusedBitmap,
Bitmap inDisabledBitmap,
boolean inResize)
inResize - whether to resize to fit the bitmap preciselypublic void setBitmapAlignment(int 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.
public void setBitmapAlignment(int alignment,
boolean inResize)
ALIGN_LEFT, ALIGN_RIGHT,
ALIGN_BOTTOM, or ALIGN_TOP - relative to the
button title.
inResize - whether to resize to handle the new alignmentpublic void setBitmapInvertOnHighlight(boolean invertOnHighlight)
public void resizeHeightToFit()
public void resizeWidthToFit()
public void calcSize()
public void paint(Pen pen)
ViewThe 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.
paint in class Containerpen - non-null; the pen to use for drawing operationspublic int getBaseline()
ControlView.getHeight(), but subclasses that display text
should override it to return something more appropriate.
getBaseline in class Control
protected void drawFrame(Pen p,
Rect dim)
protected void drawShortcut(Pen pen,
int x,
int y)
protected void drawTitle(Pen pen,
int x,
int y)
protected void drawBitmap(Pen pen,
int x,
int y,
Bitmap bitmap)
public Bitmap getCurrentBitmap()
setBitmap(danger.ui.Bitmap)public Bitmap getCurrentIconTitle()
setIconTitle(danger.ui.Bitmap)protected void onSetTitle(String title)
ControlControl.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().
onSetTitle in class Controltitle - non-null; what the title was set to
public boolean eventWidgetDown(int inWhichWidget,
Event event)
Container
eventWidgetDown in class ContainerinWhichWidget - the widget that went up
public boolean eventWidgetUp(int inWhichWidget,
Event event)
Container
eventWidgetUp in class ContainerinWhichWidget - the widget that went down
public boolean eventKeyDown(char inChar,
Event event)
ViewView.setAtAndSpacePage(boolean).
eventKeyDown in class Container
public boolean eventKeyUp(char inChar,
Event event)
Container
eventKeyUp in class ContainerinChar - the character being released.public boolean receiveEvent(Event event)
ListenerDispatcher 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.
receiveEvent in class Containerevent - non-null; the event to process
true) or not (false) this
method actually handled the event to completionpublic void setShortcut(char shortcut)
public void setShortcut(char shortcut,
int modifiers)
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.
public void setShortcut(char shortcut,
int modifiers,
boolean inResize)
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
public void setShortcut(char shortcut,
String shortcutLabel)
public void setShortcut(char shortcut,
String shortcutLabel,
boolean inResize)
inResize - whether to resize the button to fit
public void setShortcut(char shortcut,
int modifiers,
String shortcutLabel,
boolean inResize)
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 fitpublic void setShortcutLabel(String shortcutLabel)
setShortcut(char)
public void setShortcutLabel(String shortcutLabel,
boolean inResize)
inResize - whether to resize the button to fitsetShortcut(char)public int getShortcutLabelWidth(Font font)
public int getLeftPadding()
public int getRightPadding()
public int getBitmapTitlePadding()
public boolean hasShortcutLabel()
public boolean matchAndDispatchShortcut(char shortcut,
Event event)
public void setShortcutPadding(int padding)
public void setHorizontalPadding(int padding)
public void setHorizontalPadding(int left,
int right)
public void setHorizontalPadding(int left,
int right,
boolean inResize)
public void setVerticalBitmapPadding(int top,
int bottom)
BITMAP_ONLY_PADDING pixels above
and the same amount below.
public void setVerticalBitmapPadding(int top,
int bottom,
boolean inResize)
public void setBitmapTitlePadding(int padding)
public void setBitmapTitlePadding(int padding,
boolean inResize)
public final void setShortcutColor(int color)
public void setTitleJustification(int justification)
public void setIconTitle(Bitmap iconTitle)
iconTitle - unfocused version of the icon title
public void setIconTitle(Bitmap iconTitle,
Bitmap focusedIconTitle,
Bitmap disabledIconTitle)
iconTitle - unfocused version of the icon titlefocusedIconTitle - focused version of the icon title; if null,
then the iconTitle version is useddisabledIconTitle - disabled version of the icon title; if null,
then the iconTitle version is used
public void setIconTitle(Bitmap iconTitle,
Bitmap focusedIconTitle,
Bitmap disabledIconTitle,
boolean inResize)
iconTitle - unfocused version of the icon titlefocusedIconTitle - focused version of the icon title; if null,
then the iconTitle version is useddisabledIconTitle - disabled version of the icon title; if null,
then the iconTitle version is usedinResize - whether to resize the button nowprotected boolean hasTitle()