1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package javax.microedition.lcdui;
21
22 public abstract class CustomItem extends Item {
23 protected static final int TRAVERSE_HORIZONTAL = 1;
24 protected static final int TRAVERSE_VERTICAL = 2;
25 protected static final int KEY_PRESS = 4;
26 protected static final int KEY_RELEASE = 8;
27 protected static final int KEY_REPEAT = 0x10;
28 protected static final int POINTER_PRESS = 0x20;
29 protected static final int POINTER_RELEASE = 0x40;
30 protected static final int POINTER_DRAG = 0x80;
31 protected static final int NONE = 0x00;
32
33 protected CustomItem(String label) {
34 super(label);
35 }
36
37 public int getGameAction(int keycode) {
38
39 return 0;
40 }
41
42 protected final int getInteractionModes() {
43
44 return NONE;
45 }
46
47 protected abstract int getMinContentHeight();
48
49 protected abstract int getMinContentWidth();
50
51 protected abstract int getPrefContentHeight(int width);
52
53 protected abstract int getPrefContentWidth(int height);
54
55 protected void hideNotify() {
56
57
58 }
59
60 protected final void invalidate() {
61 repaintOwner();
62 }
63
64 protected void keyPressed(int keyCode) {
65
66
67 }
68
69 protected void keyReleased(int keyCode) {
70
71
72 }
73
74 protected void keyRepeated(int keyCode) {
75
76
77 }
78
79 protected abstract void paint(Graphics g, int w, int h);
80
81 protected void pointerDragged(int x, int y) {
82
83
84 }
85
86 protected void pointerPressed(int x, int y) {
87
88
89 }
90
91 protected void pointerReleased(int x, int y) {
92
93
94 }
95
96 protected final void repaint() {
97 super.repaint();
98 }
99
100 protected final void repaint(int x, int y, int w, int h) {
101
102 repaint();
103 }
104
105 protected void showNotify() {
106
107
108 }
109
110 protected void sizeChanged(int w, int h) {
111
112
113 }
114
115 protected boolean traverse(int dir, int viewportWidth,
116 int viewportHeight, int[] visRect_inout) {
117
118
119 return false;
120 }
121
122 protected void traverseOut() {
123
124
125 }
126
127
128
129
130 int paint(Graphics g) {
131
132 super.paintContent(g);
133 return super.getHeight();
134 }
135
136
137 }