Methods Summary |
---|
public int | getDisplayableHeight()Calculate the height a displayable would occupy if it was to
be displayed.
int h = 0;
if (!owner.isInFullScreenMode) {
h = ScreenSkin.HEIGHT - SoftButtonSkin.HEIGHT;
if (owner.getTitle() != null) {
h -= TitleSkin.HEIGHT;
}
if (owner.getTicker() != null) {
h -= TickerSkin.HEIGHT;
}
} else {
h = ScreenSkin.HEIGHT;
}
return h;
|
public int | getDisplayableWidth()Calculate the width a displayable would occupy if it was to
be displayed
int w = currentDisplay != null ?
currentDisplay.getWindow().getBodyWidth() :
ScreenSkin.WIDTH;
return w;
|
public int | getVerticalScrollPosition()Get the current vertical scroll position
return 0;
|
public int | getVerticalScrollProportion()Get the current vertical scroll proportion
// SYNC NOTE: return of atomic value
return 100;
|
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.
updateCommandSet();
|
void | lCallFreeze()While UI resources of this LF are created and visible already, stop any
further updates to physical screen because some "system modal dialog"
takes over physical screen buffer and user input now or
foreground is lost.
Repaint and invalidate requests from this DisplayableLF will be really
scheduled into event queue. Instead, only dirty flag is set.
After a LF enters "freeze" mode, it can be resumed of visibility or
directly replaced by a new Displayable.
This function simply sets this DisplayableLF to HIDDEN state.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in DisplayableLFImpl: lCallFreeze");
}
state = FROZEN;
|
void | lCallHide()Remove this displayable from physical screen.
The displayable should unload any resource that was allocated. It's not
required to clean the physical screen before this function returns.
This function could be called while a LF is in "freeze" mode.
This function simply sets this DisplayableLF to HIDDEN state.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in DisplayableLFImpl: lCallHide");
}
state = HIDDEN;
|
void | lCallPaint(Graphics g, java.lang.Object target)Display calls this method on it's current Displayable.
Displayable uses this opportunity to do necessary stuff
on the Graphics context, this includes,
paint Ticker, paint Title, translate as necessary.
The target Object of this repaint may be some Object
initially set by this Displayable when the repaint was
requested - allowing this Displayable to know exactly
which Object it needs to call to service this repaint,
rather than potentially querying all of its Objects to
determine the one(s) which need painting.
SYNC NOTE: The caller of this method handles synchronization.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in DisplayableLFImpl: lCallPaint");
}
|
void | lCallShow()Prepare to show this LF on physical screen. This is the
internal version of showNotify() function as defined in MIDP spec.
It is called immediately prior to this LF being made visible
on the display. The LF should load any resource that is
needed, layout. App's paint() should NOT be called in this function.
Instead, it should be in the uCallPaint() that will be called on this
LF shortly after.
This function sets this DisplayableLF to SHOWN state.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in DisplayableLFImpl: lCallShow");
}
// This will suppress drags, repeats and ups until a
// corresponding down is seen.
sawPointerPress = sawKeyPress = false;
// IMPL_NOTE: Move this to CanvasLFImpl
// set mapping between GameCanvas and DisplayAccess
// set Game key event flag based on value passed in
// GameCanvas constructor.
if (owner instanceof GameCanvas) {
GameMap.registerDisplayAccess(owner, currentDisplay.accessor);
stickyKeyMask = currentKeyMask = 0;
} else {
// set the keymask to -1 when
// the displayable is not a GameCanvas.
stickyKeyMask = currentKeyMask = -1;
}
// Setup scroll bar
currentDisplay.setVerticalScroll(getVerticalScrollPosition(),
getVerticalScrollProportion());
state = SHOWN;
|
public void | lCommitPendingInteraction()Called to commit any pending user interaction for the current item.
|
public Display | lGetCurrentDisplay()Return the Display instance in which the LF is currently shown.
return currentDisplay;
|
public Displayable | lGetDisplayable()Return the associated Displayable object.
return owner;
|
public int | lGetHeight()Returns the height of the area available to the application.
// NOTE: If we update the viewport size in all cases we change
// the displayable's size then we needn't to update it inside
// the method. So we need to investigate removing
// 'resetViewport()' below.
resetViewport();
return viewport[HEIGHT];
|
public int | lGetWidth()Returns the width of the area available to the application.
// NOTE: If we update the viewport size in all cases we change
// the displayable's size then we needn't to update it inside
// the method. So we need to investigate removing
// 'resetViewport()' below.
resetViewport();
return viewport[WIDTH];
|
public boolean | lIsShown()Implement public API isShown().
return !(currentDisplay == null) && currentDisplay.isShown(this);
|
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.
updateCommandSet();
|
void | lRequestInvalidate()Called to schedule an "invalidate" for this Displayable. Invalidation
is caused by things like size changes, content changes, or spontaneous
traversal within the Displayable.
SYNC NOTE: Caller should hold LCDUILock.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in DisplayableLFImpl: invalidate");
}
pendingInvalidate = true;
if (state == SHOWN && currentDisplay != null) {
currentDisplay.invalidate();
invalidScroll = true;
}
|
void | lRequestPaint(int x, int y, int width, int height)Request to paint this Displayable.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in DisplayableLFImpl: lRequestPaint");
}
// Note: Display will not let anyone but the current
// Displayable schedule repaints
if (lIsShown()) {
currentDisplay.repaintImpl(this,
x, y, width, height,
null);
}
|
void | lRequestPaint()Request to paint all of this Displayable.
This is the same as calling
lRequestPaint(0, 0,
viewport[WIDTH],
viewport[HEIGHT], null)
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in DisplayableLFImpl: lRequestPaint");
}
lRequestPaint(0, 0, viewport[WIDTH], viewport[HEIGHT]);
|
public void | lSetDisplay(Display d)Set the display instance the Displayable is associated with.
Caller should hold LCDUILock around this call.
// ASSERT(d == null || currentDisplay == null)
currentDisplay = d;
|
public void | lSetTicker(Ticker oldTicker, Ticker newTicker)Notifies Displayable's look & feel object of a ticker change.
SYNC NOTE: The caller of this method handles synchronization.
Display d = lGetCurrentDisplay();
if (d != null) {
d.lSetTicker(this, newTicker);
}
if (newTicker != null) {
newTicker.tickerLF.lSetOwner(this);
}
// Displayable area size may be affected by the presence or
// absence of the ticker so we need to update the viewport
resetViewport();
|
public void | lSetTitle(java.lang.String oldTitle, java.lang.String newTitle)Notifies Displayable's look & feel object of a title change.
SYNC NOTE: The caller of this method handles synchronization.
Display d = lGetCurrentDisplay();
if (d != null) {
d.lSetTitle(this, newTitle);
}
// Displayable area size may be affected by the presence or
// absence of the title so we need to update the viewport
resetViewport();
|
void | layout()Perform any necessary layout, and update the viewport
as necessary
resetViewport();
|
private void | releaseKeyMask(int keyCode)IMPL_NOTE: Move this to CanvasLFImpl.
Called to release key mask of all the keys that were release.
// set the mask of keys pressed
switch (KeyConverter.getGameAction(keyCode)) {
case Canvas.UP:
currentKeyMask = currentKeyMask & ~ GameCanvas.UP_PRESSED;
break;
case Canvas.DOWN:
currentKeyMask = currentKeyMask & ~ GameCanvas.DOWN_PRESSED;
break;
case Canvas.LEFT:
currentKeyMask = currentKeyMask & ~ GameCanvas.LEFT_PRESSED;
break;
case Canvas.RIGHT:
currentKeyMask = currentKeyMask & ~ GameCanvas.RIGHT_PRESSED;
break;
case Canvas.FIRE:
currentKeyMask = currentKeyMask & ~ GameCanvas.FIRE_PRESSED;
break;
case Canvas.GAME_A:
currentKeyMask = currentKeyMask & ~ GameCanvas.GAME_A_PRESSED;
break;
case Canvas.GAME_B:
currentKeyMask = currentKeyMask & ~ GameCanvas.GAME_B_PRESSED;
break;
case Canvas.GAME_C:
currentKeyMask = currentKeyMask & ~ GameCanvas.GAME_C_PRESSED;
break;
case Canvas.GAME_D:
currentKeyMask = currentKeyMask & ~ GameCanvas.GAME_D_PRESSED;
break;
default:
// no key mask should be set
break;
}
|
private void | resetViewport()By default, the viewport array is configured to be
at origin 0,0 with width and height set depending
on the full screen mode setting.
// setup the default viewport, the size of the Display
if (viewport == null) {
viewport = new int[4];
}
viewport[WIDTH] = getDisplayableWidth();
viewport[HEIGHT] = getDisplayableHeight();
|
private void | setKeyMask(int keyCode)IMPL_NOTE: Move this to CanvasLFImpl.
Called to set key mask of all the keys that were pressed.
// set the mask of keys pressed
switch (KeyConverter.getGameAction(keyCode)) {
case Canvas.UP:
stickyKeyMask = stickyKeyMask | GameCanvas.UP_PRESSED;
currentKeyMask = currentKeyMask | GameCanvas.UP_PRESSED;
break;
case Canvas.DOWN:
stickyKeyMask = stickyKeyMask | GameCanvas.DOWN_PRESSED;
currentKeyMask = currentKeyMask | GameCanvas.DOWN_PRESSED;
break;
case Canvas.LEFT:
stickyKeyMask = stickyKeyMask | GameCanvas.LEFT_PRESSED;
currentKeyMask = currentKeyMask | GameCanvas.LEFT_PRESSED;
break;
case Canvas.RIGHT:
stickyKeyMask = stickyKeyMask | GameCanvas.RIGHT_PRESSED;
currentKeyMask = currentKeyMask | GameCanvas.RIGHT_PRESSED;
break;
case Canvas.FIRE:
stickyKeyMask = stickyKeyMask | GameCanvas.FIRE_PRESSED;
currentKeyMask = currentKeyMask | GameCanvas.FIRE_PRESSED;
break;
case Canvas.GAME_A:
stickyKeyMask = stickyKeyMask | GameCanvas.GAME_A_PRESSED;
currentKeyMask = currentKeyMask | GameCanvas.GAME_A_PRESSED;
break;
case Canvas.GAME_B:
stickyKeyMask = stickyKeyMask | GameCanvas.GAME_B_PRESSED;
currentKeyMask = currentKeyMask | GameCanvas.GAME_B_PRESSED;
break;
case Canvas.GAME_C:
stickyKeyMask = stickyKeyMask | GameCanvas.GAME_C_PRESSED;
currentKeyMask = currentKeyMask | GameCanvas.GAME_C_PRESSED;
break;
case Canvas.GAME_D:
stickyKeyMask = stickyKeyMask | GameCanvas.GAME_D_PRESSED;
currentKeyMask = currentKeyMask | GameCanvas.GAME_D_PRESSED;
break;
default:
// no mask should be set
break;
}
|
public void | uCallFreeze()Stop any further updates to physical screen because some
"system modal dialog" takes over physical screen buffer
and user input now or foreground is lost.
This function simply calls lCallFreeze after obtaining LCDUILock.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in DisplayableLFImpl: uCallFreeze");
}
synchronized (Display.LCDUILock) {
lCallFreeze();
}
|
public void | uCallHide()Remove this displayable from physical screen.
This function simply calls lCallHide() after obtaining LCDUILock.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in DisplayableLFImpl: uCallHide");
}
synchronized (Display.LCDUILock) {
lCallHide();
}
|
public void | uCallInvalidate()Called by the event handler to perform an
invalidation of this Displayable
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in DisplayableLFImpl: uCallInvalidate");
}
// SYNC NOTE: It is safe to obtain a lock here because
// the only subclass that can call into the app code in layout()
// is FormLFImpl and it overrides uCallInvalidate()
synchronized (Display.LCDUILock) {
pendingInvalidate = false;
layout();
}
|
public void | uCallKeyEvent(int type, int keyCode)Handle a raw key event from Display.
int eventType = -1;
synchronized (Display.LCDUILock) {
switch (type) {
case EventConstants.PRESSED:
sawKeyPress = true;
eventType = 0;
break;
case EventConstants.RELEASED:
if (sawKeyPress) {
eventType = 1;
}
break;
case EventConstants.REPEATED:
if (sawKeyPress) {
eventType = 2;
}
break;
default:
// wrong key type will be handled below
break;
}
// used later by getKeyMask()
if (currentKeyMask > -1 && eventType != -1) {
if (eventType == 1) {
releaseKeyMask(keyCode);
} else {
// set the mask on key press, repeat or type.
// don't set the mask when a key was released.
setKeyMask(keyCode);
}
}
} // synchronized
// SYNC NOTE: Since we may call into application code,
// we do so outside of LCDUILock
switch (eventType) {
case 0:
uCallKeyPressed(keyCode);
break;
case 1:
uCallKeyReleased(keyCode);
break;
case 2:
uCallKeyRepeated(keyCode);
break;
default:
/*
* TBD:
*
* Originally severity level was "ERROR".
* But it was reduced to INFO because
* a). it do not harm to the system
* b). some cases,
* Displayable processes KEY_PRESS events
* (when in system menu) & cleans all related status flag,
* while following KEY_REPEAT & KEY_RELEASE event pairs
* are not processed in the same way and therefore
* this eror messae was printed or them.
*
* As a temporary solution it was decided to disable messages
* insead of additional event filtering.
*/
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"DisplayableLFImpl: uCallKeyEvent," +
"type=" +type+ " keyCode=" +keyCode);
}
break;
}
|
void | uCallKeyPressed(int keyCode)Handle a key press
|
void | uCallKeyReleased(int keyCode)Handle a key release
|
void | uCallKeyRepeated(int keyCode)Handle a repeated key press
|
public void | uCallPaint(Graphics g, java.lang.Object target)Display calls this method on it's current Displayable.
This function simply calls lCallPaint() after obtaining LCDUILock.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in DisplayableLFImpl: uCallPaint");
}
synchronized (Display.LCDUILock) {
lCallPaint(g, target);
}
|
void | uCallPointerDragged(int x, int y)Handle a pointer drag event
|
public void | uCallPointerEvent(int type, int x, int y)Called from the event delivery loop when a pointer event is seen.
int eventType = -1;
synchronized (Display.LCDUILock) {
switch (type) {
case EventConstants.PRESSED:
sawPointerPress = true;
eventType = 0;
break;
case EventConstants.RELEASED:
if (sawPointerPress) {
eventType = 1;
}
break;
case EventConstants.DRAGGED:
if (sawPointerPress) {
eventType = 2;
}
break;
default:
// will be handled below
break;
}
} // synchronized
// SYNC NOTE: Since we may call into application code,
// we do so outside of LCDUILock
switch (eventType) {
case 0:
uCallPointerPressed(x, y);
break;
case 1:
uCallPointerReleased(x, y);
break;
case 2:
uCallPointerDragged(x, y);
break;
default:
if (sawPointerPress) {
Logging.report(Logging.ERROR, LogChannels.LC_HIGHUI,
"DisplayableLFImpl: uCallPointerEvent," +
" type=" +type+ " x=" +x+ " y=" +y);
}
break;
}
|
void | uCallPointerPressed(int x, int y)Handle a pointer press event
|
void | uCallPointerReleased(int x, int y)Handle a pointer release event
|
public void | uCallScrollContent(int scrollType, int thumbPosition)This method notify displayable to scroll its content
// by default nothing to do
|
public void | uCallShow()Prepare to show this LF on physical screen.
This function simply calls lCallShow() after obtaining LCDUILock.
boolean copyDefferedSizeChange;
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_FORM_LAYOUT,
"# in DisplayableLFImpl: uCallShow");
}
synchronized (Display.LCDUILock) {
// Assure correct screen mode
currentDisplay.lSetFullScreen(owner.isInFullScreenMode);
copyDefferedSizeChange = defferedSizeChange;
defferedSizeChange = false;
}
if (copyDefferedSizeChange) {
synchronized (Display.calloutLock) {
try {
owner.sizeChanged(viewport[WIDTH], viewport[HEIGHT]);
} catch (Throwable t) {
Display.handleThrowable(t);
}
}
}
synchronized (Display.LCDUILock) {
// Do the internal show preparation
lCallShow();
if (pendingInvalidate || copyDefferedSizeChange) {
lRequestInvalidate();
}
}
|
public void | uCallSizeChanged(int w, int h)Package private equivalent of sizeChanged()
boolean copyDefferedSizeChange;
synchronized (Display.LCDUILock) {
if (owner instanceof GameCanvas) {
GameCanvasLFImpl gameCanvasLF =
GameMap.getGameCanvasImpl((GameCanvas)owner);
if (gameCanvasLF != null) {
gameCanvasLF.lCallSizeChanged(w, h);
}
}
// If there is no Display, or if this Displayable is not
// currently visible, we simply record the fact that the
// size has changed
defferedSizeChange = (state != SHOWN);
copyDefferedSizeChange = defferedSizeChange;
/*
* sizeChangeOccurred is a boolean which (when true) indicates
* that sizeChanged() will be called at a later time. So, if it
* is false after calling super(), we go ahead and notify the
* Canvas now, rather than later
*/
resetViewport();
if (!defferedSizeChange) {
lRequestInvalidate();
}
}
if (!copyDefferedSizeChange) {
synchronized (Display.calloutLock) {
try {
owner.sizeChanged(w, h);
} catch (Throwable t) {
Display.handleThrowable(t);
}
}
}
|
public int | uGetKeyMask()\Need revisit Move this to CanvasLFImpl.
Called to get key mask of all the keys that were pressed.
synchronized (Display.LCDUILock) {
// don't release currently pressed keys
int savedMaskCopy = stickyKeyMask | currentKeyMask;
stickyKeyMask = 0;
return savedMaskCopy;
}
|
public boolean | uIsScrollNative()This method is used int repaint, int order to determine the translation
of the draw coordinates.
// only native form overrides this and returns true
return false;
|
void | uRequestPaint(int x, int y, int width, int height)Request to paint this Displayable (without holding a lock).
synchronized (Display.LCDUILock) {
lRequestPaint(x, y, width, height);
}
|
void | uRequestPaint()Request to paint all of this Displayable (without holding a lock).
synchronized (Display.LCDUILock) {
lRequestPaint();
}
|
public void | uSetFullScreenMode(boolean mode)Notifies look and feel object of a full screen mode change.
If true, this DisplayableLF will take up as much screen real estate
as possible.
boolean requestRepaint = false;
synchronized (Display.LCDUILock) {
if (lIsShown()) {
// IMPL_NOTE: Notify MainWindow of screen mode change
// currentDisplay is not null when lIsShown is true
currentDisplay.lSetFullScreen(mode);
layout();
updateCommandSet();
requestRepaint = true;
} else {
// Layout needs to happen even if the canvas is not visible
// so that correct width and height could be returned
// in getWidth() and getHeight()
layout();
}
}
// app's sizeChanged has to be called before repaint
synchronized (Display.LCDUILock) {
if (requestRepaint) {
lRequestPaint();
}
}
|
public boolean | uSetRotatedStatus(boolean newStatus)Set status of screen rotation
synchronized (Display.LCDUILock) {
if (newStatus == owner.isRotated) {
return false;
} else {
owner.isRotated = newStatus;
return true;
}
}
|
public void | updateCommandSet()Updates command set if this Displayable is visible.
SYNC NOTE: Caller should hold LCDUILock.
if (state == SHOWN && currentDisplay != null) {
currentDisplay.updateCommandSet();
}
|