Source code: javax/microedition/lcdui/Canvas.java
1 /*
2 * MicroEmulator
3 * Copyright (C) 2001 Bartek Teodorczyk <barteo@it.pl>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Contributor(s):
20 * 3GLab
21 */
22
23 package javax.microedition.lcdui;
24
25 import com.barteo.emulator.device.DeviceFactory;
26
27
28 public abstract class Canvas extends Displayable
29 {
30
31 public static final int UP = 1;
32 public static final int DOWN = 6;
33 public static final int LEFT = 2;
34 public static final int RIGHT = 5;
35 public static final int FIRE = 8;
36
37 public static final int GAME_A = 9;
38 public static final int GAME_B = 10;
39 public static final int GAME_C = 11;
40 public static final int GAME_D = 12;
41
42 public static final int KEY_NUM0 = 48;
43 public static final int KEY_NUM1 = 49;
44 public static final int KEY_NUM2 = 50;
45 public static final int KEY_NUM3 = 51;
46 public static final int KEY_NUM4 = 52;
47 public static final int KEY_NUM5 = 53;
48 public static final int KEY_NUM6 = 54;
49 public static final int KEY_NUM7 = 55;
50 public static final int KEY_NUM8 = 56;
51 public static final int KEY_NUM9 = 57;
52
53 public static final int KEY_STAR = 42;
54 public static final int KEY_POUND = 35;
55
56
57 protected Canvas()
58 {
59 }
60
61
62 public int getGameAction(int keyCode)
63 {
64 return Display.getGameAction(keyCode);
65 }
66
67
68 public int getKeyCode(int gameAction)
69 {
70 return Display.getKeyCode(gameAction);
71 }
72
73
74 public String getKeyName(int keyCode)
75 {
76 return Integer.toString(keyCode);
77 }
78
79
80 public boolean hasPointerEvents()
81 {
82 return DeviceFactory.getDevice().hasPointerEvents();
83 }
84
85
86 public boolean hasPointerMotionEvents()
87 {
88 return DeviceFactory.getDevice().hasPointerMotionEvents();
89 }
90
91
92 public boolean hasRepeatEvents()
93 {
94 return DeviceFactory.getDevice().hasRepeatEvents();
95 }
96
97
98 public int getWidth()
99 {
100 return DeviceFactory.getDevice().getDeviceDisplay().getWidth();
101 }
102
103
104 public int getHeight()
105 {
106 return DeviceFactory.getDevice().getDeviceDisplay().getHeight();
107 }
108
109
110 protected void hideNotify()
111 {
112 }
113
114
115 public boolean isDoubleBuffered()
116 {
117 return false;
118 }
119
120
121 protected void keyPressed(int keyCode)
122 {
123 }
124
125
126 protected void keyRepeated(int keyCode)
127 {
128 }
129
130
131 protected void keyReleased(int keyCode)
132 {
133 }
134
135
136 protected abstract void paint(Graphics g);
137
138
139 protected void pointerPressed(int x, int y)
140 {
141 }
142
143
144 protected void pointerReleased(int x, int y)
145 {
146 }
147
148
149 protected void pointerDragged(int x, int y)
150 {
151 }
152
153
154 public final void repaint()
155 {
156 super.repaint();
157 }
158
159
160 public final void repaint(int x, int y, int width, int height)
161 {
162 repaint();
163 }
164
165
166 public final void serviceRepaints()
167 {
168 }
169
170
171 protected void showNotify()
172 {
173 }
174
175 }