danger.ui
Class DialogWindow

java.lang.Object
  |
  +--danger.app.Listener
        |
        +--danger.ui.View
              |
              +--danger.ui.Container
                    |
                    +--danger.ui.Window
                          |
                          +--danger.ui.DialogWindow
Direct Known Subclasses:
AlertWindow, AudioPreviewWindow, DateDialog, ProgressWindow, StandardAlertWindow

public class DialogWindow
extends Window


Field Summary
static int kAppDialogStyle
           
static int kBottomPosition1
           
static int kBottomPosition2
           
static int kBottomPosition3
           
protected static int kButtonHeight
           
static int kDefaultWindowStyle
           
protected static int kMaxBottomButtons
           
protected static int kMaxButtons
           
protected static int kMinFrameButtonWidth
           
static int kSystemDialogStyle
           
static int kSystemErrorStyle
           
static int kSystemWindowStyle
           
static int kTopPosition1
           
static int kTopPosition2
           
protected  int m_bottomBorder
           
protected  boolean m_doAutoSize
           
protected  int m_leftBorder
           
protected  int m_rightBorder
           
protected  int m_topBorder
           
protected  Event mBackEvent
           
protected  Event[] mButtonEvents
           
protected  int[] mButtonIDs
           
protected  Button[] mButtons
           
protected  Button mCancelButton
           
protected  Event mCancelEvent
           
protected  Button mDefaultButton
           
protected  int mDefaultButtonPosition
           
protected  Listener mDefaultListener
           
protected  boolean mLayoutButtonsVertically
           
protected  Listener mListener
           
protected  boolean mNeedLayoutFrameButtons
           
protected  boolean mNeedToAddTopFrameButtons
           
protected  int[] mShortcuts
           
protected  View[] mTitlebarControls
           
 
Fields inherited from class danger.ui.Window
mBusyPaintCount, STATE_AUTO_HIDE_IF_IDLE, STATE_DROP_ORPHANED_EVENTS, STATE_FLOATING, STATE_FULLSCREEN
 
Fields inherited from class danger.ui.View
mOriginX, mOriginY, mStyle, STATE_CAN_FOCUS, STATE_DEBUG_BOUNDS, STATE_ENABLED, STATE_FOCUSED, STATE_TRANSPARENT, STATE_VISIBLE
 
Constructor Summary
DialogWindow()
           
DialogWindow(Bitmap inIcon)
           
DialogWindow(boolean showCancel)
           
DialogWindow(boolean showCancel, int windowStyle)
           
DialogWindow(java.lang.String inTitle)
           
DialogWindow(java.lang.String inTitle, Bitmap inIcon)
           
DialogWindow(java.lang.String inTitle, Bitmap inIcon, int windowStyle)
           
DialogWindow(java.lang.String inTitle, Bitmap inIcon, int windowStyle, boolean showCancel)
           
DialogWindow(java.lang.String inTitle, int windowStyle)
           
 
Method Summary
protected  void activateFrameButton(int index)
           
 Button addBottomFrameButton(java.lang.String buttonStr, int eventType, int data, java.lang.Object arg, int shortcut)
          Add a button to the alert window.
 void addChild(View child, int id)
           
 Button addFrameButton(int position, java.lang.String buttonStr, int eventType, int data, java.lang.Object arg)
          Add a button to the alert window.
 Button addFrameButton(int position, java.lang.String buttonStr, int eventType, int data, java.lang.Object arg, int shortcut)
          Add a button to the alert window.
 Button addFrameButton(int position, java.lang.String buttonStr, int eventType, int data, java.lang.Object arg, int shortcut, int id)
           
 Button addTopFrameButton(java.lang.String buttonStr, int eventType, int data, java.lang.Object arg, int shortcut)
           
protected  void computeTitleWidth()
           
 int convertShortcutKeyToButtonIndex(Event e)
           
 void drawDialogStyleFrame(Pen p, int windowStyle)
           
 void drawFrame(Pen p)
           
 void drawSystemWindowStyleFrame(Pen p)
           
 boolean eventWidgetUp(int widget, Event event)
          Handle the release of a device widget
 View getChildWithID(int id)
           
 Rect getContentRect()
           
 Button getDefaultFrameButton()
           
protected  Button getFrameButtonWithID(int id)
           
 Bitmap getIcon()
           
 java.lang.String getSleepScreenMessage()
          Override for system alerts
 java.lang.String getTitle()
           
 int getTitleBarHeight()
           
protected static Font getTitleFont()
           
 boolean handleShortcutKey(Event e)
          Handle a shortcut key event.
 void hide()
           
protected  void initTitleBarControlList()
           
 void layoutBottomFrameButtonsVertically(boolean flag)
          Layout buttons vertically instead of horizontally.
protected  void layoutFrame()
           
protected  void layoutFrameButtons()
           
protected  void layoutTopFrameButtons()
           
protected  Button newButtonWithShortcut(java.lang.String string, int shortcut)
           
 void paint(Pen pen)
          Draw the contents of this View.
protected  void positionBottomButtons()
           
protected  void positionDialog()
           
protected  void positionFrameButtons()
           
protected  void positionTopButtons()
           
 boolean receiveEvent(Event e)
          Entry point for event processing.
 void setAutoSize(boolean doAutoSize)
           
 void setBackEvent(Event e)
          Specifies an event to send when the back button is pressed.
 void setCancelButtonEvent(Event e)
           
 void setCancelButtonShortcutBitmap(Bitmap shortcut)
           
 void setContentSize(int width, int height)
           
 void setDefaultFrameButton(Button button)
           
 void setDefaultFrameButton(int which)
           
 void setDefaultListener(Listener listener)
           
protected  void setDrawBottomFrame(boolean drawFrame)
           
 void setEventForControlWithID(int id, Event newEvent)
           
protected  boolean setEventForFrameButtonWithID(int id, Event newEvent)
           
 void setFocusedChild(View inNewFocus)
           
 void setFrameButtonShortcut(int position, int shortcut)
           
 void setIcon(Bitmap inIcon)
           
 void setIconVerticalOffset(int offset)
           
 void setListener(Listener inListener)
          Set the listener for the alert window.
 void setNoDefaultFrameButton()
           
 void setShowCancel(boolean showCancel)
           
 void setSize(int width, int height)
           
 void setTitle(java.lang.String inTitle)
           
 void setTitleFormatDate(danger.internal.Date inDate)
           
 void setTitleFormatText(java.lang.String inArg0)
           
 void setTitleFormatText(java.lang.String[] inArgs)
           
 void setTitleFormatText(java.lang.String inArg0, java.lang.String inArg1)
           
 void setTitleFormatText(java.lang.String inArg0, java.lang.String inArg1, java.lang.String inArg2)
           
 void setWindowStyle(int windowStyle)
           
 void show()
           
 void snapToChildren(int inLeft, int inTop, int inRight, int inBottom)
          Reduces the size of this Container so that it exactly fits around its children with no extra space.
 void snapToChildren(int inLeft, int inTop, int inRight, int inBottom, boolean includeBottomFrame)
           
 
Methods inherited from class danger.ui.Window
addFromDialogResource, addFromDialogResource, addToChildIDList, addToChildIDList, adjustActionMenuState, autoHide, autoHideIfIdle, autoHideIfIdle, blocksChooser, centerHorizontal, centerOnScreen, centerUnderTitleBar, centerVertical, disableControlWithID, dropOrphanedEvents, enableControlWithID, getApplication, getControlWithID, getDescendantWithID, getExplicitIDOfChild, getIDOfChild, getListener, getWindowBelow, hideActiveMenu, hideControlWithID, isActionMenuVisible, isFloating, isFullScreen, isUnresponsive, onPeriodicPulse, onWindowPaint, receiveMessage, removeChildFromIDList, setFloating, setFormatDateForControlWithID, setFormatDateForTextControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setListenerForAllControls, setMaxChildID, setMaxControlID, setPosition, setTitled, shouldDropEvent, showControlWithID
 
Methods inherited from class danger.ui.Container
addChild, addChildAt, advanceFocus, childCount, childIsOnScreen, disable, enable, eventKeyDown, eventKeyHeld, eventKeyRepeat, eventKeyUp, eventPeriodicPulse, eventShortcut, eventWidgetDown, eventWidgetHeld, getBottomChild, getChildAt, getChildIndex, getFirstChild, getFirstFocusableChild, getFocusedChild, getLastChild, getLastFocusableChild, hideAllChildren, loseFocus, moveChildToIndex, paintChildren, reflowChildren, removeAllChildren, removeChild, reverseFocus, setFocusedChild, setWindow, showAllChildren, takeFocus
 
Methods inherited from class danger.ui.View
clear, copyStyle, getAcceptFocus, getBackgroundColor, getBottom, getBounds, getBounds, getFrame, getFrame, getHeight, getInterestingRect, getInterestingRect, getLeft, getOrigin, getOrigin, getOriginX, getOriginY, getParent, getRight, getSibling, getStyle, getStyleColor, getStyleFont, getTop, getWidth, getWindow, globalToLocal, invalidate, invalidate, invalidate, isEnabled, isFocusable, isFocused, isOnScreen, isTransparent, isVisible, keepRectInView, localToGlobal, localToGlobal, localToWindow, moveBy, offsetOrigin, offsetOrigin, onAddedToParent, onDecoded, onRemovedFromParent, onStyleChanged, receiveEventInternal, resetOrigin, sendEventToWindow, setAcceptFocus, setBackgroundColor, setBottom, setDebugBounds, setEnabled, setFrame, setHeight, setKeyedValue, setLeft, setOrigin, setOrigin, setRight, setStyle, setStyleColor, setStyleFont, setStyleFrameColor, setTop, setTransparent, setVisible, setWidth, styleIsDefault, willFocusWithin, windowToLocal
 
Methods inherited from class danger.app.Listener
cancelEvents, sendEvent, sendEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mDefaultListener

protected Listener mDefaultListener

m_doAutoSize

protected boolean m_doAutoSize

mCancelButton

protected Button mCancelButton

mTitlebarControls

protected View[] mTitlebarControls

mBackEvent

protected Event mBackEvent

mCancelEvent

protected Event mCancelEvent

m_leftBorder

protected int m_leftBorder

m_rightBorder

protected int m_rightBorder

m_topBorder

protected int m_topBorder

m_bottomBorder

protected int m_bottomBorder

mNeedLayoutFrameButtons

protected boolean mNeedLayoutFrameButtons

mNeedToAddTopFrameButtons

protected boolean mNeedToAddTopFrameButtons

mButtons

protected Button[] mButtons

mButtonEvents

protected Event[] mButtonEvents

mShortcuts

protected int[] mShortcuts

mButtonIDs

protected int[] mButtonIDs

mDefaultButtonPosition

protected int mDefaultButtonPosition

mDefaultButton

protected Button mDefaultButton

mLayoutButtonsVertically

protected boolean mLayoutButtonsVertically

mListener

protected Listener mListener

kMinFrameButtonWidth

protected static final int kMinFrameButtonWidth

kButtonHeight

protected static final int kButtonHeight

kBottomPosition1

public static final int kBottomPosition1

kBottomPosition2

public static final int kBottomPosition2

kBottomPosition3

public static final int kBottomPosition3

kTopPosition1

public static final int kTopPosition1

kTopPosition2

public static final int kTopPosition2

kMaxButtons

protected static final int kMaxButtons

kMaxBottomButtons

protected static final int kMaxBottomButtons

kDefaultWindowStyle

public static final int kDefaultWindowStyle

kSystemWindowStyle

public static final int kSystemWindowStyle

kAppDialogStyle

public static final int kAppDialogStyle

kSystemDialogStyle

public static final int kSystemDialogStyle

kSystemErrorStyle

public static final int kSystemErrorStyle
Constructor Detail

DialogWindow

public DialogWindow()

DialogWindow

public DialogWindow(boolean showCancel)

DialogWindow

public DialogWindow(boolean showCancel,
                    int windowStyle)

DialogWindow

public DialogWindow(java.lang.String inTitle)

DialogWindow

public DialogWindow(java.lang.String inTitle,
                    int windowStyle)

DialogWindow

public DialogWindow(Bitmap inIcon)

DialogWindow

public DialogWindow(java.lang.String inTitle,
                    Bitmap inIcon)

DialogWindow

public DialogWindow(java.lang.String inTitle,
                    Bitmap inIcon,
                    int windowStyle)

DialogWindow

public DialogWindow(java.lang.String inTitle,
                    Bitmap inIcon,
                    int windowStyle,
                    boolean showCancel)
Method Detail

setWindowStyle

public void setWindowStyle(int windowStyle)

addChild

public void addChild(View child,
                     int id)
Overrides:
addChild in class Container

setShowCancel

public void setShowCancel(boolean showCancel)

setListener

public void setListener(Listener inListener)
Set the listener for the alert window. This method sets the listener for the window. The listener is the object that will receive events that occur in the alert window.
Parameters:
inListener - A Listener that will receive events from the window.

setDefaultListener

public void setDefaultListener(Listener listener)

getChildWithID

public View getChildWithID(int id)
Overrides:
getChildWithID in class Container

getFrameButtonWithID

protected Button getFrameButtonWithID(int id)

setEventForControlWithID

public void setEventForControlWithID(int id,
                                     Event newEvent)
Overrides:
setEventForControlWithID in class Window

setEventForFrameButtonWithID

protected boolean setEventForFrameButtonWithID(int id,
                                               Event newEvent)

addBottomFrameButton

public Button addBottomFrameButton(java.lang.String buttonStr,
                                   int eventType,
                                   int data,
                                   java.lang.Object arg,
                                   int shortcut)
Add a button to the alert window. Adds a new button to the alert window. Up to three buttons can be defined. By default, the buttons are laid out across the bottom of the window in order from right to left. The first two buttons are right justified and the third is left justified. To have the buttons layed out vertically, see the LayoutButtonsVertically method.

addTopFrameButton

public Button addTopFrameButton(java.lang.String buttonStr,
                                int eventType,
                                int data,
                                java.lang.Object arg,
                                int shortcut)

addFrameButton

public Button addFrameButton(int position,
                             java.lang.String buttonStr,
                             int eventType,
                             int data,
                             java.lang.Object arg)
Add a button to the alert window. Adds a new button to the alert window. Up to three buttons can be defined.
Parameters:
whichButton - defines the button to be assigned. button #1 is the rightmost button; button #3 is the leftmost button.

addFrameButton

public Button addFrameButton(int position,
                             java.lang.String buttonStr,
                             int eventType,
                             int data,
                             java.lang.Object arg,
                             int shortcut)
Add a button to the alert window. Adds a new button to the alert window. Up to three buttons can be defined. The buttonStr is the name of the button. The eventType, data, and arg parameters are used when creating the new event to be sent to the ReceiveEvent method of the listener. The shortcut (1-3) maps to one of the devicewidgets: 1 = Menu, 2 = Jump, and 3 = Back. By default, the buttons are laid out across the bottom of the window in order from right(#1 button) to left(#3 button). The first two buttons are right justified and the third is left justified. To have the buttons layed out vertically, see the LayoutButtonsVertically method.
Parameters:
whichButton - values of 1-3, indicates which button to assign.
buttonStr - A String containing the label for the button.
eventType - An int containing the event type to be sent when the button is chosen.
data - An int containing any additional data to be sent in the event.
arg - An Object containing an object reference to be sent in the event.
shortcut - An int (1-3) specifying the shortcut to be used for the button.

addFrameButton

public Button addFrameButton(int position,
                             java.lang.String buttonStr,
                             int eventType,
                             int data,
                             java.lang.Object arg,
                             int shortcut,
                             int id)

setFrameButtonShortcut

public void setFrameButtonShortcut(int position,
                                   int shortcut)

setDefaultFrameButton

public void setDefaultFrameButton(int which)

setDefaultFrameButton

public void setDefaultFrameButton(Button button)

setNoDefaultFrameButton

public void setNoDefaultFrameButton()

getDefaultFrameButton

public Button getDefaultFrameButton()

layoutBottomFrameButtonsVertically

public void layoutBottomFrameButtonsVertically(boolean flag)
Layout buttons vertically instead of horizontally. Pass true to this method when you want the buttons layed out vertically from top to bottom along the left side of the window. Button 1 will closest to the top, button 3 will be closest to the bottom. When false is passed, the default horizontal layout will be performed.

newButtonWithShortcut

protected Button newButtonWithShortcut(java.lang.String string,
                                       int shortcut)

layoutTopFrameButtons

protected void layoutTopFrameButtons()

layoutFrameButtons

protected void layoutFrameButtons()

convertShortcutKeyToButtonIndex

public int convertShortcutKeyToButtonIndex(Event e)

handleShortcutKey

public boolean handleShortcutKey(Event e)
Handle a shortcut key event. This method is called when the user presses one of the three shortcut keys (Action, Back, or Jump). The default behavior is to create an event that is sent to the listener for the alert window. Override this method if you want to handle these events yourself.
Parameters:
e - An Event containing the shortcut event that was received.

activateFrameButton

protected void activateFrameButton(int index)

initTitleBarControlList

protected void initTitleBarControlList()

setCancelButtonEvent

public void setCancelButtonEvent(Event e)

setCancelButtonShortcutBitmap

public void setCancelButtonShortcutBitmap(Bitmap shortcut)

setBackEvent

public void setBackEvent(Event e)
Specifies an event to send when the back button is pressed.

setTitle

public void setTitle(java.lang.String inTitle)

getTitle

public java.lang.String getTitle()

setIcon

public void setIcon(Bitmap inIcon)

getIcon

public Bitmap getIcon()

getTitleBarHeight

public int getTitleBarHeight()

getContentRect

public Rect getContentRect()

setContentSize

public void setContentSize(int width,
                           int height)

setAutoSize

public void setAutoSize(boolean doAutoSize)

setSize

public void setSize(int width,
                    int height)
Overrides:
setSize in class Window

setFocusedChild

public void setFocusedChild(View inNewFocus)
Overrides:
setFocusedChild in class Container

show

public void show()
Overrides:
show in class Window

hide

public void hide()
Overrides:
hide in class Window

positionDialog

protected void positionDialog()

layoutFrame

protected void layoutFrame()

positionFrameButtons

protected void positionFrameButtons()

positionTopButtons

protected void positionTopButtons()

positionBottomButtons

protected void positionBottomButtons()

computeTitleWidth

protected void computeTitleWidth()

getSleepScreenMessage

public java.lang.String getSleepScreenMessage()
Override for system alerts

snapToChildren

public void snapToChildren(int inLeft,
                           int inTop,
                           int inRight,
                           int inBottom)
Description copied from class: Container
Reduces the size of this Container so that it exactly fits around its children with no extra space. It then expands the size of the Container by the passed-in margin quantities.
Overrides:
snapToChildren in class Container
Following copied from class: danger.ui.Container
Parameters:
inLeft - left margin
inTop - top margin
inRight - right margin
inBottom - bottom margin

snapToChildren

public void snapToChildren(int inLeft,
                           int inTop,
                           int inRight,
                           int inBottom,
                           boolean includeBottomFrame)

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.
Overrides:
paint in class Container

drawFrame

public void drawFrame(Pen p)

drawDialogStyleFrame

public void drawDialogStyleFrame(Pen p,
                                 int windowStyle)

drawSystemWindowStyleFrame

public void drawSystemWindowStyleFrame(Pen p)

receiveEvent

public boolean receiveEvent(Event e)
Description copied from class: Listener
Entry point for event processing. Default behaviour is to do nothing and return false. Normally this method is called from a Dispatcher when it discovers an Event in its queue that is targetted at this Listener.
Overrides:
receiveEvent in class Container

eventWidgetUp

public boolean eventWidgetUp(int widget,
                             Event event)
Description copied from class: Container
Handle the release of a device widget
Overrides:
eventWidgetUp in class Container
Following copied from class: danger.ui.Container
Parameters:
inWidget - the widget that went down
Returns:
whether or not the event was consumed

setDrawBottomFrame

protected void setDrawBottomFrame(boolean drawFrame)

getTitleFont

protected static Font getTitleFont()

setTitleFormatText

public void setTitleFormatText(java.lang.String inArg0)

setTitleFormatText

public void setTitleFormatText(java.lang.String inArg0,
                               java.lang.String inArg1)

setTitleFormatText

public void setTitleFormatText(java.lang.String inArg0,
                               java.lang.String inArg1,
                               java.lang.String inArg2)

setTitleFormatText

public void setTitleFormatText(java.lang.String[] inArgs)

setTitleFormatDate

public void setTitleFormatDate(danger.internal.Date inDate)

setIconVerticalOffset

public void setIconVerticalOffset(int offset)


Danger Confidential. Copyright © 2000-2003, Danger Inc.