|
MIDP3.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CommandLayoutPolicy
This interface is used to implement exact placement of commands.
Example:
class MyCanvas extends Canvas implements CommandLayoutPolicy { MyCanvas() { setCommandLayoutPolicy(this); } void sort(Command[] commands, int[] positions) { // sort the commands in the correct order depending on the positions available. // Implementation can use Display's getCommandPlacements to get the recommended // placement for each Command. } public boolean onCommandLayout(Displayable displayable) { Display display = displayable.getCurrentDisplay(); final int border = Display.SOFTKEY_BOTTOM; int[] positions = display.getExactPlacementPositions(border); Command[] cmd = displayable.getCommands(); sort(cmd, positions); if (cmd.length <= positions.length) { for (int i = 0; i < cmd.length; ++i) { displayable.setCommand(cmd[i], border + positions[i]); } for (int i = cmd.length; i < positions.length; ++i) { //clear all non-used placements displayable.removeCommandOrMenu(border + positions[i]); } } else { for (int i = 0; i < positions.length - 1; ++i) { displayable.setCommand(cmd[i], border + positions[i]); } Menu options = new Menu("More", null, null); for (int i = positions.length; i < cmd.length; ++i) { options.append(cmd[i]); } displayable.setMenu(options, positions[positions.length-1]); } } }
Method Summary | |
---|---|
void |
onCommandLayout(Displayable displayable)
Method called when a new layout is needed. |
Method Detail |
---|
void onCommandLayout(Displayable displayable)
Command
or Menu
not explicitly set at a placement (via
Displayable.setCommand(Command, int)
,
Displayable.setMenu(Menu, int)
, or
Item.setCommand(Command, int)
) in the
CommandLayoutPolicy
implementation will be ignored and not displayed.
displayable
- The Displayable that holds the commands that should be updated. If
displayable
is a TabbedPane, it is the
CommandLayoutPolicy implementation's responsibility to update
commands depending on the active tab etc. If
displayable
is a Form, it is the
CommandLayoutPolicy implementation's responsibility to update
commands depending on the active item etc.
|
MIDP3.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |