danger.ui
Class IconLabel

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.GroupBox
                      extended by danger.ui.IconLabel
All Implemented Interfaces:
ToolTipOwner


public class IconLabel
extends GroupBox

An IconLabel is a Container that has an icon and title over a rounded rect background. It has a convenience method for adding a Button, as well.


Field Summary
static int ICON_ALIGNMENT_BOTTOM
          For use with setIconVerticalAlignment(int).
static int ICON_ALIGNMENT_TOP
          For use with setIconVerticalAlignment(int).
static int ICON_ALIGNMENT_VERTICAL_CENTER
          For use with setIconVerticalAlignment(int).
 
Fields inherited from class danger.ui.GroupBox
CONTROL_POS_LEFT, CONTROL_POS_TOP
 
Fields inherited from class danger.ui.View
DEFAULT_SCROLL_FOCUS_MARGIN, FOCUS_DEFAULT, FOCUS_DOWNWARD, FOCUS_FROM_NOWHERE, FOCUS_LEFTWARD, FOCUS_NONE, FOCUS_RIGHTWARD, FOCUS_UPWARD, HEIGHT_AUTO, HEIGHT_FILL_TO_BOTTOM, HEIGHT_FILL_TO_TOP, HEIGHT_MATCH_CONTROL, HEIGHT_PERCENTAGE, POSITION_ABOVE, POSITION_ALIGN_BASELINE, POSITION_ALIGN_BOTTOM, POSITION_ALIGN_HORIZONTALLY, POSITION_ALIGN_LEFT, POSITION_ALIGN_PARENT_BOTTOM, POSITION_ALIGN_PARENT_RIGHT, POSITION_ALIGN_PARENT_TOP, POSITION_ALIGN_RIGHT, POSITION_ALIGN_TOP, POSITION_ALIGN_VERTICALLY, POSITION_BELOW, POSITION_BELOW_GROUP_BOX_HEADING, 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_AUTO, WIDTH_FILL_TO_LEFT, WIDTH_FILL_TO_RIGHT, WIDTH_MATCH_CONTROL, WIDTH_PERCENTAGE
 
Constructor Summary
IconLabel()
          Construct an IconLabel with no bitmp and no title.
IconLabel(Bitmap inIcon, String inTitle)
          Construct an IconLabel with the specified bitmap and title.
 
Method Summary
 Button addButton(CharSequence inButtonTitle)
          Add a button with the specified title to this icon label.
 Button addButton(String inButtonTitle)
          Add a button with the specified title to this icon label.
 int getBaseline()
          Get the baseline of this Control's text or label.
 Button getButton()
          Get the button for this icon label, as set by addButton(String) or addButton(CharSequence).
 Bitmap getIcon()
          Get the icon for this IconLabel.
 void paint(Pen p)
          Draw the contents of this View.
 void setIcon(Bitmap inIcon)
          Set the icon to display in the icon label.
 void setIconVerticalAlignment(int inAlign)
          Set the vertical alignment for the icon.
 void setSize(int inWidth, int inHeight)
          Simultaneously set the width and height of this View.
 
Methods inherited from class danger.ui.GroupBox
addChild, addChildAt, drawBackground, eventWidgetUp, getAutoResize, getHeadingBottom, isFocusable, layoutOnOffControl, onChildVisibilityChanged, onEnabledStateChanged, onViewPositionChanged, onViewSizeChanged, reflowChildren, removeAllChildren, removeChild, setAutoResize, setAutoResize, setOnOffControl, setOnOffControl, setOnOffControlsEnabledState, setValue, snapToChildren, updateChildrenEnabledState
 
Methods inherited from class danger.ui.Control
drawFocusBox, drawIdleBox, drawIdleBox, getEvent, getEventListener, getEventType, getHasBorder, getMaxToolTipLines, getTitle, getTitleSequence, getToolTip, getValue, hasToolTip, loseFocus, notifyWhenBaselineChanges, onBaselineChanged, onControlBaselineChanged, onSetHasBorder, onSetTitle, sendEvent, setEvent, setEvent, setEvent, setEvent, setEvent, setEventArg, setEventListener, setEventMethod, setHasBorder, setMaxToolTipLines, setTitle, setTitle, setToolTip, showToolTip, takeFocus
 
Methods inherited from class danger.ui.Container
addChild, addChildAt, addFromContainerResource, addFromContainerResource, addFromContainerResource, addFromDialogResource, addFromDialogResource, advanceFocus, advanceFocusInWindow, childCount, childIsOnScreen, disable, enable, eventKeyDown, eventKeyHeld, eventKeyRepeat, eventKeyUp, eventPeriodicPulse, eventRawKeyDown, eventRawKeyHeld, eventRawKeyRepeat, eventRawKeyUp, eventShortcut, eventWidgetDown, 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, pageToEnd, pageToHome, paintChildren, receiveEvent, 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, snapWidthToChildren, snapWidthToChildren, willFocusWithin, willFocusWithin
 
Methods inherited from class danger.ui.View
boundsIntersect, boundsIntersect, canLoseFocus, clear, clear, copyStyle, getAcceptFocus, getBackgroundColor, getBottom, getBounds, getBounds, getData, 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, isFocused, isObscured, isOnScreen, isTransparent, isVisible, isVisibleInHierarchy, isVisibleOnScreen, justSetVisible, localToGlobal, localToGlobal, localToGlobalH, localToGlobalV, localToWindow, moveBy, notifyWhenFocusChanges, notifyWhenObscurityChanges, notifyWhenParentSizeChanges, notifyWhenPositionChanges, notifyWhenSizeChanges, notifyWhenVisibilityChanges, offsetOrigin, offsetOrigin, onAddedToParent, onDecoded, onHide, onPeriodicPulse, onPositionChanged, onRemovedFromParent, onShortcut, onShortcut, onShortcutConsumed, onShow, onSizeChanged, onStyleChanged, onSystemFontChanged, onViewFocusChanged, onViewObscurityChanged, onViewVisibilityChanged, onWindowPaint, playLimitSound, receiveEventInternal, resetOrigin, sendEventToWindow, setAcceptFocus, setAtAndSpacePage, setBackground, setBackgroundColor, setBottom, setData, setDebugBounds, setDynamicHeight, setDynamicPosition, setDynamicWidth, setEnabled, setFocusTraversalDirection, setFocusTraversalFrom, setFocusTraversalPolicy, setFrame, setHeight, setKeyedValue, setLabelFont, setLeft, setMakeLimitNoise, setOrigin, setOrigin, setPartialFocusOK, setPosition, setPreferredDirection, setRight, setScrollFocusMargin, 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

ICON_ALIGNMENT_VERTICAL_CENTER

public static final int ICON_ALIGNMENT_VERTICAL_CENTER
For use with setIconVerticalAlignment(int). Specifies that the icon should be centered vertically.

See Also:
Constant Field Values

ICON_ALIGNMENT_TOP

public static final int ICON_ALIGNMENT_TOP
For use with setIconVerticalAlignment(int). Specifies that the icon should be placed at the top.

See Also:
Constant Field Values

ICON_ALIGNMENT_BOTTOM

public static final int ICON_ALIGNMENT_BOTTOM
For use with setIconVerticalAlignment(int). Specifies that the icon should be placed at the bottom.

See Also:
Constant Field Values
Constructor Detail

IconLabel

public IconLabel()
Construct an IconLabel with no bitmp and no title.


IconLabel

public IconLabel(Bitmap inIcon,
                 String inTitle)
Construct an IconLabel with the specified bitmap and title.

Parameters:
inIcon - the icon to display in the icon label.
inTitle - the title to display in the icon label.
Method Detail

paint

public void paint(Pen p)
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 GroupBox
Parameters:
p - 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

setSize

public void setSize(int inWidth,
                    int inHeight)
Description copied from class: View
Simultaneously set the width and height of this View.

Overrides:
setSize in class GroupBox

setIcon

public void setIcon(Bitmap inIcon)
Set the icon to display in the icon label.

Parameters:
inIcon - the icon to display in the icon label.

getIcon

public Bitmap getIcon()
Get the icon for this IconLabel. See setIcon(danger.ui.Bitmap).

Since:
4.0

addButton

public Button addButton(String inButtonTitle)
Add a button with the specified title to this icon label. The button will appear on the left side of the icon label. Returns the button that was added.

Parameters:
inButtonTitle - the title of the button to add.

addButton

public Button addButton(CharSequence inButtonTitle)
Add a button with the specified title to this icon label. The button will appear on the left side of the icon label. Returns the button that was added.

Parameters:
inButtonTitle - the title of the button to add.

getButton

public Button getButton()
Get the button for this icon label, as set by addButton(String) or addButton(CharSequence). Returns null if there is no button.


setIconVerticalAlignment

public void setIconVerticalAlignment(int inAlign)
Set the vertical alignment for the icon. The default alignment if this method is not called is ICON_ALIGNMENT_VERTICAL_CENTER.

Parameters:
inAlign - the vertical alignment for the icon; can be ICON_ALIGNMENT_VERTICAL_CENTER, ICON_ALIGNMENT_TOP, or ICON_ALIGNMENT_BOTTOM.