Methods Summary |
---|
public int | getDisplayableHeight()Calculate the height a displayable would occupy if it was to
be displayed.
return AlertSkin.HEIGHT;
|
public int | getDisplayableWidth()Calculate the width a displayable would occupy if it was to
be displayed
return AlertSkin.WIDTH;
|
static Image | getIcon(AlertType alertType)Returns the system image to draw in title area.
If AlertType is not set, no image is drawn.
if (alertType == null) {
return null;
}
if (alertType.equals(AlertType.INFO)) {
return AlertSkin.IMAGE_ICON_INFO;
} else if (alertType.equals(AlertType.WARNING)) {
return AlertSkin.IMAGE_ICON_WARN;
} else if (alertType.equals(AlertType.ERROR)) {
return AlertSkin.IMAGE_ICON_ERRR;
} else if (alertType.equals(AlertType.ALARM)) {
return AlertSkin.IMAGE_ICON_ALRM;
} else {
return AlertSkin.IMAGE_ICON_CNFM;
}
|
protected int | getMaxScroll()The maximum amount of scroll needed to see all the contents
return maxScroll;
|
protected int | getScrollAmount()This is the number of pixels left from the previous "page"
when a page up or down occurs. The same value is used for line by
line scrolling
return AlertSkin.SCROLL_AMOUNT;
|
java.lang.String | getTitle(AlertType alertType)Returns the system image to draw in title area.
If AlertType is not set, no image is drawn.
if (alert.title != null) {
return alert.title;
}
if (alertType.equals(AlertType.INFO)) {
return AlertSkin.TEXT_TITLE_INFO;
} else if (alertType.equals(AlertType.WARNING)) {
return AlertSkin.TEXT_TITLE_WARN;
} else if (alertType.equals(AlertType.ERROR)) {
return AlertSkin.TEXT_TITLE_ERRR;
} else if (alertType.equals(AlertType.ALARM)) {
return AlertSkin.TEXT_TITLE_ALRM;
} else {
return AlertSkin.TEXT_TITLE_CNFM;
}
|
public void | lAddCommand(Command cmd, int i)Notifies look & feel object of a command addition
to the Displayable .
SYNC NOTE: The caller of this method handles synchronization.
super.lAddCommand(cmd, i);
// make alert Modal
if (alert.numCommands == 2) {
lSetTimeout(alert.getTimeout());
}
|
void | lCallFreeze()Cancel the timer whenever the alert is frozen. Alert is frozen
when the display does not have foreground
super.lCallFreeze();
if (timerTask != null) {
timerTask.cancel();
timerTask = null;
}
|
void | lCallHide()Notify this Alert that it will no longer be displayed
on the given Display
super.lCallHide();
if (alert.indicator != null) {
((GaugeLFImpl)alert.indicator.gaugeLF).lCallHideNotify();
}
if (timerTask != null) {
timerTask.cancel();
timerTask = null;
}
|
void | lCallShow()Notify this Alert that is being displayed on the
given Display and whether it needs to initialize its
highlight
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in AlertLFImpl: lCallShow");
}
super.lCallShow();
if (alert.type != null) {
currentDisplay.playAlertSound(alert.type);
}
if (alert.indicator != null) {
((GaugeLFImpl)alert.indicator.gaugeLF).lCallShowNotify();
}
if (!isLayoutValid) {
layout();
}
lSetTimeout(alert.getTimeout());
// We reset any scrolling done in a previous showing
viewable[Y] = 0;
setVerticalScroll();
|
public int | lGetDefaultTimeout()Gets default timeout for the alert associated with this view
return AlertSkin.TIMEOUT;
|
public Command | lGetDismissCommand()Get command that Alert.DISMISS_COMMAND is mapped to.
return OK;
|
public int | lGetHeight()Returns the actual needed height for the Alert instead of
the maximum possible height.
// This should return the height available for content
// within the Alert dialog. It can be used by applications
// to choose appropriately sized content.
return AlertSkin.HEIGHT - AlertSkin.TITLE_HEIGHT;
|
public boolean | lIsModal()Determines if alert associated with this view is modal.
if (alert.numCommands > 1) {
return true;
}
if (!isLayoutValid) {
layout();
}
return (maxScroll > 0);
|
void | lPaintContent(Graphics g)Paint the text content of this alert, if there is any
if (alert.text != null) {
g.translate(AlertSkin.MARGIN_H, 0);
Text.paint(g, alert.text, AlertSkin.FONT_TEXT,
AlertSkin.COLOR_FG, 0,
viewable[WIDTH], viewable[HEIGHT],
0, Text.NORMAL, null);
g.translate(-AlertSkin.MARGIN_H, 0);
}
|
int | lPaintImage(Graphics g)Paint the application-supplied image for this alert, if there is one.
if (alert.image == null) {
return 0;
}
// We center the image
int offsetx = (int)
((AlertSkin.WIDTH - alert.image.getWidth()) / 2);
g.drawImage(alert.image, offsetx, 0, Graphics.TOP | Graphics.LEFT);
return alert.image.getHeight();
|
int | lPaintIndicator(Graphics g)Paint the gauge indicator for this alert, if there is one.
if (alert.indicator == null) {
return 0;
}
GaugeLFImpl indicatorLF = (GaugeLFImpl)alert.indicator.gaugeLF;
// We center the gauge
int offsetx = (int)
((AlertSkin.WIDTH - indicatorLF.bounds[WIDTH]) / 2);
g.translate(offsetx, 0);
// SYNC NOTE: paint in gauge does not involve app code.
// So it's OK to call it from LCDUILock block.
indicatorLF.lCallPaint(g, indicatorLF.bounds[WIDTH],
indicatorLF.bounds[HEIGHT]);
g.translate(-offsetx, 0);
return indicatorLF.bounds[HEIGHT];
|
void | lPaintTitleBar(Graphics g)Paint the title bar area for this alert.
if (alert.type == null && alert.title == null) {
return;
}
icon = (alert.type == null) ? null : getIcon(alert.type);
title = getTitle(alert.type);
titlew = AlertSkin.FONT_TITLE.stringWidth(title);
if (icon != null) {
iconw = icon.getWidth();
titlew += (AlertSkin.PAD_HORIZ + iconw);
iconh = icon.getHeight();
// We vertically center the icon
icony = 0;
if (iconh < AlertSkin.TITLE_HEIGHT) {
icony = (AlertSkin.TITLE_HEIGHT - iconh) / 2;
}
} else {
iconw = 0;
}
if (titlew > AlertSkin.WIDTH - (2 * AlertSkin.TITLE_MARGIN)) {
titlew = AlertSkin.WIDTH - (2 * AlertSkin.TITLE_MARGIN);
}
// We vertically center the title text
titley =
(AlertSkin.TITLE_HEIGHT - AlertSkin.FONT_TITLE.getHeight()) / 2;
switch (AlertSkin.TITLE_ALIGN) {
case Graphics.RIGHT:
titlex = AlertSkin.WIDTH - AlertSkin.TITLE_MARGIN - titlew;
break;
case Graphics.HCENTER:
titlex = (AlertSkin.WIDTH - titlew) / 2;
break;
case Graphics.LEFT:
default:
titlex = AlertSkin.TITLE_MARGIN;
break;
}
// We'll clip down the "box" for the title just in case
// its a really long string
// g.clipRect(titlex, 0, titlew, AlertSkin.TITLE_HEIGHT);
if (icon != null) {
g.drawImage(icon, titlex, icony,
Graphics.LEFT | Graphics.TOP);
titlex += (AlertSkin.PAD_HORIZ + iconw);
titlew -= (AlertSkin.PAD_HORIZ + iconw);
}
g.translate(titlex, titley);
Text.drawTruncString(g, title,
AlertSkin.FONT_TITLE, AlertSkin.COLOR_TITLE, titlew);
g.translate(-titlex, -titley);
|
public void | lRemoveCommand(Command cmd, int i)Notifies look & feel object of a command removal
from the Displayable .
SYNC NOTE: The caller of this method handles synchronization.
super.lRemoveCommand(cmd, i);
// remove modality if it was forced by command presence
if (alert.numCommands == 1) {
lSetTimeout(alert.getTimeout());
}
|
void | lRequestInvalidate()Called upon content change to schedule a request for relayout and
repaint.
super.lRequestInvalidate();
isLayoutValid = false;
|
public void | lSetImage(Image oldImg, Image newImg)Notifies look&feel object of an image change.
lRequestInvalidate();
|
public void | lSetIndicator(Gauge oldIndicator, Gauge newIndicator)Notifies look&feel object of an indicator change.
lRequestInvalidate();
|
public void | lSetString(java.lang.String oldString, java.lang.String newString)Notifies look&feel object of a string change.
lRequestInvalidate();
|
public void | lSetTimeout(int timeout)Notifies look&feel object of a timeout change.
try {
if (timerTask != null) {
timerTask.cancel();
}
if (timeout == Alert.FOREVER) {
timerTask = null;
} else {
timerTask = new TimeoutTask();
if (timeoutTimer == null) {
timeoutTimer = new Timer();
}
timeoutTimer.schedule(timerTask, timeout);
}
} catch (Throwable t) {
if (Logging.REPORT_LEVEL <= Logging.WARNING) {
Logging.report(Logging.WARNING, LogChannels.LC_HIGHUI,
"Throwable while lSetTimeout");
}
}
|
public void | lSetType(AlertType type)Notifies look&feel object of a Alert type change.
lRequestInvalidate();
|
void | layout()Layout the content of this Alert given the width and
height parameters
super.layout();
// layout() is called from DisplayableLFImpl constructor
// and at that time alert is not initialized
if (alert == null) {
maxScroll = 0;
return;
}
// The width of the viewable area is equal to the width of
// the alert minus a left and right margin
viewable[WIDTH] = AlertSkin.WIDTH - (2 * AlertSkin.MARGIN_H);
// height of activity indicator, if any
int indHeight = 0;
if (alert.indicator != null) {
GaugeLFImpl indicatorLF = (GaugeLFImpl)alert.indicator.gaugeLF;
if (indicatorLF.bounds == null) {
indicatorLF.bounds = new int[4];
}
int pW = indicatorLF.lGetPreferredWidth(-1);
if (pW > viewable[WIDTH] - (2 * AlertSkin.PAD_HORIZ)) {
pW = viewable[WIDTH] - (2 * AlertSkin.PAD_HORIZ);
}
indHeight = indicatorLF.lGetPreferredHeight(pW);
// We assign the item a bounds which is its pixel location,
// width, and height in coordinates which represent offsets
// of the viewport origin (that is, are in the viewport
// coordinate space)
indicatorLF.bounds[X] = 0;
indicatorLF.bounds[Y] = 0;
indicatorLF.bounds[WIDTH] = pW;
indicatorLF.bounds[HEIGHT] = indHeight;
}
// height of the alert's image, if any
int imageHeight = (alert.image == null) ? 0 : alert.image.getHeight();
// height of the alert's text content, if any
int textHeight = (alert.text == null) ? 0 :
Text.getHeightForWidth(alert.text, AlertSkin.FONT_TEXT,
viewable[WIDTH], 0);
// This gives us the height of the scrollable area
viewable[HEIGHT] = AlertSkin.PAD_VERT;
if (indHeight > 0) {
viewable[HEIGHT] += (indHeight + AlertSkin.PAD_VERT);
}
if (imageHeight > 0) {
viewable[HEIGHT] += (imageHeight + AlertSkin.PAD_VERT);
}
if (textHeight > 0) {
viewable[HEIGHT] += (textHeight + AlertSkin.PAD_VERT);
}
maxScroll = viewable[HEIGHT] -
(AlertSkin.HEIGHT - AlertSkin.TITLE_HEIGHT);
if (maxScroll < 0) {
maxScroll = 0;
}
isLayoutValid = true;
|
void | setVerticalScroll()Set the vertical scroll indicators for this Screen.
We override this from our superclass because the viewport[] is
set to the entire Alert dialog, but scrolling is confined to the
"inner" viewport we've constructed beneath the title to scroll
the text content. This scrolling behavior is maintained by
'maxScroll' - which represents the maximum number of pixels
needed to scroll in order to reach the bottom of the scrollable
content. If maxScroll is 0, no scrolling is necessary.
if (maxScroll == 0) {
setVerticalScroll(0, 100);
} else {
setVerticalScroll((viewable[Y] * 100 / (maxScroll)),
((AlertSkin.HEIGHT - AlertSkin.TITLE_HEIGHT)
* 100 / viewable[HEIGHT]));
}
|
public void | uCallInvalidate()This method is responsible for:
(1) Re-layout the contents
(2) setup the viewable/scroll position
(3) repaint contents
boolean wasModal = maxScroll > 0 || alert.numCommands > 1;
super.uCallInvalidate();
synchronized (Display.LCDUILock) {
if (wasModal != lIsModal()) {
lSetTimeout(alert.getTimeout());
}
lRequestPaint();
}
setVerticalScroll();
|
void | uCallKeyPressed(int keyCode)Handle a key press
int gameAction = KeyConverter.getGameAction(keyCode);
synchronized (Display.LCDUILock) {
switch (gameAction) {
case Canvas.UP:
if (viewable[Y] > 0) {
viewable[Y] -= AlertSkin.SCROLL_AMOUNT;
if (viewable[Y] < 0) {
viewable[Y] = 0;
}
lRequestPaint();
}
break;
case Canvas.DOWN:
if (viewable[Y] < maxScroll) {
viewable[Y] += AlertSkin.SCROLL_AMOUNT;
if (viewable[Y] > maxScroll) {
viewable[Y] = maxScroll;
}
lRequestPaint();
}
break;
}
}
setVerticalScroll();
|
void | uCallKeyRepeated(int keyCode)Handle a key repeat
uCallKeyPressed(keyCode);
|
public void | uCallPaint(Graphics g, java.lang.Object target)Paint the contents of this Alert given the graphics context.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
" # in AlertLFImpl: uCallPaint "+
viewable[X]+","+
viewable[Y]+","+
viewable[WIDTH]+","+
viewable[HEIGHT]);
}
clipx = g.getClipX();
clipy = g.getClipY();
clipw = g.getClipWidth();
cliph = g.getClipHeight();
synchronized (Display.LCDUILock) {
// titleHeight will be AlertSkin.TITLE_HEIGHT
lPaintTitleBar(g);
// Restore the clip
g.setClip(clipx, AlertSkin.TITLE_HEIGHT,
clipw, cliph - AlertSkin.TITLE_HEIGHT);
// translate the viewport to offset for the titlebar
g.translate(0, AlertSkin.TITLE_HEIGHT);
// translate to accommodate any scrolling we've done
g.translate(0, -viewable[Y]);
// paint the indicator
int indHeight = lPaintIndicator(g);
// translate to offset for the indicator
g.translate(0, indHeight);
// paint the image
int imgHeight = lPaintImage(g);
// translate to offset for the image
g.translate(0, imgHeight);
// paint the body text
lPaintContent(g);
// restore the translate
g.translate(-g.getTranslateX(), -g.getTranslateY());
} // synchronized
setVerticalScroll();
|
public void | uCallSizeChanged(int w, int h)Notify return screen about screen size change
super.uCallSizeChanged(w,h);
Displayable returnScreen = alert.getReturnScreen();
if (returnScreen != null) {
(returnScreen.displayableLF).uCallSizeChanged(w,h);
}
|