📄 display.java.svn-base
字号:
this.current.layoutContainer();
}
repaint(current);
}
/**
* Indicate to the implementation whether the flush graphics bug exists on this
* device. By default the flushGraphics bug is set to "true" and only disabled
* on handsets known 100% to be safe
*
* @param flushGraphicsBug true if the bug exists on this device (the safe choice)
* false for slightly higher performance.
*/
public void setFlashGraphicsBug(boolean flushGraphicsBug) {
implementation.setFlashGraphicsBug(flushGraphicsBug);
}
/**
* Indicates whether a delay should exist between calls to flush graphics during
* transition. In some devices flushGraphics is asynchronious causing it to be
* very slow with our background thread. The solution is to add a short wait allowing
* the implementation time to paint the screen. This value is set automatically by default
* but can be overriden for some devices.
*
* @param transitionDelay -1 for no delay otherwise delay in milliseconds
*/
public void setTransitionYield(int transitionDelay) {
implementation.setTransitionYield(transitionDelay);
}
/**
* Encapsulates the editing code which is specific to the platform, some platforms
* would allow "in place editing" MIDP does not.
*
* @param cmp the {@link TextArea} component
*/
void editString(Component cmp, int maxSize, int constraint, String text) {
editingText = true;
implementation.editString(cmp, maxSize, constraint, text);
editingText = false;
}
/**
* Returns the video control for the media player
*
* @param player the media player
* @return the video control for the media player
*/
Object getVideoControl(Object player) {
return implementation.getVideoControl(player);
}
Form getCurrentInternal() {
return current;
}
/**
* Same as getCurrent with the added exception of looking into the future
* transitions and returning the last current in the transition (the upcoming
* value for current)
*
* @return the form currently displayed on the screen or null if no form is
* currently displayed
*/
Form getCurrentUpcoming() {
Form upcoming = null;
// we are in the middle of a transition so we should extract the next form
if(animationQueue != null) {
Enumeration e = animationQueue.elements();
while(e.hasMoreElements()) {
Object o = e.nextElement();
if(o instanceof Transition) {
upcoming = (Form)((Transition)o).getDestination();
}
}
}
if(upcoming == null) {
return getCurrent();
}
return upcoming;
}
/**
* Return the form currently displayed on the screen or null if no form is
* currently displayed.
*
* @return the form currently displayed on the screen or null if no form is
* currently displayed
*/
public Form getCurrent(){
if(current != null && current instanceof Dialog && ((Dialog)current).isMenu()) {
Form p = current.getPreviousForm();
if(p != null) {
return p;
}
// we are in the middle of a transition so we should extract the next form
Enumeration e = animationQueue.elements();
while(e.hasMoreElements()) {
Object o = e.nextElement();
if(o instanceof Transition) {
return (Form)((Transition)o).getDestination();
}
}
}
return current;
}
/**
* Return the number of alpha levels supported by the implementation.
*
* @return the number of alpha levels supported by the implementation
*/
public int numAlphaLevels(){
return implementation.numAlphaLevels();
}
/**
* Returns the number of colors applicable on the device, note that the API
* does not support gray scale devices.
*
* @return the number of colors applicable on the device
*/
public int numColors() {
return implementation.numColors();
}
/**
* Light mode allows the UI to adapt and show less visual effects/lighter versions
* of these visual effects to work properly on low end devices.
*/
public boolean isLightMode() {
return lightMode;
}
/**
* Light mode allows the UI to adapt and show less visual effects/lighter versions
* of these visual effects to work properly on low end devices.
*/
public void setLightMode(boolean lightMode) {
this.lightMode = lightMode;
}
/**
* Return the width of the display
*
* @return the width of the display
*/
public int getDisplayWidth(){
return implementation.getDisplayWidth();
}
/**
* Return the height of the display
*
* @return the height of the display
*/
public int getDisplayHeight(){
return implementation.getDisplayHeight();
}
/**
* Causes the given component to repaint, used internally by Form
*
* @param cmp the given component to repaint
*/
void repaint(final Animation cmp){
implementation.repaint(cmp);
}
/**
* Returns the game action code matching the given key combination
*
* @param keyCode key code received from the event
* @return game action matching this keycode
*/
public int getGameAction(int keyCode){
try {
// prevent game actions from being returned by numeric keypad thus screwing up
// keypad based navigation and text input
if(keyCode >= '0' && keyCode <= '9') {
return 0;
}
if(portableKeyCodes != null) {
for(int iter = 0 ; iter < portableKeyCodeValues.length ; iter++) {
if(portableKeyCodeValues[iter] == keyCode) {
return portableKeyCodes[iter];
}
}
}
return implementation.getGameAction(keyCode);
} catch(IllegalArgumentException err) {
// this is a stupid MIDP requirement some implementations throw this
// exception for some keys
return 0;
}
}
/**
* Returns the keycode matching the given game action constant (the opposite of getGameAction).
* On some devices getKeyCode returns numeric keypad values for game actions,
* this breaks the code since we filter these values (to prevent navigation on '2').
* We pick unused negative values for game keys and assign them to game keys for
* getKeyCode so they will work with getGameAction.
*
* @param gameAction game action constant from this class
* @return keycode matching this constant
* @deprecated this method doesn't work properly across device and is mocked up here
* mostly for the case of unit testing. Do not use it for anything other than that! Do
* not rely on getKeyCode(GAME_*) == keyCodeFromKeyEvent, this will never actually happen!
*/
public int getKeyCode(int gameAction){
if(portableKeyCodes == null) {
portableKeyCodes = new int[] {GAME_DOWN, GAME_LEFT, GAME_RIGHT, GAME_UP, GAME_FIRE};
portableKeyCodeValues = new int[5];
int currentValue = -500;
int offset = 0;
while(offset < portableKeyCodeValues.length) {
currentValue--;
try {
if(implementation.getGameAction(currentValue) != 0) {
continue;
}
} catch(IllegalArgumentException ignor) {
// this is good, the game key is unassigned
}
portableKeyCodeValues[offset] = currentValue;
offset++;
}
}
for(int iter = 0 ; iter < portableKeyCodes.length ; iter++) {
if(portableKeyCodes[iter] == gameAction) {
return portableKeyCodeValues[iter];
}
}
return 0;
}
/**
* Allows overriding the softkeys initialized by the software to a different value.
* This method MUST be invoked after init() has completed.
* <p>In order to maintain the default value 0 can be passed as a value for a softkey
* thus resulting in no effect e.g. setSoftkeyCodes(0, 0, 0, -8); will only affect the back key.
* @param left the left softkey code
* @param right the right softkey code
* @param clear the clear softkey code
* @param back the back softkey code
*/
public void setSoftkeyCodes(int left, int right, int clear, int back) {
if(left != 0) {
Form.leftSK = left;
}
if(right != 0) {
Form.rightSK = right;
}
if(clear != 0) {
Form.clearSK = clear;
}
if(back != 0) {
Form.backSK = back;
}
}
/**
* Indicates whether the 3rd softbutton should be supported on this device
*/
public boolean isThirdSoftButton() {
return thirdSoftButton;
}
/**
* Indicates whether the 3rd softbutton should be supported on this device
*/
public void setThirdSoftButton(boolean thirdSoftButton) {
this.thirdSoftButton = thirdSoftButton;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -