javauis/lcdui_qt/src/javax/microedition/lcdui/game/GameCanvas.java
changeset 23 98ccebc37403
parent 21 2a9601315dfc
child 78 71ad690e91f5
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: 
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 package javax.microedition.lcdui.game;
    17 package javax.microedition.lcdui.game;
    18 
    18 
    19 import javax.microedition.lcdui.Graphics;
    19 import javax.microedition.lcdui.Graphics;
    21 import com.nokia.mj.impl.nokialcdui.LCDUIInvoker;
    21 import com.nokia.mj.impl.nokialcdui.LCDUIInvoker;
    22 
    22 
    23 /**
    23 /**
    24  * GameCanvas class.
    24  * GameCanvas class.
    25  */
    25  */
    26 public abstract class GameCanvas extends javax.microedition.lcdui.Canvas {
    26 public abstract class GameCanvas extends javax.microedition.lcdui.Canvas
       
    27 {
    27 
    28 
    28     /**
    29     /**
    29      * Bit representing UP key. (1 << Canvas.UP)
    30      * Bit representing UP key. (1 << Canvas.UP)
    30      */
    31      */
    31     public static final int UP_PRESSED = 0x0002;
    32     public static final int UP_PRESSED = 0x0002;
    73     /**
    74     /**
    74      * Constructor.
    75      * Constructor.
    75      *
    76      *
    76      * @param suppressKeyEvents supress game key events.
    77      * @param suppressKeyEvents supress game key events.
    77      */
    78      */
    78     protected GameCanvas(boolean suppressKeyEvents) {
    79     protected GameCanvas(boolean suppressKeyEvents)
       
    80     {
    79         super();
    81         super();
    80         LCDUIInvoker.initGameCanvas(this, suppressKeyEvents);
    82         LCDUIInvoker.initGameCanvas(this, suppressKeyEvents);
    81     }
    83     }
    82 
    84 
    83     /**
    85     /**
    84      * Get frameBuffer's Graphics object.
    86      * Get frameBuffer's Graphics object.
    85      *
    87      *
    86      * @return frameBuffer's Graphics
    88      * @return frameBuffer's Graphics
    87      */
    89      */
    88     protected Graphics getGraphics() {
    90     protected Graphics getGraphics()
       
    91     {
    89         return (Graphics) LCDUIInvoker.getGraphics(this);
    92         return (Graphics) LCDUIInvoker.getGraphics(this);
    90     }
    93     }
    91 
    94 
    92     /**
    95     /**
    93      * Get game key states.
    96      * Get game key states.
    94      *
    97      *
    95      * @return game key states
    98      * @return game key states
    96      */
    99      */
    97     public int getKeyStates() {
   100     public int getKeyStates()
       
   101     {
    98         return LCDUIInvoker.getKeyStates(this);
   102         return LCDUIInvoker.getKeyStates(this);
    99     }
   103     }
   100 
   104 
   101     /**
   105     /**
   102      * By default this renders the frameBuffer at (0,0).
   106      * By default this renders the frameBuffer at (0,0).
   103      *
   107      *
   104      * @param g Graphics object
   108      * @param g Graphics object
   105      */
   109      */
   106     public void paint(javax.microedition.lcdui.Graphics g) {
   110     public void paint(javax.microedition.lcdui.Graphics g)
       
   111     {
   107         // If the Graphics doesn't belong to the frame buffer
   112         // If the Graphics doesn't belong to the frame buffer
   108         LCDUIInvoker.renderGraphics(this, g);
   113         LCDUIInvoker.renderGraphics(this, g);
   109     }
   114     }
   110 
   115 
   111     /**
   116     /**
   114      * @param x clip X
   119      * @param x clip X
   115      * @param y clip Y
   120      * @param y clip Y
   116      * @param w clip width
   121      * @param w clip width
   117      * @param h clip height
   122      * @param h clip height
   118      */
   123      */
   119     public void flushGraphics(int x, int y, int w, int h) {
   124     public void flushGraphics(int x, int y, int w, int h)
   120         if (w > 0 && h > 0) {
   125     {
       
   126         if(w > 0 && h > 0)
       
   127         {
   121             LCDUIInvoker.flushGraphics(this, x, y, w, h);
   128             LCDUIInvoker.flushGraphics(this, x, y, w, h);
   122         }
   129         }
   123     }
   130     }
   124 
   131 
   125     /**
   132     /**
   126      * Flushes the frameBuffer to the display.
   133      * Flushes the frameBuffer to the display.
   127      */
   134      */
   128     public void flushGraphics() {
   135     public void flushGraphics()
       
   136     {
   129         LCDUIInvoker.flushGraphics(this, 0, 0, getWidth(), getHeight());
   137         LCDUIInvoker.flushGraphics(this, 0, 0, getWidth(), getHeight());
   130     }
   138     }
   131 
   139 
   132 }
   140 }