Methods Summary |
---|
void | createNativeResource(int ownerId)Creates and sets native resource for current ChoiceGroup.
Override function in ItemLFImpl.
nativeId = createNativeResource0(ownerId, cg.label,
(cg.owner instanceof List ?
-1 : cg.layout),
cg.choiceType, cg.fitPolicy,
cg.cgElements, cg.numOfEls,
selectedIndex);
|
private native int | createNativeResource0(int ownerId, java.lang.String label, int layout, int choiceType, int fitPolicy, javax.microedition.lcdui.ChoiceGroup.CGElement[] cgElements, int numChoices, int selectedIndex)KNI function that creates native resource for current ChoiceGroup.
|
private native void | delete0(int nativeId, int elementNum, int selectedIndex)KNI function that notifies native resource of a specified element
being deleted in the corresponding ChoiceGroup.
|
private native void | deleteAll0(int nativeId)KNI function that notifies native resource that all elements were
deleted in the corresponding ChoiceGroup.
|
boolean | equateNLA()Determine if this Item should have a newline after it
if (super.equateNLA()) {
return true;
}
return ((cg.layout & Item.LAYOUT_2) != Item.LAYOUT_2);
|
boolean | equateNLB()Determine if this Item should have a newline before it
if (super.equateNLB()) {
return true;
}
return ((cg.layout & Item.LAYOUT_2) != Item.LAYOUT_2);
|
public Font | getDefaultFont()Gets default font to render ChoiceGroup element if it was not
set by the application
return Theme.curContentFont;
|
private native int | getSelectedFlags0(int nativeId, boolean[] selectedArray, int numOfEls)KNI function that queries the state of all elements in the native
resource and returns it in the passed in selectedArray array.
|
private native int | getSelectedIndex0(int nativeId)KNI function that gets index of a currently selected index from
the ChoiceGroup's native resource.
|
private native void | insert0(int nativeId, int elementNum, java.lang.String stringPart, ImageData imagePart, boolean selected)KNI function that notifies native resource of a new element
inserted prior to the element specified
|
private native boolean | isSelected0(int nativeId, int elementNum)KNI function that queries the state of an element in the native
resource
|
public void | lDelete(int elementNum)Notifies Look &s; Feel that an element referenced by
elementNum was deleted in the corresponding
ChoiceGroup.
// adjust selected index
if (cg.numOfEls == 0) {
selectedIndex = -1;
} else if (cg.choiceType != ChoiceGroup.MULTIPLE) {
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
if (selectedIndex != -1 && selectedIndex < cg.numOfEls) {
cg.cgElements[selectedIndex].setSelected(false);
}
selectedIndex = getSelectedIndex0(nativeId);
}
if (elementNum < selectedIndex) {
selectedIndex--;
} else if (elementNum == selectedIndex &&
selectedIndex == cg.numOfEls) {
// last element is selected and deleted -
// new last should be selected
selectedIndex = cg.numOfEls - 1;
}
cg.cgElements[selectedIndex].setSelected(true);
}
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
delete0(nativeId, elementNum, selectedIndex);
}
lRequestInvalidate(true, true);
|
public void | lDeleteAll()Notifies Look &s; Feel that all elements
were deleted in the corresponding ChoiceGroup.
// Only update native resource if it exists.
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
deleteAll0(nativeId);
}
selectedIndex = -1;
lRequestInvalidate(true, true);
|
public int | lGetSelectedFlags(boolean[] selectedArray_return)Gets selected flags.(only elements corresponding to the
elements are expected to be filled). ChoiceGroup sets the rest to
false
int countSelected = 0;
if (nativeId == DisplayableLFImpl.INVALID_NATIVE_ID) {
for (int i = 0; i < cg.numOfEls; i++) {
selectedArray_return[i] = cg.cgElements[i].selected;
if (selectedArray_return[i]) {
countSelected++;
}
}
} else {
countSelected = getSelectedFlags0(nativeId, selectedArray_return,
cg.numOfEls);
// sync with native
for (int i = 0; i < cg.numOfEls; i++) {
cg.cgElements[i].setSelected(selectedArray_return[i]);
}
}
return countSelected;
|
public int | lGetSelectedIndex()Gets currently selected index
if (nativeId == DisplayableLFImpl.INVALID_NATIVE_ID) {
return selectedIndex;
} else {
// sync with native
syncSelectedIndex();
return selectedIndex;
}
|
void | lHideNativeResource()/**
Override ItemLFImpl method to sync with native resource
before hiding the native resource. Selection of native resource will
be preserved before the resource is hidden.
// sync selected flags and selectedIndex
// before any visible native resource is deleted.
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
syncSelectedIndex();
syncSelectedFlags();
}
// Hide native resource
super.lHideNativeResource();
|
public void | lInsert(int elementNum, java.lang.String stringPart, Image imagePart)Notifies Look &s; Feel that an element was inserted into the
ChoiceGroup at the the elementNum specified.
// make sure that there is a default selection
if (cg.choiceType != Choice.MULTIPLE) {
if (selectedIndex == -1) {
selectedIndex = 0;
cg.cgElements[selectedIndex].setSelected(true);
} else if (elementNum < selectedIndex &&
nativeId == DisplayableLFImpl.INVALID_NATIVE_ID) {
// an element was inserted before selectedIndex and
// selectedIndex has to be updated
selectedIndex++;
}
}
// Only update native resource if it exists.
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
ImageData imagePartData = null;
if (imagePart != null) {
imagePartData = imagePart.getImageData();
}
insert0(nativeId, elementNum,
stringPart, imagePartData,
cg.cgElements[elementNum].selected);
}
lRequestInvalidate(true, true);
|
public boolean | lIsSelected(int elementNum)Determines if an element with a passed in index
is selected or not.
if (nativeId == DisplayableLFImpl.INVALID_NATIVE_ID) {
return cg.cgElements[elementNum].selected;
}
return isSelected0(nativeId, elementNum);
|
public void | lSet(int elementNum, java.lang.String stringPart, Image imagePart)Notifies Look &s; Fell that the String and
Image parts of the
element referenced by elementNum were set in
the corresponding ChoiceGroup,
replacing the previous contents of the element.
// Only update native resource if it exists.
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
ImageData imagePartData = null;
if (imagePart != null) {
imagePartData = imagePart.getImageData();
}
// for selected value to be passed correctly to the
// newly created element we have to do the sync first
// (alternatively we could rely on native to maintain
// the selected state correctly)
syncSelectedIndex();
syncSelectedFlags();
set0(nativeId, elementNum,
stringPart, imagePartData,
cg.cgElements[elementNum].selected);
}
lRequestInvalidate(true, true);
|
public void | lSetFitPolicy(int fitPolicy)Notifies Look &s; Feel that a new text fit policy was set
in the corresponding ChoiceGroup.
// Only update native resource if it exists.
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
setFitPolicy0(nativeId, fitPolicy);
lRequestInvalidate(true, true);
}
|
public void | lSetFont(int elementNum, Font font)Notifies Look &s; Feel that a new font was set for an
element with the specified elementNum in the
corresponding ChoiceGroup.
// Only update native resource if it exists.
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
setFont0(nativeId, elementNum,
font.getFace(), font.getStyle(), font.getSize());
lRequestInvalidate(true, true);
}
|
public void | lSetSelectedFlags(boolean[] selectedArray)Notifies Look &s; Feel that selected state was changed on
several elements in the corresponding MULTIPLE ChoiceGroup
(cannot be null).
// Only update native resource if it exists.
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
setSelectedFlags0(nativeId, selectedArray,
selectedArray.length);
}
|
public void | lSetSelectedIndex(int elementNum, boolean selected)Notifies Look &s; Feel that an element was selected (or
deselected) in the corresponding ChoiceGroup.
// Only update native resource if it exists.
if (nativeId != DisplayableLFImpl.INVALID_NATIVE_ID) {
setSelectedIndex0(nativeId, elementNum, selected);
} else {
if (cg.choiceType == Choice.MULTIPLE) {
cg.cgElements[elementNum].setSelected(selected);
} else {
// selected item cannot be deselected in
// EXCLUSIVE, IMPLICIT, POPUP ChoiceGroup
if (!selected ||
(/* choiceType != Choice.IMPLICIT && */
selectedIndex == elementNum)) {
return;
}
cg.cgElements[selectedIndex].setSelected(false);
selectedIndex = elementNum;
cg.cgElements[selectedIndex].setSelected(true);
}
}
|
private native void | set0(int nativeId, int elementNum, java.lang.String stringPart, ImageData imagePart, boolean selected)KNI function that notifies native resource of a specified element
being set in the corresponding ChoiceGroup.
|
private native void | setFitPolicy0(int nativeId, int fitPolicy)KNI function that notifies native resource of fit policy change
in the corresponding ChoiceGroup.
|
private native void | setFont0(int nativeId, int elementNum, int face, int style, int size)KNI function that notifies native resource of an element's new font
setting in the corresponding ChoiceGroup.
|
private native void | setSelectedFlags0(int nativeId, boolean[] selectedArray, int numSelectedArray)KNI function that notifies native resource of new selected
states in the corresponding ChoiceGroup.
|
private native void | setSelectedIndex0(int nativeId, int elementNum, boolean selected)KNI function that notifies native resource of an element's new selected
state in the corresponding ChoiceGroup.
|
private void | syncSelectedFlags()Read and save user selection from native resource.
if (cg.numOfEls > 0 && cg.choiceType == Choice.MULTIPLE) {
boolean[] selectedArray_return = new boolean[cg.numOfEls];
getSelectedFlags0(nativeId, selectedArray_return,
cg.numOfEls);
for (int i = 0; i < cg.numOfEls; i++) {
cg.cgElements[i].setSelected(selectedArray_return[i]);
}
}
|
private void | syncSelectedIndex()Read and save user selection from native resource.
if (cg.choiceType != Choice.MULTIPLE) {
int newSelectedIndex = getSelectedIndex0(nativeId);
if (selectedIndex != newSelectedIndex) {
if (selectedIndex != -1) {
cg.cgElements[selectedIndex].setSelected(false);
}
selectedIndex = newSelectedIndex;
if (selectedIndex != -1) {
cg.cgElements[selectedIndex].setSelected(true);
}
}
}
|
boolean | uCallPeerStateChanged(int hint)Called by event delivery to notify an ItemLF in current FormLF
of a change in its peer state.
// Any hint means selection has change
// For types other than IMPLICIT List, notify itemStateListener.
if (cg.choiceType != Choice.IMPLICIT) {
return true; // notify itemStateListener
}
// For IMPLICIT List, notify commandListener
List list;
CommandListener cl;
Command cmd;
synchronized (Display.LCDUILock) {
list = (List)cg.owner;
if (list.listener == null ||
list.selectCommand == null ||
cg.numOfEls == 0) {
return false; // No itemStateListener to notify
}
cl = list.listener;
cmd = list.selectCommand;
}
try {
synchronized (Display.calloutLock) {
cl.commandAction(cmd, list);
}
} catch (Throwable thr) {
Display.handleThrowable(thr);
}
return false; // No itemStateListener to notify
|