Fields Summary |
---|
static final int | XBounds[] array index to x coordinate. |
static final int | YBounds[] array index to y coordinate. |
static final int | WIDTHBounds[] array index to width. |
static final int | HEIGHTBounds[] array index to height. |
static final int | DEFAULT_LABEL_HEIGHTThe default label height for an item. |
Item | itemThe owner of this view. Set in the constructor. |
int | nativeIdThe native MidpItem* of this view.
Set by owner screen based on the return value of
createNativeResource(). |
int[] | boundsThis is the size granted to this item by the form layout.
An array of 4 elements, describing the x, y, width, height
of this Item 's bounds in the viewport coordinate space. If
it is null , it means the Item is currently
not in the viewport.
This array is set by this.lSetLocation() and this.lSetSize(),
and read by FormLFImpl during layout. |
boolean | hasFocusA flag indicating this Item has the input focus. This is
maintained by the Item superclass for easy use by subclass
code. |
boolean | sizeChangedA flag indicating the size of this Item has changed in a
subsequent layout operation.
This variable is set and read by FormLFImpl during layout. |
boolean | visibleInViewportA flag indicating the native resource of this
Item is currently (at least
partially) visible on the Form it is on.
This is maintained by the Item superclass for easy
use by subclass code. |
boolean[] | actualBoundsInvalidFlags that are set to true when calling invalidate() on this item.
If it is known that one of the dimensions remains the same, then
the responding invalid flag will stay false .
It will turn to false after it gets laid out.
This is set by Item class and read by
FormLFImpl during layout. |
private int | preferredHeightCached preferred height when validRequestedSizes is false . |
private int | preferredWidthCached preferred width when validRequestedSizes is false . |
private int | minimumHeightCached minimum height when validRequestedSizes is false . |
private int | minimumWidthCached minimum width when validRequestedSizes is false . |
boolean | supportsNativeScrollingIf set to true rely on native scrolling mechanism of this item
and give this item all width and height available.
(Used for TextBox and List implementation). |
boolean | isNewLineThis flag marks if the last layout performed placed
this Item at the beginning of a line.
This variable is set and read by FormLFImpl during
layout. |
int | rowHeightMarks the height of the row this Item is placed on.
Note that the Item may be shorter than the height of
the row.
This variable is set and read by FormLFImpl during layout. |
static final int | INVALID_SIZEA constant used to indicate that Item sizes have to be recalculated. |
int | cachedWidthWidth used for last calculations. If that indicates if the preferredHeight, preferredWidth,
minimumHeight, minimumWidth are valid, or need a new query. |
Methods Summary |
---|
abstract void | createNativeResource(int ownerId)Create native resource of this Item .
After this call, Item.nativeId should have had the
created native resource id.
|
protected void | createTempNativeResource()Create a temporary native resource of this Item whose
id must be deleted before caller function returns.
int ownerId = (item.owner == null)
? DisplayableLFImpl.INVALID_NATIVE_ID
: ((DisplayableLFImpl)item.owner.getLF()).nativeId;
createNativeResource(ownerId);
|
private native void | delete0(int nativeId)Notify native Item to delete its resource.
|
void | deleteNativeResource()Delete native resource of this Item .
After this call, Item.nativeId should have been reset to
DisplayableLFImpl.INVALID_NATIVE_ID .
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
delete0(nativeId);
nativeId = DisplayableLFImpl.INVALID_NATIVE_ID;
}
|
boolean | equateNLA()Determine if this Item should have a newline after it.
return ((item.layout & Item.LAYOUT_NEWLINE_AFTER) ==
Item.LAYOUT_NEWLINE_AFTER);
|
boolean | equateNLB()Determine if this Item should have a newline before it.
return ((item.layout & Item.LAYOUT_NEWLINE_BEFORE) ==
Item.LAYOUT_NEWLINE_BEFORE);
|
Display | getCurrentDisplay()Return the current Display instance that this
Item is displayed in.
return (item.owner == null) ?
null : item.owner.getLF().lGetCurrentDisplay();
|
int | getLayout()Get the effective layout type of this Item .
int l = item.layout;
if (l == Item.LAYOUT_DEFAULT) {
// the spec requires the default vertical layout to be bottom
return Item.LAYOUT_BOTTOM | Item.LAYOUT_LEFT;
} else {
return l;
}
|
native int | getMinimumHeight0(int nativeId)Gets minimum height from the native resource corresponding to
this Item .
|
native int | getMinimumWidth0(int nativeId)Gets minimum width from the native resource corresponding to
this Item .
|
native int | getPreferredHeight0(int nativeId, int w)Gets preferred height from the native resource corresponding to
this Item .
|
native int | getPreferredWidth0(int nativeId, int h)Gets preferred width from the native resource corresponding to
this Item .
|
private native void | hide0(int nativeId)Makes native widget that corresponds to this Item
invisible and free native resource. After this call, the nativeId
is no longer valid.
|
void | initNativeResource()Initialize native resource - size and location.
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
if (!actualBoundsInvalid[WIDTH] && !actualBoundsInvalid[HEIGHT]) {
setSize0(nativeId, bounds[WIDTH], bounds[HEIGHT]);
}
if (!actualBoundsInvalid[X] && !actualBoundsInvalid[Y]) {
setLocation0(nativeId, bounds[X], bounds[Y]);
}
}
|
public final boolean | isRequestedSizesValid()Return whether the cached requested sizes are valid.
return (cachedWidth != INVALID_SIZE);
|
public void | lAddCommand(Command cmd, int i)Notifies L&F of a command addition in the corresponding
Item .
if (item.owner != null) {
((DisplayableLFImpl)item.owner.getLF()).updateCommandSet();
}
|
void | lCallHideNotify()Sets the visibleInViewport flag to be false.
Note the native resource is not hidden, nor deleted.
this.visibleInViewport = false;
|
void | lCallPaint(Graphics g, int w, int h)Paint the content of this Item .
The default implementation does nothing.
|
void | lCallShowNotify()Sets the visibleInViewport flag of this Item to be true.
Note that this method has no effect on the native resource.
this.visibleInViewport = true;
|
void | lCallTraverseOut()Called by the system to indicate traversal has left this
Item .
hasFocus = false;
|
public void | lCommitPendingInteraction()Called to commit any pending user interaction for the item.
|
int | lGetAdornedMinimumHeight()PLACE HOLDER
Used by the Form Layout to set the size of this Item
return lGetMinimumHeight();
|
int | lGetAdornedMinimumWidth()PLACE HOLDER
Used by the Form Layout to set the size of this Item
return lGetMinimumWidth();
|
int | lGetAdornedPreferredHeight(int width)PLACE HOLDER
Used by the Form Layout to set the size of this Item
return lGetPreferredHeight(width);
|
int | lGetAdornedPreferredWidth(int height)PLACE HOLDER
Used by the Form Layout to set the size of this Item
return lGetPreferredWidth(height);
|
protected int | lGetLockedHeight()Returns the locked height of the Item, or -1 if it's not locked
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_ITEM_LAYOUT,
" ItemLFImpl - lGetLockedHeight: " +
item.lockedHeight);
}
return item.lockedHeight;
|
int | lGetLockedWidth()Returns the locked width of the Item, or -1 if it's not locked
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_ITEM_LAYOUT,
" ItemLFImpl - lGetLockedWidth: " +
item.lockedWidth);
}
return item.lockedWidth;
|
public int | lGetMinimumHeight()Get the minimum height of this Item .
lGetRequestedSizes();
return minimumHeight;
|
public int | lGetMinimumWidth()Get the minimum width of this Item .
lGetRequestedSizes(); // Make sure cached sizes are up to date
return minimumWidth;
|
public int | lGetPreferredHeight(int w)Get the preferred height of this Item .
// note: w is not used
lGetRequestedSizes();
return preferredHeight;
|
public int | lGetPreferredWidth(int h)Get the preferred width of this Item .
// note: h is not used!
lGetRequestedSizes();
return preferredWidth;
|
void | lGetRequestedSizes()Calculate minimum and preferred width and height of this item and
store the result in instance variables:
minimumWidth, minimumHeight, preferredWidth and preferredHeight.
This function will query native resources for the sizes. For
Item s like CustomItem and
Spacer , whose sizes are only calculated in Java, this
function should be overriden to perform their own calculation.
if (cachedWidth != INVALID_SIZE) {
return;
}
// query native for real preferred sizes
boolean wasNoNative = (nativeId ==
DisplayableLFImpl.INVALID_NATIVE_ID);
// Native resource not yet created, create a temporary one
if (wasNoNative) {
createTempNativeResource();
}
minimumWidth = getMinimumWidth0(nativeId);
// ASSERT (ownerLFImpl.width
// >= minimumWidth >= 0)
minimumHeight = getMinimumHeight0(nativeId);
// ASSERT (minimumHeight >= 0)
// NOTE: When the item should shrink, the minimum size is used,
// and the minimum size is calculated with the label
// on the same line
if (shouldHShrink() && item.label != null && item.label.length() > 0) {
minimumHeight += DEFAULT_LABEL_HEIGHT;
}
preferredWidth = getPreferredWidth0(nativeId, item.lockedHeight);
if (preferredWidth < minimumWidth) {
preferredWidth = minimumWidth;
}
// Since we don't support horizontal scrolling,
// we limit the width before using it to query for preferredHeight
if (item.owner != null) {
DisplayableLFImpl ownerLFImpl =
(DisplayableLFImpl)item.owner.getLF();
// Right now the space available for items is
// always limited by the scrollbar space (see first
// FormLFImpl constructor)
// The exception of that rule is List and TextBox
// implementations that use FormLFImpl
// (notice that in the second constructor the width
// is not limited by scrollbar)
// But when a native peer cannot support vertical
// scrolling and has to be longer than the viewport
// FormLFImpl needs to provide its native scrollbar
// To make sure that happens we do the following check.
// That check must be removed if FormLFImpl supports
// dynamic change of the width available for layout.
if (ownerLFImpl.width == Display.WIDTH &&
minimumHeight > Display.HEIGHT) {
ownerLFImpl.width -= Constants.VERT_SCROLLBAR_WIDTH;
}
if (preferredWidth > ownerLFImpl.width) {
preferredWidth = ownerLFImpl.width;
}
} else {
if (preferredWidth >
Display.WIDTH - Constants.VERT_SCROLLBAR_WIDTH) {
preferredWidth =
Display.WIDTH - Constants.VERT_SCROLLBAR_WIDTH;
}
}
preferredHeight = getPreferredHeight0(nativeId,
(item.lockedWidth == -1)
? preferredWidth
: item.lockedWidth);
if (preferredHeight < minimumHeight) {
preferredHeight = minimumHeight;
}
// Delete temporary native resource
if (wasNoNative) {
deleteNativeResource();
}
cachedWidth = preferredWidth;
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_ITEM_LAYOUT,
" lGetRequestedSizes: " +
" mw=" + minimumWidth + " mh=" + minimumHeight +
" pw=" + preferredWidth + " ph=" + preferredHeight);
}
|
void | lHideNativeResource()Called by the system to hide this Item 's
native resource.
The default implementation of this method
hides native resources corresponding to this Item
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
hide0(nativeId);
}
|
void | lMove(int deltaX, int deltaY)Moves item's location by delta. Both deltaX and deltaY can be
positive and negative.
bounds[X] += deltaX;
bounds[Y] += deltaY;
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
setLocation0(nativeId, bounds[X], bounds[Y]);
}
|
public void | lRemoveCommand(Command cmd, int i)Notifies L&F of a command removal in the corresponding
Item .
if (item.owner != null) {
((DisplayableLFImpl)item.owner.getLF()).updateCommandSet();
}
|
void | lRequestInvalidate(boolean width, boolean height)Request the event scheduler to schedule an invalidate event, that
eventually will call uCallInvalidate(this item) of this item's
DisplayableLFImpl .
If caller also needs to call lSetRequestedSizes, then it must be
called AFTER this function, to have effect.
actualBoundsInvalid[WIDTH] = actualBoundsInvalid[WIDTH] || width;
actualBoundsInvalid[HEIGHT] = actualBoundsInvalid[HEIGHT] || height;
if (width || height) {
cachedWidth = INVALID_SIZE;
}
// if native resource is not visible we still need
// process invalidate to proper set the sizes of this ItemLF
// and of form container as well
if (item.owner != null) {
((DisplayableLFImpl)item.owner.getLF()).lRequestInvalidate();
}
|
void | lRequestPaint()Called by subclasses to repaint this entire Item 's bounds.
if (bounds != null) {
lRequestPaint(0, 0, bounds[WIDTH], bounds[HEIGHT]);
}
|
void | lRequestPaint(int x, int y, int w, int h)Called by subclasses to repaint a portion of this Item 's
bounds.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,
"repaint "+this+" \t owner ="+item.owner);
}
if (item.owner != null) {
if (w < 0) {
return;
} else if (w > bounds[WIDTH]) {
w = bounds[WIDTH];
}
if (h < 0) {
return;
} else if (h > bounds[HEIGHT]) {
h = bounds[HEIGHT];
}
if (x < 0) {
x = 0;
} else if (x > bounds[WIDTH]) {
return;
}
if (y < 0) {
y = 0;
} else if (y > bounds[HEIGHT]) {
return;
}
if (item.owner.getLF() instanceof FormLFImpl) {
((FormLFImpl)item.owner.getLF()).lRequestPaintItem(item,
x, y, w, h);
} else if (item.owner.getLF() instanceof AlertLFImpl) {
// ((AlertLFImpl)item.owner.getLF()).repaintItem(item,
// x, y, w, h);
((AlertLFImpl)item.owner.getLF()).lRequestPaintContents();
}
}
|
public void | lSetDefaultCommand(Command cmd, int i)Notifies L&F of the default command change in the corresponding
Item .
|
public void | lSetLabel(java.lang.String label)Notifies L&F of a label change in the corresponding
Item .
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
setLabel0(nativeId, label);
}
lRequestInvalidate(true, true);
|
public void | lSetLayout(int layout)Notifies L&F of a layout change in the corresponding
Item .
lRequestInvalidate(true, true);
|
void | lSetLocation(int x, int y)Sets item's location.
bounds[X] = x;
bounds[Y] = y;
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
setLocation0(nativeId, x, y);
}
|
public void | lSetOwner(Screen oldOwner)Notify this itemLF that its owner screen has changed.
Clear internal state if its new owner is null .
// Currently Item has no owner
if (item.owner == null) {
// Hide native resource
lHideNativeResource();
// Free any native resource
deleteNativeResource();
// do app notification
if (visibleInViewport) {
uCallHideNotify();
}
// the deleted item may be added later, so we
// have to invalidate it.
actualBoundsInvalid[X] = true;
actualBoundsInvalid[Y] = true;
actualBoundsInvalid[WIDTH] = true;
actualBoundsInvalid[HEIGHT] = true;
cachedWidth = INVALID_SIZE;
hasFocus = false;
}
|
public void | lSetPreferredSize(int width, int height)Notifies L&F of a preferred size change in the corresponding
Item .
if (width == bounds[WIDTH] && height == bounds[HEIGHT]) {
// no need to invalidate
return;
}
lRequestInvalidate(width != bounds[WIDTH],
height != bounds[HEIGHT]);
|
final void | lSetRequestedSizes(int mw, int mh, int pw, int ph)Set minimum and preferred width and height of this item.
This function should only be called on a CustomItemLFImpl
or SpacerLFImpl .
They will collect its own sizing, then call this function to cache them.
// ASSERT (this instanceof CustomItemLFImpl or SpacerLFImpl)
minimumWidth = mw;
minimumHeight = mh;
preferredWidth = pw;
preferredHeight = ph;
cachedWidth= pw;
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_ITEM_LAYOUT,
" lSetRequestedSizes: " +
" mw=" + minimumWidth + " mh=" + minimumHeight +
" pw=" + preferredWidth + " ph=" + preferredHeight);
}
|
void | lSetSize(int w, int h)Sets item's size.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_ITEM_LAYOUT,
" ItemLFImpl - lSetSize: " + w + "x" + h);
}
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
if (w < minimumWidth) {
Logging.report(Logging.INFORMATION,
LogChannels.LC_HIGHUI_ITEM_LAYOUT,
" ******* ItemLFImpl - lSetSize: " + w +
" < " + minimumWidth);
}
}
bounds[WIDTH] = w;
bounds[HEIGHT] = h;
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
setSize0(nativeId, w, h);
}
|
void | lShowNativeResource()Called by the system to show this Item 's
native resource.
The default implementation of this method shows
the native resource corresponding to this Item
SYNC NOTE:
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
show0(nativeId);
}
|
native void | setLabel0(int nativeId, java.lang.String label)Notifies native width that new label was set on this Item .
|
private native void | setLocation0(int nativeId, int x, int y)Notifies native widget that Form set location of this
Item to be at x, y.
|
private native void | setSize0(int nativeId, int w, int h)Notifies native widget that Form set size of this
Item to be at w and h.
|
boolean | shouldHExpand()Determine if this Item should horizontally expand.
return ((item.layout & Item.LAYOUT_EXPAND) == Item.LAYOUT_EXPAND);
|
boolean | shouldHShrink()Determine if this Item should horizontally shrink.
return ((item.layout & Item.LAYOUT_SHRINK) == Item.LAYOUT_SHRINK);
|
boolean | shouldVExpand()Determine if this Item should vertically expand.
return ((item.layout & Item.LAYOUT_VEXPAND) == Item.LAYOUT_VEXPAND);
|
boolean | shouldVShrink()Determine if this Item should vertically shrink.
return ((item.layout & Item.LAYOUT_VSHRINK) == Item.LAYOUT_VSHRINK);
|
private native void | show0(int nativeId)Makes native widget that corresponds to this Item
visible on the screen at the location set earlier.
|
void | uCallHideNotify()Sets the visibleInViewport flag to be false.
Note the native resource is not hidden, nor deleted.
This function simply calls lCallShowNotify() after obtaining LCDUILock.
synchronized (Display.LCDUILock) {
lCallHideNotify();
}
|
void | uCallKeyPressed(int keyCode)Called by the system to signal a key press.
|
void | uCallKeyReleased(int keyCode)Called by the system to signal a key release.
|
void | uCallKeyRepeated(int keyCode)Called by the system to signal a key repeat.
|
void | uCallPaint(Graphics g, int w, int h)Paint the content of this Item .
This function simply calls lCallPaint() after obtaining LCDUILock.
synchronized (Display.LCDUILock) {
lCallPaint(g, w, h);
}
|
abstract boolean | uCallPeerStateChanged(int hint)Called by event delivery to notify an ItemLF in current
FormLF of a change in its peer state.
Subclass should implement this function to sync its state with
the peer and choose to return proper value to let Form know
whether the itemStateListener should be notified.
|
void | uCallPointerDragged(int x, int y)Called by the system to signal a pointer drag.
|
void | uCallPointerPressed(int x, int y)Called by the system to signal a pointer press.
|
void | uCallPointerReleased(int x, int y)Called by the system to signal a pointer release.
|
void | uCallShowNotify()Sets the visibleInViewport flag of this Item to be true.
Note that this method has no effect on the native resource.
This function simply calls lCallShowNotify() after obtaining LCDUILock.
synchronized (Display.LCDUILock) {
lCallShowNotify();
}
|
void | uCallSizeChanged(int w, int h)Called by the system to indicate the size available to this
Item has changed.
synchronized (Display.LCDUILock) {
item.lUpdateLockedSize();
}
|
boolean | uCallTraverse(int dir, int viewportWidth, int viewportHeight, int[] visRect_inout)Called by the system to notify internal traverse into the item.
By default, it always returns false and should be overriden for
items with enabled internal traversal
boolean ret = false;
synchronized (Display.LCDUILock) {
if (!hasFocus || dir == CustomItem.NONE) {
if (ret = item.acceptFocus()) {
hasFocus = true;
}
}
}
return ret;
|
void | uCallTraverseOut()Called by the system to indicate traversal has left this
Item .
This function simply calls lCallTraverseOut after obtaining LCDUILock.
synchronized (Display.LCDUILock) {
lCallTraverseOut();
}
|