ImageItemLFImplpublic class ImageItemLFImpl extends ItemLFImpl implements ImageItemLFPlatform widget look and feel of ImageItem . |
Fields Summary |
---|
private final ImageItem | imgItemThe ImageItem associated with this view. | private final ImageData | itemImageDataThe ImageData associated with the item. | private int | appearanceModeAppearance mode.
The actual appearance of an ImageItem could be different to
the one set in ImageItem . An ImageItem
created with PLAIN appearance will look like a
HYPERLINK if commands were added. |
Constructors Summary |
---|
ImageItemLFImpl(ImageItem imageItem)Creates look & feel for an ImageItem .
super(imageItem);
ImageData imageData = null;
if (imageItem != null) {
Image image = imageItem.immutableImg;
if (image != null) {
imageData = image.getImageData();
}
}
this.imgItem = imageItem;
this.itemImageData = imageData;
// when no commands are added, the actual appearance
// is PLAIN; the actual appearance will be the same
// as appearance set in ImageItem if a command is added
// to this ImageItem
appearanceMode = Item.PLAIN;
|
Methods Summary |
---|
void | createNativeResource(int ownerId)Create native resource for current ImageItem .
Override function in ItemLFImpl .
nativeId = createNativeResource0(ownerId,
imgItem.label,
imgItem.layout,
itemImageData,
imgItem.altText,
appearanceMode);
| private native int | createNativeResource0(int ownerId, java.lang.String label, int layout, ImageData imageData, java.lang.String altText, int appearanceMode)KNI function that creates native resource for current
ImageItem .
| boolean | equateNLB()Determine if this Item should have a newline before it.
// MIDP1.0 already had an ability to set LAYOUT_NEWLINE_BEFORE.
// Hence there is no need to check for LAYOUT_2 (as in StringItem)
if (super.equateNLB()) {
return true;
}
// LAYOUT_NEWLINE_BEFORE is not set but LAYOUT_2 is set
// which means that items could be positioned side by side
if ((imgItem.layout & Item.LAYOUT_2) == Item.LAYOUT_2) {
return false;
}
// LAYOUT_2 was not set, hence we need to provide backward
// compatibility with MIDP1.0 where any ImageItem with a
// non-null label would go on a new line.
return imgItem.label != null && imgItem.label.length() > 0;
| public void | lAddCommand(Command cmd, int i)Notifies L&F of a command addition in the corresponding
ImageItem .
super.lAddCommand(cmd, i);
if ((imgItem.numCommands >= 1) && (appearanceMode == Item.PLAIN)) {
appearanceMode = imgItem.appearanceMode == Item.BUTTON ?
Item.BUTTON : Item.HYPERLINK;
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
setContent0(nativeId, itemImageData, imgItem.altText,
appearanceMode);
}
lRequestInvalidate(true, true);
}
| public void | lRemoveCommand(Command cmd, int i)Notifies L&F of a command removal in the corresponding
ImageItem .
super.lRemoveCommand(cmd, i);
// restore the value of the original appearanceMode
if (imgItem.numCommands < 1) {
appearanceMode = Item.PLAIN;
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
setContent0(nativeId, itemImageData, imgItem.altText,
appearanceMode);
}
lRequestInvalidate(true, true);
}
| public void | lSetAltText(java.lang.String altText)Notifies L&F of an alternative text change
in the corresponding ImageItem .
// Only update native resource if it exists.
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
setContent0(nativeId, itemImageData, altText,
appearanceMode);
}
lRequestInvalidate(true, true);
| public void | lSetImage(Image img)Notifies L&F of an image change in the corresponding
ImageItem .
// Only update native resource if it exists.
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
ImageData imageData = null;
if (img != null) {
imageData = img.getImageData();
}
setContent0(nativeId, imageData,
imgItem.altText, appearanceMode);
}
lRequestInvalidate(true, true);
| private native void | setContent0(int nativeId, ImageData imageData, java.lang.String text, int appearanceMode)KNI function that sets image on the native resource corresponding
to the current ImageItem .
| boolean | uCallPeerStateChanged(int hint)Called by event delivery to notify an ItemLF in current FormLF
of a change in its peer state.
Handle special gesture of default command.
// activate default command if hint is -1
if (hint == -1) {
Command defaultCommand;
ItemCommandListener commandListener;
synchronized (Display.LCDUILock) {
defaultCommand = imgItem.defaultCommand;
commandListener = imgItem.commandListener;
}
if (defaultCommand != null && commandListener != null) {
// Protect from any unexpected application exceptions
try {
synchronized (Display.calloutLock) {
commandListener.commandAction(defaultCommand, imgItem);
}
} catch (Throwable thr) {
Display.handleThrowable(thr);
}
}
}
// Indicate to Form to not notify ItemStateListener
return false;
|
|